diff --git a/.actrc b/.actrc new file mode 100644 index 00000000000..b16e42ec2b3 --- /dev/null +++ b/.actrc @@ -0,0 +1 @@ +--artifact-server-path /tmp/artifacts \ No newline at end of file diff --git a/.devcontainer/cli.code-workspace b/.devcontainer/cli.code-workspace new file mode 100644 index 00000000000..9188cd1f7a6 --- /dev/null +++ b/.devcontainer/cli.code-workspace @@ -0,0 +1,24 @@ +{ + "folders": [ + { "path": ".." }, + { "path": "../../cli-ci" }, + { "path": "../../cli-private" }, + { "path": "../../cli-workstation" } + + ], + "settings": { + "github-actions.workflows.pinned.workflows": [ + "cli/.github/workflows/integration.yml" + ] + }, + "extensions": { + "recommendations": [ + "gitpod.gitpod-remote-ssh", + "ms-vsliveshare.vsliveshare", + "redhat.vscode-yaml", + "golang.go", + "vscodevim.vim", + "ms-vscode.makefile-tools" + ] + } +} \ No newline at end of file diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8ff51f43335..6bf9409c4a5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,7 +8,8 @@ mailing list. ## CLI Versions The cf CLI follows a branching model: -- V8 of the cf CLI is built from the [master branch](https://github.com/cloudfoundry/cli/tree/master). **This branch is under active development**. +- V9 (Next major release) of the cf CLI is built from the [master branch](https://github.com/cloudfoundry/cli/tree/master). **This branch is under active development**. +- V8 of the cf CLI is built from the [v8 branch](https://github.com/cloudfoundry/cli/tree/v8). **This branch is under active development**. - V7 of the cf CLI is built from the [v7 branch](https://github.com/cloudfoundry/cli/tree/v7). **This branch is maintenance only** and will only be updated to patch CVEs and very severe blocking defects. - V6 of the cf CLI is built from the [v6 branch](https://github.com/cloudfoundry/cli/tree/v6). **This branch is maintenance only** and will only be updated to patch CVEs and very severe blocking defects. @@ -32,11 +33,11 @@ After reaching out to the CLI team and the conclusion is to make a PR, please fo [Product Style Guide](https://github.com/cloudfoundry/cli/wiki/CLI-Product-Specific-Style-Guide), and [Internationalization Guide](https://github.com/cloudfoundry/cli/wiki/Internationalization-Guide). 1. Fork the project repository. -1. Create a feature branch from the earliest branch that's [appropriate for your change](#cli-versions) (e.g. `git checkout v7 && git checkout -b better_cli`) and make changes on this branch +1. Create a feature branch from the earliest branch that's [appropriate for your change](#cli-versions) (e.g. `git checkout v8 && git checkout -b v8_better_cli`) and make changes on this branch * Follow the other sections on this page to [set up your development environment](#development-environment-setup), [build `cf`](#building-the-cf-binary) and [run the tests](#testing). * Tests are required for any changes. -1. Push to your fork (e.g. `git push origin better_cli`) and [submit a pull request](https://help.github.com/articles/creating-a-pull-request) -1. The cf CLI team will merge your changes from the versioned branch (e.g. v7) to master for you after the PR is merged. +1. Push to your fork (e.g. `git push origin v8_better_cli`) and [submit a pull request](https://help.github.com/articles/creating-a-pull-request) +1. The cf CLI team will merge your PR after review. Note: All contributions must be sent using GitHub Pull Requests. We prefer a small, focused pull request with a clear message @@ -96,12 +97,9 @@ how to cross compile binaries for other architectures. To run the unit tests: ```bash cd cli -make units-full # will run all unit tests -make units # runs all non-cf directory unit tests +make units ``` - -**Note: `make units-full` is recommended over `make units` if you are unsure of -how wide-reaching the intended changes are.** +(For historic reasons, there are multiple synonyms in the `Makefile`.) ## Running the Integration tests diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a698e6eb211..d0623973ab2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,21 +1,22 @@ Thank you for contributing to the CF CLI! Please read the following: -* Please make sure you have implemented changes in line with the [contributing guidelines](https://github.com/cloudfoundry/cli/blob/master/.github/CONTRIBUTING.md) +* Please make sure you have implemented changes in line with the [contributing guidelines](https://github.com/cloudfoundry/cli/blob/main/.github/CONTRIBUTING.md) * We're not allowed to accept any PRs without a signed CLA, no matter how small. If your contribution falls under a company CLA but your membership is not public, expect delays while we confirm. * All new code requires tests to protect against regressions. -* Contributions must be made against the appropriate branch. See the [contributing guidelines](https://github.com/cloudfoundry/cli/blob/master/.github/CONTRIBUTING.md) +* Contributions must be made against the appropriate branch. See the [contributing guidelines](https://github.com/cloudfoundry/cli/blob/main/.github/CONTRIBUTING.md) * Contributions must conform to our [style guide](https://github.com/cloudfoundry/cli/wiki/CLI-Product-Specific-Style-Guide). Please reach out to us if you have questions. -## Does this PR modify CLI v6, CLI v7, or CLI v8? +## Where this PR should be backported? -Please see the contribution doc above or review [Architecture Guide](https://github.com/cloudfoundry/cli/wiki/Architecture-Guide). +- [ ] [main](https://github.com/cloudfoundry/cli/tree/main) +- [ ] [v8](https://github.com/cloudfoundry/cli/tree/v8) +- [ ] [v7](https://github.com/cloudfoundry/cli/tree/v7) ## Description of the Change - We must be able to understand the design of your change from this description. Keep in mind that the maintainer reviewing this PR may not be familiar with or have worked with the code here recently, so please walk us through the concepts. @@ -25,13 +26,9 @@ have worked with the code here recently, so please walk us through the concepts. What benefits will be realized by the code change? What users would want this change? What user need is this change addressing? -## Why Should This Be In Core? - -Explain why this functionality should be in the cf CLI, as opposed to a plugin. - ## Applicable Issues -List any applicable Github Issues here +List any applicable GitHub Issues here ## How Urgent Is The Change? diff --git a/.github/bosh-lite-files/bosh-lite-dns.tf b/.github/bosh-lite-files/bosh-lite-dns.tf new file mode 100644 index 00000000000..5eddbbd3ea2 --- /dev/null +++ b/.github/bosh-lite-files/bosh-lite-dns.tf @@ -0,0 +1,11 @@ +variable "dns_zone_name" {} +variable "system_domain_suffix" {} + +resource "google_dns_record_set" "default" { + name = "*.${var.env_id}.${var.system_domain_suffix}." + type = "A" + ttl = 300 + + managed_zone = var.dns_zone_name + rrdatas = [ google_compute_address.bosh-director-ip.address ] +} \ No newline at end of file diff --git a/.github/bosh-lite-files/bosh-lite.tfvars b/.github/bosh-lite-files/bosh-lite.tfvars new file mode 100644 index 00000000000..4d999086eb9 --- /dev/null +++ b/.github/bosh-lite-files/bosh-lite.tfvars @@ -0,0 +1,2 @@ +system_domain_suffix="app-runtime-interfaces.ci.cloudfoundry.org" +dns_zone_name="app-runtime-interfaces" \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5cd92488763..49b01205660 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,5 +6,4 @@ updates: interval: daily time: '11:00' open-pull-requests-limit: 10 - target-branch: "v7" - vendor: true + target-branch: "v8" diff --git a/.github/license/CF_NOTICE b/.github/license/CF_NOTICE new file mode 100644 index 00000000000..280be3690b2 --- /dev/null +++ b/.github/license/CF_NOTICE @@ -0,0 +1,36 @@ +Copyright (c) 2015-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. + +This product contains software that is Copyright (c) 2013-2015 Pivotal Software, Inc. + +This product is licensed to you under the Apache License, Version 2.0 (the "License"). + +You may not use this project except in compliance with the License. + + +Attribution notices: + +This product includes software from https://github.com/cloudfoundry/cli/tree/main/vendor/code.cloudfoundry.org/gofileutils/fileutils that is: +Copyright (c) 2015-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. +Copyright (c) 2014-2015 Pivotal Software, Inc. +and is licensed under the Apache License, Version 2.0. + +This product includes software from https://github.com/code.cloudfoundry.org/cli/tree/main/vendor/code.cloudfoundry.org/ykk that is: +Copyright (c) 2015-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. +and is licensed under the Apache License, Version 2.0. + +This product includes software from https://github.com/code.cloudfoundry.org/cli/tree/main/vendor/code.cloudfoundry.org/cfnetworking-cli-api that is: +Copyright (c) 2016-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. +and is licensed under the Apache License, Version 2.0. + +This product includes software from https://github.com/cloudfoundry/cli/tree/main/vendor/github.com/cloudfoundry/cli-plugin-repo/web that is: +Copyright (c) 2015-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. +Copyright (c) 2015 Pivotal Software, Inc. +and is licensed under the Apache License, Version 2.0. + +This product includes software from https://github.com/cloudfoundry/cli/tree/main/vendor/github.com/cloudfoundry/dropsonde that is: +Copyright (c) 2014-2015 Pivotal Software, Inc. +and is licensed under the Apache License, Version 2.0. + +This product includes software from https://github.com/cloudfoundry/cli/tree/main/vendor/github.com/docker/docker/pkg/term that is: +Copyright 2012-2016 Docker, Inc. +and is licensed under the Apache License, Version 2.0. diff --git a/.github/license/LICENSE-WITH-3RD-PARTY-LICENSES b/.github/license/LICENSE-WITH-3RD-PARTY-LICENSES new file mode 100644 index 00000000000..d8ce5236b07 --- /dev/null +++ b/.github/license/LICENSE-WITH-3RD-PARTY-LICENSES @@ -0,0 +1,1149 @@ + + 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. + + +================ + +This product includes software with separate copyright notices and +license terms, as noted below. + + +For vendor/golang.org/x/sys/unix: + +Copyright (c) 2009 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. + + +For vendor/golang.org/x/sys/windows: + +Copyright (c) 2009 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. + + +For vendor/golang.org/x/net/websocket: + +Copyright (c) 2009 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. + + +For vendor/golang.org/x/crypto: + +Copyright (c) 2009 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. + + +For vendor/github.com/blang/semver: + +The MIT License + +Copyright (c) 2014 Benedikt Lang + +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. + + +For vendor/github.com/tedsuo/rata: + +The MIT License (MIT) + +Copyright (c) 2014 Ted Young + +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. + + +For vendor/github.com/golang/protobuf/ptypes/any: + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + + +For vendor/github.com/golang/protobuf/proto: + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + + +For vendor/github.com/jessevdk/go-flags: + +Copyright (c) 2012 Jesse van den Kieboom. 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. + +For vendor/github.com/SermoDigital/jose: + +The MIT License (MIT) + +Copyright (c) 2015 Sermo Digital LLC + +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. + + +For vendor/github.com/Azure/go-ansiterm: + +The MIT License (MIT) + +Copyright (c) 2015 Microsoft Corporation + +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. + + +For vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor: + +Extensions for Protocol Buffers to create more go like structures. + +Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +http://github.com/gogo/protobuf/gogoproto + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + + +For vendor/github.com/gogo/protobuf/gogoproto: + +Protocol Buffers for Go with Gadgets + +Copyright (c) 2013, The GoGo Authors. All rights reserved. +http://github.com/gogo/protobuf + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + + +For vendor/github.com/gogo/protobuf/proto: + +Protocol Buffers for Go with Gadgets + +Copyright (c) 2013, The GoGo Authors. All rights reserved. +http://github.com/gogo/protobuf + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + + +For vendor/github.com/google/go-querystring/query: + +Copyright (c) 2013 Google. 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. + + +For vendor/github.com/mattn/go-colorable: + +The MIT License (MIT) + +Copyright (c) 2016 Yasuhiro Matsumoto + +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. + + +For vendor/github.com/mattn/go-isatty: + +Copyright (c) Yasuhiro MATSUMOTO + +MIT License (Expat) + +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. + + +For vendor/github.com/mattn/go-runewidth: + +The MIT License (MIT) + +Copyright (c) 2016 Yasuhiro Matsumoto + +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. + + +For vendor/github.com/sajari/fuzzy: + +The MIT License (MIT) + +Copyright (c) 2014 Sajari Pty Ltd + +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. + + +For vendor/github.com/gorilla/websocket: + +Copyright (c) 2013 The Gorilla WebSocket 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. + +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. + + +For vendor/github.com/sirupsen/logrus: + +The MIT License (MIT) + +Copyright (c) 2014 Simon Eskildsen + +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. + + +For vendor/github.com/lunixbochs/vtclean: + +The MIT License (MIT) + +Copyright (c) 2015 Ryan Hileman + +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. + +For vendor/gopkg.in/cheggaaa/pb.v1: + +Copyright (c) 2012-2015, Sergey Cherepanov 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. + +For vendor/github.com/sabhiram/go-gitignore: + +The MIT License (MIT) + +Copyright (c) 2015 Shaba Abhiram + +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. + +For portions of vendor/gopkg.in/yaml.v2: + +Copyright (c) 2006 Kirill Simonov + +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. + + +For vendor/github.com/bmatcuk/doublestar: + +The MIT License (MIT) + +Copyright (c) 2014 Bob Matcuk + +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. + + +For vendor/github.com/bmizerany/pat: + +Copyright (C) 2012 by Keith Rarick, Blake Mizerany + +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. + + +For vendor/github.com/charlievieth/fs: + +The MIT License (MIT) + +Copyright (c) 2016 Charlie Vieth + +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. + + +For vendor/github.com/cppforlife/go-patch: + +Copyright (c) 2016 Dmitriy Kalinin + +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. + + +For vendor/github.com/fatih/color: + +The MIT License (MIT) + +Copyright (c) 2013 Fatih Arslan + +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. + + +For vendor/github.com/mailru/easyjson: + +Copyright (c) 2016 Mail.Ru Group + +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. + + +For vendor/github.com/vito/go-interact: + +Copyright (c) 2015-2016 Alex Suraci + +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. + + +For vendor/github.com/pkg/errors: + +Copyright (c) 2015, Dave Cheney +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. + +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. + + +For vendor/github.com/cyphar/filepath-securejoin: + +Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved. +Copyright (C) 2017 SUSE LLC. 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. + + +For vendor/golang.org/x/text: + +Copyright (c) 2009 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. diff --git a/.github/ops-files/add-oidc-provider.yml b/.github/ops-files/add-oidc-provider.yml new file mode 100644 index 00000000000..2ad7e21a443 --- /dev/null +++ b/.github/ops-files/add-oidc-provider.yml @@ -0,0 +1,155 @@ +--- +- type: replace + path: /instance_groups/name=uaa/jobs/name=uaa/properties/login/oauth?/providers? + value: + cli-oidc-provider: + type: oidc1.0 + discoveryUrl: https://uaa-oidc.service.cf.internal:8443/.well-known/openid-configuration + scopes: + - openid + linkText: My other uaa Oauth Provider + showLinkText: true + addShadowUserOnLogin: true + relyingPartyId: rp_oidc_admin + relyingPartySecret: adminsecret + skipSslValidation: true + storeCustomAttributes: true + passwordGrantEnabled: true + attributeMappings: + given_name: given_name + family_name: family_name + user_name: user_name + +- type: replace + path: /instance_groups/name=uaa:after + value: + name: uaa-oidc + instances: 1 + azs: [z1, z2, z3] + vm_type: default + stemcell: default + persistent_disk: 500 + networks: + - name: default + jobs: + - name: uaa + release: uaa + properties: + encryption: + active_key_label: 'key-1' + encryption_keys: + - label: 'key-1' + passphrase: 'MY-PASSPHRASE' + uaadb: + address: sql-db.service.cf.internal + databases: + - name: uaa_oidc + tag: uaa + db_scheme: mysql + port: 3306 + roles: + - name: uaa-oidc + password: "((uaa_oidc_database_password))" + tag: admin + uaa: + url: https://uaa-oidc.service.cf.internal:8443 + jwt: + policy: + active_key_id: key-1 + keys: + key-1: + signingKey: ((uaa-oidc-key1.private_key)) + sslCertificate: ((uaa-oidc_tls.certificate)) + sslPrivateKey: ((uaa-oidc_tls.private_key)) + ca_certs: + - ((mysql_server_certificate.ca)) + clients: + rp_oidc_admin: + authorized-grant-types: authorization_code,client_credentials,refresh_token,user_token,password,urn:ietf:params:oauth:grant-type:saml2-bearer,implicit + redirect-uri: https://uaa.service.cf.internal:8443/login/callback/cli-oidc-provider + scope: openid,uaa.admin,clients.read,clients.write,clients.secret,scim.read,scim.write,clients.admin,uaa.user,doppler.firehose + authorities: uaa.admin,clients.admin + secret: adminsecret + scim: + user: + override: true + users: + - name: admin-oidc + password: "((uaa_oidc_admin_password))" + groups: + - uaa.admin + login: + protocol: https + saml: + activeKeyId: key1 + keys: + key1: + key: ((saml_oidc-key1.private_key)) + passphrase: '' + certificate: ((saml_oidc-key1.certificate)) + +- type: replace + path: /addons/name=bosh-dns-aliases/jobs/name=bosh-dns-aliases/properties/aliases/- + value: + domain: uaa-oidc.service.cf.internal + targets: + - query: '*' + instance_group: uaa-oidc + deployment: cf + network: default + domain: bosh + +- type: replace + path: /instance_groups/name=database/jobs/name=pxc-mysql/properties/seeded_databases?/- + value: + name: uaa_oidc + username: uaa-oidc + password: "((uaa_oidc_database_password))" + +- type: replace + path: /variables?/- + value: + name: uaa_oidc_admin_password + type: password + +- type: replace + path: /variables?/- + value: + name: uaa_oidc_database_password + type: password + +- type: replace + path: /variables?/- + value: + name: uaa-oidc-key1 + type: rsa + +- type: replace + path: /variables?/- + value: + name: uaa-oidc_ca + type: certificate + options: + is_ca: true + common_name: uaa-oidc + alternative_names: ["*.uaa-oidc.service.cf.internal"] + extended_key_usage: + - server_auth + +- type: replace + path: /variables?/- + value: + name: saml_oidc-key1 + type: certificate + options: + ca: uaa-oidc_ca + common_name: saml_oidc + +- type: replace + path: /variables?/- + value: + name: uaa-oidc_tls + type: certificate + options: + ca: uaa-oidc_ca + common_name: uaa-oidc.service.cf.internal diff --git a/.github/ops-files/add-uaa-client-credentials.yml b/.github/ops-files/add-uaa-client-credentials.yml new file mode 100644 index 00000000000..68a9f060850 --- /dev/null +++ b/.github/ops-files/add-uaa-client-credentials.yml @@ -0,0 +1,11 @@ +--- +- type: replace + path: /instance_groups/name=uaa/jobs/name=uaa/properties/uaa/clients/potato-face? + value: + access-token-validity: 600 + authorized-grant-types: client_credentials + override: true + secret: ((client-secret)) + scope: openid,routing.router_groups.write,scim.read,cloud_controller.admin,uaa.user,routing.router_groups.read,cloud_controller.read,password.write,cloud_controller.write,network.admin,doppler.firehose,scim.write,uaa.admin + authorities: openid,routing.router_groups.write,scim.read,cloud_controller.admin,uaa.user,routing.router_groups.read,cloud_controller.read,password.write,cloud_controller.write,network.admin,doppler.firehose,scim.write,uaa.admin + diff --git a/.github/ops-files/bosh-lite-vm-type.yml b/.github/ops-files/bosh-lite-vm-type.yml new file mode 100644 index 00000000000..eebd6a6e886 --- /dev/null +++ b/.github/ops-files/bosh-lite-vm-type.yml @@ -0,0 +1,11 @@ +--- +# Configure sizes for bosh-lite on gcp +- type: replace + path: /resource_pools/name=vms/cloud_properties/machine_type + value: n2-standard-8 +- type: replace + path: /disk_pools/name=disks/disk_size + value: 250000 +- type: replace + path: /resource_pools/name=vms/cloud_properties/root_disk_size_gb + value: 32 \ No newline at end of file diff --git a/.github/ops-files/diego-cell-instances.yml b/.github/ops-files/diego-cell-instances.yml new file mode 100644 index 00000000000..19ea43d8077 --- /dev/null +++ b/.github/ops-files/diego-cell-instances.yml @@ -0,0 +1,4 @@ +--- +- type: replace + path: /instance_groups/name=diego-cell/instances + value: 4 diff --git a/.github/ops-files/increase-route-registration-interval.yml b/.github/ops-files/increase-route-registration-interval.yml new file mode 100644 index 00000000000..473928cab6c --- /dev/null +++ b/.github/ops-files/increase-route-registration-interval.yml @@ -0,0 +1,12 @@ +--- +- type: replace + path: /instance_groups/name=uaa/jobs/name=route_registrar/properties?/route_registrar/routes/name=uaa/registration_interval + value: 30s +- type: replace + path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=api/registration_interval + value: 30s +- type: replace + path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=policy-server/registration_interval + value: 30s +- type: remove + path: /instance_groups/name=api/jobs/name=route_registrar/properties?/route_registrar/routes/name=api/health_check/timeout diff --git a/.github/ops-files/use-latest-capi.yml b/.github/ops-files/use-latest-capi.yml new file mode 100644 index 00000000000..216b9df70c0 --- /dev/null +++ b/.github/ops-files/use-latest-capi.yml @@ -0,0 +1,10 @@ +--- +- type: replace + path: /releases/name=capi/version + value: latest + +- type: remove + path: /releases/name=capi/url? + +- type: remove + path: /releases/name=capi/sha1? diff --git a/.github/release/gon.json b/.github/release/gon.json new file mode 100644 index 00000000000..73fd4923a2a --- /dev/null +++ b/.github/release/gon.json @@ -0,0 +1,14 @@ +{ + "source" : [ + "./dist/hello-darwin_darwin_amd64/hello", + "./dist/hello-darwin_darwin_arm64/hello" + ], + "bundle_id" : "com.example.hello", + "apple_id": { + "username" : "none@example.com", + "password": "@env:AC_PASSWORD" + }, + "sign" :{ + "application_identity" : "test-sign" + } +} diff --git a/.github/release/release-notes-template.txt b/.github/release/release-notes-template.txt new file mode 100644 index 00000000000..4c58a368859 --- /dev/null +++ b/.github/release/release-notes-template.txt @@ -0,0 +1,23 @@ +Package Manager Installation +---------- +- [apt-get, yum, homebrew](https://github.com/cloudfoundry/cli#getting-started) + +Installers +---------- +- Debian [64 bit](https://packages.cloudfoundry.org/stable?release=debian64&version=new-version&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=debian32&version=new-version&source=github-rel) / [arm64](https://packages.cloudfoundry.org/stable?release=debianarm64&version=new-version&source=github-rel) (deb) +- Redhat [64 bit](https://packages.cloudfoundry.org/stable?release=redhat64&version=new-version&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=redhat32&version=new-version&source=github-rel) / [aarch64](https://packages.cloudfoundry.org/stable?release=redhataarch64&version=new-version&source=github-rel) (rpm) +- macOS [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64&version=new-version&source=github-rel) / [arm](https://packages.cloudfoundry.org/stable?release=macosarm&version=new-version&source=github-rel) (pkg) +- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64&version=new-version&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32&version=new-version&source=github-rel) (zip) + +Binaries +-------- +- Linux [64 bit](https://packages.cloudfoundry.org/stable?release=linux64-binary&version=new-version&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=linux32-binary&version=new-version&source=github-rel) / [arm64](https://packages.cloudfoundry.org/stable?release=linuxarm64-binary&version=new-version&source=github-rel) (tgz) +- macOS [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64-binary&version=new-version&source=github-rel) / [arm](https://packages.cloudfoundry.org/stable?release=macosarm-binary&version=new-version&source=github-rel) (tgz) +- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64-exe&version=new-version&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32-exe&version=new-version&source=github-rel) (zip) + + +Docker +-------- +```shell +docker pull cloudfoundry/cli:new-version +``` \ No newline at end of file diff --git a/.github/scripts/format-cve-scan-results.sh b/.github/scripts/format-cve-scan-results.sh new file mode 100755 index 00000000000..3abe35252ad --- /dev/null +++ b/.github/scripts/format-cve-scan-results.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +[[ "${TRACE:-0}" == "1" ]] && set -o xtrace + +## +# Formats CVE results in a markdown table to display a summary in a GitHub Action UI +## + +# Check if the number of arguments is correct +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +_results_filename="${1}" + +# Check if the file exists +if [ ! -f "${_results_filename}" ]; then + echo "Error: File '${_results_filename}' does not exist" + exit 1 +fi + +_number_of_cves_found=$(jq -r '.matches | length' "${_results_filename}") + +echo -e "# CVE Scan Results\n" + +if [ ${_number_of_cves_found} -eq 0 ]; then + echo -e "## Success! No vulnerabilities found.\n" +else + echo -e "## Failure: ${_number_of_cves_found} vulnerabilities found.\n" + + _table_headers='"NAME","INSTALLED","FIXED-IN","TYPE","VULNERABILITY","SEVERITY"' + _table_underlines='"----","---------","--------","----","-------------","--------"' + + jq -r "[${_table_headers}], + [${_table_underlines}], + (.matches[] | [ + .artifact.name, + .artifact.version, + .vulnerability.fix.versions[0], + .artifact.type, + .vulnerability.id, + .vulnerability.severity + ]) | @tsv" "${_results_filename}" \ + | sed 's/|/\\|/g' \ + | sed 's/\t/ | /g' +fi \ No newline at end of file diff --git a/.github/secrets.template.envrc b/.github/secrets.template.envrc new file mode 100644 index 00000000000..0e955f6f089 --- /dev/null +++ b/.github/secrets.template.envrc @@ -0,0 +1,29 @@ +ACTIONS_RUNNER_DEBUG= # boolean +ACTIONS_STEP_DEBUG= # boolean +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_S3_BUCKET= +AWS_BUCKET_INTEGRATION= +AWS_BUCKET_STAGING= + +DOCKER_HUB_USERNAME= +DOCKER_HUB_ACCESS_TOKEN= + +GIT_RELEASE_TARGET_REPO= # repo to draft a release under, in / format +GIT_REPO_ACCESS_TOKEN= # only needed when pushing to a repo other than 'self' + +GIT_DEPLOY_HOMEBREW_TAP= + +SIGNING_KEY_GPG= +SIGNING_KEY_GPG_ID= +SIGNING_KEY_GPG_PASSPHRASE= + +SIGNING_CRT_MAC= +SIGNING_KEY_MAC= +SIGNING_KEY_MAC_ID= +SIGNING_KEY_MAC_PASSPHRASE= + +SIGNING_KEY_WINDOWS_PFX= +SIGNING_KEY_WINDOWS_ID= +SIGNING_KEY_WINDOWS_PASSPHRASE= + diff --git a/.github/win/cf.ico b/.github/win/cf.ico new file mode 100644 index 00000000000..4381126babf Binary files /dev/null and b/.github/win/cf.ico differ diff --git a/.github/win/choco/chocolateyinstall.ps1.tmpl b/.github/win/choco/chocolateyinstall.ps1.tmpl new file mode 100644 index 00000000000..b9aad083a9e --- /dev/null +++ b/.github/win/choco/chocolateyinstall.ps1.tmpl @@ -0,0 +1,21 @@ +# stop on all errors +$ErrorActionPreference = 'Stop'; + +$packageName = 'cloudfoundry-cli' +$registryUninstallerKeyName = 'cloudfoundry-cli' +$version = '${version}' +$url = '${claw_url}/stable?release=windows32-exe&version=${version}&source=github-rel' +$url64 = '${claw_url}/stable?release=windows64-exe&version=${version}&source=github-rel' +$checksum = '${checksum}' +$checksum64 = '${checksum64}' +$installDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$validExitCodes = @(0) + +Install-ChocolateyZipPackage -PackageName "$packageName" ` + -Url "$url" ` + -ChecksumType sha256 ` + -Checksum "$checksum" ` + -Url64bit "$url64" ` + -ChecksumType64 sha256 ` + -Checksum64 "$checksum64" ` + -UnzipLocation "$installDir" diff --git a/.github/win/choco/cloudfoundry-cli.nuspec.tmpl b/.github/win/choco/cloudfoundry-cli.nuspec.tmpl new file mode 100644 index 00000000000..5c399ae9af3 --- /dev/null +++ b/.github/win/choco/cloudfoundry-cli.nuspec.tmpl @@ -0,0 +1,30 @@ + + + + + cloudfoundry-cli + Cloud Foundry CLI + ${version} + Cloud Foundry Foundation + Cloud Foundry Foundation + Install official command line client for Cloud Foundry. + Cloud Foundry CLI is the official command line client for Cloud Foundry + + https://github.com/cloudfoundry/cli + cf cli cloudfoundry + Cloud Foundry Foundation + https://raw.githubusercontent.com/cloudfoundry/cli/master/LICENSE + false + https://raw.githubusercontent.com/cloudfoundry/cli/main/.github/win/cf.ico + https://github.com/cloudfoundry/cli + https://docs.cloudfoundry.org/cf-cli/ + https://github.com/cloudfoundry/cli/issues + https://github.com/cloudfoundry/cli/releases + + + + + diff --git a/.github/win/common.iss b/.github/win/common.iss new file mode 100644 index 00000000000..38e17d8cae9 --- /dev/null +++ b/.github/win/common.iss @@ -0,0 +1,76 @@ +function NeedsAddPath(Param: string): boolean; +var + OrigPath: string; +begin + if IsAdminLoggedOn then + begin + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, + 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', + 'Path', OrigPath) + then begin + Result := True; + exit; + end; + end + else + begin + if not RegQueryStringValue(HKEY_CURRENT_USER, + 'Environment', + 'Path', OrigPath) + then begin + Result := True; + exit; + end; + end; + // look for the path with leading and trailing semicolon + // Pos() returns 0 if not found + Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0; +end; + +var + OptionPage: TInputOptionWizardPage; + +procedure InitializeWizard(); +begin + OptionPage := + CreateInputOptionPage( + wpWelcome, + 'Choose installation options', 'Who should this application be installed for?', + 'Please select whether you wish to make this software available for all users or just yourself.', + True, False); + + OptionPage.Add('&Anyone who uses this computer (run as administrator to enable)'); + OptionPage.Add('&Only for me'); + + if IsAdminLoggedOn then + begin + OptionPage.Values[0] := True; + end + else + begin + OptionPage.Values[1] := True; + OptionPage.CheckListBox.ItemEnabled[0] := False; + end; +end; + +function NextButtonClick(CurPageID: Integer): Boolean; +begin + if CurPageID = OptionPage.ID then + begin + if (WizardDirValue <> ExpandConstant('{userappdata}\Cloud Foundry')) AND + (WizardDirValue <> ExpandConstant('{pf}\Cloud Foundry')) then + begin + Log('User has selected a custom install path. Will not override.') + end + else if OptionPage.Values[1] then + begin + // override the default installation to program files ({pf}) + WizardForm.DirEdit.Text := ExpandConstant('{userappdata}\Cloud Foundry') + end + else + begin + WizardForm.DirEdit.Text := ExpandConstant('{pf}\Cloud Foundry'); + end; + end; + Result := True; +end; diff --git a/.github/win/innosetup/Dockerfile b/.github/win/innosetup/Dockerfile new file mode 100644 index 00000000000..0a0d5a18ed3 --- /dev/null +++ b/.github/win/innosetup/Dockerfile @@ -0,0 +1,19 @@ +# This image is not being used by the github actions workflow +# because gh-actions doesn't support windows based images +# Keeping this file as we expect to use it in the future +FROM mcr.microsoft.com/windows/servercore:ltsc2019 +SHELL ["powershell.exe"] + +ARG CHOCO_THUMBPRINT=83AC7D88C66CB8680BCE802E0F0F5C179722764B +RUN mkdir \setup + +RUN (New-Object System.Net.WebClient).DownloadFile('https://chocolatey.org/install.ps1', '\setup\installChocolatey.ps1') +RUN (Get-AuthenticodeSignature \setup\installChocolatey.ps1).SignerCertificate.Thumbprint > \setup\thumbprint +RUN if ((type \setup\thumbprint) -ne $env:CHOCO_THUMBPRINT) { \ + throw 'chocolatey installer thumbprint does not match expected. see https://docs.chocolatey.org/en-us/information/security' \ + } +RUN \setup\installChocolatey.ps1 +RUN Remove-Item -Recurse \setup + + +RUN choco install --no-progress -r -y innosetup diff --git a/.github/win/install-innosetup.ps1 b/.github/win/install-innosetup.ps1 new file mode 100644 index 00000000000..14c64bf0908 --- /dev/null +++ b/.github/win/install-innosetup.ps1 @@ -0,0 +1,18 @@ +$ErrorActionPreference = "Stop" +# in the future, this variable should cause PS to exit on non-zero exit codes from commands/exes (as opposed to PS cmdlets) +$PSNativeCommandUseErrorActionPreference = $true +# see https://github.com/PowerShell/PowerShell/issues/3415 and https://github.com/PowerShell/PowerShell-RFC/pull/277 + +# retrieved from https://docs.chocolatey.org/en-us/information/security +$chocoThumbprint = '83AC7D88C66CB8680BCE802E0F0F5C179722764B' + +$scriptPath = (Get-Location).Path + '\installChocolatey.ps1' +(New-Object System.Net.WebClient).DownloadFile('https://chocolatey.org/install.ps1', $scriptPath) +(Get-AuthenticodeSignature .\installChocolatey.ps1).SignerCertificate.Thumbprint -eq $chocoThumbprint + +Set-ExecutionPolicy Bypass -Scope Process +.\installChocolatey.ps1 + +choco install --no-progress -r -y innosetup --force + +Get-Command iscc -ErrorAction Continue diff --git a/.github/win/integrations/integration-tests.ps1 b/.github/win/integrations/integration-tests.ps1 new file mode 100644 index 00000000000..e1bc2285d0f --- /dev/null +++ b/.github/win/integrations/integration-tests.ps1 @@ -0,0 +1,108 @@ +$ErrorActionPreference = "Stop" +trap { $host.SetShouldExit(1) } + +echo "Work Directory: $pwd" +$Env:ROOT="$pwd" + +$null = New-Item -ItemType Directory -Force -Path $Env:TEMP + +# TODO: consider migrating choco to winget https://github.com/microsoft/winget-cli as preferred MS solution +if ((Get-Command "choco" -ErrorAction SilentlyContinue) -eq $null) { + Set-ExecutionPolicy Bypass -Scope Process -Force + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 + $tempvar = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1') + iex ($tempvar) +} + +function Refresh-Choco-Env { + Import-Module "C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1" + refreshenv + cd $Env:ROOT +} + +Refresh-Choco-Env + +$Env:GOPATH="$Env:ROOT\go" + +$Env:PATH="$Env:HOME\go\bin;" + "$Env:PATH" +$Env:PATH="$Env:GOPATH\bin;" + "$Env:PATH" +$Env:PATH="$Env:GOROOT\bin;" + "$Env:PATH" +$Env:PATH="$pwd;" + "$Env:PATH" +$Env:PATH="$pwd\out;" + "$Env:PATH" + +# This is for DEBUG +# function Get-Env-Info { +# echo "Powershell: $((Get-Host).Version)" +# echo "Working Directory: $pwd" +# echo "GOPATH: $Env:GOPATH" +# echo "PATH:" +# $Env:PATH.split(";") + +# echo "-------------" + +# Get-ChildItem Env: | Format-Table -Wrap -AutoSize +# } + +# Get-Env-Info + +$Env:RUN_ID=(openssl rand -hex 16) +$Env:GOFLAGS = "-mod=mod" + +if ((Get-Command "ginkgo" -ErrorAction SilentlyContinue) -eq $null) { + go install -v github.com/onsi/ginkgo/v2/ginkgo@latest +} + +$CF_INT_NAME=(Get-Content $pwd\metadata.json -Raw| Out-String | ConvertFrom-Json).name.trim() +$Env:CF_INT_PASSWORD=(Get-Content $pwd\cf-password -Raw).trim() +$Env:CF_INT_OIDC_PASSWORD=(Get-Content $pwd\uaa-oidc-password -Raw).trim() +$Env:CF_INT_OIDC_USERNAME="admin-oidc" +$Env:CF_INT_API="https://api.$CF_INT_NAME.cf-app.com" +$Env:CF_DIAL_TIMEOUT=15 +# Enable SSL vaildation once toolsmiths supports it +# $Env:SKIP_SSL_VALIDATION="false" + +Import-Certificate -Filepath "$pwd\$CF_INT_NAME.router.ca" -CertStoreLocation "cert:\LocalMachine\root" + +New-Item "go/src/code.cloudfoundry.org" -Type Directory +New-Item -ItemType SymbolicLink -Path "$pwd/go/src/code.cloudfoundry.org/cli" -Target "$pwd" + +cd go/src/code.cloudfoundry.org/cli +go install github.com/akavel/rsrc@v0.10.2 + +Get-Command make +Get-Item Makefile + +make out/cf-cli_winx64.exe +Move-Item -Path $pwd\out\cf-cli_winx64.exe -Destination $pwd\cf.exe -Force + +cf.exe api $Env:CF_INT_API --skip-ssl-validation +cf.exe auth admin $Env:CF_INT_PASSWORD +cf.exe enable-feature-flag route_sharing + +ginkgo.exe -r ` + -nodes=16 ` + -flakeAttempts=2 ` + -slowSpecThreshold=60 ` + -randomizeAllSpecs ` + ./integration/shared/isolated ` + ./integration/v7/isolated ` + ./integration/shared/experimental ` + ./integration/v7/experimental ` + ./integration/v7/push + +if ($LASTEXITCODE -gt 0) +{ + exit 1 +} + +ginkgo.exe -r ` + -flakeAttempts=2 ` + -slowSpecThreshold=60 ` + -randomizeAllSpecs ` + ./integration/shared/global ` + ./integration/v7/global + +if ($LASTEXITCODE -gt 0) +{ + exit 1 +} diff --git a/.github/win/run-innosetup.ps1 b/.github/win/run-innosetup.ps1 new file mode 100644 index 00000000000..b1f1143550a --- /dev/null +++ b/.github/win/run-innosetup.ps1 @@ -0,0 +1,20 @@ +param ($InnoSetupConfig, $CfBinary, $InstallerOutput) + +$ErrorActionPreference = "Stop" +# in the future, this variable should cause PS to exit on non-zero exit codes from commands/exes (as opposed to PS cmdlets) +$PSNativeCommandUseErrorActionPreference = $true +# see https://github.com/PowerShell/PowerShell/issues/3415 and https://github.com/PowerShell/PowerShell-RFC/pull/277 + +$innoSetupWorkDir = "$PSScriptRoot" +$licenseDir = "${PSScriptRoot}\..\license" + +Move-Item -Force "$CfBinary" $innoSetupWorkDir\cf8.exe + +# convert line-endings +Get-Content ${licenseDir}\LICENSE-WITH-3RD-PARTY-LICENSES | Set-Content "${innoSetupWorkDir}\LICENSE" +Get-Content ${licenseDir}\CF_NOTICE | Set-Content "${innoSetupWorkDir}\NOTICE" + +iscc "$InnoSetupConfig" +Move-Item "${innoSetupWorkDir}\Output\mysetup.exe" "$InstallerOutput" + +Get-ChildItem "${innoSetupWorkDir}\Output" diff --git a/.github/win/windows-installer-v8-x64.iss b/.github/win/windows-installer-v8-x64.iss new file mode 100644 index 00000000000..29f8f652d03 --- /dev/null +++ b/.github/win/windows-installer-v8-x64.iss @@ -0,0 +1,51 @@ +[Setup] +ChangesEnvironment=yes +AlwaysShowDirOnReadyPage=yes +AppName=Cloud Foundry CLI +AppVersion=VERSION +AppVerName=Cloud Foundry CLI version VERSION +AppPublisher=Cloud Foundry Foundation +ArchitecturesInstallIn64BitMode=x64compatible +ArchitecturesAllowed=x64compatible +PrivilegesRequired=none +DefaultDirName={pf}\Cloud Foundry +SetupIconFile=cf.ico +UninstallDisplayIcon={app}\cf.ico + +[Registry] +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: IsAdminLoggedOn and Uninstall32Bit() and NeedsAddPath(ExpandConstant('{app}')) +Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: not IsAdminLoggedOn and Uninstall32Bit() and NeedsAddPath(ExpandConstant('{app}')) + +[Files] +Source: LICENSE; DestDir: "{app}" +Source: NOTICE; DestDir: "{app}" +Source: cf8.exe; DestDir: "{app}" +Source: cf.ico; DestDir: "{app}" + +[Run] +Filename: "{cmd}"; Parameters: "/C mklink ""{app}\cf.exe"" ""{app}\cf8.exe""" + +[UninstallDelete] +Type: files; Name: "{app}\cf.exe" +Type: dirifempty; Name: "{app}" + +[Code] +function Uninstall32Bit(): Boolean; +var + resultCode: Integer; + uninstallString: String; + uninstallStringPath: String; +begin + uninstallString := ''; + uninstallStringPath := 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cloud Foundry CLI_is1'; + RegQueryStringValue(HKLM, uninstallStringPath, 'UninstallString', uninstallString); + + if uninstallString <> '' then + begin + uninstallString := RemoveQuotes(uninstallString); + Exec(uninstallString, '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART','', SW_HIDE, ewWaitUntilTerminated, resultCode) + end; + Result := true; +end; + +#include "common.iss" diff --git a/.github/win/windows-installer-v8-x86.iss b/.github/win/windows-installer-v8-x86.iss new file mode 100644 index 00000000000..aa3343d012b --- /dev/null +++ b/.github/win/windows-installer-v8-x86.iss @@ -0,0 +1,31 @@ +[Setup] +ChangesEnvironment=yes +AlwaysShowDirOnReadyPage=yes +AppName=Cloud Foundry CLI +AppVersion=VERSION +AppVerName=Cloud Foundry CLI version VERSION +AppPublisher=Cloud Foundry Foundation +PrivilegesRequired=none +DefaultDirName={pf}\Cloud Foundry +SetupIconFile=cf.ico +UninstallDisplayIcon={app}\cf.ico + +[Registry] +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: IsAdminLoggedOn and NeedsAddPath(ExpandConstant('{app}')) +Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: not IsAdminLoggedOn and NeedsAddPath(ExpandConstant('{app}')) + +[Files] +Source: LICENSE; DestDir: "{app}" +Source: NOTICE; DestDir: "{app}" +Source: cf8.exe; DestDir: "{app}" +Source: cf.ico; DestDir: "{app}" + +[Run] +Filename: "{cmd}"; Parameters: "/C mklink ""{app}\cf.exe"" ""{app}\cf8.exe""" + +[UninstallDelete] +Type: files; Name: "{app}\cf.exe" +Type: dirifempty; Name: "{app}" + +[Code] +#include "common.iss" diff --git a/.github/workflows/check-cves.yml b/.github/workflows/check-cves.yml new file mode 100644 index 00000000000..ad6327b5959 --- /dev/null +++ b/.github/workflows/check-cves.yml @@ -0,0 +1,33 @@ +name: "Check CVEs" + +on: + workflow_dispatch: + pull_request: + +jobs: + check-cves: + runs-on: ubuntu-latest + + steps: + - name: Check out codebase + uses: actions/checkout@v6 + + - name: Scan current project + id: scan + uses: anchore/scan-action@v7 + with: + path: "." + add-cpes-if-none: true + by-cve: true + output-format: json + + - name: Print scan results + run: .github/scripts/format-cve-scan-results.sh ${{ steps.scan.outputs.json }} > $GITHUB_STEP_SUMMARY + if: always() + + - name: Archive CVE scan results + uses: actions/upload-artifact@v6 + if: always() + with: + name: cve-scan-results-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }} + path: ${{ steps.scan.outputs.json }} diff --git a/.github/workflows/create-bosh-lite.yml b/.github/workflows/create-bosh-lite.yml new file mode 100644 index 00000000000..ad91ccb4a8c --- /dev/null +++ b/.github/workflows/create-bosh-lite.yml @@ -0,0 +1,178 @@ +name: Create environment +on: + workflow_dispatch: + workflow_call: + outputs: + env-name: + value: ${{ jobs.create-env.outputs.envName }} + description: "Name of the created environment" + +env: + BBL_IAAS: gcp + BBL_GCP_REGION: us-east1 + BBL_GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_CREDENTIALS_JSON }} + BOSH_DEPLOYMENT: cf + BOSH_NON_INTERACTIVE: true + BBL_CLI_VERSION: ${{ vars.BBL_CLI_VERSION }} + BOSH_CLI_VERSION: ${{ vars.BOSH_CLI_VERSION }} + CREDHUB_CLI_VERSION: ${{ vars.CREDHUB_CLI_VERSION }} + +jobs: + create-env: + runs-on: ubuntu-latest + outputs: + envName: ${{steps.setup-bbl-env.outputs.envName}} + steps: + - name: Install Tools + run: | + go version + + install_location=/usr/local/bin + + sudo curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v${BBL_CLI_VERSION}/bbl-v${BBL_CLI_VERSION}_linux_amd64 --silent --location --output $install_location/bbl + sudo chmod +x $install_location/bbl + bbl --version + + sudo curl https://github.com/cloudfoundry/bosh-cli/releases/download/v${BOSH_CLI_VERSION}/bosh-cli-${BOSH_CLI_VERSION}-linux-amd64 --silent --output $install_location/bosh --location + sudo chmod +x $install_location/bosh + bosh --version + + sudo curl https://github.com/cloudfoundry/credhub-cli/releases/download/${CREDHUB_CLI_VERSION}/credhub-linux-amd64-${CREDHUB_CLI_VERSION}.tgz --silent --location --output /tmp/credhub.tgz + sudo tar -xzf /tmp/credhub.tgz -C $install_location + sudo chmod +x $install_location/credhub + credhub --version + + sudo apt update + sudo apt install -y build-essential unzip wamerican + + - name: Checkout bosh-bootloader + uses: actions/checkout@v6 + with: + repository: cloudfoundry/bosh-bootloader + path: bosh-bootloader + + - name: Checkout cli + uses: actions/checkout@v6 + with: + path: cli + + - name: Setup bbl + id: setup-bbl-env + run: | + env_name="$(grep '^.\{1,4\}$' /usr/share/dict/words | + shuf -n1 | + tr -dc '[:alnum:]\n\r' | + tr '[:upper:]' '[:lower:]')" + + if [ ! -z "${env_name}" ]; then + env_name=cli-${env_name} + mkdir -p $env_name/bbl-state + fi + echo "Bbl environment name: $env_name" + echo "envName=$env_name" >> $GITHUB_OUTPUT + + - name: Create bbl env + run: | + env_name=${{ steps.setup-bbl-env.outputs.envName }} + cd $env_name/bbl-state + + cp -R ${GITHUB_WORKSPACE}/bosh-bootloader/plan-patches/bosh-lite-gcp/* . + bbl plan --name $env_name + cp ${GITHUB_WORKSPACE}/cli/.github/bosh-lite-files/bosh-lite-dns.tf terraform/ + cp ${GITHUB_WORKSPACE}/cli/.github/bosh-lite-files/bosh-lite.tfvars vars/ + cp ${GITHUB_WORKSPACE}/cli/.github/ops-files/bosh-lite-vm-type.yml bosh-deployment/gcp/ + bbl up + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v3 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }} + + - name: Setup gcloud CLI + uses: google-github-actions/setup-gcloud@v3 + + - name: Save bbl state + run: | + env_name=${{ steps.setup-bbl-env.outputs.envName }} + gsutil -m cp -R -P ./$env_name gs://cf-cli-bosh-lites/ + + - name: Checkout cf-deployment + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cf-deployment + ref: release-candidate + path: cf-deployment + + - name: Checkout bosh-deployment + uses: actions/checkout@v6 + with: + repository: cloudfoundry/bosh-deployment + path: bosh-deployment + + - name: Upload latest CAPI release + if: ${{ (vars.USE_LATEST_CAPI == true) || (vars.CAPI_RELEASE_VERSION != '') }} + env: + capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }} + run: | + if [ -z "$capi_release_version" ]; then + capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name) + fi + + echo "Latest CAPI release is $capi_release_version" + + env_name="${{ steps.setup-bbl-env.outputs.envName }}" + cd $env_name/bbl-state + eval "$(bbl print-env --shell-type posix)" + + jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv + + bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version" + - name: Deploy cf + run: | + env_name="${{ steps.setup-bbl-env.outputs.envName }}" + cd $env_name/bbl-state + eval "$(bbl print-env --shell-type posix)" + + bosh update-runtime-config ${GITHUB_WORKSPACE}/bosh-deployment/runtime-configs/dns.yml --name dns + STEMCELL_VERSION=$(bosh interpolate ${GITHUB_WORKSPACE}/cf-deployment/cf-deployment.yml --path /stemcells/alias=default/version) + bosh upload-stemcell "https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent?v=${STEMCELL_VERSION}" + bosh update-cloud-config ${GITHUB_WORKSPACE}/cf-deployment/iaas-support/bosh-lite/cloud-config.yml + SYSTEM_DOMAIN="$env_name.app-runtime-interfaces.ci.cloudfoundry.org" + + additional_args='' + if [ -n "${{ vars.USE_LATEST_CAPI }}" ] || [ -n "${{ vars.CAPI_RELEASE_VERSION }}" ]; then + additional_args="-o ${GITHUB_WORKSPACE}/cli/.github/ops-files/use-latest-capi.yml" + fi + + bosh interpolate ${GITHUB_WORKSPACE}/cf-deployment/cf-deployment.yml \ + -o ${GITHUB_WORKSPACE}/cf-deployment/operations/bosh-lite.yml \ + -o ${GITHUB_WORKSPACE}/cf-deployment/operations/use-compiled-releases.yml \ + -o ${GITHUB_WORKSPACE}/cf-deployment/operations/enable-v2-api.yml \ + -o ${GITHUB_WORKSPACE}/cf-deployment/operations/use-internal-lookup-for-route-services.yml \ + -o ${GITHUB_WORKSPACE}/cli/.github/ops-files/diego-cell-instances.yml \ + -o ${GITHUB_WORKSPACE}/cli/.github/ops-files/add-uaa-client-credentials.yml \ + -o ${GITHUB_WORKSPACE}/cli/.github/ops-files/increase-route-registration-interval.yml \ + -o ${GITHUB_WORKSPACE}/cli/.github/ops-files/add-oidc-provider.yml ${additional_args} \ + -v client-secret="${{ secrets.CLIENT_SECRET }}" \ + -v system_domain=${SYSTEM_DOMAIN} \ + > ./director.yml + + bosh deploy director.yml + + - name: delete bosh + if: failure() + run: | + env_name="${{ steps.setup-bbl-env.outputs.envName }}" + if [ -d ${env_name}/bbl-state ]; then + cd ${env_name}/bbl-state + eval "$(bbl print-env --shell-type posix)" + + echo "Deleting env ${env_name}" + bbl down --no-confirm --gcp-service-account-key=key.json + + echo "Deleting bbl state directory" + if gsutil ls gs://cf-cli-bosh-lites | grep -q /${env_name}/; then + gsutil rm -R gs://cf-cli-bosh-lites/${env_name} + fi + fi + diff --git a/.github/workflows/delete-bosh-lite.yml b/.github/workflows/delete-bosh-lite.yml new file mode 100644 index 00000000000..532a2ae2fc6 --- /dev/null +++ b/.github/workflows/delete-bosh-lite.yml @@ -0,0 +1,82 @@ +name: Delete environment +on: + workflow_dispatch: + inputs: + env-name: + description: Env name to delete + required: true + type: string + workflow_call: + inputs: + env-name: + required: true + type: string + +env: + BBL_IAAS: gcp + BBL_GCP_REGION: us-east1 + BBL_GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_CREDENTIALS_JSON }} + BOSH_DEPLOYMENT: cf + BOSH_NON_INTERACTIVE: true + ENV_NAME: ${{ inputs.env-name }} + +jobs: + delete-env: + runs-on: ubuntu-latest + outputs: + envName: ${{steps.setup-bbl-env.outputs.env_name}} + steps: + - name: Install Tools + run: | + go version + + install_location=/usr/local/bin + bbl_version=v9.0.35 + bosh_cli_artifact=bosh-cli-7.7.2-linux-amd64 + + sudo curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/${bbl_version}/bbl-${bbl_version}_linux_amd64 --silent --location --output $install_location/bbl + sudo chmod +x $install_location/bbl + bbl --version + + sudo curl https://github.com/cloudfoundry/bosh-cli/releases/download/v7.7.2/$bosh_cli_artifact --silent --output $install_location/bosh --location + sudo chmod +x $install_location/bosh + bosh --version + + sudo apt update + sudo apt install -y build-essential unzip wamerican + + - name: Checkout cli + uses: actions/checkout@v6 + with: + path: cli + + - name: Checkout bosh-bootloader + uses: actions/checkout@v6 + with: + repository: cloudfoundry/bosh-bootloader + path: bosh-bootloader + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v3 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }} + + - name: Setup gcloud CLI + uses: google-github-actions/setup-gcloud@v3 + + - name: Download file from GCS + run: | + gsutil -m cp -P -R gs://cf-cli-bosh-lites/${ENV_NAME} . + + - name: delete bosh + run: | + cd ${ENV_NAME}/bbl-state + eval "$(bbl print-env --shell-type posix)" + + echo "Deleting env ${ENV_NAME}" + echo ${BBL_GCP_SERVICE_ACCOUNT_KEY} > key.json + bbl down --no-confirm --gcp-service-account-key=key.json + + - name: delete gcs bucket + run: | + gsutil rm -R gs://cf-cli-bosh-lites/${ENV_NAME} \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000000..bd81a99e31e --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,53 @@ +name: golangci-lint + +on: + push: + tags: + - "v8.*" + pull_request: + types: + - opened + - reopened + - synchronize + branches: + - main + - v8 + paths-ignore: + - "doc/**" + - ".gitpod.yml" + - "README.md" + workflow_dispatch: + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: '0' + - name: Set up Go 1.x + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v9 + with: + version: v2.4 + args: -v + format: + name: Run go fmt + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: '0' + - name: Set Up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + - name: Run go fmt + run: make format && git diff --exit-code diff --git a/.github/workflows/release-build-sign-upload.yml b/.github/workflows/release-build-sign-upload.yml new file mode 100644 index 00000000000..a01800cfdce --- /dev/null +++ b/.github/workflows/release-build-sign-upload.yml @@ -0,0 +1,1087 @@ +name: "Release: Build Sign Upload" +run-name: "Release: Build Sign Upload [${{ github.ref_name }}]" + +# List of env variables + +# GitHub Actions specific +# +# ACTIONS_RUNNER_DEBUG +# ACTIONS_STEP_DEBUG +# +# AWS credentials +# To upload artifacts to S3 for CLAW +# +# AWS_ACCESS_KEY_ID +# AWS_REGION +# AWS_SECRET_ACCESS_KEY +# +# GitHub details +# To publish release draft +# +# GIT_DEPLOY_HOMEBREW_TAP +# GIT_RELEASE_TARGET_REPO +# GIT_REPO_ACCESS_TOKEN +# +# Signing keys +# +# SIGNING_KEY_GPG +# SIGNING_KEY_GPG_ID +# SIGNING_KEY_GPG_PASSPHRASE +# +# SIGNING_KEY_MAC_ID +# SIGNING_KEY_MAC_PASSPHRASE +# SIGNING_KEY_MAC_PFX +# +# SIGNING_KEY_WINDOWS_ID +# SIGNING_KEY_WINDOWS_PASSPHRASE +# SIGNING_KEY_WINDOWS_PFX + +on: + workflow_dispatch: + inputs: + release_version: + description: 'Release version bump' + required: true + default: 'patch' + type: choice + options: + - minor + - patch + +permissions: + contents: write + +defaults: + run: + shell: bash + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + env: + VERSION_MAJOR: 8 + outputs: + aws-s3-bucket: "v${{ steps.bump-version.outputs.version-major }}-cf-cli-releases" + + version-build: ${{ steps.bump-version.outputs.version-build }} + version-major: ${{ env.VERSION_MAJOR }} + version-minor: ${{ steps.bump-version.outputs.version-minor }} + version-patch: ${{ steps.bump-version.outputs.version-patch }} + + steps: + - name: Checkout cli + uses: actions/checkout@v6 + + - name: Bump version + id: bump-version + run: | + set -x + git fetch --tags --quiet + latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)" + echo "Latest tag is ${latest_tag}" + + version="${latest_tag#[vV]}" + + version_minor="${version#*.}" + version_minor="${version_minor%.*}" + version_patch=${version##*.} + + if [ "${{ inputs.release_version }}" == "minor" ]; then + version_minor=$(($version_minor + 1)) + version_patch=0 + else + version_patch=$(($version_patch + 1)) + fi + + new_version="${VERSION_MAJOR}.${version_minor}.${version_patch}" + echo "new version is ${new_version}" + + echo "version-build=${new_version}" >> "${GITHUB_OUTPUT}" + echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}" + echo "version-patch=${version_patch}" >> "${GITHUB_OUTPUT}" + + - name: Publish Tag + run: | + new_tag="v${{ steps.bump-version.outputs.version-build }}" + echo "new version is $new_tag" + git config user.name "cf-cli-eng" + git config user.email "cf-cli-eng@pivotal.io" + git tag -am "Bump cli version ${new_tag}" ${new_tag} + git push origin $new_tag + + build-linux: + name: Build Linux + needs: + - setup + runs-on: ubuntu-latest + + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + + steps: + + - name: Get Build Version + id: get_build_version + run: echo "VERSION_BUILD $VERSION_BUILD" + + - name: Checkout cli + uses: actions/checkout@v6 + + - name: Checkout cli-ci + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cli-ci.git + path: cli-ci + ref: main + + - name: Install Linux Packages + run: sudo apt update && sudo apt install -y --no-install-recommends fakeroot + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Print go environment + id: go-cache-paths + run: | + echo "go-build=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}" + echo "go-mod=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}" + go env + + - name: Go Assets Cache + uses: actions/cache@v5 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-mod }} + ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build Linux + env: + CF_BUILD_VERSION: ${VERSION_BUILD} + run: | + make out/cf-cli_linux_i686 + make out/cf-cli_linux_x86-64 + make out/cf-cli_linux_arm64 + + - name: Store Linux Binaries + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-linux-binaries + path: out/cf-cli_linux* + + - name: Build RedHat Packages + env: + SIGNING_KEY_GPG_ID: ${{ vars.SIGNING_KEY_GPG_ID }} + run: | + set -ex + set -o pipefail + + root=$PWD + + cat<< EOF >~/.rpmmacros + $SIGNING_KEY_GPG_ID + EOF + + RPM_VERSION=${VERSION_BUILD//-/_} + + mkdir -pv $root/packaged + + echo "Build 32-bit RedHat package" + ( + pushd cli-ci/ci/installers/rpm + cp $root/out/cf-cli_linux_i686 cf${VERSION_MAJOR} + cp ../../license/NOTICE . + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES LICENSE + cp ../completion/cf${VERSION_MAJOR} cf${VERSION_MAJOR}.bash + echo "Version: ${RPM_VERSION}" > cf-cli.spec + cat cf${VERSION_MAJOR}-cli.spec.template >> cf-cli.spec + rpmbuild --target i386 --define "_topdir $(pwd)/build" -bb cf-cli.spec + mv build/RPMS/i386/cf${VERSION_MAJOR}-cli*.rpm $root/packaged/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_i686.rpm + popd + ) + + echo "Build 64-bit RedHat package" + ( + pushd cli-ci/ci/installers/rpm + cp $root/out/cf-cli_linux_x86-64 cf${VERSION_MAJOR} + cp ../../license/NOTICE . + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES LICENSE + cp ../completion/cf${VERSION_MAJOR} cf${VERSION_MAJOR}.bash + echo "Version: ${RPM_VERSION}" > cf-cli.spec + cat cf${VERSION_MAJOR}-cli.spec.template >> cf-cli.spec + rpmbuild --target x86_64 --define "_topdir $(pwd)/build" -bb cf-cli.spec + mv build/RPMS/x86_64/cf${VERSION_MAJOR}-cli*.rpm $root/packaged/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_x86-64.rpm + popd + ) + + echo "Build arm64 RedHat package" + ( + pushd cli-ci/ci/installers/rpm + cp $root/out/cf-cli_linux_arm64 cf${VERSION_MAJOR} + cp ../../license/NOTICE . + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES LICENSE + cp ../completion/cf${VERSION_MAJOR} cf${VERSION_MAJOR}.bash + echo "Version: ${RPM_VERSION}" > cf-cli.spec + cat cf${VERSION_MAJOR}-cli.spec.template >> cf-cli.spec + rpmbuild --target aarch64 --define "_topdir $(pwd)/build" -bb cf-cli.spec + mv build/RPMS/aarch64/cf${VERSION_MAJOR}-cli*.rpm $root/packaged/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_aarch64.rpm + popd + ) + + - name: Load GPG key + env: + SIGNING_KEY_GPG: ${{ secrets.SIGNING_KEY_GPG }} + run: | + echo -n "$SIGNING_KEY_GPG" | base64 --decode | gpg --no-tty --batch --pinentry-mode loopback --import + + - name: View GPG keys + run: | + gpg --list-keys + + - name: Sign RedHat Packages + env: + SIGNING_KEY_GPG_ID: ${{ vars.SIGNING_KEY_GPG_ID }} + SIGNING_KEY_GPG_PASSPHRASE: ${{ secrets.SIGNING_KEY_GPG_PASSPHRASE }} + run: | + set -ex + set -o pipefail + + mkdir signed-redhat-installer + + cat<< EOF >~/.rpmmacros + %_signature gpg + %_gpg_name $SIGNING_KEY_GPG_ID + %_gpgbin /usr/bin/gpg2 + %__gpg_sign_cmd %{__gpg} gpg --force-v3-sigs --batch --verbose --no-armor \ + --passphrase "$SIGNING_KEY_GPG_PASSPHRASE" --no-secmem-warning -u "%{_gpg_name}" \ + -sbo %{__signature_filename} --digest-algo sha256 %{__plaintext_filename} + EOF + + cp packaged/cf*.rpm signed-redhat-installer/ + + #TODO: consider to add --key-id + #TODO: DEV shim + rpmsign --addsign signed-redhat-installer/*.rpm + + - name: Print RPM Signature + run: rpm -q --qf 'FN:\t%{FILENAMES}\nNAME:\t%{NAME}\nPGP:\t%{SIGPGP:pgpsig}\nGPG:\t%{SIGGPG:pgpsig}\n' -p *.rpm + working-directory: signed-redhat-installer + + - name: Store Signed Linux RPM Packages + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-linux-rpm-packages + path: signed-redhat-installer/*.rpm + + - name: Build Debian Packages + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + run: | + set -ex + set -o pipefail + + root=$PWD + + mkdir -pv $root/packaged-deb + + echo "Build 32-bit Debian package" + ( + SIZE="$(BLOCKSIZE=1000 du $root/out/cf-cli_linux_i686 | cut -f 1)" + pushd cli-ci/ci/installers/deb + mkdir -p cf/usr/bin cf/usr/share/doc/cf${VERSION_MAJOR}-cli/ cf/DEBIAN cf/usr/share/bash-completion/completions + cp copyright_preamble cf/DEBIAN/copyright + sed 's/^$/ ./' $root/LICENSE >> cf/DEBIAN/copyright + cat copyright_comment_header >> cf/DEBIAN/copyright + sed 's/^$/ ./' ../../license/3RD-PARTY-LICENSES >> cf/DEBIAN/copyright + cp cf/DEBIAN/copyright cf/usr/share/doc/cf${VERSION_MAJOR}-cli/copyright + cp ../../license/NOTICE cf/usr/share/doc/cf${VERSION_MAJOR}-cli + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES cf/usr/share/doc/cf${VERSION_MAJOR}-cli/LICENSE + cp control_v${VERSION_MAJOR}.template cf/DEBIAN/control + echo "Installed-Size: ${SIZE}" >> cf/DEBIAN/control + echo "Version: ${VERSION_BUILD}" >> cf/DEBIAN/control + echo "Architecture: i386" >> cf/DEBIAN/control + cp ../completion/cf${VERSION_MAJOR} cf/usr/share/bash-completion/completions/cf${VERSION_MAJOR} + cp $root/out/cf-cli_linux_i686 cf/usr/bin/cf${VERSION_MAJOR} + ln -frs cf/usr/bin/cf${VERSION_MAJOR} cf/usr/bin/cf + fakeroot dpkg-deb -Zxz --build cf cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_i686.deb + mv cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_i686.deb $root/packaged-deb + rm -rf cf + popd + ) + + echo "Build x86 64-bit Debian package" + ( + SIZE="$(BLOCKSIZE=1000 du $root/out/cf-cli_linux_x86-64 | cut -f 1)" + pushd cli-ci/ci/installers/deb + mkdir -p cf/usr/bin cf/usr/share/doc/cf${VERSION_MAJOR}-cli/ cf/DEBIAN cf/usr/share/bash-completion/completions + cp copyright_preamble cf/DEBIAN/copyright + sed 's/^$/ ./' $root/LICENSE >> cf/DEBIAN/copyright + cat copyright_comment_header >> cf/DEBIAN/copyright + sed 's/^$/ ./' ../../license/3RD-PARTY-LICENSES >> cf/DEBIAN/copyright + cp cf/DEBIAN/copyright cf/usr/share/doc/cf${VERSION_MAJOR}-cli/copyright + cp ../../license/NOTICE cf/usr/share/doc/cf${VERSION_MAJOR}-cli + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES cf/usr/share/doc/cf${VERSION_MAJOR}-cli/LICENSE + cp control_v${VERSION_MAJOR}.template cf/DEBIAN/control + echo "Installed-Size: ${SIZE}" >> cf/DEBIAN/control + echo "Version: ${VERSION_BUILD}" >> cf/DEBIAN/control + echo "Architecture: amd64" >> cf/DEBIAN/control + cp ../completion/cf${VERSION_MAJOR} cf/usr/share/bash-completion/completions/cf${VERSION_MAJOR} + cp $root/out/cf-cli_linux_x86-64 cf/usr/bin/cf${VERSION_MAJOR} + ln -frs cf/usr/bin/cf${VERSION_MAJOR} cf/usr/bin/cf + fakeroot dpkg-deb -Zxz --build cf cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_x86-64.deb + mv cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_x86-64.deb $root/packaged-deb + popd + ) + + echo "Build ARM 64-bit Debian package" + ( + SIZE="$(BLOCKSIZE=1000 du $root/out/cf-cli_linux_arm64 | cut -f 1)" + pushd cli-ci/ci/installers/deb + mkdir -p cf/usr/bin cf/usr/share/doc/cf${VERSION_MAJOR}-cli/ cf/DEBIAN cf/usr/share/bash-completion/completions + cp copyright_preamble cf/DEBIAN/copyright + sed 's/^$/ ./' $root/LICENSE >> cf/DEBIAN/copyright + cat copyright_comment_header >> cf/DEBIAN/copyright + sed 's/^$/ ./' ../../license/3RD-PARTY-LICENSES >> cf/DEBIAN/copyright + cp cf/DEBIAN/copyright cf/usr/share/doc/cf${VERSION_MAJOR}-cli/copyright + cp ../../license/NOTICE cf/usr/share/doc/cf${VERSION_MAJOR}-cli + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES cf/usr/share/doc/cf${VERSION_MAJOR}-cli/LICENSE + cp control_v${VERSION_MAJOR}.template cf/DEBIAN/control + echo "Installed-Size: ${SIZE}" >> cf/DEBIAN/control + echo "Version: ${VERSION_BUILD}" >> cf/DEBIAN/control + echo "Architecture: arm64" >> cf/DEBIAN/control + cp ../completion/cf${VERSION_MAJOR} cf/usr/share/bash-completion/completions/cf${VERSION_MAJOR} + cp $root/out/cf-cli_linux_arm64 cf/usr/bin/cf${VERSION_MAJOR} + ln -frs cf/usr/bin/cf${VERSION_MAJOR} cf/usr/bin/cf + fakeroot dpkg-deb -Zxz --build cf cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_arm64.deb + mv cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_arm64.deb $root/packaged-deb + popd + ) + + - name: Print DEB Packages Info + run: | + ls -R + for f in *.deb; do + echo $f + dpkg --info $f + done + working-directory: packaged-deb + + - name: Store Debian Packages + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-linux-deb-packages + path: packaged-deb/*.deb + + build-macos: + name: Build macOS + needs: + - setup + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + runs-on: macos-latest + steps: + + - name: Get Build Version + id: get_build_version + run: echo "VERSION_BUILD $VERSION_BUILD" + + - name: Checkout cli + uses: actions/checkout@v6 + + - name: Checkout cli-ci + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cli-ci.git + path: cli-ci + ref: main + + - name: Checkout bomutils + uses: actions/checkout@v6 + with: + repository: hogliux/bomutils.git + ref: 0.2 + path: bomutils + + - name: Build bomutils + working-directory: bomutils + run: make + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Update Homebrew + run: | + brew tap pivotalsoftware/gon + brew update + cat "$(brew --repository)/Library/Taps/pivotalsoftware/homebrew-gon/gon.rb" > .github/brew-formulae + + - name: Configure Homebrew cache + uses: actions/cache@v5 + with: + path: | + ~/Library/Caches/Homebrew/gon--* + ~/Library/Caches/Homebrew/downloads/*--gon-* + key: brew-${{ hashFiles('.github/brew-formulae') }} + restore-keys: brew- + + - name: Install Homebrew dependencies + run: | + env HOMEBREW_NO_AUTO_UPDATE=1 brew install pivotalsoftware/gon/gon coreutils + + - name: Print go environment + id: go-cache-paths + run: | + echo "go-build=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}" + echo "go-mod=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}" + go env + + - name: Go Assets Cache + uses: actions/cache@v5 + with: + path: | + ${{ steps.go-cache-paths.outputs.go-mod }} + ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build macOS Binaries + env: + CF_BUILD_VERSION: ${VERSION_BUILD} + run: | + make out/cf-cli_osx + make out/cf-cli_macosarm + + - name: Store macOS Binaries + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-macos-binaries + path: out/cf-cli* + + - name: Build macOS x86 Installer + run: | + set -ex + set -o pipefail + + root=$PWD + + mkdir -pv $root/packaged + + echo "Building OS X installer" + ( + SIZE="$(BLOCKSIZE=1000 du $root/out/cf-cli_osx | cut -f 1)" + + pushd cli-ci/ci/installers/osx_v${VERSION_MAJOR} + sed -i -e "s/VERSION/${VERSION_BUILD}/g" Distribution + sed -i -e "s/SIZE/${SIZE}/g" Distribution + mkdir -p cf-cli/usr/local/bin cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli + + cp $root/out/cf-cli_osx cf-cli/usr/local/bin/cf${VERSION_MAJOR} + gln -frs cf-cli/usr/local/bin/cf${VERSION_MAJOR} cf-cli/usr/local/bin/cf + cp ../../license/NOTICE cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli/LICENSE + chmod -R go-w cf-cli + pushd cf-cli + find usr | cpio -o --format=odc | gzip -c > ../Payload + popd + + $root/bomutils/build/bin/ls4mkbom cf-cli | sed 's/1000\/1000/0\/80/' > bom_list + mkbom -i bom_list Bom + mv Bom Payload com.cloudfoundry.cf${VERSION_MAJOR}-cli.pkg + xar -c --compression none -f cf${VERSION_MAJOR}-cli-installer_osx.pkg com.cloudfoundry.cf${VERSION_MAJOR}-cli.pkg Distribution + mv cf${VERSION_MAJOR}-cli-installer_osx.pkg $root/packaged/cf${VERSION_MAJOR}-cli-installer_osx.pkg + popd + ) + + - name: Build macOS ARM Installer + run: | + set -ex + set -o pipefail + + root=$PWD + + mkdir -pv $root/packaged + + echo "Build macOS ARM Installer" + ( + SIZE="$(BLOCKSIZE=1000 du $root/out/cf-cli_macosarm | cut -f 1)" + + pushd cli-ci/ci/installers/osx_v${VERSION_MAJOR} + sed -i -e "s/VERSION/${VERSION_BUILD}/g" Distribution + sed -i -e "s/SIZE/${SIZE}/g" Distribution + mkdir -p cf-cli/usr/local/bin cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli + + cp $root/out/cf-cli_macosarm cf-cli/usr/local/bin/cf${VERSION_MAJOR} + gln -frs cf-cli/usr/local/bin/cf${VERSION_MAJOR} cf-cli/usr/local/bin/cf + cp ../../license/NOTICE cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli + cp ../../license/LICENSE-WITH-3RD-PARTY-LICENSES cf-cli/usr/local/share/doc/cf${VERSION_MAJOR}-cli/LICENSE + chmod -R go-w cf-cli + pushd cf-cli + find usr | cpio -o --format=odc | gzip -c > ../Payload + popd + + $root/bomutils/build/bin/ls4mkbom cf-cli | sed 's/1000\/1000/0\/80/' > bom_list + mkbom -i bom_list Bom + mv Bom Payload com.cloudfoundry.cf${VERSION_MAJOR}-cli.pkg + xar -c --compression none -f cf${VERSION_MAJOR}-cli-installer_macosarm.pkg com.cloudfoundry.cf${VERSION_MAJOR}-cli.pkg Distribution + mv cf${VERSION_MAJOR}-cli-installer_macosarm.pkg $root/packaged/cf${VERSION_MAJOR}-cli-installer_macosarm.pkg + popd + ) + + - name: Load macos key + env: + SIGNING_KEY_MAC_ID: ${{ vars.SIGNING_KEY_MAC_ID }} + SIGNING_KEY_MAC_PASSPHRASE: ${{ secrets.SIGNING_KEY_MAC_PASSPHRASE }} + SIGNING_KEY_MAC_PFX: ${{ secrets.SIGNING_KEY_MAC_PFX }} + + run: | + echo -n "$SIGNING_KEY_MAC_PFX" | base64 --decode > mac-signing-key.p12 + security list-keychains -d user -s login + + ORIGINAL_KEYCHAIN="$(security default-keychain | sed -e 's/[ "]*\([^"]*\)[ "]*/\1/')" + KEYCHAIN_PATH="$HOME/Library/Keychains/build.keychain-db" + + # Create build keychain + security create-keychain -p "$SIGNING_KEYCHAIN_PASSPHRASE" "$KEYCHAIN_PATH" + # trap "security delete-keychain $KEYCHAIN_PATH" 0 + + # Append build keychain to the user domain + security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | sed s/\"//g) + + # Remove relock timeout + security set-keychain-settings "$KEYCHAIN_PATH" + + # Unlock build keychain + security unlock-keychain -p "$SIGNING_KEYCHAIN_PASSPHRASE" "$KEYCHAIN_PATH" + + # Add certificate to keychain + security import mac-signing-key.p12 -k "$KEYCHAIN_PATH" -P "$SIGNING_KEY_MAC_PASSPHRASE" -A -T $(which codesign) -T $(which productsign) + + # Enable codesigning from a non user interactive shell + security set-key-partition-list -S apple-tool:,apple:, -s -k "$SIGNING_KEYCHAIN_PASSPHRASE" -D "${IDENTITY_CERTIFICATE}" -t private "$KEYCHAIN_PATH" || echo set-key-partition-list private failed + rm mac-signing-key.p12 + + #TODO: clean keychain in a separate step + # Delete build keychain + # security delete-keychain "$KEYCHAIN_PATH" + + - name: Sign macOS + env: + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + SIGNING_KEY_MAC_ID: ${{ vars.SIGNING_KEY_MAC_ID }} + SIGNING_KEY_MAC_PASSPHRASE: ${{ secrets.SIGNING_KEY_MAC_PASSPHRASE }} + run: | + + root=$PWD + + mkdir -pv signed-macos-installer + + #TODO: DEV shim + # cp \ + productsign --timestamp \ + --sign "$SIGNING_KEY_MAC_ID" \ + "$root/packaged/cf${VERSION_MAJOR}-cli-installer_osx.pkg" \ + "signed-macos-installer/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_osx.pkg" + + #TODO: DEV shim + # cp \ + productsign --timestamp \ + --sign "$SIGNING_KEY_MAC_ID" \ + "$root/packaged/cf${VERSION_MAJOR}-cli-installer_macosarm.pkg" \ + "signed-macos-installer/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_macosarm.pkg" + + - name: Store macOS Signed Packages + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-macos-packages + path: signed-macos-installer/*.pkg + + + build-windows: + name: Build Windows + needs: + - setup + runs-on: windows-latest + defaults: + run: + shell: pwsh + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Get build-time dependencies + run: | + choco install --no-progress --limit-output -y make + go install github.com/akavel/rsrc@v0.10.2 + + - name: Build CF CLI for Windows + env: + CF_BUILD_VERSION: ${VERSION_BUILD} + run: | + Get-Command make + Get-Item Makefile + make out/cf-cli_win32.exe + make out/cf-cli_winx64.exe + + - name: Set up certificate + run: | + echo "${{ secrets.SIGNING_KEY_WINDOWS_DIGICERT_CLIENT_CERT_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12 + shell: bash + + - name: Set variables + id: variables + run: | + echo "SM_HOST=${{ vars.SIGNING_KEY_WINDOWS_DIGICERT_HOST }}" >> "$GITHUB_ENV" + echo "SM_API_KEY=${{ secrets.SIGNING_KEY_WINDOWS_DIGICERT_API_KEY }}" >> "$GITHUB_ENV" + echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV" + echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SIGNING_KEY_WINDOWS_DIGICERT_CLIENT_CERT_INSTALLATION_PASSWORD }}" >> "$GITHUB_ENV" + echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH + echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH + echo "C:\Program Files\DigiCert\DigiCert Keylocker Tools" >> $GITHUB_PATH + shell: bash + + - name: Setup Keylocker KSP on Windows + run: | + curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o Keylockertools-windows-x64.msi + msiexec /i Keylockertools-windows-x64.msi /quiet /qn + smksp_registrar.exe list + smctl.exe keypair ls + C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user + smctl windows certsync + shell: cmd + + - name: Sign Windows binaries + run: | + smctl healthcheck --all + smctl sign --fingerprint ${{ vars.SIGNING_KEY_WINDOWS_DIGICERT_CERT_FINGERPRINT }} --tool signtool --input out\cf-cli_win32.exe + smctl sign --fingerprint ${{ vars.SIGNING_KEY_WINDOWS_DIGICERT_CERT_FINGERPRINT }} --tool signtool --input out\cf-cli_winx64.exe + + - name: View binary signatures + run: | + Get-AuthenticodeSignature -Verbose -ErrorAction Stop .\out\cf-cli_win32.exe + Get-AuthenticodeSignature -Verbose -ErrorAction Stop .\out\cf-cli_winx64.exe + + - name: Make symlinks + run: | + New-Item -ItemType SymbolicLink -Target .\out\cf-cli_win32.exe -Path .\out\cf-cli_win32-link.exe + New-Item -ItemType SymbolicLink -Target .\out\cf-cli_winx64.exe -Path .\out\cf-cli_winx64-link.exe + + - name: Save signed binaries as a GitHub Action Artifact + uses: actions/upload-artifact@v6 + with: + name: cf-cli-windows-binaries + if-no-files-found: error + path: out/cf-cli_win*.exe + + - name: Install innosetup + run: .\.github\win\install-innosetup.ps1 + + - name: Run innosetup + run: | + mkdir "${env:RUNNER_TEMP}\winx64" + .\.github\win\run-innosetup.ps1 -InnoSetupConfig ".github\win\windows-installer-v${env:VERSION_MAJOR}-x64.iss" -CfBinary "out\cf-cli_winx64.exe" -InstallerOutput "${env:RUNNER_TEMP}\winx64\cf${env:VERSION_MAJOR}_installer.exe" + mkdir "${env:RUNNER_TEMP}\win32" + .\.github\win\run-innosetup.ps1 -InnoSetupConfig ".github\win\windows-installer-v${env:VERSION_MAJOR}-x86.iss" -CfBinary "out\cf-cli_win32.exe" -InstallerOutput "${env:RUNNER_TEMP}\win32\cf${env:VERSION_MAJOR}_installer.exe" + + - name: Sign Windows installers + run: | + smctl sign --fingerprint ${{ vars.SIGNING_KEY_WINDOWS_DIGICERT_CERT_FINGERPRINT }} --tool signtool --input "${env:RUNNER_TEMP}\win32\cf${env:VERSION_MAJOR}_installer.exe" + smctl sign --fingerprint ${{ vars.SIGNING_KEY_WINDOWS_DIGICERT_CERT_FINGERPRINT }} --tool signtool --input "${env:RUNNER_TEMP}\winx64\cf${env:VERSION_MAJOR}_installer.exe" + + - name: View installer signature + run: | + Get-AuthenticodeSignature -Verbose -ErrorAction Stop "${env:RUNNER_TEMP}\win32\cf${env:VERSION_MAJOR}_installer.exe" + Get-AuthenticodeSignature -Verbose -ErrorAction Stop "${env:RUNNER_TEMP}\winx64\cf${env:VERSION_MAJOR}_installer.exe" + + - name: Arrange files for upload + # note the -Path flag takes comma-delimited args + run: | + Copy-Item -Destination "${env:RUNNER_TEMP}\win32" -Path .github\win\LICENSE,.github\win\NOTICE + Copy-Item -Destination "${env:RUNNER_TEMP}\winx64" -Path .github\win\LICENSE,.github\win\NOTICE + + - name: Zip Windows artifact + run: | + pushd "${env:RUNNER_TEMP}\win32" + $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_win32.zip" + Compress-Archive -DestinationPath "$installer_zip_filename" -Path * + popd + pushd "${env:RUNNER_TEMP}\winx64" + $installer_zip_filename="${env:RUNNER_TEMP}\cf${env:VERSION_MAJOR}-cli-installer_${env:VERSION_BUILD}_winx64.zip" + Compress-Archive -DestinationPath "$installer_zip_filename" -Path * + popd + Get-ChildItem "${env:RUNNER_TEMP}" + + - name: Save installer and dist files as a GitHub Action Artifact + uses: actions/upload-artifact@v6 + with: + name: cf-cli-windows-packages + if-no-files-found: error + path: ${{ runner.temp }}/cf${{ needs.setup.outputs.version-major }}-cli-installer*win*.zip + +################################# +######## Release Section ######## +################################# + + s3-upload: + name: Upload Artifacts to S3 bucket + runs-on: ubuntu-latest + needs: + - setup + - test-rpm-package + - test-deb-package + - test-macos + - test-windows + permissions: + actions: read + contents: read + env: + AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} + AWS_REGION: ${{ vars.AWS_REGION }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_BUCKET: ${{ needs.setup.outputs.aws-s3-bucket }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Checkout cli + uses: actions/checkout@v6 + + - name: Download signed artifacts + uses: actions/download-artifact@v7 + with: + path: signed # download all artifacts to 'signed/' + + - name: Archive nix binaries for upload + run: | + + prepare_legal() { + cp ../../.github/license/LICENSE-WITH-3RD-PARTY-LICENSES LICENSE + cp ../../.github/license/CF_NOTICE NOTICE + } + + prepare_artifacts() { + chmod +x cf${VERSION_MAJOR} + ln -s cf${VERSION_MAJOR} cf + prepare_legal + } + + prepare_win_artifacts() { + cp cf${VERSION_MAJOR}.exe cf.exe + prepare_legal + } + + pushd signed + mkdir linux_i686 linux_x86-64 linux_arm64 + mv cf-cli-linux-binaries/cf-cli_linux_i686 linux_i686/cf${VERSION_MAJOR} + mv cf-cli-linux-binaries/cf-cli_linux_x86-64 linux_x86-64/cf${VERSION_MAJOR} + mv cf-cli-linux-binaries/cf-cli_linux_arm64 linux_arm64/cf${VERSION_MAJOR} + pushd linux_i686 + prepare_artifacts + tar -cvzf cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_linux_i686.tgz * + popd + pushd linux_x86-64 + prepare_artifacts + tar -cvzf cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_linux_x86-64.tgz * + popd + pushd linux_arm64 + prepare_artifacts + tar -cvzf cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_linux_arm64.tgz * + popd + + mkdir osx + mv cf-cli-macos-binaries/cf-cli_osx osx/cf${VERSION_MAJOR} + pushd osx + prepare_artifacts + tar -cvzf cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_osx.tgz * + popd + mkdir macosarm + mv cf-cli-macos-binaries/cf-cli_macosarm macosarm/cf${VERSION_MAJOR} + pushd macosarm + prepare_artifacts + tar -cvzf cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_macosarm.tgz * + popd + + mkdir win32 winx64 + mv cf-cli-windows-binaries/cf-cli_win32.exe win32/cf${VERSION_MAJOR}.exe + mv cf-cli-windows-binaries/cf-cli_winx64.exe winx64/cf${VERSION_MAJOR}.exe + pushd win32 + prepare_win_artifacts + # -y flag avoids the default behavior of dereferencing the link, so we archive the symlink as-is + zip -y cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_win32.zip * + popd + pushd winx64 + prepare_win_artifacts + # -y flag avoids the default behavior of dereferencing the link, so we archive the symlink as-is + zip -y cf${VERSION_MAJOR}-cli_${VERSION_BUILD}_winx64.zip * + popd + popd + + - name: Rearrange artifacts before upload + run: | + mkdir upload + cp -v -t upload \ + signed/cf-cli-linux-rpm-packages/cf*rpm \ + signed/cf-cli-linux-deb-packages/cf*deb \ + signed/cf-cli-macos-packages/cf*pkg \ + signed/cf-cli-windows-packages/cf*zip \ + signed/linux_i686/*tgz \ + signed/linux_x86-64/*tgz \ + signed/linux_arm64/*tgz \ + signed/osx/*tgz \ + signed/macosarm/*tgz \ + signed/win32/*zip \ + signed/winx64/*zip + + - name: Store Artifacts + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: final-artifacts + path: signed/* + + - name: Setup aws to upload installers to CLAW S3 bucket + uses: aws-actions/configure-aws-credentials@v5 + with: + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ vars.AWS_S3_ROLE_ARN }} + role-skip-session-tagging: true + role-duration-seconds: 1200 + + - name: Upload installers to CLAW S3 bucket + run: aws s3 sync upload "s3://v${VERSION_MAJOR}-cf-cli-releases/releases/v${VERSION_BUILD}/" + + - name: list S3 for human verification + run: aws s3 ls "s3://v${VERSION_MAJOR}-cf-cli-releases/releases/v${VERSION_BUILD}/" + + test-rpm-package: + name: Test RPM Artifacts + needs: + - setup + - build-linux + runs-on: ubuntu-latest + container: + image: fedora + steps: + + - name: Download Signed Linux Packages + uses: actions/download-artifact@v7 + with: + name: cf-cli-linux-rpm-packages + + - name: Display structure of downloaded files + run: ls -R + + - name: Test RPMs + run: | + rpm -q --qf 'FN:\t%{FILENAMES}\nNAME:\t%{NAME}\nPGP:\t%{SIGPGP:pgpsig}\nGPG:\t%{SIGGPG:pgpsig}\n' -p *.rpm + + test-deb-package: + name: Test Debian Artifacts + needs: + - setup + - build-linux + strategy: + matrix: + image: + - debian:11 + - debian:12 + - ubuntu:22.04 + - ubuntu:latest + runs-on: ubuntu-latest + steps: + + - name: Download Signed Linux Packages + uses: actions/download-artifact@v7 + with: + name: cf-cli-linux-deb-packages + + - name: Display structure and verify + env: + IMAGE: ${{ matrix.image }} + run: | + docker run \ + --interactive \ + --rm \ + -v .:/workspace \ + ${IMAGE} < " + grep PRETTY_NAME /etc/os-release | cut -d= -f2- + cd workspace + ls *.deb | xargs -n1 dpkg --info + EOC + + test-macos: + name: Test macOS Artifacts + needs: + - setup + - build-macos + runs-on: macos-latest + steps: + + - name: Download Signed macOS Packages + uses: actions/download-artifact@v7 + with: + name: cf-cli-macos-packages + + - name: Inspect macOS packages + run: | + ls -R + #TODO: DEV shim + pkgutil --check-signature * + + test-windows: + name: Test Windows Artifacts + needs: + - setup + - build-windows + runs-on: windows-latest + defaults: + run: + shell: pwsh + env: + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Download Signed Windows Binaries + uses: actions/download-artifact@v7 + with: + name: cf-cli-windows-binaries + + - name: Inspect Windows packages + run: | + Get-AuthenticodeSignature -Verbose -ErrorAction Stop .\cf-cli_win32.exe + Get-AuthenticodeSignature -Verbose -ErrorAction Stop .\cf-cli_winx64.exe + + - name: Download Signed Windows Binaries + uses: actions/download-artifact@v7 + with: + name: cf-cli-windows-packages + + - name: Inspect Windows files + run: | + Get-ChildItem -Force + + - name: View installer signature + run: | + Expand-Archive -DestinationPath winx64 -Path cf${env:VERSION_MAJOR}-cli-installer_*_winx64.zip + Expand-Archive -DestinationPath win32 -Path cf${env:VERSION_MAJOR}-cli-installer_*_win32.zip + + Get-AuthenticodeSignature -Verbose -ErrorAction Stop ".\winx64\cf${env:VERSION_MAJOR}_installer.exe" + Get-AuthenticodeSignature -Verbose -ErrorAction Stop ".\win32\cf${env:VERSION_MAJOR}_installer.exe" + + github-release-draft: + name: Create GitHub Release Draft + runs-on: ubuntu-latest + env: + REPO_DIR: repo + ARTIFACTS_DIR: artifacts + permissions: + actions: read + contents: write + needs: + - setup + - s3-upload + steps: + - name: Download signed artifacts + uses: actions/download-artifact@v7 + with: + name: final-artifacts + path: ${{ env.ARTIFACTS_DIR }} + + - name: Checkout CLI + uses: actions/checkout@v6 + with: + path: ${{ env.REPO_DIR }} + + - name: Prepare release notes + run: | + sed -i 's/new-version/${{ needs.setup.outputs.version-build }}/g' "${{ env.REPO_DIR }}/.github/release/release-notes-template.txt" + + - name: Create draft release + uses: softprops/action-gh-release@v2 + with: + draft: true + name: "DRAFT v${{ needs.setup.outputs.version-build }}" + tag_name: "v${{ needs.setup.outputs.version-build }}" + body_path: "${{ env.REPO_DIR }}/.github/release/release-notes-template.txt" + fail_on_unmatched_files: true + generate_release_notes: true + files: | + ${{ env.ARTIFACTS_DIR }}/cf-cli-linux-rpm-packages/cf*rpm + ${{ env.ARTIFACTS_DIR }}/cf-cli-linux-deb-packages/cf*deb + ${{ env.ARTIFACTS_DIR }}/cf-cli-macos-packages/cf*pkg + ${{ env.ARTIFACTS_DIR }}/cf-cli-windows-packages/cf*zip + ${{ env.ARTIFACTS_DIR }}/linux_i686/*tgz + ${{ env.ARTIFACTS_DIR }}/linux_x86-64/*tgz + ${{ env.ARTIFACTS_DIR }}/linux_arm64/*tgz + ${{ env.ARTIFACTS_DIR }}/osx/*tgz + ${{ env.ARTIFACTS_DIR }}/macosarm/*tgz + ${{ env.ARTIFACTS_DIR }}/win32/*zip + ${{ env.ARTIFACTS_DIR }}/winx64/*zip + + update-claw: + name: Add new release version to CLAW + runs-on: ubuntu-latest + needs: + - setup + - s3-upload + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + steps: + - name: Checkout CLAW + uses: actions/checkout@v6 + with: + repository: cloudfoundry/CLAW + ref: master + path: CLAW + ssh-key: ${{ secrets.GIT_SSH_KEY_CLAW }} + + - name: Add new version to claw variables + run: | + set -ex + + pushd CLAW + if grep --quiet "${VERSION_BUILD}" "claw-variables.yml" ; then + echo 'Version already exists in CLAW.' + exit 1 + else + echo "- ${VERSION_BUILD}" >> claw-variables.yml + + git add claw-variables.yml + + if ! [ -z "$(git status --porcelain)"]; then + git config user.name cf-cli-eng + git config user.email cf-cli-eng@pivotal.io + git commit -m "Add CF CLI ${VERSION_BUILD}" + else + echo "no new version to commit" + fi + + git push + fi + popd diff --git a/.github/workflows/release-update-repos.yml b/.github/workflows/release-update-repos.yml new file mode 100644 index 00000000000..92ea2b89bfa --- /dev/null +++ b/.github/workflows/release-update-repos.yml @@ -0,0 +1,644 @@ +name: "Release: Update Repositories" +run-name: "Release: Update Repositories [${{ github.ref_name }}]" + +on: + workflow_dispatch: + +permissions: + contents: write + +defaults: + run: + shell: bash + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + env: + VERSION_MAJOR: 8 + outputs: + version-build: ${{ steps.parse-semver.outputs.version-build }} + version-major: ${{ env.VERSION_MAJOR }} + version-minor: ${{ steps.parse-semver.outputs.version-minor }} + version-patch: ${{ steps.parse-semver.outputs.version-patch }} + claw-url: ${{ steps.set-claw-url.outputs.claw-url }} + + steps: + - name: Set CLAW URL + id: set-claw-url + run: echo "claw-url=https://packages.cloudfoundry.org" >> "${GITHUB_OUTPUT}" + + - name: Checkout cli + uses: actions/checkout@v6 + + - name: Parse semver + id: parse-semver + run: | + git fetch --tags --quiet + latest_tag="$(git tag | sort -V | grep v${VERSION_MAJOR} | tail -1)" + echo "Latest tag is ${latest_tag}" + + version="${latest_tag#[vV]}" + + version_minor="${version#*.}" + version_minor="${version_minor%.*}" + + echo "version-build=${version}" >> "${GITHUB_OUTPUT}" + echo "version-major=${version%%\.*}" >> "${GITHUB_OUTPUT}" + echo "version-minor=${version_minor}" >> "${GITHUB_OUTPUT}" + echo "version-patch=${version##*.}" >> "${GITHUB_OUTPUT}" + + echo "VERSION_BUILD=${version}" >> "${GITHUB_ENV}" + + - name: Test if CLAW serve this version + env: + CLAW_URL: ${{ steps.set-claw-url.outputs.claw-url }} + run: > + set -vx + + curl --head "${CLAW_URL}/stable?release=linux64-binary&version=${VERSION_BUILD}&source=test" 2>&1 | + grep --quiet --regexp 'HTTP.*302' + + update-homebrew: + name: Update Homebrew Repository + runs-on: ubuntu-latest + needs: setup + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Checkout cli-ci + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cli-ci.git + ref: main + path: cli-ci + + - name: Checkout homebrew-tap + uses: actions/checkout@v6 + with: + repository: cloudfoundry/homebrew-tap + ref: master + path: homebrew-tap + ssh-key: ${{ secrets.GIT_DEPLOY_HOMEBREW_TAP }} + + - name: Setup + run: > + mkdir + cf-cli-osx-tarball + cf-cli-macosarm-tarball + cf-cli-linux-tarball + + - name: Calculate checksums + run: | + set -x + + curl -L "${CLAW_URL}/stable?release=macosx64-binary&version=${VERSION_BUILD}&source=github-rel" \ + > cf-cli-osx-tarball/cf-cli_osx.tgz + + curl -L "${CLAW_URL}/stable?release=macosarm-binary&version=${VERSION_BUILD}&source=github-rel" \ + > cf-cli-macosarm-tarball/cf-cli_macosarm.tgz + + curl -L "${CLAW_URL}/stable?release=linux64-binary&version=${VERSION_BUILD}&source=github-rel" \ + > cf-cli-linux-tarball/cf-cli_linux64.tgz + + curl -L "${CLAW_URL}/stable?release=linuxarm64-binary&version=${VERSION_BUILD}&source=github-rel" \ + > cf-cli-linux-tarball/cf-cli_linuxarm64.tgz + + # Because CLAW always returns 200 we have to check if we got archive + file cf-cli-osx-tarball/cf-cli_osx.tgz | grep -q gzip || exit 1 + file cf-cli-macosarm-tarball/cf-cli_macosarm.tgz | grep -q gzip || exit 1 + file cf-cli-linux-tarball/cf-cli_linux64.tgz | grep -q gzip || exit 1 + file cf-cli-linux-tarball/cf-cli_linuxarm64.tgz | grep -q gzip || exit 1 + + pushd cf-cli-osx-tarball + CLI_OSX_SHA256=$(shasum -a 256 cf-cli_osx.tgz | cut -d ' ' -f 1) + popd + + pushd cf-cli-macosarm-tarball + CLI_MACOSARM_SHA256=$(shasum -a 256 cf-cli_macosarm.tgz | cut -d ' ' -f 1) + popd + + pushd cf-cli-linux-tarball + CLI_LINUX_64_SHA256=$(shasum -a 256 cf-cli_linux64.tgz | cut -d ' ' -f 1) + popd + + pushd cf-cli-linux-tarball + CLI_LINUX_ARM64_SHA256=$(shasum -a 256 cf-cli_linuxarm64.tgz | cut -d ' ' -f 1) + popd + + echo "CLI_OSX_SHA256=${CLI_OSX_SHA256}" >> "${GITHUB_ENV}" + echo "CLI_MACOSARM_SHA256=${CLI_MACOSARM_SHA256}" >> "${GITHUB_ENV}" + echo "CLI_LINUX_64_SHA256=${CLI_LINUX_64_SHA256}" >> "${GITHUB_ENV}" + echo "CLI_LINUX_ARM64_SHA256=${CLI_LINUX_ARM64_SHA256}" >> "${GITHUB_ENV}" + + - name: Generate Homebrew formula file + run: | + set -ex + + pushd homebrew-tap + cat < cf-cli@${VERSION_MAJOR}.rb + class CfCliAT${VERSION_MAJOR} < Formula + desc "Cloud Foundry CLI" + homepage "https://code.cloudfoundry.org/cli" + version "${VERSION_BUILD}" + + if OS.mac? + if Hardware::CPU.arm? + url "${CLAW_URL}/homebrew?arch=macosarm&version=${VERSION_BUILD}" + sha256 "${CLI_MACOSARM_SHA256}" + elsif + url "${CLAW_URL}/homebrew?arch=macosx64&version=${VERSION_BUILD}" + sha256 "${CLI_OSX_SHA256}" + end + elsif OS.linux? + url "${CLAW_URL}/stable?release=linux64-binary&version=${VERSION_BUILD}&source=homebrew" + sha256 "${CLI_LINUX_64_SHA256}" + end + + def install + bin.install "cf${VERSION_MAJOR}" + bin.install_symlink "cf${VERSION_MAJOR}" => "cf" + (bash_completion/"cf${VERSION_MAJOR}-cli").write <<-completion + $(cat ../cli-ci/ci/installers/completion/cf${VERSION_MAJOR}) + completion + doc.install "LICENSE" + doc.install "NOTICE" + end + + test do + system "#{bin}/cf${VERSION_MAJOR}" + end + end + EOF + + popd + + - name: Commit new homebrew formula + run: | + pushd homebrew-tap + git add cf-cli@${VERSION_MAJOR}.rb + + if ! [ -z "$(git status --porcelain)"]; then + git config user.name cf-cli-eng + git config user.email cf-cli-eng@pivotal.io + git commit -m "Release CF CLI ${VERSION_BUILD}" + else + echo "no new version to commit" + fi + + git push + + echo "::group::cf-cli@${VERSION_MAJOR}.rb" + cat cf-cli@${VERSION_MAJOR}.rb + echo "::endgroup::" + + echo "::group::git show" + git show + echo "::endgroup::" + + popd + + test-homebrew: + name: Test Homebrew Repository + runs-on: macos-latest + needs: + - setup + - update-homebrew + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Install CF CLI via Homebrew + run: | + set -evx + + brew install cloudfoundry/tap/cf-cli@${VERSION_MAJOR} + installed_cf_version=$(cf${VERSION_MAJOR} version) + + cf_location=$(which cf) + + echo $cf_location + echo $installed_cf_version + echo ${VERSION_BUILD} + + codesign --verify $cf_location || echo --- + + cf -v | grep "${VERSION_BUILD}" + + update-deb: + name: Update Debian Repository + runs-on: ubuntu-latest + needs: setup + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Setup + run: | + echo "VERSION_BUILD: ${VERSION_BUILD}" + + - name: Checkout + uses: actions/checkout@v6 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + - run: gem install deb-s3 + #RUN apt install -y ruby1.9.1 createrepo + + - name: Load GPG key + env: + SIGNING_KEY_GPG: ${{ secrets.SIGNING_KEY_GPG }} + SIGNING_KEY_GPG_PASSPHRASE: ${{ secrets.SIGNING_KEY_GPG_PASSPHRASE }} + run: | + echo -n "${SIGNING_KEY_GPG}" | base64 --decode | gpg --no-tty --batch --pinentry-mode loopback --import + + - name: View GPG keys + run: gpg --list-keys + + - name: Configure GPG + run: | + echo "Configure GPG" + + # mkdir gpg-dir + # export GNUPGHOME=${PWD}/gpg-dir + # chmod 700 ${GNUPGHOME} + # TODO: restore + # trap "rm -rf ${GNUPGHOME}" 0 + + cat >> ~/gpg.conf < installers/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_i686.deb + curl -L "${CLAW_URL}/stable?release=debian64&version=${VERSION_BUILD}&source=github-rel" > installers/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_x86-64.deb + curl -L "${CLAW_URL}/stable?release=debianarm64&version=${VERSION_BUILD}&source=github-rel" > installers/cf${VERSION_MAJOR}-cli-installer_${VERSION_BUILD}_arm64.deb + + - name: Update Debian Repository + env: + DEBIAN_FRONTEND: noninteractive + SIGNING_KEY_GPG_ID: ${{ vars.SIGNING_KEY_GPG_ID }} + AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }} + AWS_BUCKET_NAME: cf-cli-debian-repo + AWS_DEFAULT_REGION: us-west-2 + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ROLE_ARN: ${{ vars.AWS_S3_ROLE_ARN }} + run: | + export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn ${AWS_S3_ROLE_ARN} --role-session-name foobar --output text --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]")) + deb-s3 upload installers/*.deb \ + --preserve-versions \ + --bucket=${AWS_BUCKET_NAME} \ + --sign=${SIGNING_KEY_GPG_ID} + + test-deb: + name: Test Debian Repository + strategy: + matrix: + image: + - debian:11 + - debian:12 + - debian:13 + - ubuntu:22.04 + - ubuntu:latest + runs-on: ubuntu-latest + needs: + - setup + - update-deb + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Install CF CLI via apt + env: + IMAGE: ${{ matrix.image }} + run: | + docker run \ + --interactive \ + --rm \ + ${IMAGE} < + # s3 cp --recursive + # s3://cf-cli-rpm-repo/ + # backup + # TODO: fix https://aws.amazon.com/premiumsupport/knowledge-center/s3-access-denied-listobjects-sync/ + # + # - name: List assets + # run: | + # ls -R + # + # - name: Backup current Linux RPM repodata + # uses: actions/upload-artifact@v6 + # with: + # if-no-files-found: error + # name: cf-cli-linux-rpm-repodata-backup + # path: backup + + - name: Install Linux Packages + env: + DEBIAN_FRONTEND: noninteractive + run: > + sudo apt update + && sudo apt install --yes --no-install-recommends + gnupg + createrepo-c + python3-pip + && pip3 install awscli + + - name: Setup aws to upload installers to CLAW S3 bucket + uses: aws-actions/configure-aws-credentials@v5 + with: + aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ vars.AWS_S3_ROLE_ARN }} + role-skip-session-tagging: true + role-duration-seconds: 1200 + + - name: Download V8 RPMs + run: aws s3 sync --exclude "*" --include "releases/*/*installer*.rpm" s3://v8-cf-cli-releases . + + - name: Download V7 RPMs + run: aws s3 sync --exclude "*" --include "releases/*/*installer*.rpm" s3://v7-cf-cli-releases . + + - name: Download V6 RPMs + run: aws s3 sync --exclude "*" --include "releases/*/*installer*.rpm" s3://cf-cli-releases . + + - name: Sign repo + run: createrepo_c --checksum=sha . + + - name: List assets + run: ls -R + + - name: Store Linux RPM repodata + uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + name: cf-cli-linux-rpm-repodata + path: repodata + + - name: Upload RPM repodata + run: aws s3 sync --delete repodata s3://cf-cli-rpm-repo/repodata + + test-rpm-repo: + name: Test RPM Repository + needs: + - setup + - update-rpm + runs-on: ubuntu-latest + container: + image: fedora + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Configure Custom CF Repository + run: | + curl -sL -o /etc/yum.repos.d/cloudfoundry-cli.repo \ + ${CLAW_URL}/fedora/cloudfoundry-cli.repo + + - name: Install cf cli package + run: dnf install -y cf${VERSION_MAJOR}-cli + + - name: Print CF CLI Versions + run: | + cf -v + cf${VERSION_MAJOR} -v + + - name: Test Version Match + run: cf -v | grep -q "${VERSION_BUILD}" + + update-windows: + name: Update Windows Chocolatey Package + runs-on: windows-latest + defaults: + run: + shell: pwsh + needs: setup + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Setup + run: | + echo "VERSION_BUILD: ${VERSION_BUILD}" + + - name: Checkout + uses: actions/checkout@v6 + + - name: Calculate Checksums + run: | + foreach ($bit in @('32', '64')) { + $file="cf-cli_win${bit}.zip" + Invoke-WebRequest "${env:CLAW_URL}/stable?release=windows${bit}-exe&version=${env:VERSION_BUILD}&source=github-rel" ` + -OutFile $file + + if (-not (Test-Path -Path $file)) { + Write-Error "Failed to download $file" -ErrorAction Stop + } + + $hash = (Get-FileHash $file).Hash + Add-Content -Path "$env:GITHUB_ENV" -Value "CLI_WIN${bit}_SHA256=$hash" + } + + - name: Render Chocolatey Templates + run: | + # Ensure current directory is accurate for WriteAllLines + [System.Environment]::CurrentDirectory = (Get-Location).Path + + # Use WriteAllLines because it uses UTF8 without a BOM + $nuspec = (Get-Content -Encoding utf8 -Raw ./.github/win/choco/cloudfoundry-cli.nuspec.tmpl). + Replace('${version}', $env:VERSION_BUILD) + [System.IO.File]::WriteAllLines('./cloudfoundry-cli.nuspec', $nuspec) + + Get-Content ./cloudfoundry-cli.nuspec + + New-Item -Path ./tools -ItemType Directory -Force | Out-Null + (Get-Content -Encoding utf8 -Raw ./.github/win/choco/chocolateyinstall.ps1.tmpl). + Replace('${version}', $env:VERSION_BUILD). ` + Replace('${checksum}', $env:CLI_WIN32_SHA256). ` + Replace('${checksum64}', $env:CLI_WIN64_SHA256). ` + Replace('${claw_url}', $env:CLAW_URL) | ` + Set-Content ./tools/chocolateyinstall.ps1 -Encoding utf8 + + Get-Content ./tools/chocolateyinstall.ps1 + + - name: Create Chocolatey Package + run: | + choco pack ./cloudfoundry-cli.nuspec + + - name: Push Chocolatey Package + env: + CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }} + run: | + choco config set --name=defaultPushSource --value=https://push.chocolatey.org/ + choco setapikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/ + choco push "cloudfoundry-cli.$env:VERSION_BUILD.nupkg" + + test-windows: + name: Test Windows Chocolatey Package + runs-on: windows-latest + defaults: + run: + shell: pwsh + needs: + - setup + - update-windows + env: + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Install cf cli package + run: choco install cloudfoundry-cli --version $env:VERSION_BUILD + + - name: Print Chocolatey CF CLI Versions + run: | + cd 'C:/ProgramData/chocolatey/lib/cloudfoundry-cli/tools' + ./cf -v + Invoke-Expression "./cf$env:VERSION_MAJOR -v" + + - name: Test Chocolatey Version Match + run: | + cd 'C:/ProgramData/chocolatey/lib/cloudfoundry-cli/tools' + $found = (./cf -v | Select-String "$env:VERSION_BUILD") + if ($null -eq $found) { + Write-Error "CF CLI version $env:VERSION_BUILD was not found" -ErrorAction Stop + } + + build-docker: + name: Build Docker Image + runs-on: ubuntu-latest + needs: setup + env: + CLAW_URL: ${{ needs.setup.outputs.claw-url }} + VERSION_BUILD: ${{ needs.setup.outputs.version-build }} + VERSION_MAJOR: ${{ needs.setup.outputs.version-major }} + steps: + + - name: Setup + env: + ENVIRONMENT: ${{ github.event.inputs.environment }} + VERSION_BUILD: ${{ github.event.inputs.build_version }} + run: | + echo "VERSION_BUILD: ${VERSION_BUILD}" + echo "Environment: ${ENVIRONMENT}" + + - name: Checkout + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cli + ref: ${{ github.ref_name }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and export to Docker locally + uses: docker/build-push-action@v6 + with: + context: docker + load: true + no-cache: true + tags: ${{ env.VERSION_BUILD }} + + - name: Test docker container + run: | + cat <<\EOF > test.sh + set -eux + + # Test if CLI inside container is correct + + if ! [ -x "$(command -v cf)" ]; then + echo 'Error: cf is not installed.' >&2 + exit 1 + fi + + CF_VERSION="$(cf -v)" + VERSION=${{ env.VERSION_BUILD }} + + if [[ ! "${CF_VERSION}" == *"cf version $VERSION"* ]]; then + echo "Error: cf -v did not match expected version" + echo "Expected: $VERSION" + echo "Got ${CF_VERSION}" + exit 1 + fi + EOF + + chmod 700 test.sh + + docker run -v $(pwd):/clidir -w /clidir \ + --rm ${{ env.VERSION_BUILD }} sh test.sh + + rm test.sh + + - name: Push image + uses: docker/build-push-action@v6 + with: + context: docker + push: true + tags: cloudfoundry/cli:${{ env.VERSION_BUILD }}, cloudfoundry/cli:latest + \ No newline at end of file diff --git a/.github/workflows/test-latest-releases.yml b/.github/workflows/test-latest-releases.yml new file mode 100644 index 00000000000..d847bb24b2c --- /dev/null +++ b/.github/workflows/test-latest-releases.yml @@ -0,0 +1,146 @@ +name: "Check: Check release on package managers" +run-name: "Check: Check release on package managers [${{ github.ref_name }}]" + +on: + workflow_dispatch: + inputs: + major-version: + description: Major version to retrieve + required: true + type: choice + options: + - '8' + - '7' + version: + description: Version of CLI to check if it is present + type: string + required: true + claw-url: + description: Location of CLAW + type: string + required: true + default: https://packages.cloudfoundry.org + +defaults: + run: + shell: bash + +jobs: + test-homebrew: + name: Test Homebrew Repository + runs-on: macos-latest + env: + CLAW_URL: ${{ inputs.claw-url }} + VERSION_BUILD: ${{ inputs.version }} + VERSION_MAJOR: ${{ inputs.major-version }} + steps: + + - name: Install CF CLI via Homebrew + run: | + set -evx + + brew install cloudfoundry/tap/cf-cli@${VERSION_MAJOR} + installed_cf_version=$(cf${VERSION_MAJOR} version) + + cf_location=$(which cf) + + echo $cf_location + echo $installed_cf_version + echo ${VERSION_BUILD} + + codesign --verify $cf_location || echo --- + + cf -v | grep "${VERSION_BUILD}" + + test-deb: + name: Test Debian Repository + strategy: + matrix: + os: [ubuntu-22.04, ubuntu-latest] + runs-on: ${{ matrix.os }} + env: + CLAW_URL: ${{ inputs.claw-url }} + VERSION_BUILD: ${{ inputs.version }} + VERSION_MAJOR: ${{ inputs.major-version }} + steps: + + - name: Install CF CLI via apt + run: | + set -o pipefail -e + + sudo apt update + sudo apt install -y wget gnupg + + wget -q -O - ${CLAW_URL}/debian/cli.cloudfoundry.org.key | sudo apt-key add - + echo "deb ${CLAW_URL}/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list + + sudo apt update + sudo apt install -y cf${VERSION_MAJOR}-cli + + which cf + + set -x + + cf -v + cf${VERSION_MAJOR} -v + + cf -v | grep "${VERSION_BUILD}" + + + test-rpm-repo: + name: Test RPM Repository + runs-on: ubuntu-latest + container: + image: fedora + env: + CLAW_URL: ${{ inputs.claw-url }} + VERSION_BUILD: ${{ inputs.version }} + VERSION_MAJOR: ${{ inputs.major-version }} + steps: + + - name: Configure Custom CF Repository + run: | + curl -sL -o /etc/yum.repos.d/cloudfoundry-cli.repo \ + ${CLAW_URL}/fedora/cloudfoundry-cli.repo + + - name: Install cf cli package + run: dnf install -y cf${VERSION_MAJOR}-cli + + - name: Print CF CLI Versions + run: | + cf -v + cf${VERSION_MAJOR} -v + + - name: Test Version Match + run: cf -v | grep -q "${VERSION_BUILD}" + + test-windows: + name: Test Windows Chocolatey Package + runs-on: windows-latest + defaults: + run: + shell: pwsh + env: + VERSION_BUILD: ${{ inputs.version }} + VERSION_MAJOR: ${{ inputs.major-version }} + steps: + + - name: Install cf cli package + run: choco install cloudfoundry-cli --version $env:VERSION_BUILD + + - name: Print Chocolatey CF CLI Versions + run: | + cd 'C:/ProgramData/chocolatey/lib/cloudfoundry-cli/tools' + ./cf -v + Invoke-Expression "./cf$env:VERSION_MAJOR -v" + + - name: Test Chocolatey Version Match + run: | + cd 'C:/ProgramData/chocolatey/lib/cloudfoundry-cli/tools' + $found = (./cf -v | Select-String "$env:VERSION_BUILD") + if ($null -eq $found) { + Write-Error "CF CLI version $env:VERSION_BUILD was not found" -ErrorAction Stop + } + + +# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell: diff --git a/.github/workflows/tests-integration-reusable.yml b/.github/workflows/tests-integration-reusable.yml new file mode 100644 index 00000000000..fc8149c9516 --- /dev/null +++ b/.github/workflows/tests-integration-reusable.yml @@ -0,0 +1,144 @@ +name: "REUSABLE: Integration Tests" + +on: + workflow_call: + inputs: + name: + required: true + type: string + env-name: + required: true + type: string + gitRef: + type: string + default: ${{github.event.workflow_run.head_sha}} + run-with-client-creds: + required: true + type: boolean + +env: + ENV_NAME: ${{ inputs.env-name }} + NODES: 4 + FLAKE_ATTEMPTS: ${{ vars.TEST_FLAKE_ATTEMPTS || '5' }} + BBL_CLI_VERSION: ${{ vars.BBL_CLI_VERSION }} + BOSH_CLI_VERSION: ${{ vars.BOSH_CLI_VERSION }} + CREDHUB_CLI_VERSION: ${{ vars.CREDHUB_CLI_VERSION }} + +jobs: + run-integration-tests: + defaults: + run: + shell: bash + runs-on: ubuntu-latest + steps: + - name: Checkout cli + uses: actions/checkout@v6 + with: + ref: ${{inputs.gitRef}} + fetch-depth: 0 + path: cli + + - name: Checkout CF deployment tasks + uses: actions/checkout@v6 + with: + repository: cloudfoundry/cf-deployment-concourse-tasks + path: cf-deployment-concourse-tasks + + - name: Set Up Go + uses: actions/setup-go@v6 + with: + go-version-file: cli/go.mod + check-latest: true + + - name: Install Tools + run: | + go version + + install_location=/usr/local/bin + + sudo curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v${BBL_CLI_VERSION}/bbl-v${BBL_CLI_VERSION}_linux_amd64 --silent --location --output $install_location/bbl + sudo chmod +x $install_location/bbl + bbl --version + + sudo curl https://github.com/cloudfoundry/bosh-cli/releases/download/v${BOSH_CLI_VERSION}/bosh-cli-${BOSH_CLI_VERSION}-linux-amd64 --silent --output $install_location/bosh --location + sudo chmod +x $install_location/bosh + bosh --version + + sudo curl https://github.com/cloudfoundry/credhub-cli/releases/download/${CREDHUB_CLI_VERSION}/credhub-linux-amd64-${CREDHUB_CLI_VERSION}.tgz --silent --location --output /tmp/credhub.tgz + sudo tar -xzf /tmp/credhub.tgz -C $install_location + sudo chmod +x $install_location/credhub + credhub --version + + sudo apt-get update + sudo apt-get install -y build-essential unzip + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v3 + with: + credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }} + + - name: Setup gcloud CLI + uses: google-github-actions/setup-gcloud@v3 + + - name: Download file from GCS + run: | + gsutil -m cp -R -P gs://cf-cli-bosh-lites/${ENV_NAME} . + + - name: Run Integration Tests + if: ${{ !inputs.run-with-client-creds }} + run: | + pushd ./${ENV_NAME}/bbl-state + eval "$(bbl print-env --shell-type posix)" + popd + + cd cli + export CF_INT_PASSWORD="$(credhub get -n /bosh-${ENV_NAME}/cf/cf_admin_password | bosh interpolate --path /value -)" + export CF_INT_OIDC_USERNAME="admin-oidc" + export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-${ENV_NAME}/cf/uaa_oidc_admin_password | bosh interpolate --path /value -) + API_URL="api.${ENV_NAME}.app-runtime-interfaces.ci.cloudfoundry.org" + export CF_INT_API="https://$API_URL" + export CF_DIAL_TIMEOUT=15 + export CF_USERNAME=admin + export GOPATH=$PWD/go + export PATH="$GOPATH/bin:$PATH" + export PATH="$PWD/out:$PATH" + export CF_INT_TEST_NAME="int" + export CF_PASSWORD=${CF_INT_PASSWORD} + + make build + + cf api ${CF_INT_API} --skip-ssl-validation + cf auth + + make integration-tests-full-ci + + - name: Run Integration Tests with client credentials + if: ${{ inputs.run-with-client-creds }} + env: + CF_INT_CLIENT_ID: 'potato-face' + CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + run: | + pushd ./${ENV_NAME}/bbl-state + eval "$(bbl print-env --shell-type posix)" + popd + + cd cli + export CF_INT_PASSWORD="$(credhub get -n /bosh-${ENV_NAME}/cf/cf_admin_password | bosh interpolate --path /value -)" + export CF_INT_OIDC_USERNAME="admin-oidc" + export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-${ENV_NAME}/cf/uaa_oidc_admin_password | bosh interpolate --path /value -) + API_URL="api.${ENV_NAME}.app-runtime-interfaces.ci.cloudfoundry.org" + export CF_INT_API="https://$API_URL" + export CF_DIAL_TIMEOUT=15 + export CF_USERNAME=admin + export GOPATH=$PWD/go + export PATH="$GOPATH/bin:$PATH" + export PATH="$PWD/out:$PATH" + export CF_INT_TEST_NAME="cc" + export CF_PASSWORD=${CF_INT_PASSWORD} + + make build + + cf api ${CF_INT_API} --skip-ssl-validation + cf auth + + make integration-tests-ci-client-creds \ No newline at end of file diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml new file mode 100644 index 00000000000..3a646851d22 --- /dev/null +++ b/.github/workflows/tests-integration.yml @@ -0,0 +1,148 @@ +name: "Tests: Integration" + +run-name: "Integration [${{ github.event_name }}: ${{ github.event.pull_request.head.sha || github.event.push.after || github.event.workflow_run.head_sha}}]: ${{ github.event.workflow_run.head_commit.message }}" + +on: + workflow_dispatch: + inputs: + workflow: + description: Tests to run + required: true + type: choice + options: + - all + - run-integration-tests-cf-env + - run-integration-tests-cf-env-with-client-creds + env-name: + description: Pre-provisioned environment name to use in tests + required: false + type: string + + push: + tags: + - "v8.*" + pull_request_target: + branches: + - main + - v8 + paths-ignore: + - "doc/**" + - ".gitpod.yml" + - "README.md" + +jobs: + get-sha: + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + outputs: + gitRef: ${{steps.calculate.outputs.ref}} + steps: + - id: calculate + run: | + if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then + echo "checkout pull request head ${{ github.event.pull_request.head.sha }}" + echo "ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT + elif [[ "${{ github.event_name }}" == "push" ]]; then + echo "checkout push request ${{github.event.push.after}}" + echo "ref=${{github.event.push.after}}" >> $GITHUB_OUTPUT + else + echo "checkout else ${{ github.event.workflow_run.head_sha }}" + echo "ref=${{github.event.workflow_run.head_sha}}" >> $GITHUB_OUTPUT + fi + units: + name: Basic units to gate for integration tests + runs-on: ubuntu-latest + needs: + - get-sha + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{needs.get-sha.outputs.gitRef}} + fetch-depth: 0 + - name: Set Up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + - name: Run Units + run: make units + + create-cf-env: + name: Create bosh lite env + needs: + - get-sha + - units + if: ${{ inputs.env-name == '' }} + uses: ./.github/workflows/create-bosh-lite.yml + secrets: inherit + + set-env-name: + name: Update env name + runs-on: ubuntu-latest + needs: + - get-sha + - units + - create-cf-env + outputs: + env-name: ${{ steps.set-name.outputs.env-name }} + if: ${{ always() && github.actor != 'dependabot[bot]' }} + steps: + - name: set env name + id: set-name + run: | + if [[ -n "${{ inputs.env-name }}" ]]; then + echo "env-name=${{ inputs.env-name }}" >> $GITHUB_OUTPUT + else + echo "env-name=${{ needs.create-cf-env.outputs.env-name }}" >> $GITHUB_OUTPUT + fi + + run-integration-tests-cf-env: + name: Integration tests + needs: + - get-sha + - set-env-name + if: ${{ + always() && + needs.set-env-name.result == 'success' && + (github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || + inputs.workflow == 'run-integration-tests-cf-env') }} + uses: ./.github/workflows/tests-integration-reusable.yml + with: + name: Integration + gitRef: ${{needs.get-sha.outputs.gitRef}} + env-name: ${{ needs.set-env-name.outputs.env-name }} + run-with-client-creds: false + secrets: inherit + + run-integration-tests-cf-env-with-client-creds: + name: Client credentials + needs: + - get-sha + - set-env-name + - run-integration-tests-cf-env + if: ${{ + always() && + needs.set-env-name.result == 'success' && + (github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || + inputs.workflow == 'run-integration-tests-cf-env-with-client-creds') && + needs.run-integration-tests-cf-env.result != 'failure' }} + uses: ./.github/workflows/tests-integration-reusable.yml + with: + name: Integration client creds + env-name: ${{ needs.set-env-name.outputs.env-name }} + gitRef: ${{needs.get-sha.outputs.gitRef}} + run-with-client-creds: true + secrets: inherit + + delete-env: + name: Unclaim environment + if: ${{ always() && inputs.env-name == '' && needs.set-env-name.result == 'success' }} + needs: + - set-env-name + - run-integration-tests-cf-env + - run-integration-tests-cf-env-with-client-creds + uses: ./.github/workflows/delete-bosh-lite.yml + with: + env-name: ${{ needs.set-env-name.outputs.env-name }} + secrets: inherit diff --git a/.github/workflows/tests-unit.yml b/.github/workflows/tests-unit.yml new file mode 100644 index 00000000000..cd28395ad96 --- /dev/null +++ b/.github/workflows/tests-unit.yml @@ -0,0 +1,64 @@ +name: Unit Tests + +run-name: >- + Unit Tests: + ${{ github.event_name == 'pull_request' + && format('PR #{0} - {1}', github.event.pull_request.number, github.event.pull_request.title) + || format('{0} to {1}', github.event_name, github.ref_name) + }} + +on: + workflow_dispatch: + push: + tags: + - "v9.*" + - "v8.*" + pull_request: + branches: + - main + - v9 + - v8 + paths-ignore: + - "doc/**" + - ".gitpod.yml" + - "README.md" + +permissions: + contents: read + +jobs: + unit-tests: + name: Unit Tests (${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - ubuntu-22.04 + - macos-latest + - macos-14 + - windows-latest + runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || 'bash' }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Setup Go Environment + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + cache: true + + - name: Install Windows Build Dependencies + if: matrix.os == 'windows-latest' + run: choco install --no-progress --limit-output -y make + + - name: Execute Unit Tests + run: make units + +# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell: diff --git a/.github/workflows/units.yml b/.github/workflows/units.yml deleted file mode 100644 index 5c6446e4f65..00000000000 --- a/.github/workflows/units.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Units Tests - -on: - push: - branches: - - "*" - -permissions: - contents: write - -defaults: - run: - shell: bash - -jobs: - lint: - name: Lint code - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Run go fmt - run: go fmt && git diff --exit-code - - units-linux: - name: Units Linux - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set up Test - run: | - go get -u github.com/onsi/ginkgo/ginkgo - go get github.com/onsi/gomega/matchers@v1.10.5 - - - name: Run Linux Units - run: make units - env: - ACK_GINKGO_RC: true - - units-macos: - name: Units OS X - runs-on: macos-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set up Test - run: | - go get -u github.com/onsi/ginkgo/ginkgo - go get github.com/onsi/gomega/matchers@v1.10.5 - - - name: Run MacOS Units - run: make units - env: - ACK_GINKGO_RC: true - - units-windows: - name: Units Windows - runs-on: windows-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set up Test - run: | - go get -u github.com/onsi/ginkgo/ginkgo - go get github.com/onsi/gomega/matchers@v1.10.5 - - - name: Run Windows Units - shell: pwsh - run: > - ginkgo -r -p - -randomizeAllSpecs - -randomizeSuites - -skipPackage integration,cf\ssh,plugin,cf\actors\plugin,cf\commands\plugin,cf\actors\plugin,util\randomword - -flakeAttempts=2 - env: - ACK_GINKGO_RC: true diff --git a/.github/workflows/code-quality.yml b/.github/workflows/util-code-quality.yml similarity index 56% rename from .github/workflows/code-quality.yml rename to .github/workflows/util-code-quality.yml index eb0e0323d1b..29f7b0a677a 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/util-code-quality.yml @@ -1,10 +1,11 @@ name: "Code Quality" on: - push: - branches: [ master, '*' ] + workflow_dispatch: pull_request: - branches: [ master ] + branches: + - main + - v8 schedule: - cron: '45 5 * * *' @@ -12,6 +13,7 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest + if: ${{ github.repository == 'cloudfoundry/cli' }} permissions: actions: read contents: read @@ -20,16 +22,18 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v4 with: languages: go config-file: ./.github/codeql/codeql-config.yml - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v4 + +# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell: diff --git a/.gitignore b/.gitignore index 85d8d090b19..a35518518ec 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ tmp/ .hg/ +.envrc + *.test /tags @@ -55,9 +57,9 @@ tmp/ fixtures/.cf #Compiled Plugins -fixtures/plugins/test_1 -fixtures/plugins/test_2 -fixtures/plugins/empty_plugin +fixtures/plugins/test_1/test_1 +fixtures/plugins/test_2/test_2 +fixtures/plugins/empty_plugin/empty_plugin fixtures/config/plugin-config/.cf/plugins/test_1 fixtures/config/plugin-config/.cf/plugins/test_2 fixtures/config/plugin-config/.cf/plugins/empty_plugin @@ -66,3 +68,5 @@ integration/assets/test_plugin/test_plugin ### VisualStudioCode ### .vscode +.secrets +.vars diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000000..614f7d18cc0 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,34 @@ +additionalRepositories: + - url: https://github.com/cloudfoundry/cli-ci + - url: https://github.com/cloudfoundry/cli-private + - url: https://github.com/cloudfoundry/cli-workstation + +workspaceLocation: cli/.devcontainer/cli.code-workspace + +tasks: + - name: Setup Workspace + before: > + sudo apt install --yes + icdiff + tldr + fzf + + brew install + asdf + cloudfoundry/tap/credhub-cli + cloudfoundry/tap/bbl + cloudfoundry/tap/bosh-cli + act + tmux + neovim + init: > + tldr --update + + make clean build + command: out/cf version + +vscode: + extensions: + - vscodevim.vim + - eamodio.gitlens + - golang.go diff --git a/.golangci.json b/.golangci.json index d116b5a620b..9836e7d9434 100644 --- a/.golangci.json +++ b/.golangci.json @@ -1,47 +1,131 @@ { - "run": { - "concurrency": 4, - "timeout": "20m", - "skip-files": [ - "integration/helpers/fake_server.go" - ] + "formatters": { + "enable": [ + "goimports" + ], + "exclusions": { + "generated": "lax", + "paths": [ + "integration/helpers/fake_server.go", + "command/plugin/*.go$", + "third_party$", + "builtin$", + "examples$", + "cf$", + "fixtures$", + "plugin$" + ] + } + }, + "issues": { + "max-same-issues": 0 }, "linters": { - "disable-all": true, + "default": "none", "enable": [ - "govet", - "goimports", "errcheck", - "staticcheck", - "unused", - "structcheck", - "varcheck", + "govet", "ineffassign", - "deadcode" - ] + "staticcheck", + "unused" + ], + "settings": { + "staticcheck": { + "checks": [ + "all", + "-S1002", + "-S1005", + "-S1007", + "-S1009", + "-S1011", + "-S1012", + "-S1016", + "-S1020", + "-S1039", + "-ST1001", + "-ST1003", + "-ST1005", + "-ST1012", + "-ST1016", + "-QF1001", + "-QF1002", + "-QF1003", + "-QF1004", + "-QF1008", + "-QF1012", + "-SA5008" + ] + } + }, + "exclusions": { + "generated": "lax", + "paths": [ + "integration/helpers/fake_server.go", + "command/plugin/*.go$", + "third_party$", + "builtin$", + "examples$", + "cf$", + "fixtures$", + "plugin$" + ], + "presets": [ + "comments", + "common-false-positives", + "legacy", + "std-error-handling" + ], + "rules": [ + { + "linters": ["unused"], + "text": "field usage is unused" + }, + { + "linters": ["unused"], + "text": "field relatedCommands is unused" + }, + { + "linters": ["unused"], + "text": "field allproxy is unused" + }, + { + "linters": ["unused"], + "text": "field dockerPassword is unused" + }, + { + "linters": ["unused"], + "text": "field envCFStagingTimeout is unused" + }, + { + "linters": ["unused"], + "text": "field envCFStartupTimeout is unused" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `GinkgoWriter.Write` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `client.GetApplicationTasks` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `logger.output.Stop` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `request.ResetBody` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `c.terminalHelper.RestoreTerminal` is not checked" + } + ] + } }, - "linters-settings": {}, - "issues": { - "max-same-issue": 0, - "exclude": [ - "Error return value of `client.GetApplicationTasks` is not checked", - "Error return value of `logger.output.Stop` is not checked", - "Error return value of `request.ResetBody` is not checked", - "Error return value of `GinkgoWriter.Write` is not checked", - "Error return value of `c.terminalHelper.RestoreTerminal` is not checked", - "U1000: field `allproxy` is unused", - "U1000: field `dockerPassword` is unused", - "U1000: field `envCFStagingTimeout` is unused", - "U1000: field `envCFStartupTimeout` is unused", - "U1000: field `relatedCommands` is unused", - "U1000: field `usage` is unused", - "SA5008: duplicate struct tag \"choice\"", - "`allproxy` is unused", - "`dockerPassword` is unused", - "`envCFStagingTimeout` is unused", - "`envCFStartupTimeout` is unused", - "`relatedCommands` is unused", - "`usage` is unused" - ] - } + "run": { + "concurrency": 4, + "timeout": "60m" + }, + "version": "2" } diff --git a/.grype.yaml b/.grype.yaml new file mode 100644 index 00000000000..3113d6c38eb --- /dev/null +++ b/.grype.yaml @@ -0,0 +1,3 @@ +ignore: + - package: + type: gem diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bcd768fece3..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go -go: - - 1.13.x -go_import_path: code.cloudfoundry.org/cli -install: -- go get -u github.com/onsi/ginkgo/ginkgo -script: -- NODES=1 make units-full -branches: - only: - - master - - travis -os: - - linux diff --git a/BUILD_VERSION b/BUILD_VERSION deleted file mode 100644 index ae9a76b9249..00000000000 --- a/BUILD_VERSION +++ /dev/null @@ -1 +0,0 @@ -8.0.0 diff --git a/Makefile b/Makefile index 195d9286aa3..26b1637990a 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,30 @@ -SHELL := env PATH=$(PATH) /bin/bash CF_DIAL_TIMEOUT ?= 15 NODES ?= 10 +FLAKE_ATTEMPTS ?=5 +GINKGO_SUITE_TIMEOUT=2h PACKAGES ?= api actor command types util version integration/helpers LC_ALL = "en_US.UTF-8" -CF_BUILD_VERSION ?= $$(cat BUILD_VERSION) # TODO: version specific +CF_BUILD_VERSION ?= $$(git describe --tags --abbrev=0) CF_BUILD_SHA ?= $$(git rev-parse --short HEAD) CF_BUILD_DATE ?= $$(date -u +"%Y-%m-%d") LD_FLAGS_COMMON=-w -s \ - -X code.cloudfoundry.org/cli/version.binarySHA=$(CF_BUILD_SHA) \ - -X code.cloudfoundry.org/cli/version.binaryBuildDate=$(CF_BUILD_DATE) + -X code.cloudfoundry.org/cli/v8/version.binarySHA=$(CF_BUILD_SHA) \ + -X code.cloudfoundry.org/cli/v8/version.binaryBuildDate=$(CF_BUILD_DATE) LD_FLAGS =$(LD_FLAGS_COMMON) \ - -X code.cloudfoundry.org/cli/version.binaryVersion=$(CF_BUILD_VERSION) + -X code.cloudfoundry.org/cli/v8/version.binaryVersion=$(CF_BUILD_VERSION) LD_FLAGS_LINUX = -extldflags \"-static\" $(LD_FLAGS) REQUIRED_FOR_STATIC_BINARY =-a -tags "netgo" -installsuffix netgo GOSRC = $(shell find . -name "*.go" ! -name "*test.go" ! -name "*fake*" ! -path "./integration/*") UNAME_S := $(shell uname -s) +POLL_PROGRESS_THRESHOLD=120s -TARGET = v7 -SLOW_SPEC_THRESHOLD=120 - -GINKGO_FLAGS=-r -randomizeAllSpecs -requireSuite -GINKGO_INT_FLAGS=$(GINKGO_FLAGS) -slowSpecThreshold $(SLOW_SPEC_THRESHOLD) +GINKGO_FLAGS ?= -r -randomize-all -require-suite +GINKGO_INT_FLAGS = $(GINKGO_FLAGS) --poll-progress-after $(POLL_PROGRESS_THRESHOLD) -flake-attempts $(FLAKE_ATTEMPTS) --timeout $(GINKGO_SUITE_TIMEOUT) ginkgo_int = ginkgo $(GINKGO_INT_FLAGS) -GINKGO_UNITS_FLAGS=$(GINKGO_FLAGS) -randomizeSuites -p +GINKGO_UNITS_FLAGS = $(GINKGO_FLAGS) -randomize-suites ginkgo_units = ginkgo $(GINKGO_UNITS_FLAGS) GOFLAGS := -mod=mod @@ -46,12 +45,6 @@ clean: ## Just remove all cf* files from the `out` directory clear: clean ## Make everyone happy -custom-lint: ## Run our custom linters - @echo "Running custom linters..." # this list will grow as we cleanup all the code: - bash -c "go run bin/style/main.go api util" - @echo "No custom lint errors!" - @echo - # TODO: update these fly-windows* to point at the correct CI repo fly-windows-experimental: check-target-env CF_TEST_SUITE=./integration/shared/experimental fly -t ci execute -c ci/cli/tasks/integration-windows-oneoff.yml -i cli=./ --tag "cli-windows" @@ -74,82 +67,90 @@ fly-windows-units: format: ## Run go fmt go fmt ./... +install-test-deps: ## Install "global" dependencies needed to run tests +# Running `go install ` without a version specifier will use version specified in go.mod +# See https://go.dev/ref/mod#go-install + go install github.com/onsi/ginkgo/v2/ginkgo + integration-cleanup: - $(PWD)/bin/cleanup-integration + $(CURDIR)/bin/cleanup-integration ie: integration-experimental integration-experimental: build integration-cleanup integration-shared-experimental integration-experimental-versioned ## Run all experimental integration tests, both versioned and shared across versions ise: integration-shared-experimental integration-experimental-shared: integration-shared-experimental -integration-shared-experimental: build integration-cleanup ## Run experimental integration tests that are shared between v6 and v7 +integration-shared-experimental: build install-test-deps integration-cleanup ## Run experimental integration tests that are shared between v6 and v7 $(ginkgo_int) -nodes $(NODES) integration/shared/experimental ive: integration-versioned-experimental integration-experimental-versioned: integration-versioned-experimental -integration-versioned-experimental: build integration-cleanup ## Run experimental integration tests that are specific to your CLI version - $(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/experimental +integration-versioned-experimental: build install-test-deps integration-cleanup ## Run experimental integration tests that are specific to your CLI version + $(ginkgo_int) -nodes $(NODES) integration/v7/experimental ig: integration-global integration-global: build integration-cleanup integration-shared-global integration-global-versioned ## Run all unparallelizable integration tests that make cross-cutting changes to their test CF foundation isg: integration-shared-global integration-global-shared: integration-shared-global -integration-shared-global: build integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are shared between v6 and v7 +integration-shared-global: build install-test-deps integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are shared between v6 and v7 $(ginkgo_int) integration/shared/global ivg: integration-versioned-global integration-global-versioned: integration-versioned-global -integration-versioned-global: build integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are specific to your CLI version - $(ginkgo_int) integration/$(TARGET)/global +integration-versioned-global: build install-test-deps integration-cleanup ## Serially run integration tests that make cross-cutting changes to their test CF foundation and are specific to your CLI version + $(ginkgo_int) integration/v7/global ii: integration-isolated integration-isolated: build integration-cleanup integration-shared-isolated integration-isolated-versioned ## Run all parallel-enabled integration tests, both versioned and shared across versions isi: integration-shared-isolated integration-isolated-shared: integration-shared-isolated -integration-shared-isolated: build integration-cleanup ## Run all parallel-enabled integration tests that are shared between v6 and v7 +integration-shared-isolated: build install-test-deps integration-cleanup ## Run all parallel-enabled integration tests that are shared between v6 and v7 $(ginkgo_int) -nodes $(NODES) integration/shared/isolated integration-performance: build integration-cleanup integration-shared-performance isp: integration-shared-performance integration-performance-shared: integration-shared-performance -integration-shared-performance: build integration-cleanup +integration-shared-performance: build install-test-deps integration-cleanup $(ginkgo_int) integration/shared/performance ivi: integration-versioned-isolated integration-isolated-versioned: integration-versioned-isolated -integration-versioned-isolated: build integration-cleanup ## Run all parallel-enabled integration tests, both versioned and shared across versions - $(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/isolated +integration-versioned-isolated: build install-test-deps integration-cleanup ## Run all parallel-enabled integration tests, both versioned and shared across versions + $(ginkgo_int) -nodes $(NODES) integration/v7/isolated -integration-plugin: build integration-cleanup ## Run all plugin-related integration tests +integration-plugin: build install-test-deps integration-cleanup ## Run all plugin-related integration tests $(ginkgo_int) -nodes $(NODES) integration/shared/plugin ip: integration-push -integration-push: build integration-cleanup ## Run all push-related integration tests - $(ginkgo_int) -nodes $(NODES) integration/$(TARGET)/push +integration-push: build install-test-deps integration-cleanup ## Run all push-related integration tests + $(ginkgo_int) -nodes $(NODES) integration/v7/push -integration-selfcontained: build +integration-selfcontained: build install-test-deps $(ginkgo_int) -nodes $(NODES) integration/v7/selfcontained integration-tests: build integration-cleanup integration-isolated integration-push integration-global integration-selfcontained ## Run all isolated, push, selfcontained, and global integration tests +integration-tests-ci-client-creds: build integration-cleanup integration-push integration-global integration-selfcontained i: integration-tests-full integration-full-tests: integration-tests-full integration-tests-full: build integration-cleanup integration-isolated integration-push integration-experimental integration-plugin integration-global integration-selfcontained ## Run all isolated, push, experimental, plugin, selfcontained, and global integration tests -integration-tests-full-ci: integration-cleanup - $(ginkgo_int) -nodes $(NODES) -flakeAttempts $(FLAKE_ATTEMPTS) \ - integration/shared/isolated integration/v7/isolated integration/shared/plugin integration/shared/experimental integration/v7/experimental integration/v7/push - $(ginkgo_int) -flakeAttempts $(FLAKE_ATTEMPTS) integration/shared/global integration/v7/global +integration-tests-full-ci: install-test-deps integration-cleanup + $(ginkgo_int) -nodes $(NODES) -flake-attempts $(FLAKE_ATTEMPTS) \ + integration/shared/isolated integration/v7/isolated + $(ginkgo_int) -nodes $(NODES) -flake-attempts $(FLAKE_ATTEMPTS) \ + integration/shared/plugin integration/shared/experimental + $(ginkgo_int) -nodes $(NODES) -flake-attempts $(FLAKE_ATTEMPTS) \ + integration/v7/experimental integration/v7/push + $(ginkgo_int) -flake-attempts $(FLAKE_ATTEMPTS) integration/shared/global integration/v7/global -lint: custom-lint ## Runs all linters and formatters +lint: format ## Runs all linters and formatters @echo "Running linters..." - go list -f "{{.Dir}}" ./... \ - | grep -v -e "/cf/" -e "/fixtures/" -e "/assets/" -e "/plugin/" -e "/command/plugin" -e "fakes" \ - | xargs golangci-lint run + golangci-lint run -v @echo "No lint errors!" # TODO: version specific tagging for all these builds @@ -173,14 +174,19 @@ out/cf-cli_linux_x86-64: $(GOSRC) CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \ $(REQUIRED_FOR_STATIC_BINARY) \ -ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_x86-64 . + +out/cf-cli_linux_arm64: $(GOSRC) + CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build \ + $(REQUIRED_FOR_STATIC_BINARY) \ + -ldflags "$(LD_FLAGS_LINUX)" -o out/cf-cli_linux_arm64 . out/cf-cli_osx: $(GOSRC) GOARCH=amd64 GOOS=darwin go build \ -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_osx . -out/cf-cli_osx_arm: $(GOSRC) +out/cf-cli_macosarm: $(GOSRC) GOARCH=arm64 GOOS=darwin go build \ - -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_osx_arm . + -a -ldflags "$(LD_FLAGS)" -o out/cf-cli_macosarm . out/cf-cli_win32.exe: $(GOSRC) rsrc.syso GOARCH=386 GOOS=windows go build -tags="forceposix" -o out/cf-cli_win32.exe -ldflags "$(LD_FLAGS)" . @@ -197,15 +203,22 @@ test: units ## (synonym for units) units: units-full ## (synonym for units-full) -units-plugin: - CF_HOME=$(PWD)/fixtures $(ginkgo_units) -nodes 1 -flakeAttempts 2 -skipPackage integration ./**/plugin* ./plugin +units-plugin: install-test-deps + CF_HOME=$(CURDIR)/fixtures $(ginkgo_units) -nodes 1 -flake-attempts 2 -skip-package integration ./**/plugin* ./plugin -units-non-plugin: - @rm -f $(wildcard fixtures/plugins/*.exe) +ifeq ($(OS),Windows_NT) +units-non-plugin: install-test-deps + @rm -f $(wildcard fixtures/plugins/*/*.exe) @ginkgo version - CF_HOME=$(PWD)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \ - -skipPackage integration,cf/ssh,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword - CF_HOME=$(PWD)/fixtures $(ginkgo_units) -flakeAttempts 3 cf/ssh + CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \ + -skip-package integration,plugin,cf\actors\plugin,cf\commands\plugin,cf\actors\plugin,util\randomword +else +units-non-plugin: install-test-deps + @rm -f $(wildcard fixtures/plugins/*/*.exe) + @ginkgo version + CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \ + -skip-package integration,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword +endif units-full: build units-plugin units-non-plugin @echo "\nSWEET SUITE SUCCESS" @@ -213,10 +226,10 @@ units-full: build units-plugin units-non-plugin version: ## Print the version number of what would be built @echo $(CF_BUILD_VERSION)+$(CF_BUILD_SHA).$(CF_BUILD_DATE) -.PHONY: all build clean format version lint custom-lint -.PHONY: test units units-full integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push +.PHONY: all build clean format version lint +.PHONY: test units units-full install-test-deps integration integration-tests-full integration-cleanup integration-experimental integration-plugin integration-isolated integration-push .PHONY: check-target-env fly-windows-experimental fly-windows-isolated fly-windows-plugin fly-windows-push .PHONY: help help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-34s\033[0m %s\n", $$1, $$2}' + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-34s\033[0m %s\n", $$1, $$2}' \ No newline at end of file diff --git a/README.md b/README.md index 8d4d7874481..f2c7624758a 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Once installed, you can log in and push an app. There are now three supported versions of the cf CLI: 1. The v8 cf CLI is backed by the [v3 CC API](http://v3-apidocs.cloudfoundry.org/version/3.85.0/) (with the exception of plugins). See [our v8 documentation](https://docs.cloudfoundry.org/cf-cli/v8.html) for more information. 1. The v7 cf CLI is backed by the [v3 CC API](http://v3-apidocs.cloudfoundry.org/version/3.85.0/) (with the exception of plugins). See [our v7 documentation](https://docs.cloudfoundry.org/cf-cli/v7.html) for more information. -1. The v6 cf CLI is backed by the [v2 CC API](https://apidocs.cloudfoundry.org/13.5.0/) See [our v6 documentation](https://docs.cloudfoundry.org/cf-cli) for more information. +1. The v6 cf CLI is backed by the [v2 CC API](https://v2-apidocs.cloudfoundry.org/) See [our v6 documentation](https://docs.cloudfoundry.org/cf-cli) for more information. View our [CLI v6 & v7 & v8 Versioning and Support Policy](https://github.com/cloudfoundry/cli/wiki/Versioning-and-Support-Policy) documentation. @@ -97,6 +97,6 @@ information follow: * [The CF CLI plugin development guide](https://github.com/cloudfoundry/cli/tree/master/plugin/plugin_examples) * [The official plugins repository](https://plugins.cloudfoundry.org/) -When importing the plugin code use `import "code.cloudfoundry.org/cli/plugin"`. +When importing the plugin code use `import "code.cloudfoundry.org/cli/v8/plugin"`. Older plugins that import `github.com/cloudfoundry/cli/plugin` will still work as long they vendor the plugins directory. diff --git a/actor/actionerror/actionerror_suite_test.go b/actor/actionerror/actionerror_suite_test.go index 254f942a8f8..268e4eaae8f 100644 --- a/actor/actionerror/actionerror_suite_test.go +++ b/actor/actionerror/actionerror_suite_test.go @@ -3,7 +3,7 @@ package actionerror_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/app_not_found_in_manifest_error.go b/actor/actionerror/app_not_found_in_manifest_error.go index 0c20cb04f73..ddb827e47f8 100644 --- a/actor/actionerror/app_not_found_in_manifest_error.go +++ b/actor/actionerror/app_not_found_in_manifest_error.go @@ -7,5 +7,5 @@ type AppNotFoundInManifestError struct { } func (e AppNotFoundInManifestError) Error() string { - return fmt.Sprintf("specfied app: %s not found in manifest", e.Name) + return fmt.Sprintf("specified app: %s not found in manifest", e.Name) } diff --git a/actor/actionerror/buildpack_not_found_error.go b/actor/actionerror/buildpack_not_found_error.go index 88da77ed3ac..0bd411bfac6 100644 --- a/actor/actionerror/buildpack_not_found_error.go +++ b/actor/actionerror/buildpack_not_found_error.go @@ -6,8 +6,9 @@ import "fmt" type BuildpackNotFoundError struct { BuildpackName string StackName string + Lifecycle string } func (e BuildpackNotFoundError) Error() string { - return fmt.Sprintf("Buildpack not found - Name: '%s'; Stack: '%s'", e.BuildpackName, e.StackName) + return fmt.Sprintf("Buildpack not found - Name: '%s'; Stack: '%s', Lifecyle: '%s'", e.BuildpackName, e.StackName, e.Lifecycle) } diff --git a/actor/actionerror/duplicate_service_error_test.go b/actor/actionerror/duplicate_service_error_test.go index 101c7edd774..2d430af90a8 100644 --- a/actor/actionerror/duplicate_service_error_test.go +++ b/actor/actionerror/duplicate_service_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/duplicate_service_plan_error_test.go b/actor/actionerror/duplicate_service_plan_error_test.go index 5944cf984b5..6aa63c53454 100644 --- a/actor/actionerror/duplicate_service_plan_error_test.go +++ b/actor/actionerror/duplicate_service_plan_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/enrich_api_errors.go b/actor/actionerror/enrich_api_errors.go index d372f412210..b86d06ca684 100644 --- a/actor/actionerror/enrich_api_errors.go +++ b/actor/actionerror/enrich_api_errors.go @@ -1,6 +1,6 @@ package actionerror -import "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" func EnrichAPIErrors(e error) error { switch err := e.(type) { diff --git a/actor/actionerror/enrich_api_errors_test.go b/actor/actionerror/enrich_api_errors_test.go index 0acf73fa9db..d8102e46e67 100644 --- a/actor/actionerror/enrich_api_errors_test.go +++ b/actor/actionerror/enrich_api_errors_test.go @@ -3,11 +3,11 @@ package actionerror_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/no_eligible_packages_error.go b/actor/actionerror/no_eligible_packages_error.go index 73eee7e318a..c358c4ad200 100644 --- a/actor/actionerror/no_eligible_packages_error.go +++ b/actor/actionerror/no_eligible_packages_error.go @@ -12,7 +12,7 @@ func (e NoEligiblePackagesError) Error() string { case e.AppName != "": return fmt.Sprintf("App '%s' has no eligible packages.", e.AppName) default: - return fmt.Sprintf("No eligible pacakges available for app.") + return fmt.Sprintf("No eligible packages available for app.") } } diff --git a/actor/actionerror/package_not_found_in_app_error_test.go b/actor/actionerror/package_not_found_in_app_error_test.go index 6aae72411ca..1fec5ecd1bf 100644 --- a/actor/actionerror/package_not_found_in_app_error_test.go +++ b/actor/actionerror/package_not_found_in_app_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/route_not_found_error_test.go b/actor/actionerror/route_not_found_error_test.go index 6a224716639..83b694cceb8 100644 --- a/actor/actionerror/route_not_found_error_test.go +++ b/actor/actionerror/route_not_found_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/route_option_error.go b/actor/actionerror/route_option_error.go new file mode 100644 index 00000000000..005633e59e8 --- /dev/null +++ b/actor/actionerror/route_option_error.go @@ -0,0 +1,22 @@ +package actionerror + +import "fmt" + +// RouteOptionError is returned when a route option was specified in the wrong format +type RouteOptionError struct { + Name string + Host string + DomainName string + Path string +} + +func (e RouteOptionError) Error() string { + return fmt.Sprintf("Route option '%s' for route with host '%s', domain '%s', and path '%s' was specified incorrectly. Please use key-value pair format key=value.", e.Name, e.Host, e.DomainName, e.path()) +} + +func (e RouteOptionError) path() string { + if e.Path == "" { + return "/" + } + return e.Path +} diff --git a/actor/actionerror/route_option_support_error.go b/actor/actionerror/route_option_support_error.go new file mode 100644 index 00000000000..9fcffbb4054 --- /dev/null +++ b/actor/actionerror/route_option_support_error.go @@ -0,0 +1,12 @@ +package actionerror + +import "fmt" + +// RouteOptionSupportError is returned when route options are not supported +type RouteOptionSupportError struct { + ErrorText string +} + +func (e RouteOptionSupportError) Error() string { + return fmt.Sprintf("Route option support: '%s'", e.ErrorText) +} diff --git a/actor/actionerror/security_group_not_bound_to_space_error.go b/actor/actionerror/security_group_not_bound_to_space_error.go index 7714874d621..29ed14b9af0 100644 --- a/actor/actionerror/security_group_not_bound_to_space_error.go +++ b/actor/actionerror/security_group_not_bound_to_space_error.go @@ -3,7 +3,7 @@ package actionerror import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // SecurityGroupNotBoundToSpaceError is returned when a requested security group is diff --git a/actor/actionerror/service_instance_type_error.go b/actor/actionerror/service_instance_type_error.go index 9021fcd0591..48843d28943 100644 --- a/actor/actionerror/service_instance_type_error.go +++ b/actor/actionerror/service_instance_type_error.go @@ -3,7 +3,7 @@ package actionerror import ( "fmt" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/resources" ) type ServiceInstanceTypeError struct { diff --git a/actor/actionerror/service_not_found_error_test.go b/actor/actionerror/service_not_found_error_test.go index dd5760e8324..b5b7c97b5e6 100644 --- a/actor/actionerror/service_not_found_error_test.go +++ b/actor/actionerror/service_not_found_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/service_offering_name_ambiguity_error.go b/actor/actionerror/service_offering_name_ambiguity_error.go index b7ec5351959..b45e548bbbe 100644 --- a/actor/actionerror/service_offering_name_ambiguity_error.go +++ b/actor/actionerror/service_offering_name_ambiguity_error.go @@ -1,6 +1,6 @@ package actionerror -import "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" type ServiceOfferingNameAmbiguityError struct { ccerror.ServiceOfferingNameAmbiguityError diff --git a/actor/actionerror/service_plan_not_found_error_test.go b/actor/actionerror/service_plan_not_found_error_test.go index d3519eb5ec1..d9cbee3bcd2 100644 --- a/actor/actionerror/service_plan_not_found_error_test.go +++ b/actor/actionerror/service_plan_not_found_error_test.go @@ -3,8 +3,8 @@ package actionerror_test import ( "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/space_not_found_error_test.go b/actor/actionerror/space_not_found_error_test.go index a0682186b30..0708268b432 100644 --- a/actor/actionerror/space_not_found_error_test.go +++ b/actor/actionerror/space_not_found_error_test.go @@ -1,8 +1,8 @@ package actionerror_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/actionerror/task_failed_error.go b/actor/actionerror/task_failed_error.go new file mode 100644 index 00000000000..66134d2ef51 --- /dev/null +++ b/actor/actionerror/task_failed_error.go @@ -0,0 +1,7 @@ +package actionerror + +type TaskFailedError struct{} + +func (TaskFailedError) Error() string { + return "Task failed to complete successfully" +} diff --git a/actor/actionerror/user_not_found.go b/actor/actionerror/user_not_found.go index 57f50c8ee19..5c024a420e9 100644 --- a/actor/actionerror/user_not_found.go +++ b/actor/actionerror/user_not_found.go @@ -3,7 +3,7 @@ package actionerror import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // UserNotFoundError is an error wrapper that represents the case diff --git a/actor/cfnetworkingaction/cfnetworkingaction_suite_test.go b/actor/cfnetworkingaction/cfnetworkingaction_suite_test.go index 061796e1948..40da8cfc05e 100644 --- a/actor/cfnetworkingaction/cfnetworkingaction_suite_test.go +++ b/actor/cfnetworkingaction/cfnetworkingaction_suite_test.go @@ -1,7 +1,7 @@ package cfnetworkingaction_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_cloud_controller_client.go b/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_cloud_controller_client.go index f83e102f681..a9dad99d647 100644 --- a/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_cloud_controller_client.go +++ b/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_cloud_controller_client.go @@ -4,9 +4,9 @@ package cfnetworkingactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeCloudControllerClient struct { @@ -84,15 +84,16 @@ func (fake *FakeCloudControllerClient) GetApplicationByNameAndSpace(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationByNameAndSpaceStub + fakeReturns := fake.getApplicationByNameAndSpaceReturns fake.recordInvocation("GetApplicationByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationByNameAndSpaceMutex.Unlock() - if fake.GetApplicationByNameAndSpaceStub != nil { - return fake.GetApplicationByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -150,15 +151,16 @@ func (fake *FakeCloudControllerClient) GetApplications(arg1 ...ccv3.Query) ([]re fake.getApplicationsArgsForCall = append(fake.getApplicationsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetApplicationsStub + fakeReturns := fake.getApplicationsReturns fake.recordInvocation("GetApplications", []interface{}{arg1}) fake.getApplicationsMutex.Unlock() - if fake.GetApplicationsStub != nil { - return fake.GetApplicationsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -216,15 +218,16 @@ func (fake *FakeCloudControllerClient) GetOrganizations(arg1 ...ccv3.Query) ([]r fake.getOrganizationsArgsForCall = append(fake.getOrganizationsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetOrganizationsStub + fakeReturns := fake.getOrganizationsReturns fake.recordInvocation("GetOrganizations", []interface{}{arg1}) fake.getOrganizationsMutex.Unlock() - if fake.GetOrganizationsStub != nil { - return fake.GetOrganizationsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -282,15 +285,16 @@ func (fake *FakeCloudControllerClient) GetSpaces(arg1 ...ccv3.Query) ([]resource fake.getSpacesArgsForCall = append(fake.getSpacesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetSpacesStub + fakeReturns := fake.getSpacesReturns fake.recordInvocation("GetSpaces", []interface{}{arg1}) fake.getSpacesMutex.Unlock() - if fake.GetSpacesStub != nil { - return fake.GetSpacesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getSpacesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } diff --git a/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_networking_client.go b/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_networking_client.go index ce5fc06a3e2..4f8bacb661b 100644 --- a/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_networking_client.go +++ b/actor/cfnetworkingaction/cfnetworkingactionfakes/fake_networking_client.go @@ -4,8 +4,8 @@ package cfnetworkingactionfakes import ( "sync" - "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" ) type FakeNetworkingClient struct { @@ -59,15 +59,16 @@ func (fake *FakeNetworkingClient) CreatePolicies(arg1 []cfnetv1.Policy) error { fake.createPoliciesArgsForCall = append(fake.createPoliciesArgsForCall, struct { arg1 []cfnetv1.Policy }{arg1Copy}) + stub := fake.CreatePoliciesStub + fakeReturns := fake.createPoliciesReturns fake.recordInvocation("CreatePolicies", []interface{}{arg1Copy}) fake.createPoliciesMutex.Unlock() - if fake.CreatePoliciesStub != nil { - return fake.CreatePoliciesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createPoliciesReturns return fakeReturns.result1 } @@ -119,15 +120,16 @@ func (fake *FakeNetworkingClient) ListPolicies(arg1 ...string) ([]cfnetv1.Policy fake.listPoliciesArgsForCall = append(fake.listPoliciesArgsForCall, struct { arg1 []string }{arg1}) + stub := fake.ListPoliciesStub + fakeReturns := fake.listPoliciesReturns fake.recordInvocation("ListPolicies", []interface{}{arg1}) fake.listPoliciesMutex.Unlock() - if fake.ListPoliciesStub != nil { - return fake.ListPoliciesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listPoliciesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -187,15 +189,16 @@ func (fake *FakeNetworkingClient) RemovePolicies(arg1 []cfnetv1.Policy) error { fake.removePoliciesArgsForCall = append(fake.removePoliciesArgsForCall, struct { arg1 []cfnetv1.Policy }{arg1Copy}) + stub := fake.RemovePoliciesStub + fakeReturns := fake.removePoliciesReturns fake.recordInvocation("RemovePolicies", []interface{}{arg1Copy}) fake.removePoliciesMutex.Unlock() - if fake.RemovePoliciesStub != nil { - return fake.RemovePoliciesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.removePoliciesReturns return fakeReturns.result1 } diff --git a/actor/cfnetworkingaction/cloud_controller_client.go b/actor/cfnetworkingaction/cloud_controller_client.go index c5d6c48c91b..be262f0e522 100644 --- a/actor/cfnetworkingaction/cloud_controller_client.go +++ b/actor/cfnetworkingaction/cloud_controller_client.go @@ -1,8 +1,8 @@ package cfnetworkingaction import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . CloudControllerClient diff --git a/actor/cfnetworkingaction/networking_client.go b/actor/cfnetworkingaction/networking_client.go index 46fe668573a..0508a33cfd2 100644 --- a/actor/cfnetworkingaction/networking_client.go +++ b/actor/cfnetworkingaction/networking_client.go @@ -1,6 +1,6 @@ package cfnetworkingaction -import "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1" +import "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . NetworkingClient diff --git a/actor/cfnetworkingaction/policy.go b/actor/cfnetworkingaction/policy.go index a0e44b246ed..30778dfb4aa 100644 --- a/actor/cfnetworkingaction/policy.go +++ b/actor/cfnetworkingaction/policy.go @@ -1,13 +1,13 @@ package cfnetworkingaction import ( - "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) type Policy struct { diff --git a/actor/cfnetworkingaction/policy_test.go b/actor/cfnetworkingaction/policy_test.go index d1319b509fd..925a605ae93 100644 --- a/actor/cfnetworkingaction/policy_test.go +++ b/actor/cfnetworkingaction/policy_test.go @@ -4,16 +4,16 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - - "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction/cfnetworkingactionfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction/cfnetworkingactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/pluginaction/checksum.go b/actor/pluginaction/checksum.go index 0d0a0f9e073..8a223bb25be 100644 --- a/actor/pluginaction/checksum.go +++ b/actor/pluginaction/checksum.go @@ -1,6 +1,6 @@ package pluginaction -import "code.cloudfoundry.org/cli/util/configv3" +import "code.cloudfoundry.org/cli/v8/util/configv3" func (actor Actor) ValidateFileChecksum(path string, checksum string) bool { plugin := configv3.Plugin{Location: path} diff --git a/actor/pluginaction/checksum_test.go b/actor/pluginaction/checksum_test.go index 73792f2bcb3..c17519b3f6b 100644 --- a/actor/pluginaction/checksum_test.go +++ b/actor/pluginaction/checksum_test.go @@ -1,12 +1,11 @@ package pluginaction_test import ( - "io/ioutil" "os" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -25,11 +24,11 @@ var _ = Describe("Checksums", func() { var file *os.File BeforeEach(func() { var err error - file, err = ioutil.TempFile("", "") + file, err = os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) defer file.Close() - err = ioutil.WriteFile(file.Name(), []byte("foo"), 0600) + err = os.WriteFile(file.Name(), []byte("foo"), 0600) Expect(err).NotTo(HaveOccurred()) }) diff --git a/actor/pluginaction/config.go b/actor/pluginaction/config.go index 74410faa41f..307aefcdff6 100644 --- a/actor/pluginaction/config.go +++ b/actor/pluginaction/config.go @@ -1,6 +1,6 @@ package pluginaction -import "code.cloudfoundry.org/cli/util/configv3" +import "code.cloudfoundry.org/cli/v8/util/configv3" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Config diff --git a/actor/pluginaction/install.go b/actor/pluginaction/install.go index 7ce2e23bbcc..67f1610892c 100644 --- a/actor/pluginaction/install.go +++ b/actor/pluginaction/install.go @@ -1,18 +1,15 @@ package pluginaction import ( - "io/ioutil" "os" "path/filepath" "sort" "strings" - "github.com/blang/semver" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/generic" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/generic" "code.cloudfoundry.org/gofileutils/fileutils" ) @@ -89,10 +86,6 @@ func (actor Actor) GetAndValidatePlugin(pluginMetadata PluginMetadata, commandLi return configv3.Plugin{}, actionerror.PluginInvalidError{Err: err} } - cliVersion, err := semver.Make(actor.config.BinaryVersion()) - if err != nil { - return configv3.Plugin{}, actionerror.PluginInvalidError{Err: err} - } var pluginLibraryMajorVersion int hasPluginLibraryVersion := plugin.LibraryVersion != configv3.PluginVersion{} if !hasPluginLibraryVersion { @@ -101,13 +94,8 @@ func (actor Actor) GetAndValidatePlugin(pluginMetadata PluginMetadata, commandLi pluginLibraryMajorVersion = plugin.LibraryVersion.Major } - switch cliVersion.Major { - case 6, 7, 8: - if pluginLibraryMajorVersion > 1 { - return configv3.Plugin{}, actionerror.PluginInvalidLibraryVersionError{} - } - default: - panic("unrecognized major version") + if pluginLibraryMajorVersion > 1 { + return configv3.Plugin{}, actionerror.PluginInvalidLibraryVersionError{} } installedPlugins := actor.config.Plugins() @@ -189,7 +177,7 @@ func (actor Actor) InstallPluginFromPath(path string, plugin configv3.Plugin) er } func makeTempFile(tempDir string) (*os.File, error) { - tempFile, err := ioutil.TempFile(tempDir, "") + tempFile, err := os.CreateTemp(tempDir, "") if err != nil { return nil, err } diff --git a/actor/pluginaction/install_test.go b/actor/pluginaction/install_test.go index cd4da19c828..2d8e5e4f310 100644 --- a/actor/pluginaction/install_test.go +++ b/actor/pluginaction/install_test.go @@ -2,18 +2,17 @@ package pluginaction_test import ( "errors" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -32,7 +31,7 @@ var _ = Describe("install actions", func() { actor = NewActor(fakeConfig, fakeClient) var err error - tempPluginDir, err = ioutil.TempDir("", "") + tempPluginDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) }) @@ -46,7 +45,7 @@ var _ = Describe("install actions", func() { var pluginPath string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "") + tempFile, err := os.CreateTemp("", "") Expect(err).ToNot(HaveOccurred()) _, err = tempFile.WriteString("cthulhu") @@ -66,7 +65,7 @@ var _ = Describe("install actions", func() { copyPath, err := actor.CreateExecutableCopy(pluginPath, tempPluginDir) Expect(err).ToNot(HaveOccurred()) - contents, err := ioutil.ReadFile(copyPath) + contents, err := os.ReadFile(copyPath) Expect(err).ToNot(HaveOccurred()) Expect(contents).To(BeEquivalentTo("cthulhu")) }) @@ -101,14 +100,14 @@ var _ = Describe("install actions", func() { BeforeEach(func() { data = []byte("some test data") fakeClient.DownloadPluginStub = func(_ string, path string, _ plugin.ProxyReader) error { - err := ioutil.WriteFile(path, data, 0700) + err := os.WriteFile(path, data, 0700) Expect(err).ToNot(HaveOccurred()) return nil } }) It("returns the path to the file and the size", func() { Expect(downloadErr).ToNot(HaveOccurred()) - fileData, err := ioutil.ReadFile(path) + fileData, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) Expect(fileData).To(Equal(data)) @@ -139,7 +138,7 @@ var _ = Describe("install actions", func() { When("the file exists", func() { BeforeEach(func() { - pluginFile, err := ioutil.TempFile("", "") + pluginFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) err = pluginFile.Close() Expect(err).NotTo(HaveOccurred()) @@ -661,14 +660,14 @@ var _ = Describe("install actions", func() { }, } - pluginFile, err := ioutil.TempFile("", "") + pluginFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) err = pluginFile.Close() Expect(err).NotTo(HaveOccurred()) pluginPath = pluginFile.Name() - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) pluginHomeDir = filepath.Join(tempDir, ".cf", "plugin") diff --git a/actor/pluginaction/install_unix_test.go b/actor/pluginaction/install_unix_test.go index 6eb7796dd1b..d1cdb380f45 100644 --- a/actor/pluginaction/install_unix_test.go +++ b/actor/pluginaction/install_unix_test.go @@ -1,16 +1,16 @@ +//go:build !windows // +build !windows package pluginaction_test import ( - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -25,7 +25,7 @@ var _ = Describe("install actions", func() { BeforeEach(func() { fakeConfig = new(pluginactionfakes.FakeConfig) var err error - tempPluginDir, err = ioutil.TempDir("", "") + tempPluginDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) actor = NewActor(fakeConfig, nil) }) @@ -40,7 +40,7 @@ var _ = Describe("install actions", func() { var pluginPath string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "") + tempFile, err := os.CreateTemp("", "") Expect(err).ToNot(HaveOccurred()) _, err = tempFile.WriteString("cthulhu") @@ -85,14 +85,14 @@ var _ = Describe("install actions", func() { }, } - pluginFile, err := ioutil.TempFile("", "") + pluginFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) err = pluginFile.Close() Expect(err).NotTo(HaveOccurred()) pluginPath = pluginFile.Name() - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) pluginHomeDir = filepath.Join(tempDir, ".cf", "plugin") diff --git a/actor/pluginaction/install_windows_test.go b/actor/pluginaction/install_windows_test.go index 536b61932a1..04a1c11ccf3 100644 --- a/actor/pluginaction/install_windows_test.go +++ b/actor/pluginaction/install_windows_test.go @@ -1,14 +1,14 @@ +//go:build windows // +build windows package pluginaction_test import ( - "io/ioutil" "os" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -22,7 +22,7 @@ var _ = Describe("install actions", func() { BeforeEach(func() { fakeConfig = new(pluginactionfakes.FakeConfig) var err error - tempPluginDir, err = ioutil.TempDir("", "") + tempPluginDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) actor = NewActor(fakeConfig, nil) }) @@ -37,7 +37,7 @@ var _ = Describe("install actions", func() { var pluginPath string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "") + tempFile, err := os.CreateTemp("", "") Expect(err).ToNot(HaveOccurred()) _, err = tempFile.WriteString("cthulhu") diff --git a/actor/pluginaction/list.go b/actor/pluginaction/list.go index 437ba91a35f..23a76e2a052 100644 --- a/actor/pluginaction/list.go +++ b/actor/pluginaction/list.go @@ -1,8 +1,8 @@ package pluginaction import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "github.com/blang/semver/v4" ) type OutdatedPlugin struct { diff --git a/actor/pluginaction/list_test.go b/actor/pluginaction/list_test.go index 0fa9a7a72fd..d2c8caffff8 100644 --- a/actor/pluginaction/list_test.go +++ b/actor/pluginaction/list_test.go @@ -3,12 +3,12 @@ package pluginaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/pluginaction/plugin_client.go b/actor/pluginaction/plugin_client.go index b7cb8071711..6c992a243f8 100644 --- a/actor/pluginaction/plugin_client.go +++ b/actor/pluginaction/plugin_client.go @@ -1,6 +1,6 @@ package pluginaction -import "code.cloudfoundry.org/cli/api/plugin" +import "code.cloudfoundry.org/cli/v8/api/plugin" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginClient diff --git a/actor/pluginaction/plugin_info.go b/actor/pluginaction/plugin_info.go index 8ca0133f286..c0bb3ddec53 100644 --- a/actor/pluginaction/plugin_info.go +++ b/actor/pluginaction/plugin_info.go @@ -3,9 +3,9 @@ package pluginaction import ( "runtime" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/generic" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/generic" ) type PluginInfo struct { diff --git a/actor/pluginaction/plugin_info_test.go b/actor/pluginaction/plugin_info_test.go index caf4728ac32..eefeb1ec0c1 100644 --- a/actor/pluginaction/plugin_info_test.go +++ b/actor/pluginaction/plugin_info_test.go @@ -3,12 +3,12 @@ package pluginaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/pluginaction/plugin_repository.go b/actor/pluginaction/plugin_repository.go index 600ba67a91c..777a5000ce7 100644 --- a/actor/pluginaction/plugin_repository.go +++ b/actor/pluginaction/plugin_repository.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/util/configv3" ) func (actor Actor) AddPluginRepository(repoName string, repoURL string) error { diff --git a/actor/pluginaction/plugin_repository_test.go b/actor/pluginaction/plugin_repository_test.go index d7d3956aab5..de99fdf0975 100644 --- a/actor/pluginaction/plugin_repository_test.go +++ b/actor/pluginaction/plugin_repository_test.go @@ -4,12 +4,12 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -104,7 +104,7 @@ var _ = Describe("Plugin Repository Actions", func() { }) }) - When("the repository name is the same and repostiroy URL is the same except for trailing slash", func() { + When("the repository name is the same and repository URL is the same except for trailing slash", func() { BeforeEach(func() { fakeConfig.PluginRepositoriesReturns([]configv3.PluginRepository{ { diff --git a/actor/pluginaction/pluginaction_suite_test.go b/actor/pluginaction/pluginaction_suite_test.go index 949f243c16e..5dd0ee739b6 100644 --- a/actor/pluginaction/pluginaction_suite_test.go +++ b/actor/pluginaction/pluginaction_suite_test.go @@ -1,7 +1,7 @@ package pluginaction_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/actor/pluginaction/pluginactionfakes/fake_command_list.go b/actor/pluginaction/pluginactionfakes/fake_command_list.go index 8d72e434889..2efd0621f1d 100644 --- a/actor/pluginaction/pluginactionfakes/fake_command_list.go +++ b/actor/pluginaction/pluginactionfakes/fake_command_list.go @@ -4,7 +4,7 @@ package pluginactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" ) type FakeCommandList struct { @@ -40,15 +40,16 @@ func (fake *FakeCommandList) HasAlias(arg1 string) bool { fake.hasAliasArgsForCall = append(fake.hasAliasArgsForCall, struct { arg1 string }{arg1}) + stub := fake.HasAliasStub + fakeReturns := fake.hasAliasReturns fake.recordInvocation("HasAlias", []interface{}{arg1}) fake.hasAliasMutex.Unlock() - if fake.HasAliasStub != nil { - return fake.HasAliasStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.hasAliasReturns return fakeReturns.result1 } @@ -100,15 +101,16 @@ func (fake *FakeCommandList) HasCommand(arg1 string) bool { fake.hasCommandArgsForCall = append(fake.hasCommandArgsForCall, struct { arg1 string }{arg1}) + stub := fake.HasCommandStub + fakeReturns := fake.hasCommandReturns fake.recordInvocation("HasCommand", []interface{}{arg1}) fake.hasCommandMutex.Unlock() - if fake.HasCommandStub != nil { - return fake.HasCommandStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.hasCommandReturns return fakeReturns.result1 } diff --git a/actor/pluginaction/pluginactionfakes/fake_config.go b/actor/pluginaction/pluginactionfakes/fake_config.go index 4d2581800e7..576280e1bce 100644 --- a/actor/pluginaction/pluginactionfakes/fake_config.go +++ b/actor/pluginaction/pluginactionfakes/fake_config.go @@ -4,8 +4,8 @@ package pluginactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeConfig struct { @@ -97,9 +97,10 @@ func (fake *FakeConfig) AddPlugin(arg1 configv3.Plugin) { fake.addPluginArgsForCall = append(fake.addPluginArgsForCall, struct { arg1 configv3.Plugin }{arg1}) + stub := fake.AddPluginStub fake.recordInvocation("AddPlugin", []interface{}{arg1}) fake.addPluginMutex.Unlock() - if fake.AddPluginStub != nil { + if stub != nil { fake.AddPluginStub(arg1) } } @@ -129,9 +130,10 @@ func (fake *FakeConfig) AddPluginRepository(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.AddPluginRepositoryStub fake.recordInvocation("AddPluginRepository", []interface{}{arg1, arg2}) fake.addPluginRepositoryMutex.Unlock() - if fake.AddPluginRepositoryStub != nil { + if stub != nil { fake.AddPluginRepositoryStub(arg1, arg2) } } @@ -160,15 +162,16 @@ func (fake *FakeConfig) BinaryVersion() string { ret, specificReturn := fake.binaryVersionReturnsOnCall[len(fake.binaryVersionArgsForCall)] fake.binaryVersionArgsForCall = append(fake.binaryVersionArgsForCall, struct { }{}) + stub := fake.BinaryVersionStub + fakeReturns := fake.binaryVersionReturns fake.recordInvocation("BinaryVersion", []interface{}{}) fake.binaryVersionMutex.Unlock() - if fake.BinaryVersionStub != nil { - return fake.BinaryVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryVersionReturns return fakeReturns.result1 } @@ -213,15 +216,16 @@ func (fake *FakeConfig) GetPlugin(arg1 string) (configv3.Plugin, bool) { fake.getPluginArgsForCall = append(fake.getPluginArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPluginStub + fakeReturns := fake.getPluginReturns fake.recordInvocation("GetPlugin", []interface{}{arg1}) fake.getPluginMutex.Unlock() - if fake.GetPluginStub != nil { - return fake.GetPluginStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginReturns return fakeReturns.result1, fakeReturns.result2 } @@ -275,15 +279,16 @@ func (fake *FakeConfig) PluginHome() string { ret, specificReturn := fake.pluginHomeReturnsOnCall[len(fake.pluginHomeArgsForCall)] fake.pluginHomeArgsForCall = append(fake.pluginHomeArgsForCall, struct { }{}) + stub := fake.PluginHomeStub + fakeReturns := fake.pluginHomeReturns fake.recordInvocation("PluginHome", []interface{}{}) fake.pluginHomeMutex.Unlock() - if fake.PluginHomeStub != nil { - return fake.PluginHomeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginHomeReturns return fakeReturns.result1 } @@ -327,15 +332,16 @@ func (fake *FakeConfig) PluginRepositories() []configv3.PluginRepository { ret, specificReturn := fake.pluginRepositoriesReturnsOnCall[len(fake.pluginRepositoriesArgsForCall)] fake.pluginRepositoriesArgsForCall = append(fake.pluginRepositoriesArgsForCall, struct { }{}) + stub := fake.PluginRepositoriesStub + fakeReturns := fake.pluginRepositoriesReturns fake.recordInvocation("PluginRepositories", []interface{}{}) fake.pluginRepositoriesMutex.Unlock() - if fake.PluginRepositoriesStub != nil { - return fake.PluginRepositoriesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginRepositoriesReturns return fakeReturns.result1 } @@ -379,15 +385,16 @@ func (fake *FakeConfig) Plugins() []configv3.Plugin { ret, specificReturn := fake.pluginsReturnsOnCall[len(fake.pluginsArgsForCall)] fake.pluginsArgsForCall = append(fake.pluginsArgsForCall, struct { }{}) + stub := fake.PluginsStub + fakeReturns := fake.pluginsReturns fake.recordInvocation("Plugins", []interface{}{}) fake.pluginsMutex.Unlock() - if fake.PluginsStub != nil { - return fake.PluginsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginsReturns return fakeReturns.result1 } @@ -431,9 +438,10 @@ func (fake *FakeConfig) RemovePlugin(arg1 string) { fake.removePluginArgsForCall = append(fake.removePluginArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RemovePluginStub fake.recordInvocation("RemovePlugin", []interface{}{arg1}) fake.removePluginMutex.Unlock() - if fake.RemovePluginStub != nil { + if stub != nil { fake.RemovePluginStub(arg1) } } @@ -462,15 +470,16 @@ func (fake *FakeConfig) WritePluginConfig() error { ret, specificReturn := fake.writePluginConfigReturnsOnCall[len(fake.writePluginConfigArgsForCall)] fake.writePluginConfigArgsForCall = append(fake.writePluginConfigArgsForCall, struct { }{}) + stub := fake.WritePluginConfigStub + fakeReturns := fake.writePluginConfigReturns fake.recordInvocation("WritePluginConfig", []interface{}{}) fake.writePluginConfigMutex.Unlock() - if fake.WritePluginConfigStub != nil { - return fake.WritePluginConfigStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.writePluginConfigReturns return fakeReturns.result1 } diff --git a/actor/pluginaction/pluginactionfakes/fake_plugin_client.go b/actor/pluginaction/pluginactionfakes/fake_plugin_client.go index 4cd201cd615..c65f369e821 100644 --- a/actor/pluginaction/pluginactionfakes/fake_plugin_client.go +++ b/actor/pluginaction/pluginactionfakes/fake_plugin_client.go @@ -4,8 +4,8 @@ package pluginactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/api/plugin" ) type FakePluginClient struct { @@ -47,15 +47,16 @@ func (fake *FakePluginClient) DownloadPlugin(arg1 string, arg2 string, arg3 plug arg2 string arg3 plugin.ProxyReader }{arg1, arg2, arg3}) + stub := fake.DownloadPluginStub + fakeReturns := fake.downloadPluginReturns fake.recordInvocation("DownloadPlugin", []interface{}{arg1, arg2, arg3}) fake.downloadPluginMutex.Unlock() - if fake.DownloadPluginStub != nil { - return fake.DownloadPluginStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.downloadPluginReturns return fakeReturns.result1 } @@ -107,15 +108,16 @@ func (fake *FakePluginClient) GetPluginRepository(arg1 string) (plugin.PluginRep fake.getPluginRepositoryArgsForCall = append(fake.getPluginRepositoryArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPluginRepositoryStub + fakeReturns := fake.getPluginRepositoryReturns fake.recordInvocation("GetPluginRepository", []interface{}{arg1}) fake.getPluginRepositoryMutex.Unlock() - if fake.GetPluginRepositoryStub != nil { - return fake.GetPluginRepositoryStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginRepositoryReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/pluginaction/pluginactionfakes/fake_plugin_metadata.go b/actor/pluginaction/pluginactionfakes/fake_plugin_metadata.go index 47d16dc403e..353202c19ec 100644 --- a/actor/pluginaction/pluginactionfakes/fake_plugin_metadata.go +++ b/actor/pluginaction/pluginactionfakes/fake_plugin_metadata.go @@ -4,8 +4,8 @@ package pluginactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakePluginMetadata struct { @@ -32,15 +32,16 @@ func (fake *FakePluginMetadata) GetMetadata(arg1 string) (configv3.Plugin, error fake.getMetadataArgsForCall = append(fake.getMetadataArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetMetadataStub + fakeReturns := fake.getMetadataReturns fake.recordInvocation("GetMetadata", []interface{}{arg1}) fake.getMetadataMutex.Unlock() - if fake.GetMetadataStub != nil { - return fake.GetMetadataStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getMetadataReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/pluginaction/pluginactionfakes/fake_plugin_uninstaller.go b/actor/pluginaction/pluginactionfakes/fake_plugin_uninstaller.go index 060fa438753..8a7c70e5740 100644 --- a/actor/pluginaction/pluginactionfakes/fake_plugin_uninstaller.go +++ b/actor/pluginaction/pluginactionfakes/fake_plugin_uninstaller.go @@ -4,7 +4,7 @@ package pluginactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" ) type FakePluginUninstaller struct { @@ -31,15 +31,16 @@ func (fake *FakePluginUninstaller) Run(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.RunStub + fakeReturns := fake.runReturns fake.recordInvocation("Run", []interface{}{arg1, arg2}) fake.runMutex.Unlock() - if fake.RunStub != nil { - return fake.RunStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.runReturns return fakeReturns.result1 } diff --git a/actor/pluginaction/uninstall.go b/actor/pluginaction/uninstall.go index 485217256b9..441dca6ed1c 100644 --- a/actor/pluginaction/uninstall.go +++ b/actor/pluginaction/uninstall.go @@ -5,7 +5,7 @@ import ( "os/exec" "time" - "code.cloudfoundry.org/cli/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginUninstaller diff --git a/actor/pluginaction/uninstall_test.go b/actor/pluginaction/uninstall_test.go index 895f4e2cb54..8bb04794d2e 100644 --- a/actor/pluginaction/uninstall_test.go +++ b/actor/pluginaction/uninstall_test.go @@ -2,16 +2,15 @@ package pluginaction_test import ( "errors" - "io/ioutil" "os" "os/exec" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/actor/pluginaction/pluginactionfakes" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/actor/pluginaction/pluginactionfakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -35,11 +34,11 @@ var _ = Describe("Plugin actor", func() { BeforeEach(func() { var err error - pluginHome, err = ioutil.TempDir("", "") + pluginHome, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) binaryPath = filepath.Join(pluginHome, "banana-faceman") - err = ioutil.WriteFile(binaryPath, nil, 0600) + err = os.WriteFile(binaryPath, nil, 0600) Expect(err).ToNot(HaveOccurred()) fakePluginUninstaller = new(pluginactionfakes.FakePluginUninstaller) @@ -55,8 +54,8 @@ var _ = Describe("Plugin actor", func() { }) It("returns a PluginNotFoundError", func() { - err := actor.UninstallPlugin(fakePluginUninstaller, "some-non-existent-plugin") - Expect(err).To(MatchError(actionerror.PluginNotFoundError{PluginName: "some-non-existent-plugin"})) + err := actor.UninstallPlugin(fakePluginUninstaller, "some-nonexistent-plugin") + Expect(err).To(MatchError(actionerror.PluginNotFoundError{PluginName: "some-nonexistent-plugin"})) }) }) @@ -188,7 +187,7 @@ var _ = Describe("Plugin actor", func() { Expect(err).ToNot(HaveOccurred()) err = os.Mkdir(binaryPath, 0700) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(binaryPath, "foooooo"), nil, 0500) + err = os.WriteFile(filepath.Join(binaryPath, "foooooo"), nil, 0500) Expect(err).ToNot(HaveOccurred()) }) diff --git a/actor/sharedaction/auth_test.go b/actor/sharedaction/auth_test.go index 9fbf5e65066..dc2e219517a 100644 --- a/actor/sharedaction/auth_test.go +++ b/actor/sharedaction/auth_test.go @@ -3,9 +3,9 @@ package sharedaction_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/check_target.go b/actor/sharedaction/check_target.go index 5621e845054..a852ed87dea 100644 --- a/actor/sharedaction/check_target.go +++ b/actor/sharedaction/check_target.go @@ -1,6 +1,6 @@ package sharedaction -import "code.cloudfoundry.org/cli/actor/actionerror" +import "code.cloudfoundry.org/cli/v8/actor/actionerror" // CheckTarget confirms that the user is logged in. Optionally it will also // check if an organization and space are targeted. diff --git a/actor/sharedaction/check_target_test.go b/actor/sharedaction/check_target_test.go index a0846072628..0030cef620d 100644 --- a/actor/sharedaction/check_target_test.go +++ b/actor/sharedaction/check_target_test.go @@ -3,11 +3,10 @@ package sharedaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/fix_mode_unix.go b/actor/sharedaction/fix_mode_unix.go index bbe7e9fc15c..680fe4cf8e8 100644 --- a/actor/sharedaction/fix_mode_unix.go +++ b/actor/sharedaction/fix_mode_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package sharedaction diff --git a/actor/sharedaction/fix_mode_windows.go b/actor/sharedaction/fix_mode_windows.go index 422a0ccb031..2e726c70782 100644 --- a/actor/sharedaction/fix_mode_windows.go +++ b/actor/sharedaction/fix_mode_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package sharedaction diff --git a/actor/sharedaction/help.go b/actor/sharedaction/help.go index a1120cd3ed3..20667b7e718 100644 --- a/actor/sharedaction/help.go +++ b/actor/sharedaction/help.go @@ -5,8 +5,8 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/util/sorting" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/util/sorting" ) const ( diff --git a/actor/sharedaction/help_test.go b/actor/sharedaction/help_test.go index d729999aa5a..d0f3baf37fe 100644 --- a/actor/sharedaction/help_test.go +++ b/actor/sharedaction/help_test.go @@ -1,11 +1,11 @@ package sharedaction_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/is_org_targeted_test.go b/actor/sharedaction/is_org_targeted_test.go index e13bca342f5..465eebe771f 100644 --- a/actor/sharedaction/is_org_targeted_test.go +++ b/actor/sharedaction/is_org_targeted_test.go @@ -1,9 +1,9 @@ package sharedaction_test import ( - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/is_space_targeted_test.go b/actor/sharedaction/is_space_targeted_test.go index a1bdaca43ae..775c282d491 100644 --- a/actor/sharedaction/is_space_targeted_test.go +++ b/actor/sharedaction/is_space_targeted_test.go @@ -1,9 +1,9 @@ package sharedaction_test import ( - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/log_cache_client.go b/actor/sharedaction/log_cache_client.go index ed3403a1051..3be1f69018b 100644 --- a/actor/sharedaction/log_cache_client.go +++ b/actor/sharedaction/log_cache_client.go @@ -4,8 +4,8 @@ import ( "context" "time" - logcache "code.cloudfoundry.org/go-log-cache" - "code.cloudfoundry.org/go-loggregator/v8/rpc/loggregator_v2" + logcache "code.cloudfoundry.org/go-log-cache/v2" + "code.cloudfoundry.org/go-loggregator/v9/rpc/loggregator_v2" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . LogCacheClient diff --git a/actor/sharedaction/logging.go b/actor/sharedaction/logging.go index 820767661ac..bb1cb095bdf 100644 --- a/actor/sharedaction/logging.go +++ b/actor/sharedaction/logging.go @@ -8,9 +8,9 @@ import ( "strings" "time" - logcache "code.cloudfoundry.org/go-log-cache" - "code.cloudfoundry.org/go-log-cache/rpc/logcache_v1" - "code.cloudfoundry.org/go-loggregator/v8/rpc/loggregator_v2" + logcache "code.cloudfoundry.org/go-log-cache/v2" + "code.cloudfoundry.org/go-log-cache/v2/rpc/logcache_v1" + "code.cloudfoundry.org/go-loggregator/v9/rpc/loggregator_v2" "github.com/sirupsen/logrus" ) diff --git a/actor/sharedaction/logging_test.go b/actor/sharedaction/logging_test.go index abbb94c1257..736582c75ef 100644 --- a/actor/sharedaction/logging_test.go +++ b/actor/sharedaction/logging_test.go @@ -7,11 +7,11 @@ import ( "net/url" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - logcache "code.cloudfoundry.org/go-log-cache" - "code.cloudfoundry.org/go-loggregator/v8/rpc/loggregator_v2" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + logcache "code.cloudfoundry.org/go-log-cache/v2" + "code.cloudfoundry.org/go-loggregator/v9/rpc/loggregator_v2" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/sharedaction/resource.go b/actor/sharedaction/resource.go index 944883be0eb..2a69476cfec 100644 --- a/actor/sharedaction/resource.go +++ b/actor/sharedaction/resource.go @@ -5,14 +5,13 @@ import ( "crypto/sha1" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" "code.cloudfoundry.org/ykk" ignore "github.com/sabhiram/go-gitignore" log "github.com/sirupsen/logrus" @@ -214,7 +213,7 @@ func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error // filemode for user is forced to be readable and executable. func (actor Actor) ZipArchiveResources(sourceArchivePath string, filesToInclude []Resource) (string, error) { log.WithField("sourceArchive", sourceArchivePath).Info("zipping source files from archive") - zipFile, err := ioutil.TempFile("", "cf-cli-") + zipFile, err := os.CreateTemp("", "cf-cli-") if err != nil { return "", err } @@ -274,7 +273,7 @@ func (actor Actor) ZipArchiveResources(sourceArchivePath string, filesToInclude // filemode for user is forced to be readable and executable. func (actor Actor) ZipDirectoryResources(sourceDir string, filesToInclude []Resource) (string, error) { log.WithField("sourceDir", sourceDir).Info("zipping source files from directory") - zipFile, err := ioutil.TempFile("", "cf-cli-") + zipFile, err := os.CreateTemp("", "cf-cli-") if err != nil { return "", err } @@ -434,7 +433,7 @@ func (Actor) generateArchiveCFIgnoreMatcher(files []*zip.File) (*ignore.GitIgnor } defer fileReader.Close() - raw, err := ioutil.ReadAll(fileReader) + raw, err := io.ReadAll(fileReader) if err != nil { return nil, err } diff --git a/actor/sharedaction/resource_darwin_test.go b/actor/sharedaction/resource_darwin_test.go index f9e87be6eab..1c710ad5cca 100644 --- a/actor/sharedaction/resource_darwin_test.go +++ b/actor/sharedaction/resource_darwin_test.go @@ -1,15 +1,15 @@ +//go:build !windows && !linux // +build !windows,!linux package sharedaction_test import ( - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -30,20 +30,20 @@ var _ = Describe("Resource Actions", func() { // tmpfile3 var err error - srcDir, err = ioutil.TempDir("", "v2-resource-actions") + srcDir, err = os.MkdirTemp("", "v2-resource-actions") Expect(err).ToNot(HaveOccurred()) subDir := filepath.Join(srcDir, "level1", "level2") err = os.MkdirAll(subDir, 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) + err = os.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) Expect(err).ToNot(HaveOccurred()) err = os.Symlink("file-that-may-or-may-not-exist", filepath.Join(srcDir, "symlink1")) @@ -63,7 +63,7 @@ var _ = Describe("Resource Actions", func() { ) BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "example") + tmpfile, err := os.CreateTemp("", "example") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) @@ -110,7 +110,7 @@ var _ = Describe("Resource Actions", func() { When("a symlink file points to an existing file", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, "file-that-may-or-may-not-exist"), []byte("Bananarama"), 0655) + err := os.WriteFile(filepath.Join(srcDir, "file-that-may-or-may-not-exist"), []byte("Bananarama"), 0655) Expect(err).ToNot(HaveOccurred()) }) diff --git a/actor/sharedaction/resource_linux_test.go b/actor/sharedaction/resource_linux_test.go index bc48769ae34..f85f7485669 100644 --- a/actor/sharedaction/resource_linux_test.go +++ b/actor/sharedaction/resource_linux_test.go @@ -1,15 +1,15 @@ +//go:build !windows && !darwin // +build !windows,!darwin package sharedaction_test import ( - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -30,20 +30,20 @@ var _ = Describe("Resource Actions", func() { // tmpfile3 var err error - srcDir, err = ioutil.TempDir("", "v2-resource-actions") + srcDir, err = os.MkdirTemp("", "v2-resource-actions") Expect(err).ToNot(HaveOccurred()) subDir := filepath.Join(srcDir, "level1", "level2") err = os.MkdirAll(subDir, 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) + err = os.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) Expect(err).ToNot(HaveOccurred()) err = os.Symlink("file-that-may-or-may-not-exist", filepath.Join(srcDir, "symlink1")) @@ -63,7 +63,7 @@ var _ = Describe("Resource Actions", func() { ) BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "example") + tmpfile, err := os.CreateTemp("", "example") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) @@ -110,7 +110,7 @@ var _ = Describe("Resource Actions", func() { When("a symlink file points to an existing file", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, "file-that-may-or-may-not-exist"), []byte("Bananarama"), 0655) + err := os.WriteFile(filepath.Join(srcDir, "file-that-may-or-may-not-exist"), []byte("Bananarama"), 0655) Expect(err).ToNot(HaveOccurred()) }) diff --git a/actor/sharedaction/resource_test.go b/actor/sharedaction/resource_test.go index 46a002ee796..d57ea238ab9 100644 --- a/actor/sharedaction/resource_test.go +++ b/actor/sharedaction/resource_test.go @@ -3,17 +3,16 @@ package sharedaction_test import ( "archive/zip" "io" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" "code.cloudfoundry.org/ykk" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -34,20 +33,20 @@ var _ = Describe("Resource Actions", func() { // tmpfile3 var err error - srcDir, err = ioutil.TempDir("", "resource-actions-test") + srcDir, err = os.MkdirTemp("", "resource-actions-test") Expect(err).ToNot(HaveOccurred()) subDir := filepath.Join(srcDir, "level1", "level2") err = os.MkdirAll(subDir, 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0600) + err = os.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0600) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0600) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0600) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0600) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0600) Expect(err).ToNot(HaveOccurred()) relativePath, err := filepath.Rel(srcDir, subDir) @@ -69,7 +68,7 @@ var _ = Describe("Resource Actions", func() { Describe("SharedToV3Resource", func() { var returnedV3Resource V3Resource - var sharedResource = Resource{Filename: "file1", SHA1: "a43rknl", Mode: os.FileMode(644), Size: 100000} + var sharedResource = Resource{Filename: "file1", SHA1: "a43rknl", Mode: os.FileMode(0644), Size: 100000} JustBeforeEach(func() { returnedV3Resource = sharedResource.ToV3Resource() @@ -82,7 +81,7 @@ var _ = Describe("Resource Actions", func() { Value: "a43rknl", }, SizeInBytes: 100000, - Mode: os.FileMode(644), + Mode: os.FileMode(0644), })) }) @@ -97,7 +96,7 @@ var _ = Describe("Resource Actions", func() { Value: "a43rknl", }, SizeInBytes: 100000, - Mode: os.FileMode(644), + Mode: os.FileMode(0644), } JustBeforeEach(func() { @@ -105,7 +104,7 @@ var _ = Describe("Resource Actions", func() { }) It("returns a ccv3 Resource", func() { - Expect(returnedSharedResource).To(Equal(Resource{Filename: "file1", SHA1: "a43rknl", Mode: os.FileMode(644), Size: 100000})) + Expect(returnedSharedResource).To(Equal(Resource{Filename: "file1", SHA1: "a43rknl", Mode: os.FileMode(0644), Size: 100000})) }) }) @@ -137,7 +136,7 @@ var _ = Describe("Resource Actions", func() { When("the archive can be accessed properly", func() { BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "fake-archive") + tmpfile, err := os.CreateTemp("", "fake-archive") Expect(err).ToNot(HaveOccurred()) _, err = tmpfile.Write([]byte("123456")) Expect(err).ToNot(HaveOccurred()) @@ -176,7 +175,7 @@ var _ = Describe("Resource Actions", func() { ) BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "zip-archive-resources") + tmpfile, err := os.CreateTemp("", "zip-archive-resources") Expect(err).ToNot(HaveOccurred()) defer tmpfile.Close() archive = tmpfile.Name() @@ -429,7 +428,7 @@ func expectFileContentsToEqual(file *zip.File, expectedContents string) { Expect(err).ToNot(HaveOccurred()) defer reader.Close() - body, err := ioutil.ReadAll(reader) + body, err := io.ReadAll(reader) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(Equal(expectedContents)) diff --git a/actor/sharedaction/resource_unix_test.go b/actor/sharedaction/resource_unix_test.go index cfbcceb112e..ad52c86ecfd 100644 --- a/actor/sharedaction/resource_unix_test.go +++ b/actor/sharedaction/resource_unix_test.go @@ -1,17 +1,17 @@ +//go:build !windows // +build !windows package sharedaction_test import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" "code.cloudfoundry.org/ykk" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -32,20 +32,20 @@ var _ = Describe("Resource Actions", func() { // tmpfile3 var err error - srcDir, err = ioutil.TempDir("", "v2-resource-actions") + srcDir, err = os.MkdirTemp("", "v2-resource-actions") Expect(err).ToNot(HaveOccurred()) subDir := filepath.Join(srcDir, "level1", "level2") err = os.MkdirAll(subDir, 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) + err = os.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0644) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0751) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0655) Expect(err).ToNot(HaveOccurred()) }) @@ -63,7 +63,7 @@ var _ = Describe("Resource Actions", func() { ) BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "example") + tmpfile, err := os.CreateTemp("", "example") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) @@ -83,7 +83,7 @@ var _ = Describe("Resource Actions", func() { When("archive is empty", func() { BeforeEach(func() { var err error - srcDir, err = ioutil.TempDir("", "v2-resource-actions-empty") + srcDir, err = os.MkdirTemp("", "v2-resource-actions-empty") Expect(err).ToNot(HaveOccurred()) }) @@ -101,7 +101,7 @@ var _ = Describe("Resource Actions", func() { var symlinkToArchive string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "symlink-to-archive") + tempFile, err := os.CreateTemp("", "symlink-to-archive") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) symlinkToArchive = tempFile.Name() @@ -135,7 +135,7 @@ var _ = Describe("Resource Actions", func() { When("a .cfignore file exists in the archive", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) Expect(err).ToNot(HaveOccurred()) }) @@ -156,9 +156,9 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { for _, filename := range DefaultIgnoreLines { if filename != ".cfignore" { - err := ioutil.WriteFile(filepath.Join(srcDir, filename), nil, 0655) + err := os.WriteFile(filepath.Join(srcDir, filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) + err = os.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) } } @@ -205,7 +205,7 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { tmpDir = srcDir - tmpFile, err := ioutil.TempFile("", "symlink-file-") + tmpFile, err := os.CreateTemp("", "symlink-file-") Expect(err).ToNot(HaveOccurred()) Expect(tmpFile.Close()).To(Succeed()) @@ -235,7 +235,7 @@ var _ = Describe("Resource Actions", func() { When("a .cfignore file exists in the sourceDir", func() { Context("with relative paths", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) Expect(err).ToNot(HaveOccurred()) }) @@ -253,7 +253,7 @@ var _ = Describe("Resource Actions", func() { Context("with absolute paths - where '/' == sourceDir", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("/level1/level2"), 0655) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("/level1/level2"), 0655) Expect(err).ToNot(HaveOccurred()) }) @@ -274,9 +274,9 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { for _, filename := range DefaultIgnoreLines { if filename != ".cfignore" { - err := ioutil.WriteFile(filepath.Join(srcDir, filename), nil, 0655) + err := os.WriteFile(filepath.Join(srcDir, filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) + err = os.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) } } @@ -299,7 +299,7 @@ var _ = Describe("Resource Actions", func() { When("trace files are in the source directory", func() { BeforeEach(func() { traceFilePath := filepath.Join(srcDir, "i-am-trace.txt") - err := ioutil.WriteFile(traceFilePath, nil, 0655) + err := os.WriteFile(traceFilePath, nil, 0655) Expect(err).ToNot(HaveOccurred()) fakeConfig.VerboseReturns(false, []string{traceFilePath, "/some-other-path"}) @@ -325,7 +325,7 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { var err error - emptyDir, err = ioutil.TempDir("", "v2-resource-actions-empty") + emptyDir, err = os.MkdirTemp("", "v2-resource-actions-empty") Expect(err).ToNot(HaveOccurred()) }) diff --git a/actor/sharedaction/resource_windows_test.go b/actor/sharedaction/resource_windows_test.go index 9aa3b6ee290..27329679ee6 100644 --- a/actor/sharedaction/resource_windows_test.go +++ b/actor/sharedaction/resource_windows_test.go @@ -1,15 +1,14 @@ package sharedaction_test import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" "code.cloudfoundry.org/ykk" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -30,20 +29,20 @@ var _ = Describe("Resource Actions", func() { // tmpfile3 var err error - srcDir, err = ioutil.TempDir("", "v2-resource-actions") + srcDir, err = os.MkdirTemp("", "v2-resource-actions") Expect(err).ToNot(HaveOccurred()) subDir := filepath.Join(srcDir, "level1", "level2") err = os.MkdirAll(subDir, 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0666) + err = os.WriteFile(filepath.Join(subDir, "tmpFile1"), []byte("why hello"), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0666) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile2"), []byte("Hello, Binky"), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0666) + err = os.WriteFile(filepath.Join(srcDir, "tmpFile3"), []byte("Bananarama"), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -61,7 +60,7 @@ var _ = Describe("Resource Actions", func() { ) BeforeEach(func() { - tmpfile, err := ioutil.TempFile("", "gather-archive-resource-test") + tmpfile, err := os.CreateTemp("", "gather-archive-resource-test") Expect(err).ToNot(HaveOccurred()) defer tmpfile.Close() archive = tmpfile.Name() @@ -96,7 +95,7 @@ var _ = Describe("Resource Actions", func() { var symlinkToArchive string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "symlink-to-archive") + tempFile, err := os.CreateTemp("", "symlink-to-archive") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) symlinkToArchive = tempFile.Name() @@ -130,7 +129,7 @@ var _ = Describe("Resource Actions", func() { When("a .cfignore file exists in the archive", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0655) Expect(err).ToNot(HaveOccurred()) }) @@ -151,9 +150,9 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { for _, filename := range DefaultIgnoreLines { if filename != ".cfignore" { - err := ioutil.WriteFile(filepath.Join(srcDir, filename), nil, 0655) + err := os.WriteFile(filepath.Join(srcDir, filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) + err = os.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) } } @@ -213,7 +212,7 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { tmpDir = srcDir - tmpFile, err := ioutil.TempFile("", "symlink-file-") + tmpFile, err := os.CreateTemp("", "symlink-file-") Expect(err).ToNot(HaveOccurred()) Expect(tmpFile.Close()).To(Succeed()) @@ -243,7 +242,7 @@ var _ = Describe("Resource Actions", func() { When("a .cfignore file exists in the sourceDir", func() { Context("with relative paths", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0666) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("level2"), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -261,7 +260,7 @@ var _ = Describe("Resource Actions", func() { Context("with absolute paths - where '/' == sourceDir", func() { BeforeEach(func() { - err := ioutil.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("/level1/level2"), 0666) + err := os.WriteFile(filepath.Join(srcDir, ".cfignore"), []byte("/level1/level2"), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -282,9 +281,9 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { for _, filename := range DefaultIgnoreLines { if filename != ".cfignore" { - err := ioutil.WriteFile(filepath.Join(srcDir, filename), nil, 0655) + err := os.WriteFile(filepath.Join(srcDir, filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) + err = os.WriteFile(filepath.Join(srcDir, "level1", filename), nil, 0655) Expect(err).ToNot(HaveOccurred()) } } @@ -307,7 +306,7 @@ var _ = Describe("Resource Actions", func() { When("trace files are in the source directory", func() { BeforeEach(func() { traceFilePath := filepath.Join(srcDir, "i-am-trace.txt") - err := ioutil.WriteFile(traceFilePath, nil, 0666) + err := os.WriteFile(traceFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) fakeConfig.VerboseReturns(false, []string{traceFilePath, "C:\\some-other-path"}) @@ -333,7 +332,7 @@ var _ = Describe("Resource Actions", func() { BeforeEach(func() { var err error - emptyDir, err = ioutil.TempDir("", "v2-resource-actions-empty") + emptyDir, err = os.MkdirTemp("", "v2-resource-actions-empty") Expect(err).ToNot(HaveOccurred()) }) diff --git a/actor/sharedaction/secure_shell_client.go b/actor/sharedaction/secure_shell_client.go index af276009b0c..a9f959decd1 100644 --- a/actor/sharedaction/secure_shell_client.go +++ b/actor/sharedaction/secure_shell_client.go @@ -1,6 +1,6 @@ package sharedaction -import "code.cloudfoundry.org/cli/util/clissh" +import "code.cloudfoundry.org/cli/v8/util/clissh" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SecureShellClient diff --git a/actor/sharedaction/sharedaction_suite_test.go b/actor/sharedaction/sharedaction_suite_test.go index 192b53011c7..022001ef6e1 100644 --- a/actor/sharedaction/sharedaction_suite_test.go +++ b/actor/sharedaction/sharedaction_suite_test.go @@ -6,12 +6,11 @@ import ( "os" "path/filepath" "strings" + "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" - - "testing" ) func TestSharedAction(t *testing.T) { diff --git a/actor/sharedaction/sharedactionfakes/fake_config.go b/actor/sharedaction/sharedactionfakes/fake_config.go index 9bad4b6fb7d..300c0a8cf4b 100644 --- a/actor/sharedaction/sharedactionfakes/fake_config.go +++ b/actor/sharedaction/sharedactionfakes/fake_config.go @@ -4,7 +4,7 @@ package sharedactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" ) type FakeConfig struct { @@ -111,15 +111,16 @@ func (fake *FakeConfig) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -163,15 +164,16 @@ func (fake *FakeConfig) BinaryName() string { ret, specificReturn := fake.binaryNameReturnsOnCall[len(fake.binaryNameArgsForCall)] fake.binaryNameArgsForCall = append(fake.binaryNameArgsForCall, struct { }{}) + stub := fake.BinaryNameStub + fakeReturns := fake.binaryNameReturns fake.recordInvocation("BinaryName", []interface{}{}) fake.binaryNameMutex.Unlock() - if fake.BinaryNameStub != nil { - return fake.BinaryNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryNameReturns return fakeReturns.result1 } @@ -215,15 +217,16 @@ func (fake *FakeConfig) CurrentUserName() (string, error) { ret, specificReturn := fake.currentUserNameReturnsOnCall[len(fake.currentUserNameArgsForCall)] fake.currentUserNameArgsForCall = append(fake.currentUserNameArgsForCall, struct { }{}) + stub := fake.CurrentUserNameStub + fakeReturns := fake.currentUserNameReturns fake.recordInvocation("CurrentUserName", []interface{}{}) fake.currentUserNameMutex.Unlock() - if fake.CurrentUserNameStub != nil { - return fake.CurrentUserNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -270,15 +273,16 @@ func (fake *FakeConfig) HasTargetedOrganization() bool { ret, specificReturn := fake.hasTargetedOrganizationReturnsOnCall[len(fake.hasTargetedOrganizationArgsForCall)] fake.hasTargetedOrganizationArgsForCall = append(fake.hasTargetedOrganizationArgsForCall, struct { }{}) + stub := fake.HasTargetedOrganizationStub + fakeReturns := fake.hasTargetedOrganizationReturns fake.recordInvocation("HasTargetedOrganization", []interface{}{}) fake.hasTargetedOrganizationMutex.Unlock() - if fake.HasTargetedOrganizationStub != nil { - return fake.HasTargetedOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasTargetedOrganizationReturns return fakeReturns.result1 } @@ -322,15 +326,16 @@ func (fake *FakeConfig) HasTargetedSpace() bool { ret, specificReturn := fake.hasTargetedSpaceReturnsOnCall[len(fake.hasTargetedSpaceArgsForCall)] fake.hasTargetedSpaceArgsForCall = append(fake.hasTargetedSpaceArgsForCall, struct { }{}) + stub := fake.HasTargetedSpaceStub + fakeReturns := fake.hasTargetedSpaceReturns fake.recordInvocation("HasTargetedSpace", []interface{}{}) fake.hasTargetedSpaceMutex.Unlock() - if fake.HasTargetedSpaceStub != nil { - return fake.HasTargetedSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasTargetedSpaceReturns return fakeReturns.result1 } @@ -374,15 +379,16 @@ func (fake *FakeConfig) IsCFOnK8s() bool { ret, specificReturn := fake.isCFOnK8sReturnsOnCall[len(fake.isCFOnK8sArgsForCall)] fake.isCFOnK8sArgsForCall = append(fake.isCFOnK8sArgsForCall, struct { }{}) + stub := fake.IsCFOnK8sStub + fakeReturns := fake.isCFOnK8sReturns fake.recordInvocation("IsCFOnK8s", []interface{}{}) fake.isCFOnK8sMutex.Unlock() - if fake.IsCFOnK8sStub != nil { - return fake.IsCFOnK8sStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isCFOnK8sReturns return fakeReturns.result1 } @@ -426,15 +432,16 @@ func (fake *FakeConfig) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -478,15 +485,16 @@ func (fake *FakeConfig) TargetedOrganizationName() string { ret, specificReturn := fake.targetedOrganizationNameReturnsOnCall[len(fake.targetedOrganizationNameArgsForCall)] fake.targetedOrganizationNameArgsForCall = append(fake.targetedOrganizationNameArgsForCall, struct { }{}) + stub := fake.TargetedOrganizationNameStub + fakeReturns := fake.targetedOrganizationNameReturns fake.recordInvocation("TargetedOrganizationName", []interface{}{}) fake.targetedOrganizationNameMutex.Unlock() - if fake.TargetedOrganizationNameStub != nil { - return fake.TargetedOrganizationNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetedOrganizationNameReturns return fakeReturns.result1 } @@ -530,15 +538,16 @@ func (fake *FakeConfig) Verbose() (bool, []string) { ret, specificReturn := fake.verboseReturnsOnCall[len(fake.verboseArgsForCall)] fake.verboseArgsForCall = append(fake.verboseArgsForCall, struct { }{}) + stub := fake.VerboseStub + fakeReturns := fake.verboseReturns fake.recordInvocation("Verbose", []interface{}{}) fake.verboseMutex.Unlock() - if fake.VerboseStub != nil { - return fake.VerboseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.verboseReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/sharedaction/sharedactionfakes/fake_log_cache_client.go b/actor/sharedaction/sharedactionfakes/fake_log_cache_client.go index ac0cf83dfa7..c12f5871676 100644 --- a/actor/sharedaction/sharedactionfakes/fake_log_cache_client.go +++ b/actor/sharedaction/sharedactionfakes/fake_log_cache_client.go @@ -6,9 +6,9 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - client "code.cloudfoundry.org/go-log-cache" - "code.cloudfoundry.org/go-loggregator/v8/rpc/loggregator_v2" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + client "code.cloudfoundry.org/go-log-cache/v2" + "code.cloudfoundry.org/go-loggregator/v9/rpc/loggregator_v2" ) type FakeLogCacheClient struct { @@ -41,15 +41,16 @@ func (fake *FakeLogCacheClient) Read(arg1 context.Context, arg2 string, arg3 tim arg3 time.Time arg4 []client.ReadOption }{arg1, arg2, arg3, arg4}) + stub := fake.ReadStub + fakeReturns := fake.readReturns fake.recordInvocation("Read", []interface{}{arg1, arg2, arg3, arg4}) fake.readMutex.Unlock() - if fake.ReadStub != nil { - return fake.ReadStub(arg1, arg2, arg3, arg4...) + if stub != nil { + return stub(arg1, arg2, arg3, arg4...) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/sharedaction/sharedactionfakes/fake_secure_shell_client.go b/actor/sharedaction/sharedactionfakes/fake_secure_shell_client.go index a9fa609a871..a409307b2e0 100644 --- a/actor/sharedaction/sharedactionfakes/fake_secure_shell_client.go +++ b/actor/sharedaction/sharedactionfakes/fake_secure_shell_client.go @@ -4,8 +4,8 @@ package sharedactionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/util/clissh" ) type FakeSecureShellClient struct { @@ -76,15 +76,16 @@ func (fake *FakeSecureShellClient) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -133,15 +134,16 @@ func (fake *FakeSecureShellClient) Connect(arg1 string, arg2 string, arg3 string arg4 string arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.ConnectStub + fakeReturns := fake.connectReturns fake.recordInvocation("Connect", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.connectMutex.Unlock() - if fake.ConnectStub != nil { - return fake.ConnectStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1 } - fakeReturns := fake.connectReturns return fakeReturns.result1 } @@ -199,15 +201,16 @@ func (fake *FakeSecureShellClient) InteractiveSession(arg1 []string, arg2 clissh arg1 []string arg2 clissh.TTYRequest }{arg1Copy, arg2}) + stub := fake.InteractiveSessionStub + fakeReturns := fake.interactiveSessionReturns fake.recordInvocation("InteractiveSession", []interface{}{arg1Copy, arg2}) fake.interactiveSessionMutex.Unlock() - if fake.InteractiveSessionStub != nil { - return fake.InteractiveSessionStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.interactiveSessionReturns return fakeReturns.result1 } @@ -264,15 +267,16 @@ func (fake *FakeSecureShellClient) LocalPortForward(arg1 []clissh.LocalPortForwa fake.localPortForwardArgsForCall = append(fake.localPortForwardArgsForCall, struct { arg1 []clissh.LocalPortForward }{arg1Copy}) + stub := fake.LocalPortForwardStub + fakeReturns := fake.localPortForwardReturns fake.recordInvocation("LocalPortForward", []interface{}{arg1Copy}) fake.localPortForwardMutex.Unlock() - if fake.LocalPortForwardStub != nil { - return fake.LocalPortForwardStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.localPortForwardReturns return fakeReturns.result1 } @@ -323,15 +327,16 @@ func (fake *FakeSecureShellClient) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/actor/sharedaction/ssh.go b/actor/sharedaction/ssh.go index 600d4cc3ec8..601da7e2319 100644 --- a/actor/sharedaction/ssh.go +++ b/actor/sharedaction/ssh.go @@ -1,6 +1,6 @@ package sharedaction -import "code.cloudfoundry.org/cli/util/clissh" +import "code.cloudfoundry.org/cli/v8/util/clissh" type TTYOption clissh.TTYRequest diff --git a/actor/sharedaction/ssh_test.go b/actor/sharedaction/ssh_test.go index ce193cc9d1b..fb939d820d7 100644 --- a/actor/sharedaction/ssh_test.go +++ b/actor/sharedaction/ssh_test.go @@ -3,10 +3,10 @@ package sharedaction_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/util/clissh" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/util/clissh" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/actor.go b/actor/v7action/actor.go index 6fb6cbe0a35..b42793d27d7 100644 --- a/actor/v7action/actor.go +++ b/actor/v7action/actor.go @@ -2,9 +2,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/util/configv3" "code.cloudfoundry.org/clock" ) diff --git a/actor/v7action/application.go b/actor/v7action/application.go index 95f1abb4694..7c45b6ff09b 100644 --- a/actor/v7action/application.go +++ b/actor/v7action/application.go @@ -5,13 +5,13 @@ import ( "fmt" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - "code.cloudfoundry.org/cli/util/unique" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + "code.cloudfoundry.org/cli/v8/util/unique" ) func (actor Actor) DeleteApplicationByNameAndSpace(name, spaceGUID string, deleteRoutes bool) (Warnings, error) { @@ -162,6 +162,7 @@ func (actor Actor) CreateApplicationInSpace(app resources.Application, spaceGUID LifecycleBuildpacks: app.LifecycleBuildpacks, StackName: app.StackName, Name: app.Name, + Credentials: app.Credentials, SpaceGUID: spaceGUID, }) @@ -226,7 +227,8 @@ func (actor Actor) GetUnstagedNewestPackageGUID(appGUID string) (string, Warning packages, warnings, err := actor.CloudControllerClient.GetPackages( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, - ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}) + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}) allWarnings = append(allWarnings, warnings...) if err != nil { return "", allWarnings, err @@ -241,6 +243,7 @@ func (actor Actor) GetUnstagedNewestPackageGUID(appGUID string) (string, Warning newestPackage.GUID, ccv3.Query{Key: ccv3.StatesFilter, Values: []string{"STAGED"}}, ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) allWarnings = append(allWarnings, warnings...) if err != nil { @@ -296,9 +299,9 @@ func (actor Actor) PollStart(app resources.Application, noWait bool, handleInsta } } -// PollStartForRolling polls a deploying application's processes until some are started. It does the same thing as PollStart, except it accounts for rolling deployments and whether +// PollStartForDeployment polls a deploying application's processes until some are started. It does the same thing as PollStart, except it accounts for rolling/canary deployments and whether // they have failed or been canceled during polling. -func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) { +func (actor Actor) PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) { var ( deployment resources.Deployment processes []resources.Process @@ -319,7 +322,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID } return allWarnings, actionerror.StartupTimeoutError{Name: app.Name} case <-timer.C(): - if !isDeployed(deployment) { + if !isDeployProcessed(deployment) { ccDeployment, warnings, err := actor.getDeployment(deploymentGUID) allWarnings = append(allWarnings, warnings...) if err != nil { @@ -333,7 +336,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID } } - if noWait || isDeployed(deployment) { + if noWait || isDeployProcessed(deployment) { stopPolling, warnings, err := actor.PollProcesses(processes, handleInstanceDetails) allWarnings = append(allWarnings, warnings...) if stopPolling || err != nil { @@ -346,7 +349,12 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID } } -func isDeployed(d resources.Deployment) bool { +func isDeployProcessed(d resources.Deployment) bool { + if d.Strategy == constant.DeploymentStrategyCanary { + return d.StatusValue == constant.DeploymentStatusValueActive && d.StatusReason == constant.DeploymentStatusReasonPaused || + d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed + } + return d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed } @@ -374,7 +382,7 @@ func (actor Actor) PollProcesses(processes []resources.Process, handleInstanceDe return true, allWarnings, actionerror.AllInstancesCrashedError{} } - //precondition: !instances.Empty() && no instances are running + // precondition: !instances.Empty() && no instances are running // do not increment numStableProcesses return false, allWarnings, nil } @@ -400,6 +408,17 @@ func (actor Actor) UpdateApplication(app resources.Application) (resources.Appli return updatedApp, Warnings(warnings), nil } +// UpdateApplicationName updates the name of an application +func (actor Actor) UpdateApplicationName(newAppName string, appGUID string) (resources.Application, Warnings, error) { + + updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationName(newAppName, appGUID) + if err != nil { + return resources.Application{}, Warnings(warnings), err + } + + return updatedApp, Warnings(warnings), nil +} + func (actor Actor) getDeployment(deploymentGUID string) (resources.Deployment, Warnings, error) { deployment, warnings, err := actor.CloudControllerClient.GetDeployment(deploymentGUID) if err != nil { @@ -426,7 +445,7 @@ func (actor Actor) getProcesses(deployment resources.Deployment, appGUID string, // if the deployment is deployed we know web are all running and PollProcesses will see those as stable // so just getting all processes is equivalent to just getting non-web ones and polling those - if isDeployed(deployment) { + if isDeployProcessed(deployment) { processes, warnings, err := actor.CloudControllerClient.GetApplicationProcesses(appGUID) if err != nil { return processes, Warnings(warnings), err @@ -444,8 +463,8 @@ func (actor Actor) RenameApplicationByNameAndSpaceGUID(appName, newAppName, spac if err != nil { return resources.Application{}, allWarnings, err } - application.Name = newAppName - application, warnings, err = actor.UpdateApplication(application) + appGUID := application.GUID + application, warnings, err = actor.UpdateApplicationName(newAppName, appGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return resources.Application{}, allWarnings, err diff --git a/actor/v7action/application_feature.go b/actor/v7action/application_feature.go index 24c00e7e0d3..0c7576d5ad9 100644 --- a/actor/v7action/application_feature.go +++ b/actor/v7action/application_feature.go @@ -1,8 +1,8 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) GetAppFeature(appGUID string, featureName string) (resources.ApplicationFeature, Warnings, error) { diff --git a/actor/v7action/application_feature_test.go b/actor/v7action/application_feature_test.go index aabe1dff9c0..1254fc39728 100644 --- a/actor/v7action/application_feature_test.go +++ b/actor/v7action/application_feature_test.go @@ -4,12 +4,12 @@ import ( "errors" "time" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" "code.cloudfoundry.org/clock/fakeclock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/application_manifest.go b/actor/v7action/application_manifest.go index 9e23a1ee87e..46382bc1d49 100644 --- a/actor/v7action/application_manifest.go +++ b/actor/v7action/application_manifest.go @@ -1,8 +1,8 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ManifestParser diff --git a/actor/v7action/application_manifest_test.go b/actor/v7action/application_manifest_test.go index 709fcbbe656..f71cd25855e 100644 --- a/actor/v7action/application_manifest_test.go +++ b/actor/v7action/application_manifest_test.go @@ -3,15 +3,15 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" "code.cloudfoundry.org/clock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -303,7 +303,7 @@ var _ = Describe("Application Manifest Actions", func() { It("returns the error and warnings", func() { Expect(executeErr).To(Equal(expectedErr)) Expect(warnings).To(ConsistOf("get-application-warning")) - _ = manifestBytes //TODO DELETE ME + _ = manifestBytes // TODO DELETE ME }) }) }) diff --git a/actor/v7action/application_summary.go b/actor/v7action/application_summary.go index 42776cf493e..c989c54ac68 100644 --- a/actor/v7action/application_summary.go +++ b/actor/v7action/application_summary.go @@ -1,10 +1,13 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" ) type ApplicationSummary struct { @@ -17,6 +20,7 @@ type ApplicationSummary struct { type DetailedApplicationSummary struct { ApplicationSummary CurrentDroplet resources.Droplet + Deployment resources.Deployment } func (a ApplicationSummary) GetIsolationSegmentName() (string, bool) { @@ -32,67 +36,45 @@ func (a ApplicationSummary) hasIsolationSegment() bool { len(a.ProcessSummaries[0].InstanceDetails[0].IsolationSegment) > 0 } -func (actor Actor) GetAppSummariesForSpace(spaceGUID string, labelSelector string) ([]ApplicationSummary, Warnings, error) { +func (actor Actor) GetAppSummariesForSpace(spaceGUID string, labelSelector string, omitStats bool) ([]ApplicationSummary, Warnings, error) { var allWarnings Warnings var allSummaries []ApplicationSummary keys := []ccv3.Query{ {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, {Key: ccv3.OrderBy, Values: []string{ccv3.NameOrder}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { keys = append(keys, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) } - apps, warnings, err := actor.CloudControllerClient.GetApplications(keys...) - allWarnings = append(allWarnings, warnings...) + apps, ccv3Warnings, err := actor.CloudControllerClient.GetApplications(keys...) + allWarnings = append(allWarnings, ccv3Warnings...) if err != nil { return nil, allWarnings, err } - var processes []resources.Process - warnings, err = batcher.RequestByGUID(toAppGUIDs(apps), func(guids []string) (ccv3.Warnings, error) { - batch, warnings, err := actor.CloudControllerClient.GetProcesses(ccv3.Query{ - Key: ccv3.AppGUIDFilter, Values: guids, - }) - processes = append(processes, batch...) - return warnings, err - }) - allWarnings = append(allWarnings, warnings...) - if err != nil { - return nil, allWarnings, err - } + var processSummariesByAppGUID map[string]ProcessSummaries + var warnings Warnings - processSummariesByAppGUID := make(map[string]ProcessSummaries, len(apps)) - for _, process := range processes { - instances, warnings, err := actor.CloudControllerClient.GetProcessInstances(process.GUID) - allWarnings = append(allWarnings, Warnings(warnings)...) + if !omitStats { + processSummariesByAppGUID, warnings, err = actor.getProcessSummariesForApps(apps) + allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } - - var instanceDetails []ProcessInstance - for _, instance := range instances { - instanceDetails = append(instanceDetails, ProcessInstance(instance)) - } - - processSummary := ProcessSummary{ - Process: resources.Process(process), - InstanceDetails: instanceDetails, - } - - processSummariesByAppGUID[process.AppGUID] = append(processSummariesByAppGUID[process.AppGUID], processSummary) } var routes []resources.Route - warnings, err = batcher.RequestByGUID(toAppGUIDs(apps), func(guids []string) (ccv3.Warnings, error) { + ccv3Warnings, err = batcher.RequestByGUID(toAppGUIDs(apps), func(guids []string) (ccv3.Warnings, error) { batch, warnings, err := actor.CloudControllerClient.GetRoutes(ccv3.Query{ Key: ccv3.AppGUIDFilter, Values: guids, }) routes = append(routes, batch...) return warnings, err }) - allWarnings = append(allWarnings, warnings...) + allWarnings = append(allWarnings, ccv3Warnings...) if err != nil { return nil, allWarnings, err } @@ -141,9 +123,60 @@ func (actor Actor) GetDetailedAppSummary(appName, spaceGUID string, withObfuscat return DetailedApplicationSummary{}, allWarnings, err } + detailedSummary, warnings, err = actor.addDeployment(detailedSummary) + allWarnings = append(allWarnings, warnings...) + if err != nil { + return DetailedApplicationSummary{}, allWarnings, err + } + return detailedSummary, allWarnings, err } +func (actor Actor) getProcessSummariesForApps(apps []resources.Application) (map[string]ProcessSummaries, Warnings, error) { + processSummariesByAppGUID := make(map[string]ProcessSummaries) + var allWarnings Warnings + var processes []resources.Process + + warnings, err := batcher.RequestByGUID(toAppGUIDs(apps), func(guids []string) (ccv3.Warnings, error) { + batch, warnings, err := actor.CloudControllerClient.GetProcesses(ccv3.Query{ + Key: ccv3.AppGUIDFilter, Values: guids, + }) + processes = append(processes, batch...) + return warnings, err + }) + allWarnings = append(allWarnings, warnings...) + if err != nil { + return nil, allWarnings, err + } + + for _, process := range processes { + instances, warnings, err := actor.CloudControllerClient.GetProcessInstances(process.GUID) + allWarnings = append(allWarnings, Warnings(warnings)...) + + if err != nil { + switch err.(type) { + case ccerror.ProcessNotFoundError, ccerror.InstanceNotFoundError: + continue + default: + return nil, allWarnings, err + } + } + + var instanceDetails []ProcessInstance + for _, instance := range instances { + instanceDetails = append(instanceDetails, ProcessInstance(instance)) + } + + processSummary := ProcessSummary{ + Process: resources.Process(process), + InstanceDetails: instanceDetails, + } + + processSummariesByAppGUID[process.AppGUID] = append(processSummariesByAppGUID[process.AppGUID], processSummary) + } + return processSummariesByAppGUID, allWarnings, nil +} + func (actor Actor) createSummary(app resources.Application, withObfuscatedValues bool) (ApplicationSummary, Warnings, error) { var allWarnings Warnings @@ -182,6 +215,19 @@ func (actor Actor) addDroplet(summary ApplicationSummary) (DetailedApplicationSu }, allWarnings, nil } +func (actor Actor) addDeployment(detailedSummary DetailedApplicationSummary) (DetailedApplicationSummary, Warnings, error) { + var allWarnings Warnings + + deployment, warnings, err := actor.GetLatestActiveDeploymentForApp(detailedSummary.GUID) + allWarnings = append(allWarnings, warnings...) + if err != nil && !errors.Is(err, actionerror.ActiveDeploymentNotFoundError{}) { + return DetailedApplicationSummary{}, allWarnings, err + } + + detailedSummary.Deployment = deployment + return detailedSummary, allWarnings, nil +} + func toAppGUIDs(apps []resources.Application) []string { guids := make([]string, len(apps)) diff --git a/actor/v7action/application_summary_test.go b/actor/v7action/application_summary_test.go index ef136015aab..dcba2bc5c08 100644 --- a/actor/v7action/application_summary_test.go +++ b/actor/v7action/application_summary_test.go @@ -4,19 +4,18 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/clock" - "code.cloudfoundry.org/cli/actor/actionerror" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -72,6 +71,7 @@ var _ = Describe("Application Summary Actions", func() { var ( spaceGUID string labelSelector string + omitStats bool summaries []ApplicationSummary warnings Warnings @@ -81,10 +81,11 @@ var _ = Describe("Application Summary Actions", func() { BeforeEach(func() { spaceGUID = "some-space-guid" labelSelector = "some-key=some-value" + omitStats = false }) JustBeforeEach(func() { - summaries, warnings, executeErr = actor.GetAppSummariesForSpace(spaceGUID, labelSelector) + summaries, warnings, executeErr = actor.GetAppSummariesForSpace(spaceGUID, labelSelector, omitStats) }) When("getting the application is successful", func() { @@ -274,6 +275,7 @@ var _ = Describe("Application Summary Actions", func() { ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}}, ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}}, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{"some-key=some-value"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) Expect(fakeCloudControllerClient.GetProcessesCallCount()).To(Equal(1)) @@ -294,6 +296,7 @@ var _ = Describe("Application Summary Actions", func() { Expect(fakeCloudControllerClient.GetApplicationsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}}, ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) }) }) @@ -361,6 +364,93 @@ var _ = Describe("Application Summary Actions", func() { Expect(warnings).To(ConsistOf("get-apps-warning")) }) }) + + When("omitStats flag is provided", func() { + BeforeEach(func() { + omitStats = true + + fakeCloudControllerClient.GetApplicationsReturns( + []resources.Application{ + { + Name: "some-app-name", + GUID: "some-app-guid", + State: constant.ApplicationStarted, + }, + }, + ccv3.Warnings{"get-apps-warning"}, + nil, + ) + + listedProcesses := []resources.Process{ + { + GUID: "some-process-web-guid", + Type: "web", + Command: *types.NewFilteredString("[Redacted Value]"), + MemoryInMB: types.NullUint64{Value: 64, IsSet: true}, + AppGUID: "some-app-guid", + }, + } + + fakeCloudControllerClient.GetProcessesReturns( + listedProcesses, + ccv3.Warnings{"get-app-processes-warning"}, + nil, + ) + }) + It("doesn't call the stats endpoint", func() { + Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(0)) + }) + }) + + When("an application is deleted in between", func() { + + BeforeEach(func() { + fakeCloudControllerClient.GetApplicationsReturns( + []resources.Application{ + { + Name: "some-app-name", + GUID: "some-app-guid", + State: constant.ApplicationStarted, + }, + }, + nil, + nil, + ) + + fakeCloudControllerClient.GetProcessesReturns( + []resources.Process{ + { + GUID: "some-process-web-guid", + Type: "web", + Command: *types.NewFilteredString("[Redacted Value]"), + MemoryInMB: types.NullUint64{Value: 64, IsSet: true}, + AppGUID: "some-app-guid", + }, + }, + nil, + nil, + ) + + fakeCloudControllerClient.GetProcessInstancesReturns(nil, nil, ccerror.ProcessNotFoundError{}) + }) + + It("does not fail and has empty ProcessSummaries & Routes", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(summaries).To(Equal([]ApplicationSummary{ + { + Application: resources.Application{ + Name: "some-app-name", + GUID: "some-app-guid", + State: constant.ApplicationStarted, + }, + ProcessSummaries: nil, + Routes: nil, + }, + })) + + }) + }) }) Describe("GetDetailedAppSummary", func() { @@ -483,6 +573,142 @@ var _ = Describe("Application Summary Actions", func() { ) }) + When("getting application deployment succeeds", func() { + When("the deployment is active", func() { + When("the deployment strategy is rolling", func() { + When("the deployment is in progress", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentsReturns( + []resources.Deployment{ + { + GUID: "some-deployment-guid", + Strategy: "rolling", + StatusValue: "ACTIVE", + StatusReason: "DEPLOYING", + }, + }, + nil, + nil, + ) + }) + It("returns the deployment information", func() { + Expect(summary.Deployment).To(Equal(resources.Deployment{ + GUID: "some-deployment-guid", + Strategy: "rolling", + StatusValue: "ACTIVE", + StatusReason: "DEPLOYING", + })) + }) + }) + + When("the deployment is canceled", func() { + When("the deployment is in progress", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentsReturns( + []resources.Deployment{ + { + GUID: "some-deployment-guid", + Strategy: "rolling", + StatusValue: "ACTIVE", + StatusReason: "CANCELLING", + }, + }, + nil, + nil, + ) + }) + It("returns the deployment information", func() { + Expect(summary.Deployment).To(Equal(resources.Deployment{ + GUID: "some-deployment-guid", + Strategy: "rolling", + StatusValue: "ACTIVE", + StatusReason: "CANCELLING", + })) + }) + }) + }) + }) + + When("the deployment strategy is canary", func() { + When("the deployment is paused", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentsReturns( + []resources.Deployment{ + { + GUID: "some-deployment-guid", + Strategy: "canary", + StatusValue: "ACTIVE", + StatusReason: "PAUSED", + }, + }, + nil, + nil, + ) + }) + It("returns the deployment information", func() { + Expect(summary.Deployment).To(Equal(resources.Deployment{ + GUID: "some-deployment-guid", + Strategy: "canary", + StatusValue: "ACTIVE", + StatusReason: "PAUSED", + })) + }) + }) + }) + }) + + When("the deployment is not active", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentsReturns( + []resources.Deployment{ + { + GUID: "", + Strategy: "", + StatusValue: "", + StatusReason: "", + }, + }, + nil, + nil, + ) + }) + It("returns no deployment information", func() { + Expect(summary.Deployment).To(Equal(resources.Deployment{ + GUID: "", + Strategy: "", + StatusValue: "", + StatusReason: "", + })) + }) + }) + }) + + When("getting application deployment fails", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentsReturns( + nil, + ccv3.Warnings{"get-deployments-warning"}, + errors.New("some-error"), + ) + }) + + It("returns the warnings and error", func() { + Expect(executeErr).To(MatchError("some-error")) + Expect(warnings).To(ConsistOf( + "get-apps-warning", + "get-app-processes-warning", + "get-process-by-type-warning", + "get-process-sidecars-warning", + "get-process-instances-warning", + "get-process-by-type-warning", + "get-process-sidecars-warning", + "get-process-instances-warning", + "get-app-droplet-warning", + "get-deployments-warning", + )) + }) + }) + When("getting application routes succeeds", func() { BeforeEach(func() { fakeCloudControllerClient.GetApplicationRoutesReturns( @@ -498,7 +724,7 @@ var _ = Describe("Application Summary Actions", func() { It("returns the summary and warnings with droplet information", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(summary).To(Equal(DetailedApplicationSummary{ - ApplicationSummary: v7action.ApplicationSummary{ + ApplicationSummary: ApplicationSummary{ Application: resources.Application{ Name: "some-app-name", GUID: "some-app-guid", @@ -642,7 +868,7 @@ var _ = Describe("Application Summary Actions", func() { It("returns the summary and warnings without droplet information", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(summary).To(Equal(DetailedApplicationSummary{ - ApplicationSummary: v7action.ApplicationSummary{ + ApplicationSummary: ApplicationSummary{ Application: resources.Application{ Name: "some-app-name", GUID: "some-app-guid", diff --git a/actor/v7action/application_test.go b/actor/v7action/application_test.go index 4d02f5c565c..3eeb2dd03a2 100644 --- a/actor/v7action/application_test.go +++ b/actor/v7action/application_test.go @@ -5,17 +5,17 @@ import ( "fmt" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/batcher" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/batcher" "code.cloudfoundry.org/clock/fakeclock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -286,7 +286,7 @@ var _ = Describe("Application Actions", func() { }) It("returns an ApplicationNotFoundError and the warnings", func() { - _, warnings, err := actor.GetApplicationsByGUIDs([]string{"some-app-guid", "non-existent-app-guid"}) + _, warnings, err := actor.GetApplicationsByGUIDs([]string{"some-app-guid", "nonexistent-app-guid"}) Expect(warnings).To(ConsistOf("some-warning")) Expect(err).To(MatchError(actionerror.ApplicationsNotFoundError{})) }) @@ -773,6 +773,76 @@ var _ = Describe("Application Actions", func() { }) }) + Describe("UpdateApplicationName", func() { + var ( + resultApp resources.Application + newAppName, appGUID string + warnings Warnings + err error + ) + + JustBeforeEach(func() { + newAppName = "some-new-app-name" + appGUID = "some-app-guid" + + resultApp, warnings, err = actor.UpdateApplicationName(newAppName, appGUID) + }) + + When("the app successfully gets updated", func() { + var apiResponseApp resources.Application + + BeforeEach(func() { + apiResponseApp = resources.Application{ + GUID: "response-app-guid", + StackName: "response-stack-name", + Name: "response-app-name", + LifecycleType: constant.AppLifecycleTypeBuildpack, + LifecycleBuildpacks: []string{"response-buildpack-1", "response-buildpack-2"}, + } + fakeCloudControllerClient.UpdateApplicationNameReturns( + apiResponseApp, + ccv3.Warnings{"some-warning"}, + nil, + ) + }) + + It("creates and returns the application and warnings", func() { + Expect(err).ToNot(HaveOccurred()) + Expect(resultApp).To(Equal(resources.Application{ + Name: apiResponseApp.Name, + GUID: apiResponseApp.GUID, + StackName: apiResponseApp.StackName, + LifecycleType: apiResponseApp.LifecycleType, + LifecycleBuildpacks: apiResponseApp.LifecycleBuildpacks, + })) + Expect(warnings).To(ConsistOf("some-warning")) + + Expect(fakeCloudControllerClient.UpdateApplicationNameCallCount()).To(Equal(1)) + appName, appGuid := fakeCloudControllerClient.UpdateApplicationNameArgsForCall(0) + Expect(appName).To(Equal("some-new-app-name")) + Expect(appGuid).To(Equal("some-app-guid")) + }) + }) + + When("the cc client returns an error", func() { + var expectedError error + + BeforeEach(func() { + expectedError = errors.New("I am a CloudControllerClient Error") + fakeCloudControllerClient.UpdateApplicationNameReturns( + resources.Application{}, + ccv3.Warnings{"some-warning"}, + expectedError, + ) + }) + + It("raises the error and warnings", func() { + Expect(err).To(MatchError(expectedError)) + Expect(warnings).To(ConsistOf("some-warning")) + }) + }) + }) + Describe("PollStart", func() { var ( app resources.Application @@ -963,7 +1033,7 @@ var _ = Describe("Application Actions", func() { }) }) - Describe("PollStartForRolling", func() { + Describe("PollStartForDeployment", func() { var ( app resources.Application deploymentGUID string @@ -995,7 +1065,7 @@ var _ = Describe("Application Actions", func() { JustBeforeEach(func() { go func() { - warnings, executeErr = actor.PollStartForRolling(app, deploymentGUID, noWait, handleInstanceDetails) + warnings, executeErr = actor.PollStartForDeployment(app, deploymentGUID, noWait, handleInstanceDetails) done <- true }() }) @@ -1297,160 +1367,205 @@ var _ = Describe("Application Actions", func() { }) When("things eventually become healthy", func() { - When("the no wait flag is given", func() { - BeforeEach(func() { - // in total three loops 1: deployment still deploying 2: deployment deployed processes starting 3: processes started - noWait = true - - // Always return deploying as a way to check we respect no wait - fakeCloudControllerClient.GetDeploymentReturns( - resources.Deployment{ - StatusValue: constant.DeploymentStatusValueActive, - NewProcesses: []resources.Process{{GUID: "new-deployment-process"}}, - }, - ccv3.Warnings{"get-deployment-warning"}, - nil, - ) + When("it is a rolling deployment", func() { + When("the no wait flag is given", func() { + BeforeEach(func() { + // in total three loops 1: deployment still deploying 2: deployment deployed processes starting 3: processes started + noWait = true - // We only poll the processes. Two loops for fun - fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(0, - []ccv3.ProcessInstance{{State: constant.ProcessInstanceStarting}}, - ccv3.Warnings{"poll-processes-warning-1"}, - nil, - ) + // Always return deploying as a way to check we respect no wait + fakeCloudControllerClient.GetDeploymentReturns( + resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + NewProcesses: []resources.Process{{GUID: "new-deployment-process"}}, + }, + ccv3.Warnings{"get-deployment-warning"}, + nil, + ) - fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(1, - []ccv3.ProcessInstance{{State: constant.ProcessInstanceRunning}}, - ccv3.Warnings{"poll-processes-warning-2"}, - nil, - ) - }) + // We only poll the processes. Two loops for fun + fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(0, + []ccv3.ProcessInstance{{State: constant.ProcessInstanceStarting}}, + ccv3.Warnings{"poll-processes-warning-1"}, + nil, + ) - It("polls the start of the application correctly and returns warnings and no error", func() { - // Initial tick - fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2) + fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(1, + []ccv3.ProcessInstance{{State: constant.ProcessInstanceRunning}}, + ccv3.Warnings{"poll-processes-warning-2"}, + nil, + ) + }) - // assert one of our watcher is the timeout - Expect(fakeConfig.StartupTimeoutCallCount()).To(Equal(1)) + It("polls the start of the application correctly and returns warnings and no error", func() { + // Initial tick + fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2) - // the first time through we always get the deployment regardless of no-wait - Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1)) - Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) - Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(1)) - Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("new-deployment-process")) - Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(1)) + // assert one of our watcher is the timeout + Expect(fakeConfig.StartupTimeoutCallCount()).To(Equal(1)) - fakeClock.Increment(1 * time.Second) + // the first time through we always get the deployment regardless of no-wait + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("new-deployment-process")) + Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(1)) - Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(2)) - Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) - Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(2)) - Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("new-deployment-process")) + fakeClock.Increment(1 * time.Second) - Eventually(done).Should(Receive(BeTrue())) + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(2)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(2)) + Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("new-deployment-process")) - Expect(executeErr).NotTo(HaveOccurred()) - Expect(warnings).To(ConsistOf( - "get-deployment-warning", - "poll-processes-warning-1", - "get-deployment-warning", - "poll-processes-warning-2", - )) + Eventually(done).Should(Receive(BeTrue())) - Expect(fakeCloudControllerClient.GetDeploymentCallCount()).To(Equal(2)) - Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(0)) - Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2)) - Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(1)) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf( + "get-deployment-warning", + "poll-processes-warning-1", + "get-deployment-warning", + "poll-processes-warning-2", + )) + Expect(fakeCloudControllerClient.GetDeploymentCallCount()).To(Equal(2)) + Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(0)) + Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2)) + Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(1)) + }) }) + When("the no wait flag is not given", func() { + BeforeEach(func() { + // in total three loops 1: deployment still deploying 2: deployment deployed processes starting 3: processes started + fakeCloudControllerClient.GetDeploymentReturnsOnCall(0, + resources.Deployment{StatusValue: constant.DeploymentStatusValueActive}, + ccv3.Warnings{"get-deployment-warning-1"}, + nil, + ) - }) + // Poll the deployment twice to make sure we are polling (one in the above before each) + fakeCloudControllerClient.GetDeploymentReturnsOnCall(1, + resources.Deployment{StatusValue: constant.DeploymentStatusValueFinalized, StatusReason: constant.DeploymentStatusReasonDeployed}, + ccv3.Warnings{"get-deployment-warning-2"}, + nil, + ) - When("the no wait flag is not given", func() { - BeforeEach(func() { - // in total three loops 1: deployment still deploying 2: deployment deployed processes starting 3: processes started - fakeCloudControllerClient.GetDeploymentReturnsOnCall(0, - resources.Deployment{StatusValue: constant.DeploymentStatusValueActive}, - ccv3.Warnings{"get-deployment-warning-1"}, - nil, - ) + // then we get the processes. This should only be called once + fakeCloudControllerClient.GetApplicationProcessesReturns( + []resources.Process{{GUID: "process-guid"}}, + ccv3.Warnings{"get-processes-warning"}, + nil, + ) - // Poll the deployment twice to make sure we are polling (one in the above before each) - fakeCloudControllerClient.GetDeploymentReturnsOnCall(1, - resources.Deployment{StatusValue: constant.DeploymentStatusValueFinalized, StatusReason: constant.DeploymentStatusReasonDeployed}, - ccv3.Warnings{"get-deployment-warning-2"}, - nil, - ) + // then we poll the processes. Two loops for fun + fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(0, + []ccv3.ProcessInstance{{State: constant.ProcessInstanceStarting}}, + ccv3.Warnings{"poll-processes-warning-1"}, + nil, + ) - // then we get the processes. This should only be called once - fakeCloudControllerClient.GetApplicationProcessesReturns( - []resources.Process{{GUID: "process-guid"}}, - ccv3.Warnings{"get-processes-warning"}, - nil, - ) + fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(1, + []ccv3.ProcessInstance{{State: constant.ProcessInstanceRunning}}, + ccv3.Warnings{"poll-processes-warning-2"}, + nil, + ) + }) - // then we poll the processes. Two loops for fun - fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(0, - []ccv3.ProcessInstance{{State: constant.ProcessInstanceStarting}}, - ccv3.Warnings{"poll-processes-warning-1"}, - nil, - ) + It("polls the start of the application correctly and returns warnings and no error", func() { + // Initial tick + fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2) - fakeCloudControllerClient.GetProcessInstancesReturnsOnCall(1, - []ccv3.ProcessInstance{{State: constant.ProcessInstanceRunning}}, - ccv3.Warnings{"poll-processes-warning-2"}, - nil, - ) - }) + // assert one of our watchers is for the timeout + Expect(fakeConfig.StartupTimeoutCallCount()).To(Equal(1)) - It("polls the start of the application correctly and returns warnings and no error", func() { - // Initial tick - fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2) + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(1)) - // assert one of our watchers is for the timeout - Expect(fakeConfig.StartupTimeoutCallCount()).To(Equal(1)) + // start the second loop where the deployment is deployed so we poll processes + fakeClock.Increment(1 * time.Second) - Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1)) - Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) - Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(1)) + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(2)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(1)).To(Equal(deploymentGUID)) + Eventually(fakeCloudControllerClient.GetApplicationProcessesCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetApplicationProcessesArgsForCall(0)).To(Equal(app.GUID)) + Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("process-guid")) + Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(2)) - // start the second loop where the deployment is deployed so we poll processes - fakeClock.Increment(1 * time.Second) + fakeClock.Increment(1 * time.Second) - Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(2)) - Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(1)).To(Equal(deploymentGUID)) - Eventually(fakeCloudControllerClient.GetApplicationProcessesCallCount).Should(Equal(1)) - Expect(fakeCloudControllerClient.GetApplicationProcessesArgsForCall(0)).To(Equal(app.GUID)) - Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(1)) - Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("process-guid")) - Eventually(fakeConfig.PollingIntervalCallCount).Should(Equal(2)) + // we should stop polling because it is deployed + Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(2)) + Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("process-guid")) - fakeClock.Increment(1 * time.Second) + Eventually(done).Should(Receive(BeTrue())) - // we should stop polling because it is deployed - Eventually(fakeCloudControllerClient.GetProcessInstancesCallCount).Should(Equal(2)) - Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("process-guid")) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf( + "get-deployment-warning-1", + "get-deployment-warning-2", + "get-processes-warning", + "poll-processes-warning-1", + "poll-processes-warning-2", + )) - Eventually(done).Should(Receive(BeTrue())) + Expect(fakeCloudControllerClient.GetDeploymentCallCount()).To(Equal(2)) + Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(1)) + Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2)) + Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(2)) + }) + }) + }) - Expect(executeErr).NotTo(HaveOccurred()) - Expect(warnings).To(ConsistOf( - "get-deployment-warning-1", - "get-deployment-warning-2", - "get-processes-warning", - "poll-processes-warning-1", - "poll-processes-warning-2", - )) + When("it is a canary deployment", func() { + When("the no wait flag is not given", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetDeploymentReturnsOnCall(0, + resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + }, + nil, + nil, + ) - Expect(fakeCloudControllerClient.GetDeploymentCallCount()).To(Equal(2)) - Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(1)) - Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2)) - Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(2)) + fakeCloudControllerClient.GetDeploymentReturnsOnCall(1, + resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonPaused, + }, + nil, + nil, + ) + }) - }) + It("stops polling when the deployment status is paused", func() { + // Initial tick + fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2) - }) + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + // start the second loop where the deployment is deployed so we poll processes + fakeClock.Increment(1 * time.Second) + + Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(2)) + Expect(fakeCloudControllerClient.GetDeploymentArgsForCall(1)).To(Equal(deploymentGUID)) + + fakeClock.Increment(1 * time.Second) + + // we should stop polling because it is deployed + Eventually(done).Should(Receive(BeTrue())) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(fakeCloudControllerClient.GetDeploymentCallCount()).To(Equal(2)) + Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(1)) + }) + }) + }) }) }) @@ -1889,6 +2004,7 @@ var _ = Describe("Application Actions", func() { ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{"some-app-guid"}}, ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -1928,8 +2044,9 @@ var _ = Describe("Application Actions", func() { packageGuid, queries := fakeCloudControllerClient.GetPackageDropletsArgsForCall(0) Expect(packageGuid).To(Equal("package-guid")) Expect(queries).To(ConsistOf( - ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, ccv3.Query{Key: ccv3.StatesFilter, Values: []string{"STAGED"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -2016,7 +2133,7 @@ var _ = Describe("Application Actions", func() { }, ccv3.Warnings{"get-app-warning"}, nil) - fakeCloudControllerClient.UpdateApplicationReturns( + fakeCloudControllerClient.UpdateApplicationNameReturns( resources.Application{}, ccv3.Warnings{"update-app-warning"}, expectedError) @@ -2042,7 +2159,7 @@ var _ = Describe("Application Actions", func() { nil, ) - fakeCloudControllerClient.UpdateApplicationReturns( + fakeCloudControllerClient.UpdateApplicationNameReturns( resources.Application{ Name: "new-app-name", GUID: "old-app-guid", @@ -2060,13 +2177,9 @@ var _ = Describe("Application Actions", func() { GUID: "old-app-guid", })) Expect(warnings).To(ConsistOf("get-app-warning", "update-app-warning")) - - Expect(fakeCloudControllerClient.UpdateApplicationArgsForCall(0)).To(Equal( - resources.Application{ - Name: "new-app-name", - GUID: "old-app-guid", - })) - + appName, appGuid := fakeCloudControllerClient.UpdateApplicationNameArgsForCall(0) + Expect(appName).To(Equal("new-app-name")) + Expect(appGuid).To(Equal("old-app-guid")) }) }) diff --git a/actor/v7action/auth.go b/actor/v7action/auth.go index c69d4836a90..ba730f8456d 100644 --- a/actor/v7action/auth.go +++ b/actor/v7action/auth.go @@ -6,10 +6,10 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type defaultAuthActor struct { @@ -25,7 +25,7 @@ func NewDefaultAuthActor(config Config, uaaClient UAAClient) AuthActor { } func (actor defaultAuthActor) Authenticate(credentials map[string]string, origin string, grantType constant.GrantType) error { - if grantType == constant.GrantTypePassword && actor.config.UAAGrantType() == string(constant.GrantTypeClientCredentials) { + if (grantType == constant.GrantTypePassword || grantType == constant.GrantTypeJwtBearer) && actor.config.UAAGrantType() == string(constant.GrantTypeClientCredentials) { return actionerror.PasswordGrantTypeLogoutRequiredError{} } @@ -45,7 +45,7 @@ func (actor defaultAuthActor) Authenticate(credentials map[string]string, origin actor.config.SetUAAGrantType(string(grantType)) } - if grantType == constant.GrantTypeClientCredentials { + if (grantType == constant.GrantTypeClientCredentials || grantType == constant.GrantTypeJwtBearer) && credentials["client_id"] != "" { actor.config.SetUAAClientCredentials(credentials["client_id"], "") } @@ -97,7 +97,11 @@ func (actor Actor) isTokenRevocable(token string) bool { } payload := make(map[string]interface{}) - json.Unmarshal(jsonPayload, &payload) + err = json.Unmarshal(jsonPayload, &payload) + if err != nil { + return false + } + revocable, ok := payload["revocable"].(bool) if !ok { diff --git a/actor/v7action/auth_test.go b/actor/v7action/auth_test.go index 1949fe81838..53a7b7374c3 100644 --- a/actor/v7action/auth_test.go +++ b/actor/v7action/auth_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/build.go b/actor/v7action/build.go index a6aeda49b3e..b496c9e6ac8 100644 --- a/actor/v7action/build.go +++ b/actor/v7action/build.go @@ -5,10 +5,10 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" log "github.com/sirupsen/logrus" ) @@ -33,16 +33,19 @@ func (actor Actor) StagePackage(packageGUID, appName, spaceGUID string) (<-chan } app := apps[0] - pkgs, allWarnings, err := actor.CloudControllerClient.GetPackages(ccv3.Query{ - Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}, - }) + pkgs, allWarnings, err := actor.CloudControllerClient.GetPackages( + ccv3.Query{Key: ccv3.GUIDFilter, Values: []string{packageGUID}}, + ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + ) warningsStream <- Warnings(allWarnings) if err != nil { errorStream <- err return } - if !packageInPackages(packageGUID, pkgs) { + if len(pkgs) == 0 { err = actionerror.PackageNotFoundInAppError{GUID: packageGUID, AppName: appName} errorStream <- err return @@ -87,7 +90,7 @@ func (actor Actor) StagePackage(packageGUID, appName, spaceGUID string) (<-chan timer.Reset(actor.Config.PollingInterval()) default: - //TODO: uncomment after #150569020 + // TODO: uncomment after #150569020 // droplet, warnings, err := actor.CloudControllerClient.GetDroplet(build.DropletGUID) // warningsStream <- Warnings(warnings) // if err != nil { @@ -166,12 +169,3 @@ func (actor Actor) PollBuild(buildGUID string, appName string) (resources.Drople } } } - -func packageInPackages(targetPkgGUID string, pkgs []resources.Package) bool { - for i := range pkgs { - if pkgs[i].GUID == targetPkgGUID { - return true - } - } - return false -} diff --git a/actor/v7action/build_test.go b/actor/v7action/build_test.go index 380188c5bc6..426cf0915c0 100644 --- a/actor/v7action/build_test.go +++ b/actor/v7action/build_test.go @@ -4,14 +4,14 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" "code.cloudfoundry.org/clock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -104,7 +104,7 @@ var _ = Describe("Build Actions", func() { BeforeEach(func() { fakeCloudControllerClient.GetApplicationsReturns([]resources.Application{{GUID: appGUID}}, ccv3.Warnings{"get-apps-warning"}, nil) fakeCloudControllerClient.GetPackagesReturns( - []resources.Package{{GUID: "some-other-package-guid"}}, + []resources.Package{}, ccv3.Warnings{"get-packages-warning"}, nil, ) @@ -138,7 +138,7 @@ var _ = Describe("Build Actions", func() { fakeCloudControllerClient.GetBuildReturnsOnCall(1, resources.Build{CreatedAt: "some-time", GUID: buildGUID, State: constant.BuildStaged, DropletGUID: "some-droplet-guid"}, ccv3.Warnings{"get-warnings-3", "get-warnings-4"}, nil) }) - //TODO: uncommend after #150569020 + // TODO: uncommend after #150569020 // FWhen("looking up the droplet fails", func() { // BeforeEach(func() { // fakeCloudControllerClient.GetDropletReturns(resources.Droplet{}, ccv3.Warnings{"droplet-warnings-1", "droplet-warnings-2"}, errors.New("some-droplet-error")) @@ -180,7 +180,10 @@ var _ = Describe("Build Actions", func() { Expect(fakeCloudControllerClient.GetPackagesCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetPackagesArgsForCall(0)).To(Equal([]ccv3.Query{ + {Key: ccv3.GUIDFilter, Values: []string{packageGUID}}, {Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.CreateBuildCallCount()).To(Equal(1)) diff --git a/actor/v7action/buildpack.go b/actor/v7action/buildpack.go index 0fc3eab27cd..7e429316f14 100644 --- a/actor/v7action/buildpack.go +++ b/actor/v7action/buildpack.go @@ -6,11 +6,11 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util" ) type JobURL ccv3.JobURL @@ -21,52 +21,60 @@ type Downloader interface { Download(url string, tmpDirPath string) (string, error) } -func (actor Actor) GetBuildpacks(labelSelector string) ([]resources.Buildpack, Warnings, error) { - queries := []ccv3.Query{ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.PositionOrder}}} +func (actor Actor) GetBuildpacks(labelSelector string, lifecycle string) ([]resources.Buildpack, Warnings, error) { + queries := []ccv3.Query{} if labelSelector != "" { queries = append(queries, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) } + if lifecycle != "" { + queries = append(queries, ccv3.Query{Key: ccv3.LifecycleFilter, Values: []string{lifecycle}}) + } + buildpacks, warnings, err := actor.CloudControllerClient.GetBuildpacks(queries...) return buildpacks, Warnings(warnings), err } -// GetBuildpackByNameAndStack returns a buildpack with the provided name and -// stack. If `buildpackStack` is not specified, and there are multiple +// GetBuildpackByNameAndStackAndLifecycle returns a buildpack with the provided name, stack, +// and lifecycle. If `buildpackStack` is not specified, and there are multiple // buildpacks with the same name, it will return the one with no stack, if -// present. -func (actor Actor) GetBuildpackByNameAndStack(buildpackName string, buildpackStack string) (resources.Buildpack, Warnings, error) { +// present. If `buildpackLifecycle` is not specified and there are multiple buildpacks with +// the same name, it will return the one with the default_app_lifecycle, if present. +func (actor Actor) GetBuildpackByNameAndStackAndLifecycle(buildpackName string, buildpackStack string, buildpackLifecycle string) (resources.Buildpack, Warnings, error) { var ( buildpacks []resources.Buildpack warnings ccv3.Warnings err error ) - if buildpackStack == "" { - buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{buildpackName}, + queries := []ccv3.Query{{ + Key: ccv3.NameFilter, + Values: []string{buildpackName}, + }} + + if buildpackStack != "" { + queries = append(queries, ccv3.Query{ + Key: ccv3.StackFilter, + Values: []string{buildpackStack}, }) - } else { - buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks( - ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{buildpackName}, - }, - ccv3.Query{ - Key: ccv3.StackFilter, - Values: []string{buildpackStack}, - }, - ) } + if buildpackLifecycle != "" { + queries = append(queries, ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }) + } + + buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(queries...) + if err != nil { return resources.Buildpack{}, Warnings(warnings), err } if len(buildpacks) == 0 { - return resources.Buildpack{}, Warnings(warnings), actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack} + return resources.Buildpack{}, Warnings(warnings), actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack, Lifecycle: buildpackLifecycle} } if len(buildpacks) > 1 { @@ -87,9 +95,9 @@ func (actor Actor) CreateBuildpack(buildpack resources.Buildpack) (resources.Bui return buildpack, Warnings(warnings), err } -func (actor Actor) UpdateBuildpackByNameAndStack(buildpackName string, buildpackStack string, buildpack resources.Buildpack) (resources.Buildpack, Warnings, error) { +func (actor Actor) UpdateBuildpackByNameAndStackAndLifecycle(buildpackName string, buildpackStack string, buildpackLifecycle string, buildpack resources.Buildpack) (resources.Buildpack, Warnings, error) { var warnings Warnings - foundBuildpack, getWarnings, err := actor.GetBuildpackByNameAndStack(buildpackName, buildpackStack) + foundBuildpack, getWarnings, err := actor.GetBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle) warnings = append(warnings, getWarnings...) if err != nil { @@ -250,9 +258,9 @@ func Zipit(source, target, prefix string) error { return err } -func (actor Actor) DeleteBuildpackByNameAndStack(buildpackName string, buildpackStack string) (Warnings, error) { +func (actor Actor) DeleteBuildpackByNameAndStackAndLifecycle(buildpackName string, buildpackStack string, buildpackLifecycle string) (Warnings, error) { var allWarnings Warnings - buildpack, getBuildpackWarnings, err := actor.GetBuildpackByNameAndStack(buildpackName, buildpackStack) + buildpack, getBuildpackWarnings, err := actor.GetBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle) allWarnings = append(allWarnings, getBuildpackWarnings...) if err != nil { return allWarnings, err diff --git a/actor/v7action/buildpack_test.go b/actor/v7action/buildpack_test.go index 22052d53b32..59e184f5d32 100644 --- a/actor/v7action/buildpack_test.go +++ b/actor/v7action/buildpack_test.go @@ -3,19 +3,18 @@ package v7action_test import ( "errors" "io" - "io/ioutil" "os" "path/filepath" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -29,23 +28,24 @@ var _ = Describe("Buildpack", func() { actor, fakeCloudControllerClient, _, _, _, _, _ = NewTestActor() }) - Describe("GetBuildpackByNameAndStack", func() { + Describe("GetBuildpackByNameAndStackAndLifecycle", func() { var ( - buildpackName = "buildpack-1" - buildpackStack = "stack-name" - buildpack resources.Buildpack - warnings Warnings - executeErr error + buildpackName = "buildpack-1" + buildpackStack = "stack-name" + buildpackLifecycle = "buildpack" + buildpack resources.Buildpack + warnings Warnings + executeErr error ) JustBeforeEach(func() { - buildpack, warnings, executeErr = actor.GetBuildpackByNameAndStack(buildpackName, buildpackStack) + buildpack, warnings, executeErr = actor.GetBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle) }) When("getting buildpacks fails", func() { BeforeEach(func() { - buildpackStack = "real-good-stack" + buildpackLifecycle = "some-lifecycle" fakeCloudControllerClient.GetBuildpacksReturns( nil, ccv3.Warnings{"some-warning-1", "some-warning-2"}, @@ -66,6 +66,10 @@ var _ = Describe("Buildpack", func() { Key: ccv3.StackFilter, Values: []string{buildpackStack}, }, + ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }, )) }) }) @@ -120,16 +124,17 @@ var _ = Describe("Buildpack", func() { nil) }) - It("returns warnings and a BuilpackNotFoundError", func() { - Expect(executeErr).To(MatchError(actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack})) + It("returns warnings and a BuildpackNotFoundError", func() { + Expect(executeErr).To(MatchError(actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack, Lifecycle: buildpackLifecycle})) Expect(warnings).To(ConsistOf("some-warning-1", "some-warning-2")) }) }) When("getting buildpacks is successful", func() { - When("No stack is specified", func() { + When("No stack or lifecycle is specified", func() { BeforeEach(func() { buildpackStack = "" + buildpackLifecycle = "" buildpackName = "my-buildpack" ccBuildpack := resources.Buildpack{Name: "my-buildpack", GUID: "some-guid"} @@ -145,7 +150,7 @@ var _ = Describe("Buildpack", func() { Expect(buildpack).To(Equal(resources.Buildpack{Name: "my-buildpack", GUID: "some-guid"})) }) - It("Does not pass a stack query to the client", func() { + It("Does not pass a stack or lifecycle query to the client", func() { Expect(fakeCloudControllerClient.GetBuildpacksCallCount()).To(Equal(1)) queries := fakeCloudControllerClient.GetBuildpacksArgsForCall(0) Expect(queries).To(ConsistOf( @@ -157,10 +162,11 @@ var _ = Describe("Buildpack", func() { }) }) - When("A stack is specified", func() { + When("only a stack is specified", func() { BeforeEach(func() { buildpackStack = "good-stack" buildpackName = "my-buildpack" + buildpackLifecycle = "" ccBuildpack := resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Stack: "good-stack"} fakeCloudControllerClient.GetBuildpacksReturns( @@ -175,7 +181,7 @@ var _ = Describe("Buildpack", func() { Expect(buildpack).To(Equal(resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Stack: "good-stack"})) }) - It("Does pass a stack query to the client", func() { + It("Only passes a stack query to the client", func() { Expect(fakeCloudControllerClient.GetBuildpacksCallCount()).To(Equal(1)) queries := fakeCloudControllerClient.GetBuildpacksArgsForCall(0) Expect(queries).To(ConsistOf( @@ -190,6 +196,78 @@ var _ = Describe("Buildpack", func() { )) }) }) + When("only a lifecycle is specified", func() { + BeforeEach(func() { + buildpackLifecycle = "good-lifecycle" + buildpackStack = "" + buildpackName = "my-buildpack" + + ccBuildpack := resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Lifecycle: "good-lifecycle"} + fakeCloudControllerClient.GetBuildpacksReturns( + []resources.Buildpack{ccBuildpack}, + ccv3.Warnings{"some-warning-1", "some-warning-2"}, + nil) + }) + + It("Returns the proper buildpack", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(warnings).To(ConsistOf("some-warning-1", "some-warning-2")) + Expect(buildpack).To(Equal(resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Lifecycle: "good-lifecycle"})) + }) + + It("Only passes a lifecycle query to the client", func() { + Expect(fakeCloudControllerClient.GetBuildpacksCallCount()).To(Equal(1)) + queries := fakeCloudControllerClient.GetBuildpacksArgsForCall(0) + Expect(queries).To(ConsistOf( + ccv3.Query{ + Key: ccv3.NameFilter, + Values: []string{buildpackName}, + }, + ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }, + )) + }) + }) + When("When stack and lifecycle are specified", func() { + BeforeEach(func() { + buildpackLifecycle = "good-lifecycle" + buildpackStack = "good-stack" + buildpackName = "my-buildpack" + + ccBuildpack := resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Lifecycle: "good-lifecycle", Stack: "good-stack"} + fakeCloudControllerClient.GetBuildpacksReturns( + []resources.Buildpack{ccBuildpack}, + ccv3.Warnings{"some-warning-1", "some-warning-2"}, + nil) + }) + + It("Returns the proper buildpack", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(warnings).To(ConsistOf("some-warning-1", "some-warning-2")) + Expect(buildpack).To(Equal(resources.Buildpack{Name: "my-buildpack", GUID: "some-guid", Lifecycle: "good-lifecycle", Stack: "good-stack"})) + }) + + It("Only passes a lifecycle query to the client", func() { + Expect(fakeCloudControllerClient.GetBuildpacksCallCount()).To(Equal(1)) + queries := fakeCloudControllerClient.GetBuildpacksArgsForCall(0) + Expect(queries).To(ConsistOf( + ccv3.Query{ + Key: ccv3.NameFilter, + Values: []string{buildpackName}, + }, + ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }, + ccv3.Query{ + Key: ccv3.StackFilter, + Values: []string{buildpackStack}, + }, + )) + }) + }) }) }) @@ -199,10 +277,11 @@ var _ = Describe("Buildpack", func() { warnings Warnings executeErr error labelSelector string + lifecycle string ) JustBeforeEach(func() { - buildpacks, warnings, executeErr = actor.GetBuildpacks(labelSelector) + buildpacks, warnings, executeErr = actor.GetBuildpacks(labelSelector, lifecycle) }) It("calls CloudControllerClient.GetBuildpacks()", func() { @@ -212,10 +291,10 @@ var _ = Describe("Buildpack", func() { When("a label selector is not provided", func() { BeforeEach(func() { labelSelector = "" + lifecycle = "" }) - It("only passes through a OrderBy query to the CloudControllerClient", func() { - positionQuery := ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.PositionOrder}} - Expect(fakeCloudControllerClient.GetBuildpacksArgsForCall(0)).To(ConsistOf(positionQuery)) + It("does not pass a query to the CloudControllerClient", func() { + Expect(fakeCloudControllerClient.GetBuildpacksArgsForCall(0)).To(BeEmpty()) }) }) @@ -266,6 +345,25 @@ var _ = Describe("Buildpack", func() { })) }) }) + + When("lifecycle flag is provided", func() { + BeforeEach(func() { + ccBuildpacks := []resources.Buildpack{ + {Name: "cnb-1", Position: types.NullInt{Value: 1, IsSet: true}, Lifecycle: "cnb"}, + {Name: "cnb-2", Position: types.NullInt{Value: 2, IsSet: true}, Lifecycle: "cnb"}, + } + fakeCloudControllerClient.GetBuildpacksReturns( + ccBuildpacks, + ccv3.Warnings{}, + nil) + lifecycle = "cnb" + }) + + It("passes the lifecycle as a query", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeCloudControllerClient.GetBuildpacksArgsForCall(0)).To(ContainElement(ccv3.Query{Key: ccv3.LifecycleFilter, Values: []string{"cnb"}})) + }) + }) }) Describe("CreateBuildpack", func() { @@ -319,9 +417,10 @@ var _ = Describe("Buildpack", func() { Describe("UpdateBuildpackByNameAndStack", func() { var ( - buildpackName = "my-buidpack" - buildpackStack = "my-stack" - buildpack = resources.Buildpack{ + buildpackName = "my-buildpack" + buildpackStack = "my-stack" + buildpackLifecycle = "cnb" + buildpack = resources.Buildpack{ Stack: "new-stack", } @@ -331,7 +430,7 @@ var _ = Describe("Buildpack", func() { ) JustBeforeEach(func() { - retBuildpack, warnings, executeErr = actor.UpdateBuildpackByNameAndStack(buildpackName, buildpackStack, buildpack) + retBuildpack, warnings, executeErr = actor.UpdateBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle, buildpack) }) When("it is successful", func() { @@ -358,6 +457,10 @@ var _ = Describe("Buildpack", func() { Key: ccv3.StackFilter, Values: []string{buildpackStack}, }, + ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }, )) paramBuildpack := fakeCloudControllerClient.UpdateBuildpackArgsForCall(0) @@ -512,7 +615,7 @@ var _ = Describe("Buildpack", func() { fakeDownloader = new(v7actionfakes.FakeDownloader) var err error - tmpDirPath, err = ioutil.TempDir("", "buildpackdir-") + tmpDirPath, err = os.MkdirTemp("", "buildpackdir-") Expect(err).ToNot(HaveOccurred()) }) @@ -550,13 +653,13 @@ var _ = Describe("Buildpack", func() { var tempFile *os.File BeforeEach(func() { var err error - inPath, err = ioutil.TempDir("", "buildpackdir-") + inPath, err = os.MkdirTemp("", "buildpackdir-") Expect(err).ToNot(HaveOccurred()) - tempFile, err = ioutil.TempFile(inPath, "foo") + tempFile, err = os.CreateTemp(inPath, "foo") Expect(err).ToNot(HaveOccurred()) - tmpDirPath, err = ioutil.TempDir("", "buildpackdir-") + tmpDirPath, err = os.MkdirTemp("", "buildpackdir-") Expect(err).ToNot(HaveOccurred()) }) @@ -577,10 +680,10 @@ var _ = Describe("Buildpack", func() { When("the buildpack path points to an empty directory", func() { BeforeEach(func() { var err error - inPath, err = ioutil.TempDir("", "some-empty-dir") + inPath, err = os.MkdirTemp("", "some-empty-dir") Expect(err).ToNot(HaveOccurred()) - tmpDirPath, err = ioutil.TempDir("", "buildpackdir-") + tmpDirPath, err = os.MkdirTemp("", "buildpackdir-") Expect(err).ToNot(HaveOccurred()) }) @@ -608,7 +711,7 @@ var _ = Describe("Buildpack", func() { }) Describe("Zipit", func() { - //tested in buildpack_linux_test.go and buildpack_windows_test.go + // tested in buildpack_linux_test.go and buildpack_windows_test.go var ( source string target string @@ -632,18 +735,19 @@ var _ = Describe("Buildpack", func() { }) }) - Describe("DeleteBuildpackByNameAndStack", func() { + Describe("DeleteBuildpackByNameAndStackAndLifecycle", func() { var ( - buildpackName = "buildpack-name" - buildpackStack = "buildpack-stack" - buildpackGUID = "buildpack-guid" - jobURL = "buildpack-delete-job-url" - warnings Warnings - executeErr error + buildpackName = "buildpack-name" + buildpackStack = "buildpack-stack" + buildpackLifecycle = "buildpack-stack" + buildpackGUID = "buildpack-guid" + jobURL = "buildpack-delete-job-url" + warnings Warnings + executeErr error ) JustBeforeEach(func() { - warnings, executeErr = actor.DeleteBuildpackByNameAndStack(buildpackName, buildpackStack) + warnings, executeErr = actor.DeleteBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle) }) When("getting the buildpack fails", func() { @@ -667,6 +771,10 @@ var _ = Describe("Buildpack", func() { Key: ccv3.StackFilter, Values: []string{buildpackStack}, }, + ccv3.Query{ + Key: ccv3.LifecycleFilter, + Values: []string{buildpackLifecycle}, + }, )) }) }) diff --git a/actor/v7action/buildpack_unix_test.go b/actor/v7action/buildpack_unix_test.go index 6ec78dbac64..3bf553a0b22 100644 --- a/actor/v7action/buildpack_unix_test.go +++ b/actor/v7action/buildpack_unix_test.go @@ -1,18 +1,18 @@ +//go:build !windows // +build !windows package v7action_test import ( "fmt" - "io/ioutil" "os" "path/filepath" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/integration/helpers" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/integration/helpers" "code.cloudfoundry.org/ykk" ) @@ -35,14 +35,14 @@ var _ = Describe("Buildpack", func() { BeforeEach(func() { var err error - source, err = ioutil.TempDir("", "zipit-source-") + source, err = os.MkdirTemp("", "zipit-source-") Expect(err).ToNot(HaveOccurred()) - Expect(ioutil.WriteFile(filepath.Join(source, "file1"), []byte{}, 0700)).To(Succeed()) - Expect(ioutil.WriteFile(filepath.Join(source, "file2"), []byte{}, 0644)).To(Succeed()) - subDir, err = ioutil.TempDir(source, "zipit-subdir-") + Expect(os.WriteFile(filepath.Join(source, "file1"), []byte{}, 0700)).To(Succeed()) + Expect(os.WriteFile(filepath.Join(source, "file2"), []byte{}, 0644)).To(Succeed()) + subDir, err = os.MkdirTemp(source, "zipit-subdir-") Expect(err).ToNot(HaveOccurred()) - Expect(ioutil.WriteFile(filepath.Join(subDir, "file3"), []byte{}, 0755)).To(Succeed()) + Expect(os.WriteFile(filepath.Join(subDir, "file3"), []byte{}, 0755)).To(Succeed()) p := filepath.FromSlash(fmt.Sprintf("buildpack-%s.zip", helpers.RandomName())) target, err = filepath.Abs(p) diff --git a/actor/v7action/buildpack_windows_test.go b/actor/v7action/buildpack_windows_test.go index 8e1218dadb2..969e380f01c 100644 --- a/actor/v7action/buildpack_windows_test.go +++ b/actor/v7action/buildpack_windows_test.go @@ -1,18 +1,18 @@ +//go:build windows // +build windows package v7action_test import ( "fmt" - "io/ioutil" "os" "path/filepath" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/integration/helpers" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/integration/helpers" "code.cloudfoundry.org/ykk" ) @@ -35,14 +35,14 @@ var _ = Describe("Buildpack", func() { BeforeEach(func() { var err error - source, err = ioutil.TempDir("", "zipit-source-") + source, err = os.MkdirTemp("", "zipit-source-") Expect(err).ToNot(HaveOccurred()) - ioutil.WriteFile(filepath.Join(source, "file1"), []byte{}, 0666) - ioutil.WriteFile(filepath.Join(source, "file2"), []byte{}, 0666) - subDir, err = ioutil.TempDir(source, "zipit-subdir-") + os.WriteFile(filepath.Join(source, "file1"), []byte{}, 0666) + os.WriteFile(filepath.Join(source, "file2"), []byte{}, 0666) + subDir, err = os.MkdirTemp(source, "zipit-subdir-") Expect(err).ToNot(HaveOccurred()) - ioutil.WriteFile(filepath.Join(subDir, "file3"), []byte{}, 0666) + os.WriteFile(filepath.Join(subDir, "file3"), []byte{}, 0666) p := filepath.FromSlash(fmt.Sprintf("buildpack-%s.zip", helpers.RandomName())) target, err = filepath.Abs(p) diff --git a/actor/v7action/cloud_controller_client.go b/actor/v7action/cloud_controller_client.go index e7f87fab036..0acf7b7168a 100644 --- a/actor/v7action/cloud_controller_client.go +++ b/actor/v7action/cloud_controller_client.go @@ -4,10 +4,10 @@ import ( "io" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . CloudControllerClient @@ -18,10 +18,10 @@ type CloudControllerClient interface { ApplySpaceQuota(quotaGUID string, spaceGUID string) (resources.RelationshipList, ccv3.Warnings, error) CheckRoute(domainGUID string, hostname string, path string, port int) (bool, ccv3.Warnings, error) CancelDeployment(deploymentGUID string) (ccv3.Warnings, error) + ContinueDeployment(deploymentGUID string) (ccv3.Warnings, error) CopyPackage(sourcePackageGUID string, targetAppGUID string) (resources.Package, ccv3.Warnings, error) CreateApplication(app resources.Application) (resources.Application, ccv3.Warnings, error) - CreateApplicationDeployment(appGUID string, dropletGUID string) (string, ccv3.Warnings, error) - CreateApplicationDeploymentByRevision(appGUID string, revisionGUID string) (string, ccv3.Warnings, error) + CreateApplicationDeployment(dep resources.Deployment) (string, ccv3.Warnings, error) CreateApplicationProcessScale(appGUID string, process resources.Process) (resources.Process, ccv3.Warnings, error) CreateApplicationTask(appGUID string, task resources.Task) (resources.Task, ccv3.Warnings, error) CreateBuild(build resources.Build) (resources.Build, ccv3.Warnings, error) @@ -84,9 +84,11 @@ type CloudControllerClient interface { GetDroplet(guid string) (resources.Droplet, ccv3.Warnings, error) GetDroplets(query ...ccv3.Query) ([]resources.Droplet, ccv3.Warnings, error) GetEnvironmentVariableGroup(group constant.EnvironmentVariableGroupName) (resources.EnvironmentVariables, ccv3.Warnings, error) + GetEnvironmentVariablesByURL(url string) (resources.EnvironmentVariables, ccv3.Warnings, error) GetEvents(query ...ccv3.Query) ([]ccv3.Event, ccv3.Warnings, error) GetFeatureFlag(featureFlagName string) (resources.FeatureFlag, ccv3.Warnings, error) GetFeatureFlags() ([]resources.FeatureFlag, ccv3.Warnings, error) + GetRoot() (ccv3.Root, ccv3.Warnings, error) GetInfo() (ccv3.Info, ccv3.Warnings, error) GetIsolationSegment(guid string) (resources.IsolationSegment, ccv3.Warnings, error) GetIsolationSegmentOrganizations(isolationSegmentGUID string) ([]resources.Organization, ccv3.Warnings, error) @@ -136,32 +138,38 @@ type CloudControllerClient interface { GetAppFeature(appGUID string, featureName string) (resources.ApplicationFeature, ccv3.Warnings, error) GetStacks(query ...ccv3.Query) ([]resources.Stack, ccv3.Warnings, error) GetStagingSecurityGroups(spaceGUID string, queries ...ccv3.Query) ([]resources.SecurityGroup, ccv3.Warnings, error) + GetTask(guid string) (resources.Task, ccv3.Warnings, error) GetUser(userGUID string) (resources.User, ccv3.Warnings, error) GetUsers(query ...ccv3.Query) ([]resources.User, ccv3.Warnings, error) MakeRequestSendReceiveRaw(Method string, URL string, headers http.Header, requestBody []byte) ([]byte, *http.Response, error) MapRoute(routeGUID string, appGUID string, destinationProtocol string) (ccv3.Warnings, error) + MoveRoute(routeGUID string, spaceGUID string) (ccv3.Warnings, error) PollJob(jobURL ccv3.JobURL) (ccv3.Warnings, error) PollJobForState(jobURL ccv3.JobURL, state constant.JobState) (ccv3.Warnings, error) PollJobToEventStream(jobURL ccv3.JobURL) chan ccv3.PollJobEvent PurgeServiceOffering(serviceOfferingGUID string) (ccv3.Warnings, error) ResourceMatch(resources []ccv3.Resource) ([]ccv3.Resource, ccv3.Warnings, error) - RootResponse() (ccv3.Info, ccv3.Warnings, error) + RootResponse() (ccv3.Root, ccv3.Warnings, error) SetApplicationDroplet(appGUID string, dropletGUID string) (resources.Relationship, ccv3.Warnings, error) SharePrivateDomainToOrgs(domainGuid string, sharedOrgs ccv3.SharedOrgs) (ccv3.Warnings, error) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (resources.RelationshipList, ccv3.Warnings, error) + ShareRoute(routeGUID string, spaceGUID string) (ccv3.Warnings, error) TargetCF(settings ccv3.TargetSettings) UnbindSecurityGroupRunningSpace(securityGroupGUID string, spaceGUID string) (ccv3.Warnings, error) UnbindSecurityGroupStagingSpace(securityGroupGUID string, spaceGUID string) (ccv3.Warnings, error) UnmapRoute(routeGUID string, destinationGUID string) (ccv3.Warnings, error) + UnshareRoute(routeGUID string, spaceGUID string) (ccv3.Warnings, error) UnsharePrivateDomainFromOrg(domainGUID string, sharedOrgGUID string) (ccv3.Warnings, error) UnshareServiceInstanceFromSpace(serviceInstanceGUID string, sharedToSpaceGUID string) (ccv3.Warnings, error) UpdateAppFeature(appGUID string, enabled bool, featureName string) (ccv3.Warnings, error) UpdateApplication(app resources.Application) (resources.Application, ccv3.Warnings, error) + UpdateApplicationName(newAppName string, appGUID string) (resources.Application, ccv3.Warnings, error) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (ccv3.JobURL, ccv3.Warnings, error) UpdateApplicationEnvironmentVariables(appGUID string, envVars resources.EnvironmentVariables) (resources.EnvironmentVariables, ccv3.Warnings, error) UpdateApplicationRestart(appGUID string) (resources.Application, ccv3.Warnings, error) UpdateApplicationStart(appGUID string) (resources.Application, ccv3.Warnings, error) UpdateApplicationStop(appGUID string) (resources.Application, ccv3.Warnings, error) + UpdateDestination(routeGUID string, destinationGUID string, protocol string) (ccv3.Warnings, error) UpdateBuildpack(buildpack resources.Buildpack) (resources.Buildpack, ccv3.Warnings, error) UpdateEnvironmentVariableGroup(group constant.EnvironmentVariableGroupName, envVars resources.EnvironmentVariables) (resources.EnvironmentVariables, ccv3.Warnings, error) UpdateFeatureFlag(flag resources.FeatureFlag) (resources.FeatureFlag, ccv3.Warnings, error) @@ -170,6 +178,7 @@ type CloudControllerClient interface { UpdateOrganizationQuota(orgQuota resources.OrganizationQuota) (resources.OrganizationQuota, ccv3.Warnings, error) UpdateProcess(process resources.Process) (resources.Process, ccv3.Warnings, error) UpdateResourceMetadata(resource string, resourceGUID string, metadata resources.Metadata) (ccv3.JobURL, ccv3.Warnings, error) + UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, ccv3.Warnings, error) UpdateSecurityGroupRunningSpace(securityGroupGUID string, spaceGUIDs []string) (ccv3.Warnings, error) UpdateSecurityGroupStagingSpace(securityGroupGUID string, spaceGUIDs []string) (ccv3.Warnings, error) UpdateSecurityGroup(securityGroup resources.SecurityGroup) (resources.SecurityGroup, ccv3.Warnings, error) diff --git a/actor/v7action/config.go b/actor/v7action/config.go index 8c4eb01020a..5b52080167d 100644 --- a/actor/v7action/config.go +++ b/actor/v7action/config.go @@ -3,7 +3,7 @@ package v7action import ( "time" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Config diff --git a/actor/v7action/curl.go b/actor/v7action/curl.go index 7e82c966fe0..cd388025105 100644 --- a/actor/v7action/curl.go +++ b/actor/v7action/curl.go @@ -3,12 +3,12 @@ package v7action import ( "bufio" "fmt" - "io/ioutil" "net/http" "net/textproto" + "os" "strings" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) func (actor Actor) MakeCurlRequest( @@ -34,7 +34,7 @@ func (actor Actor) MakeCurlRequest( trimmedData := strings.Trim(string(data), `"'`) if strings.HasPrefix(trimmedData, "@") { trimmedData = strings.Trim(trimmedData[1:], `"'`) - requestBodyBytes, err = ioutil.ReadFile(trimmedData) + requestBodyBytes, err = os.ReadFile(trimmedData) if err != nil { return nil, nil, translatableerror.RequestCreationError{Err: err} } diff --git a/actor/v7action/curl_test.go b/actor/v7action/curl_test.go index 19849c1370f..4f6120b425c 100644 --- a/actor/v7action/curl_test.go +++ b/actor/v7action/curl_test.go @@ -2,14 +2,13 @@ package v7action_test import ( "errors" - "io/ioutil" "net/http" "os" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -123,7 +122,7 @@ var _ = Describe("Curl Actions", func() { var tempFile string BeforeEach(func() { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) tempFile = file.Name() @@ -156,7 +155,7 @@ var _ = Describe("Curl Actions", func() { var tempFile string BeforeEach(func() { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) tempFile = file.Name() diff --git a/actor/v7action/deployment.go b/actor/v7action/deployment.go index c532df85398..5aedbe15867 100644 --- a/actor/v7action/deployment.go +++ b/actor/v7action/deployment.go @@ -1,21 +1,14 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) -func (actor Actor) CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, Warnings, error) { - deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeployment(appGUID, dropletGUID) - - return deploymentGUID, Warnings(warnings), err -} - -func (actor Actor) CreateDeploymentByApplicationAndRevision(appGUID string, revisionGUID string) (string, Warnings, error) { - deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeploymentByRevision(appGUID, revisionGUID) - +func (actor Actor) CreateDeployment(dep resources.Deployment) (string, Warnings, error) { + deploymentGUID, warnings, err := actor.CloudControllerClient.CreateApplicationDeployment(dep) return deploymentGUID, Warnings(warnings), err } @@ -25,6 +18,7 @@ func (actor Actor) GetLatestActiveDeploymentForApp(appGUID string) (resources.De ccv3.Query{Key: ccv3.StatusValueFilter, Values: []string{string(constant.DeploymentStatusValueActive)}}, ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { @@ -35,10 +29,15 @@ func (actor Actor) GetLatestActiveDeploymentForApp(appGUID string) (resources.De return resources.Deployment{}, Warnings(warnings), actionerror.ActiveDeploymentNotFoundError{} } - return resources.Deployment(ccDeployments[0]), Warnings(warnings), nil + return ccDeployments[0], Warnings(warnings), nil } func (actor Actor) CancelDeployment(deploymentGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.CancelDeployment(deploymentGUID) return Warnings(warnings), err } + +func (actor Actor) ContinueDeployment(deploymentGUID string) (Warnings, error) { + warnings, err := actor.CloudControllerClient.ContinueDeployment(deploymentGUID) + return Warnings(warnings), err +} diff --git a/actor/v7action/deployment_test.go b/actor/v7action/deployment_test.go index 0cb8744cc52..ce4e833c127 100644 --- a/actor/v7action/deployment_test.go +++ b/actor/v7action/deployment_test.go @@ -3,14 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -18,28 +17,32 @@ var _ = Describe("Deployment Actions", func() { var ( actor *Actor executeErr error - warnings v7action.Warnings + warnings Warnings returnedDeploymentGUID string fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient ) BeforeEach(func() { actor, fakeCloudControllerClient, _, _, _, _, _ = NewTestActor() - fakeCloudControllerClient.CreateApplicationDeploymentByRevisionReturns( + fakeCloudControllerClient.CreateApplicationDeploymentReturns( "some-deployment-guid", ccv3.Warnings{"create-warning-1", "create-warning-2"}, errors.New("create-error"), ) }) - Describe("CreateDeploymentByApplicationAndRevision", func() { + Describe("Create a deployment with app and revision guids", func() { JustBeforeEach(func() { - returnedDeploymentGUID, warnings, executeErr = actor.CreateDeploymentByApplicationAndRevision("some-app-guid", "some-revision-guid") + var dep resources.Deployment + dep.Strategy = constant.DeploymentStrategyRolling + dep.RevisionGUID = "some-revision-guid" + dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}} + returnedDeploymentGUID, warnings, executeErr = actor.CreateDeployment(dep) }) When("the client fails", func() { BeforeEach(func() { - fakeCloudControllerClient.CreateApplicationDeploymentByRevisionReturns( + fakeCloudControllerClient.CreateApplicationDeploymentReturns( "some-deployment-guid", ccv3.Warnings{"create-warning-1", "create-warning-2"}, errors.New("create-deployment-error"), @@ -54,28 +57,32 @@ var _ = Describe("Deployment Actions", func() { It("delegates to the cloud controller client", func() { - Expect(fakeCloudControllerClient.CreateApplicationDeploymentByRevisionCallCount()).To(Equal(1), "CreateApplicationDeploymentByRevision call count") - givenAppGUID, givenRevisionGUID := fakeCloudControllerClient.CreateApplicationDeploymentByRevisionArgsForCall(0) + Expect(fakeCloudControllerClient.CreateApplicationDeploymentCallCount()).To(Equal(1), "CreateApplicationDeploymentByRevision call count") + dep := fakeCloudControllerClient.CreateApplicationDeploymentArgsForCall(0) - Expect(givenAppGUID).To(Equal("some-app-guid")) - Expect(givenRevisionGUID).To(Equal("some-revision-guid")) + Expect(dep.Relationships[constant.RelationshipTypeApplication].GUID).To(Equal("some-app-guid")) + Expect(dep.RevisionGUID).To(Equal("some-revision-guid")) Expect(returnedDeploymentGUID).To(Equal("some-deployment-guid")) Expect(warnings).To(Equal(Warnings{"create-warning-1", "create-warning-2"})) }) }) - Describe("CreateDeploymentByApplicationAndDroplet", func() { + Describe("Create a deployment with app and droplet guids", func() { It("delegates to the cloud controller client", func() { fakeCloudControllerClient.CreateApplicationDeploymentReturns("some-deployment-guid", ccv3.Warnings{"create-warning-1", "create-warning-2"}, errors.New("create-error")) - returnedDeploymentGUID, warnings, executeErr := actor.CreateDeploymentByApplicationAndDroplet("some-app-guid", "some-droplet-guid") + var dep resources.Deployment + dep.Strategy = constant.DeploymentStrategyCanary + dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}} + dep.DropletGUID = "some-droplet-guid" + returnedDeploymentGUID, warnings, executeErr := actor.CreateDeployment(dep) Expect(fakeCloudControllerClient.CreateApplicationDeploymentCallCount()).To(Equal(1)) - givenAppGUID, givenDropletGUID := fakeCloudControllerClient.CreateApplicationDeploymentArgsForCall(0) + dep1 := fakeCloudControllerClient.CreateApplicationDeploymentArgsForCall(0) - Expect(givenAppGUID).To(Equal("some-app-guid")) - Expect(givenDropletGUID).To(Equal("some-droplet-guid")) + Expect(dep1.Relationships[constant.RelationshipTypeApplication].GUID).To(Equal("some-app-guid")) + Expect(dep1.DropletGUID).To(Equal("some-droplet-guid")) Expect(returnedDeploymentGUID).To(Equal("some-deployment-guid")) Expect(warnings).To(Equal(Warnings{"create-warning-1", "create-warning-2"})) @@ -108,6 +115,7 @@ var _ = Describe("Deployment Actions", func() { {Key: ccv3.StatusValueFilter, Values: []string{string(constant.DeploymentStatusValueActive)}}, {Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) }) @@ -205,4 +213,49 @@ var _ = Describe("Deployment Actions", func() { }) }) }) + + Describe("ContinueDeployment", func() { + var ( + deploymentGUID string + + warnings Warnings + executeErr error + ) + + BeforeEach(func() { + deploymentGUID = "dep-guid" + }) + + JustBeforeEach(func() { + warnings, executeErr = actor.ContinueDeployment(deploymentGUID) + }) + + It("delegates to the cc client", func() { + Expect(fakeCloudControllerClient.ContinueDeploymentCallCount()).To(Equal(1)) + Expect(fakeCloudControllerClient.ContinueDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + }) + + When("the client fails", func() { + BeforeEach(func() { + fakeCloudControllerClient.ContinueDeploymentReturns(ccv3.Warnings{"continue-deployment-warnings"}, errors.New("continue-deployment-error")) + }) + + It("returns the warnings and error", func() { + Expect(executeErr).To(MatchError("continue-deployment-error")) + Expect(warnings).To(ConsistOf("continue-deployment-warnings")) + }) + + }) + + When("the client succeeds", func() { + BeforeEach(func() { + fakeCloudControllerClient.ContinueDeploymentReturns(ccv3.Warnings{"continue-deployment-warnings"}, nil) + }) + + It("returns the warnings and error", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(warnings).To(ConsistOf("continue-deployment-warnings")) + }) + }) + }) }) diff --git a/actor/v7action/domain.go b/actor/v7action/domain.go index d9ed8c9ac59..28a36c53c87 100644 --- a/actor/v7action/domain.go +++ b/actor/v7action/domain.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type SharedOrgs ccv3.SharedOrgs @@ -172,6 +172,8 @@ func (actor Actor) GetDomainAndOrgGUIDsByName(domainName string, orgName string) func (actor Actor) getDomainByName(domainName string) (resources.Domain, ccv3.Warnings, error) { domains, warnings, err := actor.CloudControllerClient.GetDomains( ccv3.Query{Key: ccv3.NameFilter, Values: []string{domainName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) switch { case err != nil: diff --git a/actor/v7action/domain_test.go b/actor/v7action/domain_test.go index 645ac92fb25..66f6b5bba7d 100644 --- a/actor/v7action/domain_test.go +++ b/actor/v7action/domain_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -63,6 +63,8 @@ var _ = Describe("Domain Actions", func() { givenQuery := fakeCloudControllerClient.GetDomainsArgsForCall(0) Expect(givenQuery).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{domainName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.CheckRouteCallCount()).To(Equal(1)) @@ -438,7 +440,11 @@ var _ = Describe("Domain Actions", func() { }) When("the API layer call is successful", func() { - expectedQuery := []ccv3.Query{{Key: ccv3.NameFilter, Values: []string{domain1Name}}} + expectedQuery := []ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{domain1Name}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + } BeforeEach(func() { fakeCloudControllerClient.GetDomainsReturns( ccv3Domains, @@ -512,7 +518,11 @@ var _ = Describe("Domain Actions", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) actualQuery := fakeCloudControllerClient.GetDomainsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{"private-domain.com"}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{"private-domain.com"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.SharePrivateDomainToOrgsCallCount()).To(Equal(1)) domainGuid, sharedOrgs := fakeCloudControllerClient.SharePrivateDomainToOrgsArgsForCall(0) @@ -572,7 +582,7 @@ var _ = Describe("Domain Actions", func() { BeforeEach(func() { fakeCloudControllerClient.UnsharePrivateDomainFromOrgReturns( ccv3.Warnings{"unshare-domain-warning"}, - errors.New("unsahre-domain-error"), + errors.New("unshare-domain-error"), ) }) @@ -582,7 +592,7 @@ var _ = Describe("Domain Actions", func() { Expect(actualDomainGUID).To(Equal("private-domain-guid")) Expect(actualOrgGUID).To(Equal("org-guid")) - Expect(executeErr).To(MatchError(errors.New("unsahre-domain-error"))) + Expect(executeErr).To(MatchError(errors.New("unshare-domain-error"))) Expect(warnings).To(ConsistOf("get-orgs-warning", "get-domains-warning", "unshare-domain-warning")) }) }) @@ -634,7 +644,11 @@ var _ = Describe("Domain Actions", func() { It("returns the error and doesnt get the domain", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) actualQuery := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{orgName}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{orgName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(0)) @@ -665,11 +679,19 @@ var _ = Describe("Domain Actions", func() { It("returns the error and doesnt get the domain", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) actualQuery := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{orgName}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{orgName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) actualQuery = fakeCloudControllerClient.GetDomainsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{domainName}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{domainName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(executeErr).To(MatchError(errors.New("get-domains-error"))) Expect(warnings).To(ConsistOf("get-orgs-warning", "get-domains-warning")) @@ -690,11 +712,19 @@ var _ = Describe("Domain Actions", func() { It("returns the GUIDs", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) actualQuery := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{orgName}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{orgName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) actualQuery = fakeCloudControllerClient.GetDomainsArgsForCall(0) - Expect(actualQuery).To(Equal([]ccv3.Query{{Key: ccv3.NameFilter, Values: []string{domainName}}})) + Expect(actualQuery).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{domainName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("get-orgs-warning", "get-domains-warning")) diff --git a/actor/v7action/droplet.go b/actor/v7action/droplet.go index e9ec7935c44..313562501e9 100644 --- a/actor/v7action/droplet.go +++ b/actor/v7action/droplet.go @@ -3,10 +3,10 @@ package v7action import ( "io" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateApplicationDroplet creates a new droplet without a package for the app with @@ -156,6 +156,8 @@ func (actor Actor) DownloadDropletByGUIDAndAppName(dropletGUID string, appName s droplets, getDropletWarnings, err := actor.CloudControllerClient.GetDroplets( ccv3.Query{Key: ccv3.GUIDFilter, Values: []string{dropletGUID}}, ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) allWarnings = append(allWarnings, getDropletWarnings...) if err != nil { diff --git a/actor/v7action/droplet_test.go b/actor/v7action/droplet_test.go index f477c283623..641cbbfb165 100644 --- a/actor/v7action/droplet_test.go +++ b/actor/v7action/droplet_test.go @@ -5,15 +5,15 @@ import ( "io" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -783,6 +783,8 @@ var _ = Describe("Droplet Actions", func() { Expect(fakeCloudControllerClient.GetDropletsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.GUIDFilter, Values: []string{"some-droplet-guid"}}, ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{"some-app-guid"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.DownloadDropletCallCount()).To(Equal(1)) diff --git a/actor/v7action/environment_variable.go b/actor/v7action/environment_variable.go index a5588b5a5d5..1f9dae8b967 100644 --- a/actor/v7action/environment_variable.go +++ b/actor/v7action/environment_variable.go @@ -1,11 +1,11 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) // EnvironmentVariableGroups represents all environment variables for application diff --git a/actor/v7action/environment_variable_test.go b/actor/v7action/environment_variable_test.go index 81b2aaa738a..66e4d55ddf8 100644 --- a/actor/v7action/environment_variable_test.go +++ b/actor/v7action/environment_variable_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/event.go b/actor/v7action/event.go index 36b1726f694..33676b9f077 100644 --- a/actor/v7action/event.go +++ b/actor/v7action/event.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/util/generic" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/util/generic" ) type Event struct { @@ -30,6 +30,7 @@ func (actor Actor) GetRecentEventsByApplicationNameAndSpace(appName string, spac ccEvents, warnings, err := actor.CloudControllerClient.GetEvents( ccv3.Query{Key: ccv3.TargetGUIDFilter, Values: []string{app.GUID}}, ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) allWarnings = append(allWarnings, warnings...) diff --git a/actor/v7action/event_test.go b/actor/v7action/event_test.go index b8eb6f30c9e..2ed5405e82c 100644 --- a/actor/v7action/event_test.go +++ b/actor/v7action/event_test.go @@ -3,11 +3,11 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/feature_flag.go b/actor/v7action/feature_flag.go index 00b97402fb1..983f85165cb 100644 --- a/actor/v7action/feature_flag.go +++ b/actor/v7action/feature_flag.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" ) // GetFeatureFlagByName returns a featureFlag with the provided name. diff --git a/actor/v7action/feature_flag_test.go b/actor/v7action/feature_flag_test.go index 0c245ae55d5..ee2dbd3623e 100644 --- a/actor/v7action/feature_flag_test.go +++ b/actor/v7action/feature_flag_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/fix_mode_unix.go b/actor/v7action/fix_mode_unix.go index 69330b77eb9..5a3e9de0821 100644 --- a/actor/v7action/fix_mode_unix.go +++ b/actor/v7action/fix_mode_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package v7action diff --git a/actor/v7action/fix_mode_windows.go b/actor/v7action/fix_mode_windows.go index e6cd6c1256d..2ad56dedc16 100644 --- a/actor/v7action/fix_mode_windows.go +++ b/actor/v7action/fix_mode_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package v7action diff --git a/actor/v7action/info.go b/actor/v7action/info.go index 723c1b58520..37231dbe713 100644 --- a/actor/v7action/info.go +++ b/actor/v7action/info.go @@ -1,10 +1,19 @@ package v7action -import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" +type Root ccv3.Root type Info ccv3.Info -func (actor Actor) GetRootResponse() (Info, Warnings, error) { +func (actor Actor) GetRootResponse() (Root, Warnings, error) { + root, warnings, err := actor.CloudControllerClient.GetRoot() + if err != nil { + return Root{}, Warnings(warnings), err + } + return Root(root), Warnings(warnings), nil +} + +func (actor Actor) GetInfoResponse() (Info, Warnings, error) { info, warnings, err := actor.CloudControllerClient.GetInfo() if err != nil { return Info{}, Warnings(warnings), err diff --git a/actor/v7action/info_test.go b/actor/v7action/info_test.go index a0e4e4f166e..c20262d0f3b 100644 --- a/actor/v7action/info_test.go +++ b/actor/v7action/info_test.go @@ -3,11 +3,11 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -23,11 +23,11 @@ var _ = Describe("Info Actions", func() { }) Describe("GetRootResponse", func() { - When("getting info is successful", func() { + When("getting root is successful", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns( - ccv3.Info{ - Links: ccv3.InfoLinks{ + fakeCloudControllerClient.GetRootReturns( + ccv3.Root{ + Links: ccv3.RootLinks{ LogCache: resources.APILink{HREF: "some-log-cache-url"}, }, }, @@ -42,11 +42,58 @@ var _ = Describe("Info Actions", func() { Expect(warnings).To(ConsistOf("warning-1", "warning-2")) - Expect(fakeCloudControllerClient.GetInfoCallCount()).To(Equal(1)) + Expect(fakeCloudControllerClient.GetRootCallCount()).To(Equal(1)) Expect(rootInfo.Links.LogCache.HREF).To(Equal("some-log-cache-url")) }) }) + When("the cloud controller client returns an error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("I am a CloudControllerClient Error") + fakeCloudControllerClient.GetRootReturns( + ccv3.Root{}, + ccv3.Warnings{"warning-1", "warning-2"}, + expectedErr, + ) + }) + + It("returns the same error and all warnings", func() { + _, warnings, err := actor.GetRootResponse() + Expect(err).To(MatchError(expectedErr)) + Expect(warnings).To(ConsistOf("warning-1", "warning-2")) + }) + }) + }) + + Describe("GetInfoResponse", func() { + When("getting info is successful", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetInfoReturns( + ccv3.Info{ + Name: "test-name", + Build: "test-build", + OSBAPIVersion: "1.0", + }, + ccv3.Warnings{"warning-1", "warning-2"}, + nil, + ) + }) + + It("returns all warnings and info", func() { + info, warnings, err := actor.GetInfoResponse() + Expect(err).ToNot(HaveOccurred()) + + Expect(warnings).To(ConsistOf("warning-1", "warning-2")) + + Expect(fakeCloudControllerClient.GetInfoCallCount()).To(Equal(1)) + Expect(info.Name).To(Equal("test-name")) + Expect(info.Build).To(Equal("test-build")) + Expect(info.OSBAPIVersion).To(Equal("1.0")) + }) + }) + When("the cloud controller client returns an error", func() { var expectedErr error @@ -60,7 +107,7 @@ var _ = Describe("Info Actions", func() { }) It("returns the same error and all warnings", func() { - _, warnings, err := actor.GetRootResponse() + _, warnings, err := actor.GetInfoResponse() Expect(err).To(MatchError(expectedErr)) Expect(warnings).To(ConsistOf("warning-1", "warning-2")) }) diff --git a/actor/v7action/isolation_segment.go b/actor/v7action/isolation_segment.go index 1ca9e7671a9..a0fa3ae946a 100644 --- a/actor/v7action/isolation_segment.go +++ b/actor/v7action/isolation_segment.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) type IsolationSegmentSummary struct { @@ -101,6 +101,8 @@ func (actor Actor) AssignIsolationSegmentToSpaceByNameAndSpace(isolationSegmentN func (actor Actor) GetIsolationSegmentByName(name string) (resources.IsolationSegment, Warnings, error) { isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { return resources.IsolationSegment{}, Warnings(warnings), err diff --git a/actor/v7action/isolation_segment_test.go b/actor/v7action/isolation_segment_test.go index 8b8a89e7ef8..f1569e8349d 100644 --- a/actor/v7action/isolation_segment_test.go +++ b/actor/v7action/isolation_segment_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -110,6 +110,8 @@ var _ = Describe("Isolation Segment Actions", func() { Expect(fakeCloudControllerClient.GetIsolationSegmentsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetIsolationSegmentsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"some-iso-seg"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.DeleteIsolationSegmentCallCount()).To(Equal(1)) @@ -266,6 +268,8 @@ var _ = Describe("Isolation Segment Actions", func() { Expect(fakeCloudControllerClient.GetIsolationSegmentsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetIsolationSegmentsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"some-iso-seg"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.UpdateSpaceIsolationSegmentRelationshipCallCount()).To(Equal(1)) @@ -438,6 +442,8 @@ var _ = Describe("Isolation Segment Actions", func() { Expect(fakeCloudControllerClient.GetIsolationSegmentsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetIsolationSegmentsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"some-iso-seg"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) }) @@ -711,7 +717,7 @@ var _ = Describe("Isolation Segment Actions", func() { }) }) - When("fetching the resourece fails", func() { + When("fetching the resource fails", func() { BeforeEach(func() { fakeCloudControllerClient.GetOrganizationDefaultIsolationSegmentReturns( resources.Relationship{}, diff --git a/actor/v7action/job.go b/actor/v7action/job.go index 03244778eb3..d9558f9e184 100644 --- a/actor/v7action/job.go +++ b/actor/v7action/job.go @@ -1,8 +1,8 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) type JobState constant.JobState diff --git a/actor/v7action/job_test.go b/actor/v7action/job_test.go index 01f8ae8079b..bfe10768e88 100644 --- a/actor/v7action/job_test.go +++ b/actor/v7action/job_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/k8s_auth.go b/actor/v7action/k8s_auth.go index bbbfadb9059..3c430bb6309 100644 --- a/actor/v7action/k8s_auth.go +++ b/actor/v7action/k8s_auth.go @@ -5,11 +5,11 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) @@ -52,11 +52,37 @@ func NewKubernetesAuthActor(config Config, k8sConfigGetter KubernetesConfigGette } func (actor kubernetesAuthActor) Authenticate(credentials map[string]string, origin string, grantType constant.GrantType) error { - actor.config.SetKubernetesAuthInfo(credentials["k8s-auth-info"]) - return nil + username := credentials["username"] + availableUsernames, err := actor.getAvailableUsernames() + if err != nil { + return err + } + + for _, u := range availableUsernames { + if u == username { + actor.config.SetKubernetesAuthInfo(username) + return nil + } + } + + return errors.New("kubernetes user not found in configuration: " + username) } func (actor kubernetesAuthActor) GetLoginPrompts() (map[string]coreconfig.AuthPrompt, error) { + availableUsernames, err := actor.getAvailableUsernames() + if err != nil { + return nil, err + } + sort.Strings(availableUsernames) + + return map[string]coreconfig.AuthPrompt{"username": { + Type: coreconfig.AuthPromptTypeMenu, + Entries: availableUsernames, + DisplayName: "Choose your Kubernetes authentication info", + }}, nil +} + +func (actor kubernetesAuthActor) getAvailableUsernames() ([]string, error) { conf, err := actor.k8sConfigGetter.Get() if err != nil { return nil, err @@ -66,17 +92,11 @@ func (actor kubernetesAuthActor) GetLoginPrompts() (map[string]coreconfig.AuthPr return nil, errors.New("no kubernetes authentication infos configured") } - var prompts []string + var usernames []string for authInfo := range conf.AuthInfos { - prompts = append(prompts, authInfo) + usernames = append(usernames, authInfo) } - sort.Strings(prompts) - - return map[string]coreconfig.AuthPrompt{"k8s-auth-info": { - Type: coreconfig.AuthPromptTypeMenu, - Entries: prompts, - DisplayName: "Choose your Kubernetes authentication info", - }}, nil + return usernames, nil } func (actor kubernetesAuthActor) GetCurrentUser() (configv3.User, error) { diff --git a/actor/v7action/k8s_auth_test.go b/actor/v7action/k8s_auth_test.go index 91ee1c6edaf..55b90594521 100644 --- a/actor/v7action/k8s_auth_test.go +++ b/actor/v7action/k8s_auth_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) @@ -34,8 +34,13 @@ var _ = Describe("KubernetesAuthActor", func() { }) Describe("Authenticate", func() { + var username string + BeforeEach(func() { + username = "bar" + }) + JustBeforeEach(func() { - err = k8sAuthActor.Authenticate(map[string]string{"k8s-auth-info": "bar"}, "", constant.GrantTypePassword) + err = k8sAuthActor.Authenticate(map[string]string{"username": username}, "", constant.GrantTypePassword) }) It("sets the Kubernetes auth-info", func() { @@ -43,6 +48,36 @@ var _ = Describe("KubernetesAuthActor", func() { Expect(config.SetKubernetesAuthInfoCallCount()).To(Equal(1)) Expect(config.SetKubernetesAuthInfoArgsForCall(0)).To(Equal("bar")) }) + + When("the given username is not in the k8s config", func() { + BeforeEach(func() { + username = "no-such-person" + }) + + It("returns the error", func() { + Expect(err).To(MatchError("kubernetes user not found in configuration: " + username)) + }) + }) + + When("getting the k8s config fails", func() { + BeforeEach(func() { + k8sConfigGetter.GetReturns(nil, errors.New("oomph!")) + }) + + It("returns the error", func() { + Expect(err).To(MatchError("oomph!")) + }) + }) + + When("no auth infos are in the k8s config", func() { + BeforeEach(func() { + k8sConfigGetter.GetReturns(&clientcmdapi.Config{}, nil) + }) + + It("returns an error", func() { + Expect(err).To(MatchError("no kubernetes authentication infos configured")) + }) + }) }) Describe("GetLoginPrompts", func() { @@ -55,16 +90,16 @@ var _ = Describe("KubernetesAuthActor", func() { It("returns an auth prompt menu", func() { Expect(err).NotTo(HaveOccurred()) Expect(authPrompts).To(HaveLen(1)) - Expect(authPrompts).To(HaveKey("k8s-auth-info")) + Expect(authPrompts).To(HaveKey("username")) - authPrompt := authPrompts["k8s-auth-info"] + authPrompt := authPrompts["username"] Expect(authPrompt.Type).To(Equal(coreconfig.AuthPromptTypeMenu)) Expect(authPrompt.DisplayName).To(Equal("Choose your Kubernetes authentication info")) Expect(authPrompt.Entries).To(ConsistOf("foo", "bar")) }) It("sorts the entries", func() { - authPrompt := authPrompts["k8s-auth-info"] + authPrompt := authPrompts["username"] Expect(authPrompt.Entries).To(Equal([]string{"bar", "foo"})) }) diff --git a/actor/v7action/label.go b/actor/v7action/label.go index 5ed9845e869..cf7aa936822 100644 --- a/actor/v7action/label.go +++ b/actor/v7action/label.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) func (actor *Actor) GetApplicationLabels(appName string, spaceGUID string) (map[string]types.NullString, Warnings, error) { @@ -56,8 +56,8 @@ func (actor *Actor) GetStackLabels(stackName string) (map[string]types.NullStrin return actor.extractLabels(resource.Metadata, warnings, err) } -func (actor *Actor) GetBuildpackLabels(buildpackName string, buildpackStack string) (map[string]types.NullString, Warnings, error) { - resource, warnings, err := actor.GetBuildpackByNameAndStack(buildpackName, buildpackStack) +func (actor *Actor) GetBuildpackLabels(buildpackName string, buildpackStack string, buildpackLifecycle string) (map[string]types.NullString, Warnings, error) { + resource, warnings, err := actor.GetBuildpackByNameAndStackAndLifecycle(buildpackName, buildpackStack, buildpackLifecycle) return actor.extractLabels(resource.Metadata, warnings, err) } @@ -81,8 +81,8 @@ func (actor *Actor) UpdateApplicationLabelsByApplicationName(appName string, spa return actor.updateResourceMetadata("app", app.GUID, resources.Metadata{Labels: labels}, warnings) } -func (actor *Actor) UpdateBuildpackLabelsByBuildpackNameAndStack(buildpackName string, stack string, labels map[string]types.NullString) (Warnings, error) { - buildpack, warnings, err := actor.GetBuildpackByNameAndStack(buildpackName, stack) +func (actor *Actor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(buildpackName string, stack string, lifecycle string, labels map[string]types.NullString) (Warnings, error) { + buildpack, warnings, err := actor.GetBuildpackByNameAndStackAndLifecycle(buildpackName, stack, lifecycle) if err != nil { return warnings, err } diff --git a/actor/v7action/label_test.go b/actor/v7action/label_test.go index df3a573ad40..42fa796c7c8 100644 --- a/actor/v7action/label_test.go +++ b/actor/v7action/label_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -142,6 +142,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetDomainsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -221,6 +223,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -311,6 +315,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetDomainsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"sub.example.com"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -321,6 +327,8 @@ var _ = Describe("labels", func() { ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{""}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{"/my-route/path"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -413,6 +421,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -494,6 +504,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetStacksCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetStacksArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -938,6 +950,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetDomainsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -1022,6 +1036,8 @@ var _ = Describe("labels", func() { ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{""}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{"/my-route/path"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -1102,6 +1118,8 @@ var _ = Describe("labels", func() { Expect(fakeCloudControllerClient.GetStacksCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetStacksArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{resourceName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) diff --git a/actor/v7action/logging.go b/actor/v7action/logging.go index 5c77b2d1595..ac056713947 100644 --- a/actor/v7action/logging.go +++ b/actor/v7action/logging.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" "github.com/SermoDigital/jose/jws" ) diff --git a/actor/v7action/logging_test.go b/actor/v7action/logging_test.go index 8cefdb9a6b1..68fd8ab4abf 100644 --- a/actor/v7action/logging_test.go +++ b/actor/v7action/logging_test.go @@ -5,15 +5,15 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - logcache "code.cloudfoundry.org/go-log-cache" - "code.cloudfoundry.org/go-loggregator/v8/rpc/loggregator_v2" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + logcache "code.cloudfoundry.org/go-log-cache/v2" + "code.cloudfoundry.org/go-loggregator/v9/rpc/loggregator_v2" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/marketplace.go b/actor/v7action/marketplace.go index cc6f3a3ffbf..bf4830dfecc 100644 --- a/actor/v7action/marketplace.go +++ b/actor/v7action/marketplace.go @@ -1,7 +1,7 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" ) type ServiceOfferingWithPlans ccv3.ServiceOfferingWithPlans diff --git a/actor/v7action/marketplace_test.go b/actor/v7action/marketplace_test.go index 7cb2fdda9ec..cee3fd1600f 100644 --- a/actor/v7action/marketplace_test.go +++ b/actor/v7action/marketplace_test.go @@ -3,11 +3,11 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/organization.go b/actor/v7action/organization.go index dbe432ef645..1ebed1b9d09 100644 --- a/actor/v7action/organization.go +++ b/actor/v7action/organization.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) GetOrganizations(labelSelector string) ([]resources.Organization, Warnings, error) { @@ -35,6 +35,8 @@ func (actor Actor) GetOrganizationByGUID(orgGUID string) (resources.Organization func (actor Actor) GetOrganizationByName(name string) (resources.Organization, Warnings, error) { orgs, warnings, err := actor.CloudControllerClient.GetOrganizations( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { return resources.Organization{}, Warnings(warnings), err diff --git a/actor/v7action/organization_quota.go b/actor/v7action/organization_quota.go index 1352d43dc46..b76e4cdd03a 100644 --- a/actor/v7action/organization_quota.go +++ b/actor/v7action/organization_quota.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type QuotaLimits struct { @@ -15,6 +15,7 @@ type QuotaLimits struct { TotalServiceInstances *types.NullInt TotalRoutes *types.NullInt TotalReservedPorts *types.NullInt + TotalLogVolume *types.NullInt } func (actor Actor) ApplyOrganizationQuotaByName(quotaName string, orgGUID string) (Warnings, error) { @@ -75,10 +76,9 @@ func (actor Actor) GetOrganizationQuotas() ([]resources.OrganizationQuota, Warni func (actor Actor) GetOrganizationQuotaByName(orgQuotaName string) (resources.OrganizationQuota, Warnings, error) { ccv3OrgQuotas, warnings, err := actor.CloudControllerClient.GetOrganizationQuotas( - ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{orgQuotaName}, - }, + ccv3.Query{Key: ccv3.NameFilter, Values: []string{orgQuotaName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { return resources.OrganizationQuota{}, Warnings(warnings), err @@ -119,6 +119,7 @@ func createQuotaStruct(name string, limits QuotaLimits) resources.OrganizationQu TotalMemory: limits.TotalMemoryInMB, InstanceMemory: limits.PerProcessMemoryInMB, TotalAppInstances: limits.TotalInstances, + TotalLogVolume: limits.TotalLogVolume, } ServiceLimit := resources.ServiceLimit{ TotalServiceInstances: limits.TotalServiceInstances, @@ -164,6 +165,7 @@ func convertUnlimitedToNil(apps *resources.AppLimit, routes *resources.RouteLimi apps.TotalMemory, apps.InstanceMemory, apps.TotalAppInstances, + apps.TotalLogVolume, services.TotalServiceInstances, routes.TotalRoutes, routes.TotalReservedPorts, diff --git a/actor/v7action/organization_quota_test.go b/actor/v7action/organization_quota_test.go index 6cfe1fd21a9..a8ece325f09 100644 --- a/actor/v7action/organization_quota_test.go +++ b/actor/v7action/organization_quota_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -17,8 +17,8 @@ var _ = Describe("Organization Quota Actions", func() { var ( actor *Actor fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient - trueValue bool = true - falseValue bool = false + trueValue = true + falseValue = false ) BeforeEach(func() { @@ -102,10 +102,9 @@ var _ = Describe("Organization Quota Actions", func() { Expect(fakeCloudControllerClient.GetOrganizationQuotasCallCount()).To(Equal(1)) passedQuotaQuery := fakeCloudControllerClient.GetOrganizationQuotasArgsForCall(0) Expect(passedQuotaQuery).To(Equal([]ccv3.Query{ - { - Key: "names", - Values: []string{quotaName}, - }, + {Key: ccv3.NameFilter, Values: []string{quotaName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.ApplyOrganizationQuotaCallCount()).To(Equal(1)) passedQuotaGUID, passedOrgGUID := fakeCloudControllerClient.ApplyOrganizationQuotaArgsForCall(0) @@ -158,6 +157,8 @@ var _ = Describe("Organization Quota Actions", func() { query := fakeCloudControllerClient.GetOrganizationQuotasArgsForCall(0) Expect(query).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{quotaName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.DeleteOrganizationQuotaCallCount()).To(Equal(1)) @@ -368,6 +369,8 @@ var _ = Describe("Organization Quota Actions", func() { query := fakeCloudControllerClient.GetOrganizationQuotasArgsForCall(0) Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{quotaName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(warnings).To(ConsistOf("some-quota-warning")) @@ -399,6 +402,7 @@ var _ = Describe("Organization Quota Actions", func() { PaidServicesAllowed: &trueValue, TotalRoutes: &types.NullInt{Value: 6, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, } }) @@ -438,6 +442,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: true}, InstanceMemory: nil, TotalAppInstances: nil, + TotalLogVolume: nil, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -480,6 +485,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true}, TotalRoutes: &types.NullInt{Value: -1, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: -1, IsSet: true}, } ccv3Quota = resources.OrganizationQuota{ Quota: resources.Quota{ @@ -488,6 +494,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -506,7 +513,7 @@ var _ = Describe("Organization Quota Actions", func() { ) }) - It("call the create endpoint with the respective values and returns warnings", func() { + It("calls the create endpoint with the respective values and returns warnings", func() { Expect(fakeCloudControllerClient.CreateOrganizationQuotaCallCount()).To(Equal(1)) Expect(warnings).To(ConsistOf("some-quota-warning")) @@ -516,7 +523,7 @@ var _ = Describe("Organization Quota Actions", func() { }) }) - When("The create org quota endpoint succeeds", func() { + When("the create org quota endpoint succeeds", func() { var ( ccv3Quota resources.OrganizationQuota ) @@ -528,6 +535,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -546,7 +554,7 @@ var _ = Describe("Organization Quota Actions", func() { ) }) - It("call the create endpoint with the respective values and returns warnings", func() { + It("calls the create endpoint with the respective values and returns warnings", func() { Expect(fakeCloudControllerClient.CreateOrganizationQuotaCallCount()).To(Equal(1)) Expect(warnings).To(ConsistOf("some-quota-warning")) @@ -577,6 +585,7 @@ var _ = Describe("Organization Quota Actions", func() { PaidServicesAllowed: &trueValue, TotalRoutes: &types.NullInt{Value: 6, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 64, IsSet: true}, } fakeCloudControllerClient.GetOrganizationQuotasReturns( @@ -622,6 +631,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: nil, InstanceMemory: nil, TotalAppInstances: nil, + TotalLogVolume: nil, }, Services: resources.ServiceLimit{ TotalServiceInstances: nil, @@ -669,6 +679,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true}, TotalRoutes: &types.NullInt{Value: -1, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: -1, IsSet: true}, } ccv3Quota = resources.OrganizationQuota{ Quota: resources.Quota{ @@ -677,6 +688,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -722,6 +734,7 @@ var _ = Describe("Organization Quota Actions", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 64, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, diff --git a/actor/v7action/organization_summary.go b/actor/v7action/organization_summary.go index 2fdc28c4a01..5553acf96bd 100644 --- a/actor/v7action/organization_summary.go +++ b/actor/v7action/organization_summary.go @@ -3,7 +3,7 @@ package v7action import ( "sort" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/resources" ) type OrganizationSummary struct { diff --git a/actor/v7action/organization_summary_test.go b/actor/v7action/organization_summary_test.go index c711b4a7d11..8445d9b40b5 100644 --- a/actor/v7action/organization_summary_test.go +++ b/actor/v7action/organization_summary_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" "code.cloudfoundry.org/clock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/organization_test.go b/actor/v7action/organization_test.go index a3aa2365054..efeb65de65a 100644 --- a/actor/v7action/organization_test.go +++ b/actor/v7action/organization_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -208,6 +208,8 @@ var _ = Describe("Organization Actions", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"some-org-name"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) }) @@ -434,10 +436,11 @@ var _ = Describe("Organization Actions", func() { Expect(warnings).To(ConsistOf("warning-1", "warning-2", "warning-5", "warning-6", "warning-7", "warning-8")) Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) - Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(Equal([]ccv3.Query{{ - Key: ccv3.NameFilter, - Values: []string{"some-org"}, - }})) + Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{"some-org"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.DeleteOrganizationCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.DeleteOrganizationArgsForCall(0)).To(Equal("some-org-guid")) diff --git a/actor/v7action/package.go b/actor/v7action/package.go index 38f080da08b..d0ef95550c6 100644 --- a/actor/v7action/package.go +++ b/actor/v7action/package.go @@ -5,11 +5,11 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" log "github.com/sirupsen/logrus" ) @@ -131,18 +131,11 @@ func (actor Actor) CreateAndUploadBitsPackageByApplicationNameAndSpace(appName s func (actor Actor) GetNewestReadyPackageForApplication(app resources.Application) (resources.Package, Warnings, error) { ccv3Packages, warnings, err := actor.CloudControllerClient.GetPackages( - ccv3.Query{ - Key: ccv3.AppGUIDFilter, - Values: []string{app.GUID}, - }, - ccv3.Query{ - Key: ccv3.StatesFilter, - Values: []string{string(constant.PackageReady)}, - }, - ccv3.Query{ - Key: ccv3.OrderBy, - Values: []string{ccv3.CreatedAtDescendingOrder}, - }, + ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}}, + ccv3.Query{Key: ccv3.StatesFilter, Values: []string{string(constant.PackageReady)}}, + ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { diff --git a/actor/v7action/package_test.go b/actor/v7action/package_test.go index 1bcaf162c5c..80afcb9783c 100644 --- a/actor/v7action/package_test.go +++ b/actor/v7action/package_test.go @@ -3,20 +3,18 @@ package v7action_test import ( "errors" "io" - "io/ioutil" "os" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" ) @@ -191,6 +189,8 @@ var _ = Describe("Package Actions", func() { ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{"some-app-guid"}}, ccv3.Query{Key: ccv3.StatesFilter, Values: []string{"READY"}}, ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(err).ToNot(HaveOccurred()) @@ -419,7 +419,7 @@ var _ = Describe("Package Actions", func() { When("bits path is a directory", func() { BeforeEach(func() { var err error - bitsPath, err = ioutil.TempDir("", "example") + bitsPath, err = os.MkdirTemp("", "example") Expect(err).ToNot(HaveOccurred()) }) @@ -617,7 +617,7 @@ var _ = Describe("Package Actions", func() { Expect(tableWarnings).To(ConsistOf("some-app-warning", "some-package-warning", "upload-package-warning", "poll-package-warning", "poll-package-warning")) - // hacky, get packages is called an extry time cause the + // hacky, get packages is called an extra time cause the // JustBeforeEach executes everything once as well Expect(fakeCloudControllerClient.GetPackageCallCount()).To(Equal(3)) Expect(fakeConfig.PollingIntervalCallCount()).To(Equal(3)) @@ -641,7 +641,7 @@ var _ = Describe("Package Actions", func() { oldCurrentDir, err = os.Getwd() Expect(err).NotTo(HaveOccurred()) - appDir, err = ioutil.TempDir("", "example") + appDir, err = os.MkdirTemp("", "example") Expect(err).ToNot(HaveOccurred()) Expect(os.Chdir(appDir)).NotTo(HaveOccurred()) @@ -670,12 +670,12 @@ var _ = Describe("Package Actions", func() { When("bits path is an archive", func() { BeforeEach(func() { var err error - tempFile, err := ioutil.TempFile("", "bits-zip-test") + tempFile, err := os.CreateTemp("", "bits-zip-test") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) tempFilePath := tempFile.Name() - bitsPathFile, err := ioutil.TempFile("", "example") + bitsPathFile, err := os.CreateTemp("", "example") Expect(err).ToNot(HaveOccurred()) Expect(bitsPathFile.Close()).To(Succeed()) bitsPath = bitsPathFile.Name() @@ -744,10 +744,10 @@ var _ = Describe("Package Actions", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "example") + tempDir, err = os.MkdirTemp("", "example") Expect(err).ToNot(HaveOccurred()) - tempFile, err := ioutil.TempFile("", "example-file-") + tempFile, err := os.CreateTemp("", "example-file-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) @@ -773,12 +773,12 @@ var _ = Describe("Package Actions", func() { BeforeEach(func() { var err error - tempArchiveFile, err := ioutil.TempFile("", "bits-zip-test") + tempArchiveFile, err := os.CreateTemp("", "bits-zip-test") Expect(err).ToNot(HaveOccurred()) Expect(tempArchiveFile.Close()).To(Succeed()) tempArchiveFilePath := tempArchiveFile.Name() - archivePathFile, err := ioutil.TempFile("", "example") + archivePathFile, err := os.CreateTemp("", "example") Expect(err).ToNot(HaveOccurred()) Expect(archivePathFile.Close()).To(Succeed()) archivePath = archivePathFile.Name() @@ -787,7 +787,7 @@ var _ = Describe("Package Actions", func() { Expect(err).NotTo(HaveOccurred()) Expect(os.Remove(tempArchiveFilePath)).To(Succeed()) - tempFile, err := ioutil.TempFile("", "example-file-") + tempFile, err := os.CreateTemp("", "example-file-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) @@ -1093,18 +1093,11 @@ var _ = Describe("Package Actions", func() { queries := fakeCloudControllerClient.GetPackagesArgsForCall(0) Expect(queries).To(Equal([]ccv3.Query{ - ccv3.Query{ - Key: ccv3.AppGUIDFilter, - Values: []string{sourceApp.GUID}, - }, - ccv3.Query{ - Key: ccv3.StatesFilter, - Values: []string{string(constant.PackageReady)}, - }, - ccv3.Query{ - Key: ccv3.OrderBy, - Values: []string{ccv3.CreatedAtDescendingOrder}, - }, + {Key: ccv3.AppGUIDFilter, Values: []string{sourceApp.GUID}}, + {Key: ccv3.StatesFilter, Values: []string{string(constant.PackageReady)}}, + {Key: ccv3.OrderBy, Values: []string{ccv3.CreatedAtDescendingOrder}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) }) }) diff --git a/actor/v7action/process.go b/actor/v7action/process.go index c25884e94c8..b9fbd90ecde 100644 --- a/actor/v7action/process.go +++ b/actor/v7action/process.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) GetProcess(processGUID string) (resources.Process, Warnings, error) { diff --git a/actor/v7action/process_health_check.go b/actor/v7action/process_health_check.go index 51f2edb57fe..90e25b4a9c3 100644 --- a/actor/v7action/process_health_check.go +++ b/actor/v7action/process_health_check.go @@ -3,7 +3,7 @@ package v7action import ( "sort" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) type ProcessHealthCheck struct { diff --git a/actor/v7action/process_health_check_test.go b/actor/v7action/process_health_check_test.go index 33d1340b66e..97e15d08f11 100644 --- a/actor/v7action/process_health_check_test.go +++ b/actor/v7action/process_health_check_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/process_instance.go b/actor/v7action/process_instance.go index 53938990a2c..cefa44757c0 100644 --- a/actor/v7action/process_instance.go +++ b/actor/v7action/process_instance.go @@ -3,11 +3,11 @@ package v7action import ( "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) type ProcessInstance ccv3.ProcessInstance diff --git a/actor/v7action/process_instance_test.go b/actor/v7action/process_instance_test.go index 96ecff7c603..52b27cf7f0e 100644 --- a/actor/v7action/process_instance_test.go +++ b/actor/v7action/process_instance_test.go @@ -4,13 +4,13 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/process_readiness_health_check.go b/actor/v7action/process_readiness_health_check.go new file mode 100644 index 00000000000..4538a34b62c --- /dev/null +++ b/actor/v7action/process_readiness_health_check.go @@ -0,0 +1,72 @@ +package v7action + +import ( + "sort" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" +) + +type ProcessReadinessHealthCheck struct { + ProcessType string + HealthCheckType constant.HealthCheckType + Endpoint string + InvocationTimeout int64 + Interval int64 +} + +type ProcessReadinessHealthChecks []ProcessReadinessHealthCheck + +func (phs ProcessReadinessHealthChecks) Sort() { + sort.Slice(phs, func(i int, j int) bool { + var iScore int + var jScore int + + switch phs[i].ProcessType { + case constant.ProcessTypeWeb: + iScore = 0 + default: + iScore = 1 + } + + switch phs[j].ProcessType { + case constant.ProcessTypeWeb: + jScore = 0 + default: + jScore = 1 + } + + if iScore == 1 && jScore == 1 { + return phs[i].ProcessType < phs[j].ProcessType + } + return iScore < jScore + }) +} + +func (actor Actor) GetApplicationProcessReadinessHealthChecksByNameAndSpace(appName string, spaceGUID string) ([]ProcessReadinessHealthCheck, Warnings, error) { + app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) + if err != nil { + return nil, allWarnings, err + } + + ccv3Processes, warnings, err := actor.CloudControllerClient.GetApplicationProcesses(app.GUID) + allWarnings = append(allWarnings, Warnings(warnings)...) + if err != nil { + return nil, allWarnings, err + } + + var processReadinessHealthChecks ProcessReadinessHealthChecks + for _, ccv3Process := range ccv3Processes { + processReadinessHealthCheck := ProcessReadinessHealthCheck{ + ProcessType: ccv3Process.Type, + HealthCheckType: ccv3Process.ReadinessHealthCheckType, + Endpoint: ccv3Process.ReadinessHealthCheckEndpoint, + InvocationTimeout: ccv3Process.ReadinessHealthCheckInvocationTimeout, + Interval: ccv3Process.ReadinessHealthCheckInterval, + } + processReadinessHealthChecks = append(processReadinessHealthChecks, processReadinessHealthCheck) + } + + processReadinessHealthChecks.Sort() + + return processReadinessHealthChecks, allWarnings, nil +} diff --git a/actor/v7action/process_readiness_health_check_test.go b/actor/v7action/process_readiness_health_check_test.go new file mode 100644 index 00000000000..69b556c3f4b --- /dev/null +++ b/actor/v7action/process_readiness_health_check_test.go @@ -0,0 +1,176 @@ +package v7action_test + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Process Readiness Health Check Actions", func() { + var ( + actor *Actor + fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient + ) + + BeforeEach(func() { + fakeCloudControllerClient = new(v7actionfakes.FakeCloudControllerClient) + actor = NewActor(fakeCloudControllerClient, nil, nil, nil, nil, nil) + }) + + Describe("ProcessReadinessHealthChecks", func() { + var readinessHealthChecks ProcessReadinessHealthChecks + + BeforeEach(func() { + readinessHealthChecks = ProcessReadinessHealthChecks{ + { + ProcessType: "worker", + HealthCheckType: constant.Process, + }, + { + ProcessType: "console", + HealthCheckType: constant.Process, + }, + { + ProcessType: constant.ProcessTypeWeb, + HealthCheckType: constant.HTTP, + Endpoint: constant.ProcessHealthCheckEndpointDefault, + }, + } + }) + + Describe("Sort", func() { + It("sorts readiness health checks with web first and then alphabetically sorted", func() { + readinessHealthChecks.Sort() + Expect(readinessHealthChecks[0].ProcessType).To(Equal(constant.ProcessTypeWeb)) + Expect(readinessHealthChecks[1].ProcessType).To(Equal("console")) + Expect(readinessHealthChecks[2].ProcessType).To(Equal("worker")) + }) + }) + }) + + Describe("GetApplicationProcessReadinessHealthChecksByNameAndSpace", func() { + var ( + warnings Warnings + executeErr error + processReadinessHealthChecks []ProcessReadinessHealthCheck + ) + + JustBeforeEach(func() { + processReadinessHealthChecks, warnings, executeErr = actor.GetApplicationProcessReadinessHealthChecksByNameAndSpace("some-app-name", "some-space-guid") + }) + + When("application does not exist", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetApplicationsReturns( + []resources.Application{}, + ccv3.Warnings{"some-warning"}, + nil, + ) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).To(Equal(actionerror.ApplicationNotFoundError{Name: "some-app-name"})) + Expect(warnings).To(ConsistOf("some-warning")) + }) + }) + + When("getting application returns an error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some-error") + fakeCloudControllerClient.GetApplicationsReturns( + []resources.Application{}, + ccv3.Warnings{"some-warning"}, + expectedErr, + ) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).To(Equal(expectedErr)) + Expect(warnings).To(ConsistOf("some-warning")) + }) + }) + + When("application exists", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetApplicationsReturns( + []resources.Application{ + { + GUID: "some-app-guid", + }, + }, + ccv3.Warnings{"some-warning"}, + nil, + ) + }) + + When("getting application processes returns an error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some-error") + fakeCloudControllerClient.GetApplicationProcessesReturns( + []resources.Process{}, + ccv3.Warnings{"some-process-warning"}, + expectedErr, + ) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).To(Equal(expectedErr)) + Expect(warnings).To(ConsistOf("some-warning", "some-process-warning")) + }) + }) + + When("application has processes", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetApplicationProcessesReturns( + []resources.Process{ + { + GUID: "process-guid-1", + Type: "process-type-1", + ReadinessHealthCheckType: "readiness-health-check-type-1", + ReadinessHealthCheckEndpoint: "readiness-health-check-endpoint-1", + ReadinessHealthCheckInvocationTimeout: 42, + }, + { + GUID: "process-guid-2", + Type: "process-type-2", + ReadinessHealthCheckType: "readiness-health-check-type-2", + ReadinessHealthCheckInvocationTimeout: 0, + }, + }, + ccv3.Warnings{"some-process-warning"}, + nil, + ) + }) + + It("returns health checks", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("some-warning", "some-process-warning")) + Expect(processReadinessHealthChecks).To(Equal([]ProcessReadinessHealthCheck{ + { + ProcessType: "process-type-1", + HealthCheckType: "readiness-health-check-type-1", + Endpoint: "readiness-health-check-endpoint-1", + InvocationTimeout: 42, + }, + { + ProcessType: "process-type-2", + HealthCheckType: "readiness-health-check-type-2", + InvocationTimeout: 0, + }, + })) + }) + }) + }) + }) +}) diff --git a/actor/v7action/process_summary.go b/actor/v7action/process_summary.go index 72f1e9aa66a..1ed1b492340 100644 --- a/actor/v7action/process_summary.go +++ b/actor/v7action/process_summary.go @@ -5,8 +5,8 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" log "github.com/sirupsen/logrus" ) diff --git a/actor/v7action/process_summary_test.go b/actor/v7action/process_summary_test.go index f5bee52adc4..31b6c20f323 100644 --- a/actor/v7action/process_summary_test.go +++ b/actor/v7action/process_summary_test.go @@ -1,11 +1,11 @@ package v7action_test import ( - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/process_test.go b/actor/v7action/process_test.go index 9c95905f316..32f5172a73b 100644 --- a/actor/v7action/process_test.go +++ b/actor/v7action/process_test.go @@ -3,15 +3,15 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" ) diff --git a/actor/v7action/resource_match.go b/actor/v7action/resource_match.go index dc5db1c3429..09fc05eb9a9 100644 --- a/actor/v7action/resource_match.go +++ b/actor/v7action/resource_match.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" log "github.com/sirupsen/logrus" ) @@ -21,12 +21,14 @@ func (actor Actor) ResourceMatch(resources []sharedaction.V3Resource) ([]shareda ) for _, chunk := range resourceChunks { - newMatchedAPIResources, warnings, err := actor.CloudControllerClient.ResourceMatch(chunk) - allWarnings = append(allWarnings, warnings...) - if err != nil { - return nil, allWarnings, err + if len(chunk) > 0 { + newMatchedAPIResources, warnings, err := actor.CloudControllerClient.ResourceMatch(chunk) + allWarnings = append(allWarnings, warnings...) + if err != nil { + return nil, allWarnings, err + } + matchedAPIResources = append(matchedAPIResources, newMatchedAPIResources...) } - matchedAPIResources = append(matchedAPIResources, newMatchedAPIResources...) } var matchedResources []sharedaction.V3Resource @@ -51,8 +53,10 @@ func (Actor) chunkResources(resources []sharedaction.V3Resource) [][]ccv3.Resour } if len(currentSet) == constant.MaxNumberOfResourcesForMatching || index+1 == len(resources) { - chunkedResources = append(chunkedResources, currentSet) - currentSet = []ccv3.Resource{} + if len(currentSet) > 0 { + chunkedResources = append(chunkedResources, currentSet) + currentSet = []ccv3.Resource{} + } } } return chunkedResources diff --git a/actor/v7action/resource_match_test.go b/actor/v7action/resource_match_test.go index 1759b2a5baf..f508dde21b3 100644 --- a/actor/v7action/resource_match_test.go +++ b/actor/v7action/resource_match_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "fmt" - "code.cloudfoundry.org/cli/actor/sharedaction" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/revisions.go b/actor/v7action/revisions.go index 47b79205db6..d1b26866596 100644 --- a/actor/v7action/revisions.go +++ b/actor/v7action/revisions.go @@ -3,11 +3,11 @@ package v7action import ( "strconv" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/versioncheck" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/versioncheck" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) const MinimumCCAPIVersionForDeployable = "3.86.0" @@ -43,11 +43,12 @@ func (actor *Actor) GetRevisionsByApplicationNameAndSpace(appName string, spaceG } func (actor Actor) GetRevisionByApplicationAndVersion(appGUID string, revisionVersion int) (resources.Revision, Warnings, error) { - query := ccv3.Query{ - Key: ccv3.VersionsFilter, - Values: []string{strconv.Itoa(revisionVersion)}, + query := []ccv3.Query{ + {Key: ccv3.VersionsFilter, Values: []string{strconv.Itoa(revisionVersion)}}, + {Key: ccv3.PerPage, Values: []string{"2"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } - revisions, warnings, apiErr := actor.CloudControllerClient.GetApplicationRevisions(appGUID, query) + revisions, warnings, apiErr := actor.CloudControllerClient.GetApplicationRevisions(appGUID, query...) if apiErr != nil { return resources.Revision{}, Warnings(warnings), apiErr } @@ -75,6 +76,20 @@ func (actor Actor) GetRevisionByApplicationAndVersion(appGUID string, revisionVe return revisions[0], Warnings(warnings), nil } +func (actor Actor) GetEnvironmentVariableGroupByRevision(revision resources.Revision) (EnvironmentVariableGroup, bool, Warnings, error) { + envVarApiLink, isPresent := revision.Links["environment_variables"] + if !isPresent { + return EnvironmentVariableGroup{}, isPresent, Warnings{"Unable to retrieve environment variables for revision."}, nil + } + + environmentVariables, warnings, err := actor.CloudControllerClient.GetEnvironmentVariablesByURL(envVarApiLink.HREF) + if err != nil { + return EnvironmentVariableGroup{}, false, Warnings(warnings), err + } + + return EnvironmentVariableGroup(environmentVariables), true, Warnings(warnings), nil +} + func (actor Actor) setRevisionsDeployableByDropletStateForApp(appGUID string, revisions []resources.Revision) ([]resources.Revision, Warnings, error) { droplets, warnings, err := actor.CloudControllerClient.GetDroplets( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, diff --git a/actor/v7action/revisions_test.go b/actor/v7action/revisions_test.go index 176707531da..771902651f4 100644 --- a/actor/v7action/revisions_test.go +++ b/actor/v7action/revisions_test.go @@ -4,13 +4,14 @@ import ( "errors" "strconv" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -212,14 +213,15 @@ var _ = Describe("Revisions Actions", func() { }) It("returns the revision", func() { - expectedQuery := ccv3.Query{ - Key: ccv3.VersionsFilter, - Values: []string{strconv.Itoa(revisionVersion)}, + expectedQuery := []ccv3.Query{ + {Key: ccv3.VersionsFilter, Values: []string{strconv.Itoa(revisionVersion)}}, + {Key: ccv3.PerPage, Values: []string{"2"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } Expect(fakeCloudControllerClient.GetApplicationRevisionsCallCount()).To(Equal(1), "GetApplicationRevisions call count") appGuid, query := fakeCloudControllerClient.GetApplicationRevisionsArgsForCall(0) Expect(appGuid).To(Equal("some-app-guid")) - Expect(query).To(ContainElement(expectedQuery)) + Expect(query).To(ConsistOf(expectedQuery)) Expect(fakeConfig.APIVersionCallCount()).To(Equal(1), "APIVersion call count") Expect(fakeCloudControllerClient.GetDropletsCallCount()).To(Equal(0), "GetDroplets call count") @@ -252,14 +254,15 @@ var _ = Describe("Revisions Actions", func() { }) It("fills in deployable based on droplet status", func() { - expectedQuery := ccv3.Query{ - Key: ccv3.VersionsFilter, - Values: []string{strconv.Itoa(revisionVersion)}, + expectedQuery := []ccv3.Query{ + {Key: ccv3.VersionsFilter, Values: []string{strconv.Itoa(revisionVersion)}}, + {Key: ccv3.PerPage, Values: []string{"2"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } Expect(fakeCloudControllerClient.GetApplicationRevisionsCallCount()).To(Equal(1), "GetApplicationRevisions call count") appGuid, query := fakeCloudControllerClient.GetApplicationRevisionsArgsForCall(0) Expect(appGuid).To(Equal("some-app-guid")) - Expect(query).To(ContainElement(expectedQuery)) + Expect(query).To(ConsistOf(expectedQuery)) Expect(fakeConfig.APIVersionCallCount()).To(Equal(1), "APIVersion call count") Expect(fakeCloudControllerClient.GetDropletsCallCount()).To(Equal(1), "GetDroplets call count") @@ -395,4 +398,81 @@ var _ = Describe("Revisions Actions", func() { }) }) }) + + Describe("GetEnvironmentVariableGroupByRevision", func() { + var ( + actor *Actor + environmentVariablesGroup EnvironmentVariableGroup + executeErr error + fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient + fakeConfig *v7actionfakes.FakeConfig + isPresent bool + revision resources.Revision + warnings Warnings + ) + + BeforeEach(func() { + fakeCloudControllerClient = new(v7actionfakes.FakeCloudControllerClient) + fakeConfig = new(v7actionfakes.FakeConfig) + actor = NewActor(fakeCloudControllerClient, fakeConfig, nil, nil, nil, nil) + revision = resources.Revision{ + Links: resources.APILinks{ + "environment_variables": resources.APILink{ + HREF: "url", + }, + }, + } + fakeConfig.APIVersionReturns("3.86.0") + }) + + JustBeforeEach(func() { + environmentVariablesGroup, isPresent, warnings, executeErr = actor.GetEnvironmentVariableGroupByRevision(revision) + }) + + When("the revision does not provide HREF", func() { + BeforeEach(func() { + revision = resources.Revision{} + }) + + It("returns as not present", func() { + Expect(executeErr).To(Not(HaveOccurred())) + Expect(warnings).To(ConsistOf("Unable to retrieve environment variables for revision.")) + Expect(isPresent).To(Equal(false)) + }) + }) + + When("finding the environment variables fails", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetEnvironmentVariablesByURLReturns( + nil, + ccv3.Warnings{"get-env-vars-warning-1"}, + errors.New("get-env-vars-error-1"), + ) + }) + + It("returns an error and warnings", func() { + Expect(executeErr).To(MatchError("get-env-vars-error-1")) + Expect(warnings).To(ConsistOf("get-env-vars-warning-1")) + }) + }) + + When("finding the environment variables succeeds", func() { + BeforeEach(func() { + fakeCloudControllerClient.GetEnvironmentVariablesByURLReturns( + resources.EnvironmentVariables{"foo": *types.NewFilteredString("bar")}, + ccv3.Warnings{"get-env-vars-warning-1"}, + nil, + ) + }) + + It("returns the environment variables and warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeCloudControllerClient.GetEnvironmentVariablesByURLCallCount()).To(Equal(1)) + Expect(fakeCloudControllerClient.GetEnvironmentVariablesByURLArgsForCall(0)).To(Equal("url")) + Expect(warnings).To(ConsistOf("get-env-vars-warning-1")) + Expect(len(environmentVariablesGroup)).To(Equal(1)) + Expect(environmentVariablesGroup["foo"].Value).To(Equal("bar")) + }) + }) + }) }) diff --git a/actor/v7action/role.go b/actor/v7action/role.go index 437d3242a94..9fe786cfa72 100644 --- a/actor/v7action/role.go +++ b/actor/v7action/role.go @@ -1,11 +1,11 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) CreateOrgRole(roleType constant.RoleType, orgGUID string, userNameOrGUID string, userOrigin string, isClient bool) (Warnings, error) { @@ -167,18 +167,11 @@ func (actor Actor) getUserGuidForDeleteRole(isClient bool, userNameOrGUID string func (actor Actor) GetRoleGUID(queryKey ccv3.QueryKey, orgOrSpaceGUID string, userGUID string, roleType constant.RoleType) (string, Warnings, error) { ccv3Roles, _, warnings, err := actor.CloudControllerClient.GetRoles( - ccv3.Query{ - Key: ccv3.UserGUIDFilter, - Values: []string{userGUID}, - }, - ccv3.Query{ - Key: ccv3.RoleTypesFilter, - Values: []string{string(roleType)}, - }, - ccv3.Query{ - Key: queryKey, - Values: []string{orgOrSpaceGUID}, - }, + ccv3.Query{Key: ccv3.UserGUIDFilter, Values: []string{userGUID}}, + ccv3.Query{Key: ccv3.RoleTypesFilter, Values: []string{string(roleType)}}, + ccv3.Query{Key: queryKey, Values: []string{orgOrSpaceGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { diff --git a/actor/v7action/role_test.go b/actor/v7action/role_test.go index fa280ec8f12..85bad2b4e0c 100644 --- a/actor/v7action/role_test.go +++ b/actor/v7action/role_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -417,18 +417,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{userNameOrGUID}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.SpaceDeveloperRole)}, - }, - { - Key: ccv3.SpaceGUIDFilter, - Values: []string{spaceGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{userNameOrGUID}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.SpaceDeveloperRole)}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) passedRoleGUID := fakeCloudControllerClient.DeleteRoleArgsForCall(0) @@ -468,18 +461,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{"user-guid"}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.SpaceDeveloperRole)}, - }, - { - Key: ccv3.SpaceGUIDFilter, - Values: []string{spaceGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{"user-guid"}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.SpaceDeveloperRole)}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) @@ -691,18 +677,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{userGUID}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.SpaceDeveloperRole)}, - }, - { - Key: ccv3.SpaceGUIDFilter, - Values: []string{orgOrSpaceGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{userGUID}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.SpaceDeveloperRole)}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{orgOrSpaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) Expect(warnings).To(ConsistOf("get-roles-warning")) @@ -732,18 +711,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{userGUID}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.SpaceDeveloperRole)}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{orgOrSpaceGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{userGUID}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.SpaceDeveloperRole)}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{orgOrSpaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) Expect(warnings).To(ConsistOf("get-roles-warning")) @@ -766,18 +738,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{"user-guid"}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.SpaceDeveloperRole)}, - }, - { - Key: ccv3.SpaceGUIDFilter, - Values: []string{orgOrSpaceGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{"user-guid"}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.SpaceDeveloperRole)}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{orgOrSpaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) Expect(warnings).To(ConsistOf("get-roles-warning")) @@ -883,18 +848,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{userNameOrGUID}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.OrgBillingManagerRole)}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{orgGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{userNameOrGUID}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.OrgBillingManagerRole)}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) passedRoleGUID := fakeCloudControllerClient.DeleteRoleArgsForCall(0) @@ -934,18 +892,11 @@ var _ = Describe("Role Actions", func() { passedRolesQuery := fakeCloudControllerClient.GetRolesArgsForCall(0) Expect(passedRolesQuery).To(Equal( []ccv3.Query{ - { - Key: ccv3.UserGUIDFilter, - Values: []string{"user-guid"}, - }, - { - Key: ccv3.RoleTypesFilter, - Values: []string{string(constant.OrgBillingManagerRole)}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{orgGUID}, - }, + {Key: ccv3.UserGUIDFilter, Values: []string{"user-guid"}}, + {Key: ccv3.RoleTypesFilter, Values: []string{string(constant.OrgBillingManagerRole)}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, }, )) diff --git a/actor/v7action/route.go b/actor/v7action/route.go index d59c318c61f..8ef0a4479e3 100644 --- a/actor/v7action/route.go +++ b/actor/v7action/route.go @@ -5,16 +5,16 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - "code.cloudfoundry.org/cli/util/extract" - "code.cloudfoundry.org/cli/util/lookuptable" - "code.cloudfoundry.org/cli/util/railway" - "code.cloudfoundry.org/cli/util/sorting" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + "code.cloudfoundry.org/cli/v8/util/extract" + "code.cloudfoundry.org/cli/v8/util/lookuptable" + "code.cloudfoundry.org/cli/v8/util/railway" + "code.cloudfoundry.org/cli/v8/util/sorting" ) type RouteSummary struct { @@ -26,7 +26,7 @@ type RouteSummary struct { ServiceInstanceName string } -func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, Warnings, error) { +func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, port int, options map[string]*string) (resources.Route, Warnings, error) { allWarnings := Warnings{} domain, warnings, err := actor.GetDomainByName(domainName) allWarnings = append(allWarnings, warnings...) @@ -41,6 +41,7 @@ func (actor Actor) CreateRoute(spaceGUID, domainName, hostname, path string, por Host: hostname, Path: path, Port: port, + Options: options, }) actorWarnings := Warnings(apiWarnings) @@ -84,7 +85,8 @@ func (actor Actor) GetRouteDestinationByAppGUID(route resources.Route, appGUID s func (actor Actor) GetRoutesBySpace(spaceGUID string, labelSelector string) ([]resources.Route, Warnings, error) { allWarnings := Warnings{} queries := []ccv3.Query{ - ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { queries = append(queries, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) @@ -144,10 +146,9 @@ func (actor Actor) parseRoutePath(routePath string) (string, string, string, res func (actor Actor) GetRoute(routePath string, spaceGUID string) (resources.Route, Warnings, error) { filters := []ccv3.Query{ - { - Key: ccv3.SpaceGUIDFilter, - Values: []string{spaceGUID}, - }, + {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } host, path, port, domain, allWarnings, err := actor.parseRoutePath(routePath) @@ -190,7 +191,8 @@ func (actor Actor) GetRoute(routePath string, spaceGUID string) (resources.Route func (actor Actor) GetRoutesByOrg(orgGUID string, labelSelector string) ([]resources.Route, Warnings, error) { allWarnings := Warnings{} queries := []ccv3.Query{ - ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { queries = append(queries, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) @@ -370,6 +372,8 @@ func (actor Actor) GetRouteByAttributes(domain resources.Domain, hostname string {Key: ccv3.DomainGUIDFilter, Values: []string{domain.GUID}}, {Key: ccv3.HostsFilter, Values: []string{hostname}}, {Key: ccv3.PathsFilter, Values: []string{path}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } if domain.IsTCP() { @@ -398,11 +402,28 @@ func (actor Actor) MapRoute(routeGUID string, appGUID string, destinationProtoco return Warnings(warnings), err } +func (actor Actor) UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, Warnings, error) { + route, warnings, err := actor.CloudControllerClient.UpdateRoute(routeGUID, options) + return route, Warnings(warnings), err +} + +func (actor Actor) UpdateDestination(routeGUID string, destinationGUID string, protocol string) (Warnings, error) { + warnings, err := actor.CloudControllerClient.UpdateDestination(routeGUID, destinationGUID, protocol) + return Warnings(warnings), err +} func (actor Actor) UnmapRoute(routeGUID string, destinationGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.UnmapRoute(routeGUID, destinationGUID) return Warnings(warnings), err } +func (actor Actor) ShareRoute(routeGUID string, spaceGUID string) (Warnings, error) { + warnings, err := actor.CloudControllerClient.ShareRoute(routeGUID, spaceGUID) + return Warnings(warnings), err +} +func (actor Actor) UnshareRoute(routeGUID string, spaceGUID string) (Warnings, error) { + warnings, err := actor.CloudControllerClient.UnshareRoute(routeGUID, spaceGUID) + return Warnings(warnings), err +} func (actor Actor) GetApplicationRoutes(appGUID string) ([]resources.Route, Warnings, error) { allWarnings := Warnings{} @@ -419,6 +440,11 @@ func (actor Actor) GetApplicationRoutes(appGUID string) ([]resources.Route, Warn return routes, allWarnings, nil } +func (actor Actor) MoveRoute(routeGUID string, spaceGUID string) (Warnings, error) { + warnings, err := actor.CloudControllerClient.MoveRoute(routeGUID, spaceGUID) + return Warnings(warnings), err +} + func getDomainName(fullURL, host, path string, port int) string { domainWithoutHost := strings.TrimPrefix(fullURL, host+".") domainWithoutPath := strings.TrimSuffix(domainWithoutHost, path) diff --git a/actor/v7action/route_binding.go b/actor/v7action/route_binding.go index 6d2d2788b5b..ed471d34ace 100644 --- a/actor/v7action/route_binding.go +++ b/actor/v7action/route_binding.go @@ -1,12 +1,12 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/railway" ) type CreateRouteBindingParams struct { @@ -128,6 +128,8 @@ func (actor Actor) getRouteBinding(serviceInstanceGUID, routeGUID string) (resou bindings, _, warnings, err := actor.CloudControllerClient.GetRouteBindings( ccv3.Query{Key: ccv3.RouteGUIDFilter, Values: []string{routeGUID}}, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) switch { @@ -156,6 +158,8 @@ func (actor Actor) getRouteForBinding(params getRouteForBindingParams) (resource ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{domain.GUID}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{params.Hostname}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{params.Path}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) return }, diff --git a/actor/v7action/route_binding_test.go b/actor/v7action/route_binding_test.go index 34a7485a188..ef926c0a00f 100644 --- a/actor/v7action/route_binding_test.go +++ b/actor/v7action/route_binding_test.go @@ -1,16 +1,16 @@ package v7action_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -169,6 +169,8 @@ var _ = Describe("Route Binding Action", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetDomainsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{domainName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -210,6 +212,8 @@ var _ = Describe("Route Binding Action", func() { ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{domainGUID}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{hostname}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{path}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -458,6 +462,8 @@ var _ = Describe("Route Binding Action", func() { Expect(fakeCloudControllerClient.GetDomainsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetDomainsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{domainName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -499,6 +505,8 @@ var _ = Describe("Route Binding Action", func() { ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{domainGUID}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{hostname}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{path}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -546,6 +554,8 @@ var _ = Describe("Route Binding Action", func() { Expect(fakeCloudControllerClient.GetRouteBindingsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.RouteGUIDFilter, Values: []string{routeGUID}}, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) diff --git a/actor/v7action/route_test.go b/actor/v7action/route_test.go index 064b1863761..55bd75fa11f 100644 --- a/actor/v7action/route_test.go +++ b/actor/v7action/route_test.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -33,16 +33,20 @@ var _ = Describe("Route Actions", func() { hostname string path string port int + options map[string]*string ) BeforeEach(func() { hostname = "" path = "" port = 0 + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + options = map[string]*string{"loadbalancing": lbLeastConnections} }) JustBeforeEach(func() { - _, warnings, executeErr = actor.CreateRoute("space-guid", "domain-name", hostname, path, port) + _, warnings, executeErr = actor.CreateRoute("space-guid", "domain-name", hostname, path, port, options) }) When("the API layer calls are successful", func() { @@ -56,7 +60,7 @@ var _ = Describe("Route Actions", func() { ) fakeCloudControllerClient.CreateRouteReturns( - resources.Route{GUID: "route-guid", SpaceGUID: "space-guid", DomainGUID: "domain-guid", Host: "hostname", Path: "path-name"}, + resources.Route{GUID: "route-guid", SpaceGUID: "space-guid", DomainGUID: "domain-guid", Host: "hostname", Path: "path-name", Options: options}, ccv3.Warnings{"create-warning-1", "create-warning-2"}, nil) }) @@ -80,6 +84,7 @@ var _ = Describe("Route Actions", func() { DomainGUID: "domain-guid", Host: hostname, Path: path, + Options: options, }, )) }) @@ -102,6 +107,7 @@ var _ = Describe("Route Actions", func() { SpaceGUID: "space-guid", DomainGUID: "domain-guid", Port: 1234, + Options: options, }, )) }) @@ -296,9 +302,11 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query := fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query).To(HaveLen(1)) + Expect(query).To(HaveLen(2)) Expect(query[0].Key).To(Equal(ccv3.SpaceGUIDFilter)) Expect(query[0].Values).To(ConsistOf("space-guid")) + Expect(query[1].Key).To(Equal(ccv3.PerPage)) + Expect(query[1].Values).To(ConsistOf(ccv3.MaxPerPage)) }) When("a label selector is provided", func() { @@ -312,6 +320,7 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) expectedQuery := []ccv3.Query{ {Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, {Key: ccv3.LabelSelectorFilter, Values: []string{"ink=blink"}}, } actualQuery := fakeCloudControllerClient.GetRoutesArgsForCall(0) @@ -397,15 +406,14 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query = fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query).To(HaveLen(4)) - Expect(query[0].Key).To(Equal(ccv3.SpaceGUIDFilter)) - Expect(query[0].Values).To(ConsistOf("space-guid")) - Expect(query[1].Key).To(Equal(ccv3.DomainGUIDFilter)) - Expect(query[1].Values).To(ConsistOf("domain-guid")) - Expect(query[2].Key).To(Equal(ccv3.HostsFilter)) - Expect(query[2].Values).To(ConsistOf("hostname")) - Expect(query[3].Key).To(Equal(ccv3.PathsFilter)) - Expect(query[3].Values).To(ConsistOf("/the-path")) + Expect(query).To(ConsistOf( + ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}}, + ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, + ccv3.Query{Key: ccv3.HostsFilter, Values: []string{"hostname"}}, + ccv3.Query{Key: ccv3.PathsFilter, Values: []string{"/the-path"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + )) }) }) @@ -438,8 +446,14 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query = fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query[2].Key).To(Equal(ccv3.HostsFilter)) - Expect(query[2].Values).To(ConsistOf("")) + Expect(query).To(ConsistOf( + ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}}, + ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, + ccv3.Query{Key: ccv3.HostsFilter, Values: []string{""}}, + ccv3.Query{Key: ccv3.PathsFilter, Values: []string{""}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + )) }) }) @@ -481,8 +495,15 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query = fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query[4].Key).To(Equal(ccv3.PortsFilter)) - Expect(query[4].Values).To(ConsistOf("8080")) + Expect(query).To(ConsistOf( + ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}}, + ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, + ccv3.Query{Key: ccv3.HostsFilter, Values: []string{""}}, + ccv3.Query{Key: ccv3.PathsFilter, Values: []string{""}}, + ccv3.Query{Key: ccv3.PortsFilter, Values: []string{"8080"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + )) }) }) @@ -619,9 +640,11 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query := fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query).To(HaveLen(1)) + Expect(query).To(HaveLen(2)) Expect(query[0].Key).To(Equal(ccv3.OrganizationGUIDFilter)) Expect(query[0].Values).To(ConsistOf("org-guid")) + Expect(query[1].Key).To(Equal(ccv3.PerPage)) + Expect(query[1].Values).To(ConsistOf(ccv3.MaxPerPage)) }) When("a label selector is provided", func() { @@ -635,6 +658,7 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) expectedQuery := []ccv3.Query{ {Key: ccv3.OrganizationGUIDFilter, Values: []string{"org-guid"}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, {Key: ccv3.LabelSelectorFilter, Values: []string{"env=prod"}}, } actualQuery := fakeCloudControllerClient.GetRoutesArgsForCall(0) @@ -1216,6 +1240,8 @@ var _ = Describe("Route Actions", func() { query := fakeCloudControllerClient.GetDomainsArgsForCall(0) Expect(query).To(ConsistOf([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{"domain.com"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) // Get the route based on the domain GUID @@ -1225,6 +1251,8 @@ var _ = Describe("Route Actions", func() { {Key: ccv3.DomainGUIDFilter, Values: []string{"domain-guid"}}, {Key: ccv3.HostsFilter, Values: []string{"hostname"}}, {Key: ccv3.PathsFilter, Values: []string{"/path"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) // Delete the route asynchronously @@ -1265,6 +1293,8 @@ var _ = Describe("Route Actions", func() { query := fakeCloudControllerClient.GetDomainsArgsForCall(0) Expect(query).To(ConsistOf([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{"domain.com"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) // Get the route based on the domain GUID @@ -1275,6 +1305,8 @@ var _ = Describe("Route Actions", func() { {Key: ccv3.HostsFilter, Values: []string{""}}, {Key: ccv3.PathsFilter, Values: []string{""}}, {Key: ccv3.PortsFilter, Values: []string{"1026"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) // Delete the route asynchronously @@ -1443,6 +1475,8 @@ var _ = Describe("Route Actions", func() { ccv3.Query{Key: ccv3.DomainGUIDFilter, Values: []string{domainGUID}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{hostname}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{path}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(warnings).To(ConsistOf("get-routes-warning")) @@ -1512,6 +1546,8 @@ var _ = Describe("Route Actions", func() { ccv3.Query{Key: ccv3.PortsFilter, Values: []string{fmt.Sprintf("%d", port)}}, ccv3.Query{Key: ccv3.HostsFilter, Values: []string{""}}, ccv3.Query{Key: ccv3.PathsFilter, Values: []string{""}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(warnings).To(ConsistOf("get-routes-warning")) @@ -1590,6 +1626,46 @@ var _ = Describe("Route Actions", func() { }) }) + Describe("UnshareRoute", func() { + var ( + routeGUID string + spaceGUID string + + executeErr error + warnings Warnings + ) + + JustBeforeEach(func() { + warnings, executeErr = actor.UnshareRoute(routeGUID, spaceGUID) + }) + + BeforeEach(func() { + routeGUID = "route-guid" + spaceGUID = "space-guid" + }) + + When("the cloud controller client errors", func() { + BeforeEach(func() { + fakeCloudControllerClient.UnshareRouteReturns(ccv3.Warnings{"unshare-route-warning"}, errors.New("unshare-route-error")) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).To(MatchError(errors.New("unshare-route-error"))) + Expect(warnings).To(ConsistOf("unshare-route-warning")) + }) + }) + + When("the cloud controller client succeeds", func() { + BeforeEach(func() { + fakeCloudControllerClient.UnshareRouteReturns(ccv3.Warnings{"unshare-route-warning"}, nil) + }) + + It("returns the warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(warnings).To(ConsistOf("unshare-route-warning")) + }) + }) + }) Describe("UnmapRoute", func() { var ( routeGUID string @@ -1631,6 +1707,49 @@ var _ = Describe("Route Actions", func() { }) }) + Describe("UpdateDestination", func() { + var ( + routeGUID string + destinationGUID string + protocol string + + executeErr error + warnings Warnings + ) + + JustBeforeEach(func() { + warnings, executeErr = actor.UpdateDestination(routeGUID, destinationGUID, protocol) + }) + + BeforeEach(func() { + routeGUID = "route-guid" + destinationGUID = "destination-guid" + protocol = "http2" + }) + + When("the cloud controller client errors", func() { + BeforeEach(func() { + fakeCloudControllerClient.UpdateDestinationReturns(ccv3.Warnings{"unmap-route-warning"}, errors.New("unmap-route-error")) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).To(MatchError(errors.New("unmap-route-error"))) + Expect(warnings).To(ConsistOf("unmap-route-warning")) + }) + }) + + When("the cloud controller client succeeds", func() { + BeforeEach(func() { + fakeCloudControllerClient.UpdateDestinationReturns(ccv3.Warnings{"unmap-route-warning"}, nil) + }) + + It("returns the error and warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(warnings).To(ConsistOf("unmap-route-warning")) + }) + }) + }) + Describe("DeleteOrphanedRoutes", func() { var ( spaceGUID string diff --git a/actor/v7action/router_group.go b/actor/v7action/router_group.go index 2be81f31aef..0a19c612d65 100644 --- a/actor/v7action/router_group.go +++ b/actor/v7action/router_group.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" ) type RouterGroup router.RouterGroup diff --git a/actor/v7action/router_group_test.go b/actor/v7action/router_group_test.go index 4c1f5239d16..8301dd2a66b 100644 --- a/actor/v7action/router_group_test.go +++ b/actor/v7action/router_group_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/routing_client.go b/actor/v7action/routing_client.go index 29229591612..37019d9637c 100644 --- a/actor/v7action/routing_client.go +++ b/actor/v7action/routing_client.go @@ -1,6 +1,6 @@ package v7action -import "code.cloudfoundry.org/cli/api/router" +import "code.cloudfoundry.org/cli/v8/api/router" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RoutingClient diff --git a/actor/v7action/security_group.go b/actor/v7action/security_group.go index 73099a307ee..825146f0287 100644 --- a/actor/v7action/security_group.go +++ b/actor/v7action/security_group.go @@ -2,16 +2,16 @@ package v7action import ( "encoding/json" - "io/ioutil" + "io" "os" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) type SecurityGroupSummary struct { @@ -75,7 +75,11 @@ func (actor Actor) CreateSecurityGroup(name, filePath string) (Warnings, error) func (actor Actor) GetSecurityGroup(securityGroupName string) (resources.SecurityGroup, Warnings, error) { allWarnings := Warnings{} - securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups(ccv3.Query{Key: ccv3.NameFilter, Values: []string{securityGroupName}}) + securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups( + ccv3.Query{Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + ) allWarnings = append(allWarnings, warnings...) if err != nil { @@ -92,7 +96,11 @@ func (actor Actor) GetSecurityGroup(securityGroupName string) (resources.Securit func (actor Actor) GetSecurityGroupSummary(securityGroupName string) (SecurityGroupSummary, Warnings, error) { allWarnings := Warnings{} securityGroupSummary := SecurityGroupSummary{} - securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups(ccv3.Query{Key: ccv3.NameFilter, Values: []string{securityGroupName}}) + securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups( + ccv3.Query{Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + ) allWarnings = append(allWarnings, warnings...) @@ -247,7 +255,11 @@ func (actor Actor) UpdateSecurityGroup(name, filePath string) (Warnings, error) } // fetch security group from API - securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups(ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}) + securityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups( + ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + ) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err @@ -377,7 +389,7 @@ func parsePath(path string) ([]byte, error) { return nil, err } - bytes, err := ioutil.ReadAll(file) + bytes, err := io.ReadAll(file) if err != nil { return nil, err } diff --git a/actor/v7action/security_group_test.go b/actor/v7action/security_group_test.go index ed0a72500eb..73cbd5cfedb 100644 --- a/actor/v7action/security_group_test.go +++ b/actor/v7action/security_group_test.go @@ -4,18 +4,17 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "os" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/batcher" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/batcher" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -193,7 +192,7 @@ var _ = Describe("Security Group Actions", func() { }, }, } - tempFile, executeErr = ioutil.TempFile("", "") + tempFile, executeErr = os.CreateTemp("", "") Expect(executeErr).ToNot(HaveOccurred()) filePath = tempFile.Name() @@ -324,6 +323,8 @@ var _ = Describe("Security Group Actions", func() { Expect(fakeCloudControllerClient.GetSecurityGroupsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"security-group-name"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(0)) @@ -403,6 +404,8 @@ var _ = Describe("Security Group Actions", func() { Expect(fakeCloudControllerClient.GetSecurityGroupsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{"security-group-name"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) @@ -697,7 +700,7 @@ var _ = Describe("Security Group Actions", func() { ) }) - It("makes mutiple calls to get spaces", func() { + It("makes multiple calls to get spaces", func() { Expect(len(securityGroupSummaries)).To(Equal(1)) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(batches)) Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)). @@ -1016,6 +1019,8 @@ var _ = Describe("Security Group Actions", func() { orgsQuery := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) Expect(orgsQuery).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{orgName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) @@ -1023,12 +1028,16 @@ var _ = Describe("Security Group Actions", func() { Expect(spacesQuery).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{spaceName}}, {Key: ccv3.OrganizationGUIDFilter, Values: []string{"some-org-guid"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.GetSecurityGroupsCallCount()).To(Equal(1)) securityGroupsQuery := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(securityGroupsQuery).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.UnbindSecurityGroupStagingSpaceCallCount()).To(Equal(1)) @@ -1038,7 +1047,7 @@ var _ = Describe("Security Group Actions", func() { }) }) - When("the seurity group is not bound to the space", func() { + When("the security group is not bound to the space", func() { BeforeEach(func() { fakeCloudControllerClient.UnbindSecurityGroupStagingSpaceReturns( ccv3.Warnings{"get-security-group-warning"}, @@ -1136,7 +1145,7 @@ var _ = Describe("Security Group Actions", func() { "destination": "10.10.10.0/24" } ]`) - tempFile, executeErr = ioutil.TempFile("", "") + tempFile, executeErr = os.CreateTemp("", "") Expect(executeErr).ToNot(HaveOccurred()) filePath = tempFile.Name() @@ -1171,6 +1180,8 @@ var _ = Describe("Security Group Actions", func() { givenQuery := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(givenQuery).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) givenSecurityGroup := fakeCloudControllerClient.UpdateSecurityGroupArgsForCall(0) @@ -1240,7 +1251,7 @@ var _ = Describe("Security Group Actions", func() { var ( securityGroupName = "tom" globallyEnabled bool - lifeycle constant.SecurityGroupLifecycle + lifecycle constant.SecurityGroupLifecycle executeErr error trueValue = true @@ -1248,7 +1259,7 @@ var _ = Describe("Security Group Actions", func() { ) JustBeforeEach(func() { - warnings, executeErr = actor.UpdateSecurityGroupGloballyEnabled(securityGroupName, lifeycle, globallyEnabled) + warnings, executeErr = actor.UpdateSecurityGroupGloballyEnabled(securityGroupName, lifecycle, globallyEnabled) }) When("the request succeeds", func() { @@ -1273,7 +1284,7 @@ var _ = Describe("Security Group Actions", func() { When("updating staging to true", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleStaging + lifecycle = constant.SecurityGroupLifecycleStaging globallyEnabled = true }) @@ -1282,6 +1293,8 @@ var _ = Describe("Security Group Actions", func() { query := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(query).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.UpdateSecurityGroupCallCount()).To(Equal(1)) @@ -1298,7 +1311,7 @@ var _ = Describe("Security Group Actions", func() { When("updating staging to false", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleStaging + lifecycle = constant.SecurityGroupLifecycleStaging globallyEnabled = false }) @@ -1307,6 +1320,8 @@ var _ = Describe("Security Group Actions", func() { query := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(query).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.UpdateSecurityGroupCallCount()).To(Equal(1)) @@ -1323,7 +1338,7 @@ var _ = Describe("Security Group Actions", func() { When("updating running to true", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleRunning + lifecycle = constant.SecurityGroupLifecycleRunning globallyEnabled = true }) @@ -1332,6 +1347,8 @@ var _ = Describe("Security Group Actions", func() { query := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(query).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.UpdateSecurityGroupCallCount()).To(Equal(1)) @@ -1348,7 +1365,7 @@ var _ = Describe("Security Group Actions", func() { When("updating running to false", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleRunning + lifecycle = constant.SecurityGroupLifecycleRunning globallyEnabled = false }) @@ -1357,6 +1374,8 @@ var _ = Describe("Security Group Actions", func() { query := fakeCloudControllerClient.GetSecurityGroupsArgsForCall(0) Expect(query).To(Equal([]ccv3.Query{ {Key: ccv3.NameFilter, Values: []string{securityGroupName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.UpdateSecurityGroupCallCount()).To(Equal(1)) @@ -1374,7 +1393,7 @@ var _ = Describe("Security Group Actions", func() { When("the request to get the security group errors", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleRunning + lifecycle = constant.SecurityGroupLifecycleRunning globallyEnabled = false fakeCloudControllerClient.GetSecurityGroupsReturns( @@ -1398,7 +1417,7 @@ var _ = Describe("Security Group Actions", func() { When("the request to update the security group errors", func() { BeforeEach(func() { - lifeycle = constant.SecurityGroupLifecycleRunning + lifecycle = constant.SecurityGroupLifecycleRunning globallyEnabled = false fakeCloudControllerClient.GetSecurityGroupsReturns( diff --git a/actor/v7action/service_access.go b/actor/v7action/service_access.go index 7f32b7736c9..e1bc5b1b44a 100644 --- a/actor/v7action/service_access.go +++ b/actor/v7action/service_access.go @@ -5,9 +5,9 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) type ServicePlanWithSpaceAndOrganization ccv3.ServicePlanWithSpaceAndOrganization diff --git a/actor/v7action/service_access_test.go b/actor/v7action/service_access_test.go index ec94694a36d..da7025651bc 100644 --- a/actor/v7action/service_access_test.go +++ b/actor/v7action/service_access_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/service_app_binding.go b/actor/v7action/service_app_binding.go index 0ff57797949..b34f09672d0 100644 --- a/actor/v7action/service_app_binding.go +++ b/actor/v7action/service_app_binding.go @@ -1,12 +1,12 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/railway" ) type CreateServiceAppBindingParams struct { @@ -15,6 +15,7 @@ type CreateServiceAppBindingParams struct { AppName string BindingName string Parameters types.OptionalObject + Strategy resources.BindingStrategyType } type DeleteServiceAppBindingParams struct { @@ -41,7 +42,7 @@ func (actor Actor) CreateServiceAppBinding(params CreateServiceAppBindingParams) return }, func() (warnings ccv3.Warnings, err error) { - jobURL, warnings, err = actor.createServiceAppBinding(serviceInstance.GUID, app.GUID, params.BindingName, params.Parameters) + jobURL, warnings, err = actor.createServiceAppBinding(serviceInstance.GUID, app.GUID, params.BindingName, params.Parameters, params.Strategy) return }, func() (warnings ccv3.Warnings, err error) { @@ -102,13 +103,14 @@ func (actor Actor) DeleteServiceAppBinding(params DeleteServiceAppBindingParams) } } -func (actor Actor) createServiceAppBinding(serviceInstanceGUID, appGUID, bindingName string, parameters types.OptionalObject) (ccv3.JobURL, ccv3.Warnings, error) { +func (actor Actor) createServiceAppBinding(serviceInstanceGUID, appGUID, bindingName string, parameters types.OptionalObject, strategy resources.BindingStrategyType) (ccv3.JobURL, ccv3.Warnings, error) { jobURL, warnings, err := actor.CloudControllerClient.CreateServiceCredentialBinding(resources.ServiceCredentialBinding{ Type: resources.AppBinding, Name: bindingName, ServiceInstanceGUID: serviceInstanceGUID, AppGUID: appGUID, Parameters: parameters, + Strategy: strategy, }) switch err.(type) { case nil: @@ -125,6 +127,8 @@ func (actor Actor) getServiceAppBinding(serviceInstanceGUID, appGUID string) (re ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"app"}}, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) switch { diff --git a/actor/v7action/service_app_binding_test.go b/actor/v7action/service_app_binding_test.go index e9db46d4ad0..b108b3c7796 100644 --- a/actor/v7action/service_app_binding_test.go +++ b/actor/v7action/service_app_binding_test.go @@ -3,15 +3,15 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -35,6 +35,7 @@ var _ = Describe("Service App Binding Action", func() { bindingName = "fake-binding-name" spaceGUID = "fake-space-guid" fakeJobURL = ccv3.JobURL("fake-job-url") + strategy = "single" ) var ( @@ -87,6 +88,7 @@ var _ = Describe("Service App Binding Action", func() { Parameters: types.NewOptionalObject(map[string]interface{}{ "foo": "bar", }), + Strategy: resources.SingleBindingStrategy, } }) @@ -202,6 +204,7 @@ var _ = Describe("Service App Binding Action", func() { Parameters: types.NewOptionalObject(map[string]interface{}{ "foo": "bar", }), + Strategy: strategy, })) }) @@ -425,6 +428,8 @@ var _ = Describe("Service App Binding Action", func() { ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"app"}}, ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}}, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) diff --git a/actor/v7action/service_broker.go b/actor/v7action/service_broker.go index 620ddce1c66..6b6da0f637c 100644 --- a/actor/v7action/service_broker.go +++ b/actor/v7action/service_broker.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/railway" ) func (actor Actor) GetServiceBrokers() ([]resources.ServiceBroker, Warnings, error) { @@ -18,10 +18,9 @@ func (actor Actor) GetServiceBrokers() ([]resources.ServiceBroker, Warnings, err func (actor Actor) GetServiceBrokerByName(serviceBrokerName string) (resources.ServiceBroker, Warnings, error) { query := []ccv3.Query{ - { - Key: ccv3.NameFilter, - Values: []string{serviceBrokerName}, - }, + {Key: ccv3.NameFilter, Values: []string{serviceBrokerName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, } serviceBrokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers(query...) if err != nil { diff --git a/actor/v7action/service_broker_test.go b/actor/v7action/service_broker_test.go index 195843f229a..3db82caba1c 100644 --- a/actor/v7action/service_broker_test.go +++ b/actor/v7action/service_broker_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -113,10 +113,11 @@ var _ = Describe("Service Broker Actions", func() { It("returns the service broker and warnings", func() { Expect(fakeCloudControllerClient.GetServiceBrokersCallCount()).To(Equal(1)) - Expect(fakeCloudControllerClient.GetServiceBrokersArgsForCall(0)).To(ConsistOf(ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{serviceBroker1Name}, - })) + Expect(fakeCloudControllerClient.GetServiceBrokersArgsForCall(0)).To(ConsistOf( + ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceBroker1Name}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, + )) Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("some-service-broker-warning")) diff --git a/actor/v7action/service_instance.go b/actor/v7action/service_instance.go index 7ac5c7bbd5c..f7766e38d58 100644 --- a/actor/v7action/service_instance.go +++ b/actor/v7action/service_instance.go @@ -1,13 +1,13 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/railway" ) type UpdateManagedServiceInstanceParams struct { @@ -146,10 +146,13 @@ func (actor Actor) UpdateManagedServiceInstance(params UpdateManagedServiceInsta return stream, Warnings(warnings), err } -func (actor Actor) UpgradeManagedServiceInstance(serviceInstanceName string, spaceGUID string) (Warnings, error) { - var serviceInstance resources.ServiceInstance - var servicePlan resources.ServicePlan - var jobURL ccv3.JobURL +func (actor Actor) UpgradeManagedServiceInstance(serviceInstanceName string, spaceGUID string) (chan PollJobEvent, Warnings, error) { + var ( + serviceInstance resources.ServiceInstance + servicePlan resources.ServicePlan + jobURL ccv3.JobURL + stream chan PollJobEvent + ) warnings, err := railway.Sequentially( func() (warnings ccv3.Warnings, err error) { @@ -173,11 +176,12 @@ func (actor Actor) UpgradeManagedServiceInstance(serviceInstanceName string, spa return }, func() (warnings ccv3.Warnings, err error) { - return actor.CloudControllerClient.PollJobForState(jobURL, constant.JobPolling) + stream = actor.PollJobToEventStream(jobURL) + return }, ) - return Warnings(warnings), err + return stream, Warnings(warnings), err } func (actor Actor) RenameServiceInstance(currentServiceInstanceName, spaceGUID, newServiceInstanceName string) (Warnings, error) { @@ -266,17 +270,6 @@ func (actor Actor) PurgeServiceInstance(serviceInstanceName, spaceGUID string) ( } } -func (actor Actor) pollJob(jobURL ccv3.JobURL, wait bool) (ccv3.Warnings, error) { - switch { - case jobURL == "": - return ccv3.Warnings{}, nil - case wait: - return actor.CloudControllerClient.PollJob(jobURL) - default: - return actor.CloudControllerClient.PollJobForState(jobURL, constant.JobPolling) - } -} - func (actor Actor) getServiceInstanceByNameAndSpace(serviceInstanceName string, spaceGUID string, query ...ccv3.Query) (resources.ServiceInstance, ccv3.IncludedResources, ccv3.Warnings, error) { serviceInstance, includedResources, warnings, err := actor.CloudControllerClient.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID, query...) switch e := err.(type) { diff --git a/actor/v7action/service_instance_details.go b/actor/v7action/service_instance_details.go index 80597c0fc4f..b73ce83d609 100644 --- a/actor/v7action/service_instance_details.go +++ b/actor/v7action/service_instance_details.go @@ -1,12 +1,12 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/extract" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/extract" + "code.cloudfoundry.org/cli/v8/util/railway" ) const featureFlagServiceInstanceSharing string = "service_instance_sharing" diff --git a/actor/v7action/service_instance_details_test.go b/actor/v7action/service_instance_details_test.go index 018facf4a59..d5f6192055d 100644 --- a/actor/v7action/service_instance_details_test.go +++ b/actor/v7action/service_instance_details_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/service_instance_list.go b/actor/v7action/service_instance_list.go index d090b6ba5fc..37a0f78c068 100644 --- a/actor/v7action/service_instance_list.go +++ b/actor/v7action/service_instance_list.go @@ -3,13 +3,13 @@ package v7action import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/batcher" - "code.cloudfoundry.org/cli/util/extract" - "code.cloudfoundry.org/cli/util/lookuptable" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/batcher" + "code.cloudfoundry.org/cli/v8/util/extract" + "code.cloudfoundry.org/cli/v8/util/lookuptable" + "code.cloudfoundry.org/cli/v8/util/railway" ) type ServiceInstance struct { @@ -121,10 +121,20 @@ func buildPlanDetailsLookup(included ccv3.IncludedResources) map[string]planDeta } func buildBoundAppsLookup(bindings []resources.ServiceCredentialBinding, spaceGUID string) map[string][]string { + type bindingKey struct { + appGUID string + serviceInstanceGUID string + } + seenBindingKeys := make(map[bindingKey]struct{}) appsBoundLookup := make(map[string][]string) for _, binding := range bindings { if binding.Type == resources.AppBinding && binding.AppSpaceGUID == spaceGUID { - appsBoundLookup[binding.ServiceInstanceGUID] = append(appsBoundLookup[binding.ServiceInstanceGUID], binding.AppName) + bk := bindingKey{appGUID: binding.AppGUID, serviceInstanceGUID: binding.ServiceInstanceGUID} + // Prevent duplicate app names for the same service instance in case of duplicate bindings + if _, exists := seenBindingKeys[bk]; !exists { + appsBoundLookup[binding.ServiceInstanceGUID] = append(appsBoundLookup[binding.ServiceInstanceGUID], binding.AppName) + seenBindingKeys[bk] = struct{}{} + } } } return appsBoundLookup diff --git a/actor/v7action/service_instance_list_test.go b/actor/v7action/service_instance_list_test.go index d81e4c7f260..946928c3252 100644 --- a/actor/v7action/service_instance_list_test.go +++ b/actor/v7action/service_instance_list_test.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/batcher" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/batcher" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -142,6 +142,8 @@ var _ = Describe("Service Instance List Action", func() { ) fakeCloudControllerClient.GetServiceCredentialBindingsReturns( []resources.ServiceCredentialBinding{ + {Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-1", AppName: "great-app-1", AppSpaceGUID: spaceGUID}, + // Duplicate binding for (app-1, fake-guid-1) pair to ensure app names are not duplicated {Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-1", AppName: "great-app-1", AppSpaceGUID: spaceGUID}, {Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-2", AppName: "great-app-2", AppSpaceGUID: spaceGUID}, {Type: "app", ServiceInstanceGUID: "fake-guid-2", AppGUID: "app-3", AppName: "great-app-3", AppSpaceGUID: spaceGUID}, diff --git a/actor/v7action/service_instance_sharing.go b/actor/v7action/service_instance_sharing.go index d02118579db..ade1b0db833 100644 --- a/actor/v7action/service_instance_sharing.go +++ b/actor/v7action/service_instance_sharing.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/railway" ) type ServiceInstanceSharingParams struct { diff --git a/actor/v7action/service_instance_sharing_test.go b/actor/v7action/service_instance_sharing_test.go index 7f722d6ba37..baff552e429 100644 --- a/actor/v7action/service_instance_sharing_test.go +++ b/actor/v7action/service_instance_sharing_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -75,10 +75,9 @@ var _ = Describe("Service Instance Sharing", func() { Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(Equal( []ccv3.Query{ - { - Key: ccv3.NameFilter, - Values: []string{shareToOrgName}, - }, + {Key: ccv3.NameFilter, Values: []string{shareToOrgName}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(0)) }) @@ -112,14 +111,10 @@ var _ = Describe("Service Instance Sharing", func() { Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(Equal( []ccv3.Query{ - { - Key: ccv3.NameFilter, - Values: []string{shareToSpaceName}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{targetedOrgGUID}, - }, + {Key: ccv3.NameFilter, Values: []string{shareToSpaceName}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{targetedOrgGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) }) @@ -147,14 +142,10 @@ var _ = Describe("Service Instance Sharing", func() { Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(Equal( []ccv3.Query{ - { - Key: ccv3.NameFilter, - Values: []string{shareToSpaceName}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{shareToOrgGUID}, - }, + {Key: ccv3.NameFilter, Values: []string{shareToSpaceName}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{shareToOrgGUID}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) }) diff --git a/actor/v7action/service_instance_test.go b/actor/v7action/service_instance_test.go index cb1551a3db1..dbb52e32db1 100644 --- a/actor/v7action/service_instance_test.go +++ b/actor/v7action/service_instance_test.go @@ -3,15 +3,15 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -493,7 +493,7 @@ var _ = Describe("Service Instance Actions", func() { }) It("returns warnings and an error", func() { - //Expect(warnings).To(ContainElement("warning from get")) + Expect(warnings).To(ContainElement("warning from get")) Expect(executeErr).To(MatchError("bang")) }) }) @@ -1282,12 +1282,13 @@ var _ = Describe("Service Instance Actions", func() { ) var ( - err error - warnings Warnings + executeErr error + warnings Warnings + stream chan PollJobEvent ) JustBeforeEach(func() { - warnings, err = actor.UpgradeManagedServiceInstance(fakeServiceInstanceName, fakeSpaceGUID) + stream, warnings, executeErr = actor.UpgradeManagedServiceInstance(fakeServiceInstanceName, fakeSpaceGUID) }) It("makes a request to get the service instance", func() { @@ -1313,8 +1314,9 @@ var _ = Describe("Service Instance Actions", func() { }) It("returns the appropriate error", func() { + Expect(stream).To(BeNil()) Expect(warnings).To(ConsistOf("get SI warning")) - Expect(err).To(MatchError(actionerror.ServiceInstanceNotFoundError{ + Expect(executeErr).To(MatchError(actionerror.ServiceInstanceNotFoundError{ Name: fakeServiceInstanceName, })) }) @@ -1342,8 +1344,9 @@ var _ = Describe("Service Instance Actions", func() { }) It("returns the appropriate error", func() { + Expect(stream).To(BeNil()) Expect(warnings).To(ConsistOf("get SI warning")) - Expect(err).To(MatchError(actionerror.ServiceInstanceUpgradeNotAvailableError{})) + Expect(executeErr).To(MatchError(actionerror.ServiceInstanceUpgradeNotAvailableError{})) }) }) @@ -1380,10 +1383,15 @@ var _ = Describe("Service Instance Actions", func() { ccv3.Warnings{"warning from update"}, nil, ) - fakeCloudControllerClient.PollJobForStateReturns( - ccv3.Warnings{"warning from poll"}, - nil, - ) + + fakeStream := make(chan ccv3.PollJobEvent) + go func() { + fakeStream <- ccv3.PollJobEvent{ + State: constant.JobProcessing, + Warnings: ccv3.Warnings{"stream warning"}, + } + }() + fakeCloudControllerClient.PollJobToEventStreamReturns(fakeStream) }) It("makes the right calls and returns all warnings", func() { @@ -1403,15 +1411,18 @@ var _ = Describe("Service Instance Actions", func() { }) By("polling the job", func() { - Expect(fakeCloudControllerClient.PollJobForStateCallCount()).To(Equal(1)) - actualURL, actualState := fakeCloudControllerClient.PollJobForStateArgsForCall(0) - Expect(actualURL).To(Equal(jobURL)) - Expect(actualState).To(Equal(constant.JobPolling)) + Expect(fakeCloudControllerClient.PollJobToEventStreamCallCount()).To(Equal(1)) + Expect(fakeCloudControllerClient.PollJobToEventStreamArgsForCall(0)).To(Equal(jobURL)) }) - By("returning warnings and no error", func() { - Expect(err).NotTo(HaveOccurred()) - Expect(warnings).To(ConsistOf("warning from get", "warning from plan", "warning from update", "warning from poll")) + By("returning a stream, warnings and no error", func() { + Eventually(stream).Should(Receive(Equal(PollJobEvent{ + State: JobProcessing, + Warnings: Warnings{"stream warning"}, + }))) + + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("warning from get", "warning from plan", "warning from update")) }) }) }) diff --git a/actor/v7action/service_key.go b/actor/v7action/service_key.go index 0a31563620f..0940cbbd808 100644 --- a/actor/v7action/service_key.go +++ b/actor/v7action/service_key.go @@ -3,12 +3,12 @@ package v7action import ( "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/railway" ) type CreateServiceKeyParams struct { @@ -62,6 +62,7 @@ func (actor Actor) GetServiceKeysByServiceInstance(serviceInstanceName, spaceGUI keys, warnings, err = actor.CloudControllerClient.GetServiceCredentialBindings( ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstance.GUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, ) return }, @@ -155,6 +156,8 @@ func (actor Actor) getServiceKeyByServiceInstanceAndName(serviceInstanceName, se ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstance.GUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceKeyName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) return }, diff --git a/actor/v7action/service_key_test.go b/actor/v7action/service_key_test.go index 231e322a158..c1b82221a22 100644 --- a/actor/v7action/service_key_test.go +++ b/actor/v7action/service_key_test.go @@ -1,16 +1,16 @@ package v7action_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -248,6 +248,7 @@ var _ = Describe("Service Key Action", func() { Expect(fakeCloudControllerClient.GetServiceCredentialBindingsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) }) @@ -367,6 +368,8 @@ var _ = Describe("Service Key Action", func() { ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceKeyName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -508,6 +511,8 @@ var _ = Describe("Service Key Action", func() { ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceKeyName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) @@ -724,6 +729,8 @@ var _ = Describe("Service Key Action", func() { ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceKeyName}}, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) diff --git a/actor/v7action/service_offering.go b/actor/v7action/service_offering.go index 0b61ec4b143..7a04c17f2a3 100644 --- a/actor/v7action/service_offering.go +++ b/actor/v7action/service_offering.go @@ -1,10 +1,10 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/railway" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/railway" ) func (actor Actor) PurgeServiceOfferingByNameAndBroker(serviceOfferingName, serviceBrokerName string) (Warnings, error) { diff --git a/actor/v7action/service_offering_test.go b/actor/v7action/service_offering_test.go index a0379258dc5..0d9c7ff3c9a 100644 --- a/actor/v7action/service_offering_test.go +++ b/actor/v7action/service_offering_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/service_plan.go b/actor/v7action/service_plan.go index 0fcd2373488..27ca44562d5 100644 --- a/actor/v7action/service_plan.go +++ b/actor/v7action/service_plan.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) GetServicePlanByNameOfferingAndBroker(servicePlanName, serviceOfferingName, serviceBrokerName string) (resources.ServicePlan, Warnings, error) { diff --git a/actor/v7action/service_plan_test.go b/actor/v7action/service_plan_test.go index 62a3e592923..2366797b786 100644 --- a/actor/v7action/service_plan_test.go +++ b/actor/v7action/service_plan_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/shared_actor.go b/actor/v7action/shared_actor.go index 95dab5aea24..ecc441a4a1c 100644 --- a/actor/v7action/shared_actor.go +++ b/actor/v7action/shared_actor.go @@ -1,6 +1,6 @@ package v7action -import "code.cloudfoundry.org/cli/actor/sharedaction" +import "code.cloudfoundry.org/cli/v8/actor/sharedaction" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SharedActor diff --git a/actor/v7action/space.go b/actor/v7action/space.go index 449c18d8659..e788fc6abca 100644 --- a/actor/v7action/space.go +++ b/actor/v7action/space.go @@ -4,11 +4,11 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) type SpaceSummary struct { @@ -81,6 +81,8 @@ func (actor Actor) GetSpaceByNameAndOrganization(spaceName string, orgGUID strin ccv3Spaces, _, warnings, err := actor.CloudControllerClient.GetSpaces( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { diff --git a/actor/v7action/space_feature.go b/actor/v7action/space_feature.go index d60a8d8a103..a67c838c6ac 100644 --- a/actor/v7action/space_feature.go +++ b/actor/v7action/space_feature.go @@ -1,6 +1,6 @@ package v7action -import "code.cloudfoundry.org/cli/actor/actionerror" +import "code.cloudfoundry.org/cli/v8/actor/actionerror" func (actor Actor) UpdateSpaceFeature(spaceName string, orgGUID string, enabled bool, feature string) (Warnings, error) { var allWarnings Warnings diff --git a/actor/v7action/space_feature_test.go b/actor/v7action/space_feature_test.go index 8e2bfc05c87..1895f40ae0c 100644 --- a/actor/v7action/space_feature_test.go +++ b/actor/v7action/space_feature_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/resources" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -70,6 +70,8 @@ var _ = Describe("space features", func() { Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.GetSpaceFeatureCallCount()).To(Equal(1)) @@ -200,6 +202,8 @@ var _ = Describe("space features", func() { Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.UpdateSpaceFeatureCallCount()).To(Equal(1)) @@ -245,6 +249,8 @@ var _ = Describe("space features", func() { Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.UpdateSpaceFeatureCallCount()).To(Equal(1)) @@ -280,6 +286,8 @@ var _ = Describe("space features", func() { Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.UpdateSpaceFeatureCallCount()).To(Equal(1)) diff --git a/actor/v7action/space_manifest.go b/actor/v7action/space_manifest.go index 763ccfc12fe..9c6c163679f 100644 --- a/actor/v7action/space_manifest.go +++ b/actor/v7action/space_manifest.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) DiffSpaceManifest(spaceGUID string, rawManifest []byte) (resources.ManifestDiff, Warnings, error) { diff --git a/actor/v7action/space_manifest_test.go b/actor/v7action/space_manifest_test.go index d35987201b7..22321120eee 100644 --- a/actor/v7action/space_manifest_test.go +++ b/actor/v7action/space_manifest_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/space_quota.go b/actor/v7action/space_quota.go index 78f5acc38c6..3590d4a2789 100644 --- a/actor/v7action/space_quota.go +++ b/actor/v7action/space_quota.go @@ -1,9 +1,9 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor Actor) ApplySpaceQuotaByName(quotaName, spaceGUID, orgGUID string) (Warnings, error) { @@ -31,6 +31,7 @@ func (actor Actor) CreateSpaceQuota(spaceQuotaName string, orgGuid string, limit TotalMemory: limits.TotalMemoryInMB, InstanceMemory: limits.PerProcessMemoryInMB, TotalAppInstances: limits.TotalInstances, + TotalLogVolume: limits.TotalLogVolume, }, Services: resources.ServiceLimit{ TotalServiceInstances: limits.TotalServiceInstances, @@ -80,14 +81,10 @@ func (actor Actor) DeleteSpaceQuotaByName(quotaName string, orgGUID string) (War func (actor Actor) GetSpaceQuotaByName(spaceQuotaName string, orgGUID string) (resources.SpaceQuota, Warnings, error) { ccv3Quotas, warnings, err := actor.CloudControllerClient.GetSpaceQuotas( - ccv3.Query{ - Key: ccv3.OrganizationGUIDFilter, - Values: []string{orgGUID}, - }, - ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{spaceQuotaName}, - }, + ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceQuotaName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { @@ -137,6 +134,7 @@ func (actor Actor) UpdateSpaceQuota(currentName, orgGUID, newName string, limits TotalMemory: limits.TotalMemoryInMB, InstanceMemory: limits.PerProcessMemoryInMB, TotalAppInstances: limits.TotalInstances, + TotalLogVolume: limits.TotalLogVolume, }, Services: resources.ServiceLimit{ TotalServiceInstances: limits.TotalServiceInstances, diff --git a/actor/v7action/space_quota_test.go b/actor/v7action/space_quota_test.go index fed2d91c0c2..18e249bee6e 100644 --- a/actor/v7action/space_quota_test.go +++ b/actor/v7action/space_quota_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -105,14 +105,10 @@ var _ = Describe("Space Quota Actions", func() { passedQuotaQuery := fakeCloudControllerClient.GetSpaceQuotasArgsForCall(0) Expect(passedQuotaQuery).To(Equal( []ccv3.Query{ - { - Key: "organization_guids", - Values: []string{orgGUID}, - }, - { - Key: "names", - Values: []string{quotaName}, - }, + {Key: "organization_guids", Values: []string{orgGUID}}, + {Key: "names", Values: []string{quotaName}}, + {Key: "per_page", Values: []string{"1"}}, + {Key: "page", Values: []string{"1"}}, }, )) @@ -151,6 +147,7 @@ var _ = Describe("Space Quota Actions", func() { TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6}, TotalRoutes: &types.NullInt{IsSet: true, Value: 8}, TotalReservedPorts: &types.NullInt{IsSet: true, Value: 9}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 10}, } }) @@ -167,6 +164,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2}, InstanceMemory: &types.NullInt{IsSet: true, Value: 3}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 4}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 10}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{IsSet: true, Value: 6}, @@ -201,6 +199,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: true}, InstanceMemory: nil, TotalAppInstances: nil, + TotalLogVolume: nil, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -244,6 +243,7 @@ var _ = Describe("Space Quota Actions", func() { TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true}, TotalRoutes: &types.NullInt{Value: -1, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: -1, IsSet: true}, } ccv3Quota = resources.SpaceQuota{ Quota: resources.Quota{ @@ -252,6 +252,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -340,14 +341,10 @@ var _ = Describe("Space Quota Actions", func() { Expect(fakeCloudControllerClient.GetSpaceQuotasCallCount()).To(Equal(1)) query := fakeCloudControllerClient.GetSpaceQuotasArgsForCall(0) Expect(query).To(ConsistOf( - ccv3.Query{ - Key: ccv3.OrganizationGUIDFilter, - Values: []string{orgGUID}, - }, - ccv3.Query{ - Key: ccv3.NameFilter, - Values: []string{quotaName}, - }, + ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.NameFilter, Values: []string{quotaName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(fakeCloudControllerClient.DeleteSpaceQuotaCallCount()).To(Equal(1)) @@ -483,6 +480,8 @@ var _ = Describe("Space Quota Actions", func() { Expect(query).To(ConsistOf( ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, ccv3.Query{Key: ccv3.NameFilter, Values: []string{quotaName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(warnings).To(ConsistOf("some-quota-warning")) @@ -607,6 +606,7 @@ var _ = Describe("Space Quota Actions", func() { PaidServicesAllowed: &trueValue, TotalRoutes: &types.NullInt{Value: 6, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: 5, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, } fakeCloudControllerClient.GetSpaceQuotasReturns( @@ -652,6 +652,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: nil, InstanceMemory: nil, TotalAppInstances: nil, + TotalLogVolume: nil, }, Services: resources.ServiceLimit{ TotalServiceInstances: nil, @@ -699,6 +700,7 @@ var _ = Describe("Space Quota Actions", func() { TotalServiceInstances: &types.NullInt{Value: -1, IsSet: true}, TotalRoutes: &types.NullInt{Value: -1, IsSet: true}, TotalReservedPorts: &types.NullInt{Value: -1, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: -1, IsSet: true}, } ccv3Quota = resources.SpaceQuota{ @@ -708,6 +710,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -754,6 +757,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -802,6 +806,7 @@ var _ = Describe("Space Quota Actions", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, diff --git a/actor/v7action/space_test.go b/actor/v7action/space_test.go index b3f67ab13b7..358ecb9308b 100644 --- a/actor/v7action/space_test.go +++ b/actor/v7action/space_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -258,6 +258,8 @@ var _ = Describe("Space", func() { Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) }) }) @@ -281,6 +283,8 @@ var _ = Describe("Space", func() { Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.NameFilter, Values: []string{spaceName}}, ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, )) Expect(space).To(Equal(resources.Space{ GUID: "some-space-guid", @@ -524,20 +528,18 @@ var _ = Describe("Space", func() { Expect(warnings).To(ConsistOf("warning-1", "warning-2", "warning-3", "warning-4", "warning-5", "warning-6", "warning-7", "warning-8")) Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) - Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(Equal([]ccv3.Query{{ - Key: ccv3.NameFilter, - Values: []string{"some-org"}, - }})) + Expect(fakeCloudControllerClient.GetOrganizationsArgsForCall(0)).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{"some-org"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + })) Expect(fakeCloudControllerClient.GetSpacesCallCount()).To(Equal(1)) - Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(Equal([]ccv3.Query{{ - Key: ccv3.NameFilter, - Values: []string{"some-space"}, - }, - { - Key: ccv3.OrganizationGUIDFilter, - Values: []string{"some-org-guid"}, - }, + Expect(fakeCloudControllerClient.GetSpacesArgsForCall(0)).To(Equal([]ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{"some-space"}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{"some-org-guid"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, })) Expect(fakeCloudControllerClient.DeleteSpaceCallCount()).To(Equal(1)) diff --git a/actor/v7action/ssh.go b/actor/v7action/ssh.go index 30fcc6ff9e6..ca04ed554f5 100644 --- a/actor/v7action/ssh.go +++ b/actor/v7action/ssh.go @@ -3,8 +3,8 @@ package v7action import ( "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/resources" ) type SSHAuthentication struct { @@ -25,7 +25,7 @@ func (actor Actor) GetSecureShellConfigurationByApplicationNameSpaceProcessTypeA ) (SSHAuthentication, Warnings, error) { var allWarnings Warnings - rootInfo, warnings, err := actor.CloudControllerClient.GetInfo() + rootInfo, warnings, err := actor.CloudControllerClient.GetRoot() allWarnings = append(allWarnings, warnings...) if err != nil { return SSHAuthentication{}, allWarnings, err diff --git a/actor/v7action/ssh_actor.go b/actor/v7action/ssh_actor.go index 84fd26091ef..82db1ae4ffc 100644 --- a/actor/v7action/ssh_actor.go +++ b/actor/v7action/ssh_actor.go @@ -1,6 +1,6 @@ package v7action -import "code.cloudfoundry.org/cli/actor/sharedaction" +import "code.cloudfoundry.org/cli/v8/actor/sharedaction" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SSHActor diff --git a/actor/v7action/ssh_test.go b/actor/v7action/ssh_test.go index a8a7008b011..a73fc472ead 100644 --- a/actor/v7action/ssh_test.go +++ b/actor/v7action/ssh_test.go @@ -3,13 +3,13 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -92,8 +92,8 @@ var _ = Describe("SSH Actions", func() { When("the app ssh endpoint is empty", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ - Links: ccv3.InfoLinks{ + fakeCloudControllerClient.GetRootReturns(ccv3.Root{ + Links: ccv3.RootLinks{ AppSSH: resources.APILink{HREF: ""}, }, }, nil, nil) @@ -106,8 +106,8 @@ var _ = Describe("SSH Actions", func() { When("the app ssh hostkey fingerprint is empty", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ - Links: ccv3.InfoLinks{ + fakeCloudControllerClient.GetRootReturns(ccv3.Root{ + Links: ccv3.RootLinks{ AppSSH: resources.APILink{HREF: "some-app-ssh-endpoint"}, }, }, nil, nil) @@ -120,8 +120,8 @@ var _ = Describe("SSH Actions", func() { When("ssh endpoint and fingerprint are set", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ - Links: ccv3.InfoLinks{ + fakeCloudControllerClient.GetRootReturns(ccv3.Root{ + Links: ccv3.RootLinks{ AppSSH: resources.APILink{ HREF: "some-app-ssh-endpoint", Meta: resources.APILinkMeta{HostKeyFingerprint: "some-app-ssh-fingerprint"}, diff --git a/actor/v7action/stack.go b/actor/v7action/stack.go index 29ed49727df..d0b9889ff24 100644 --- a/actor/v7action/stack.go +++ b/actor/v7action/stack.go @@ -1,14 +1,16 @@ package v7action import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) func (actor *Actor) GetStackByName(stackName string) (resources.Stack, Warnings, error) { stacks, warnings, err := actor.CloudControllerClient.GetStacks( ccv3.Query{Key: ccv3.NameFilter, Values: []string{stackName}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { diff --git a/actor/v7action/stack_test.go b/actor/v7action/stack_test.go index aaab0d4aa00..92e6abdc8b2 100644 --- a/actor/v7action/stack_test.go +++ b/actor/v7action/stack_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -76,7 +76,11 @@ var _ = Describe("Stack", func() { Description: "Some stack desc", } - expectedParams := []ccv3.Query{{Key: ccv3.NameFilter, Values: []string{"some-stack-name"}}} + expectedParams := []ccv3.Query{ + {Key: ccv3.NameFilter, Values: []string{"some-stack-name"}}, + {Key: ccv3.PerPage, Values: []string{"1"}}, + {Key: ccv3.Page, Values: []string{"1"}}, + } BeforeEach(func() { fakeCloudControllerClient.GetStacksReturns( @@ -157,7 +161,7 @@ var _ = Describe("Stack", func() { Expect(warnings).To(ConsistOf("some-stack-warning")) Expect(fakeCloudControllerClient.GetStacksCallCount()).To(Equal(1)) }) - When("a label selctor is passed in", func() { + When("a label selector is passed in", func() { BeforeEach(func() { labelSelector = "some-label-selector" }) diff --git a/actor/v7action/target.go b/actor/v7action/target.go index a63a02711c2..44b700d5515 100644 --- a/actor/v7action/target.go +++ b/actor/v7action/target.go @@ -1,8 +1,8 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type TargetSettings ccv3.TargetSettings @@ -14,7 +14,7 @@ func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) { actor.CloudControllerClient.TargetCF(ccv3.TargetSettings(settings)) - rootInfo, warnings, err := actor.CloudControllerClient.GetInfo() + rootInfo, warnings, err := actor.CloudControllerClient.GetRoot() allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err diff --git a/actor/v7action/target_test.go b/actor/v7action/target_test.go index 54123fd35ce..371bc11ab97 100644 --- a/actor/v7action/target_test.go +++ b/actor/v7action/target_test.go @@ -3,12 +3,12 @@ package v7action_test import ( "errors" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -53,12 +53,12 @@ var _ = Describe("Targeting", func() { var meta struct { Version string `json:"version"` HostKeyFingerprint string `json:"host_key_fingerprint"` - OAuthClient string `json:"oath_client"` + OAuthClient string `json:"oauth_client"` } meta.Version = expectedAPIVersion - rootResponse := ccv3.Info{ - Links: ccv3.InfoLinks{ + rootResponse := ccv3.Root{ + Links: ccv3.RootLinks{ CCV3: resources.APILink{ Meta: meta, }, @@ -76,7 +76,7 @@ var _ = Describe("Targeting", func() { }, }, } - fakeCloudControllerClient.GetInfoReturns(rootResponse, ccv3.Warnings{"info-warning"}, nil) + fakeCloudControllerClient.GetRootReturns(rootResponse, ccv3.Warnings{"info-warning"}, nil) }) JustBeforeEach(func() { @@ -96,7 +96,7 @@ var _ = Describe("Targeting", func() { When("getting root info fails", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns(ccv3.Info{}, ccv3.Warnings{"info-warning"}, errors.New("info-error")) + fakeCloudControllerClient.GetRootReturns(ccv3.Root{}, ccv3.Warnings{"info-warning"}, errors.New("info-error")) }) It("returns an error and all warnings", func() { @@ -145,7 +145,7 @@ var _ = Describe("Targeting", func() { When("deployed on Kubernetes", func() { BeforeEach(func() { - fakeCloudControllerClient.GetInfoReturns(ccv3.Info{CFOnK8s: true}, nil, nil) + fakeCloudControllerClient.GetRootReturns(ccv3.Root{CFOnK8s: true}, nil, nil) }) It("sets the CFOnK8s target information", func() { diff --git a/actor/v7action/task.go b/actor/v7action/task.go index fd255bff205..6355c5649a3 100644 --- a/actor/v7action/task.go +++ b/actor/v7action/task.go @@ -1,14 +1,16 @@ package v7action import ( - "strconv" - "sort" + "strconv" + "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + log "github.com/sirupsen/logrus" ) // Run resources.Task runs the provided command in the application environment associated @@ -25,7 +27,7 @@ func (actor Actor) RunTask(appGUID string, task resources.Task) (resources.Task, } // GetApplicationTasks returns a list of tasks associated with the provided -// appplication GUID. +// application GUID. func (actor Actor) GetApplicationTasks(appGUID string, sortOrder SortOrder) ([]resources.Task, Warnings, error) { tasks, warnings, err := actor.CloudControllerClient.GetApplicationTasks(appGUID) actorWarnings := Warnings(warnings) @@ -51,6 +53,8 @@ func (actor Actor) GetTaskBySequenceIDAndApplication(sequenceID int, appGUID str tasks, warnings, err := actor.CloudControllerClient.GetApplicationTasks( appGUID, ccv3.Query{Key: ccv3.SequenceIDFilter, Values: []string{strconv.Itoa(sequenceID)}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}}, + ccv3.Query{Key: ccv3.Page, Values: []string{"1"}}, ) if err != nil { return resources.Task{}, Warnings(warnings), err @@ -67,3 +71,32 @@ func (actor Actor) TerminateTask(taskGUID string) (resources.Task, Warnings, err task, warnings, err := actor.CloudControllerClient.UpdateTaskCancel(taskGUID) return resources.Task(task), Warnings(warnings), err } + +func (actor Actor) PollTask(task resources.Task) (resources.Task, Warnings, error) { + var allWarnings Warnings + + for task.State != constant.TaskSucceeded && task.State != constant.TaskFailed { + + time.Sleep(actor.Config.PollingInterval()) + + ccTask, warnings, err := actor.CloudControllerClient.GetTask(task.GUID) + log.WithFields(log.Fields{ + "task_guid": task.GUID, + "state": task.State, + }).Debug("polling task state") + + allWarnings = append(allWarnings, warnings...) + + if err != nil { + return resources.Task{}, allWarnings, err + } + + task = resources.Task(ccTask) + } + + if task.State == constant.TaskFailed { + return task, allWarnings, actionerror.TaskFailedError{} + } + + return task, allWarnings, nil +} diff --git a/actor/v7action/task_test.go b/actor/v7action/task_test.go index 612951c72de..67d7dda72f2 100644 --- a/actor/v7action/task_test.go +++ b/actor/v7action/task_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -18,11 +18,13 @@ var _ = Describe("Task Actions", func() { var ( actor *Actor fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient + fakeConfig *v7actionfakes.FakeConfig ) BeforeEach(func() { fakeCloudControllerClient = new(v7actionfakes.FakeCloudControllerClient) - actor = NewActor(fakeCloudControllerClient, nil, nil, nil, nil, nil) + fakeConfig = new(v7actionfakes.FakeConfig) + actor = NewActor(fakeCloudControllerClient, fakeConfig, nil, nil, nil, nil) }) Describe("RunTask", func() { @@ -305,4 +307,63 @@ var _ = Describe("Task Actions", func() { }) }) }) + + Describe("PollTask", func() { + + It("polls for SUCCEDED state", func() { + firstTaskResponse := resources.Task{State: constant.TaskRunning} + secondTaskResponse := resources.Task{State: constant.TaskSucceeded} + + fakeCloudControllerClient.GetTaskReturnsOnCall(0, firstTaskResponse, nil, nil) + fakeCloudControllerClient.GetTaskReturnsOnCall(1, secondTaskResponse, nil, nil) + + task, _, _ := actor.PollTask(resources.Task{}) + + Expect(task.State).To(Equal(constant.TaskSucceeded)) + }) + + It("polls for FAILED state", func() { + firstTaskResponse := resources.Task{State: constant.TaskRunning} + secondTaskResponse := resources.Task{State: constant.TaskFailed} + + fakeCloudControllerClient.GetTaskReturnsOnCall(0, firstTaskResponse, nil, nil) + fakeCloudControllerClient.GetTaskReturnsOnCall(1, secondTaskResponse, nil, nil) + + task, _, _ := actor.PollTask(resources.Task{}) + + Expect(task.State).To(Equal(constant.TaskFailed)) + }) + + It("aggregates warnings from all requests made while polling", func() { + firstTaskResponse := resources.Task{State: constant.TaskRunning} + secondTaskResponse := resources.Task{State: constant.TaskSucceeded} + + fakeCloudControllerClient.GetTaskReturnsOnCall(0, firstTaskResponse, ccv3.Warnings{"warning-1"}, nil) + fakeCloudControllerClient.GetTaskReturnsOnCall(1, secondTaskResponse, ccv3.Warnings{"warning-2"}, nil) + + _, warnings, _ := actor.PollTask(resources.Task{}) + + Expect(warnings).To(ConsistOf("warning-1", "warning-2")) + }) + + It("handles errors from requests to cc", func() { + firstTaskResponse := resources.Task{State: constant.TaskSucceeded} + + fakeCloudControllerClient.GetTaskReturnsOnCall(0, firstTaskResponse, nil, errors.New("request-error")) + + _, _, err := actor.PollTask(resources.Task{}) + + Expect(err).To(MatchError("request-error")) + }) + + It("returns an error if the task failed", func() { + firstTaskResponse := resources.Task{State: constant.TaskFailed} + + fakeCloudControllerClient.GetTaskReturnsOnCall(0, firstTaskResponse, nil, nil) + + _, _, err := actor.PollTask(resources.Task{}) + + Expect(err).To(MatchError("Task failed to complete successfully")) + }) + }) }) diff --git a/actor/v7action/token_test.go b/actor/v7action/token_test.go index 59e0b2bf3f2..5e12794a0cc 100644 --- a/actor/v7action/token_test.go +++ b/actor/v7action/token_test.go @@ -4,11 +4,11 @@ import ( "errors" "time" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/uaa_client.go b/actor/v7action/uaa_client.go index e11903e8d30..8ff711b18ee 100644 --- a/actor/v7action/uaa_client.go +++ b/actor/v7action/uaa_client.go @@ -1,8 +1,8 @@ package v7action import ( - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UAAClient diff --git a/actor/v7action/user.go b/actor/v7action/user.go index ceee43a9d92..eb3db0feed5 100644 --- a/actor/v7action/user.go +++ b/actor/v7action/user.go @@ -3,10 +3,10 @@ package v7action import ( "sort" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateUser creates a new user in UAA and registers it with cloud controller. diff --git a/actor/v7action/user_test.go b/actor/v7action/user_test.go index 64520b2ab76..6b4ac0f38a4 100644 --- a/actor/v7action/user_test.go +++ b/actor/v7action/user_test.go @@ -3,14 +3,14 @@ package v7action_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7action/v7action_suite_test.go b/actor/v7action/v7action_suite_test.go index 675a860f222..0c2b1872a96 100644 --- a/actor/v7action/v7action_suite_test.go +++ b/actor/v7action/v7action_suite_test.go @@ -9,10 +9,10 @@ import ( "testing" "time" - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" "code.cloudfoundry.org/clock/fakeclock" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" ) diff --git a/actor/v7action/v7actionfakes/fake_cloud_controller_client.go b/actor/v7action/v7actionfakes/fake_cloud_controller_client.go index 0c37e114ddf..0add7dcd938 100644 --- a/actor/v7action/v7actionfakes/fake_cloud_controller_client.go +++ b/actor/v7action/v7actionfakes/fake_cloud_controller_client.go @@ -6,11 +6,11 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type FakeCloudControllerClient struct { @@ -77,6 +77,19 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + ContinueDeploymentStub func(string) (ccv3.Warnings, error) + continueDeploymentMutex sync.RWMutex + continueDeploymentArgsForCall []struct { + arg1 string + } + continueDeploymentReturns struct { + result1 ccv3.Warnings + result2 error + } + continueDeploymentReturnsOnCall map[int]struct { + result1 ccv3.Warnings + result2 error + } CopyPackageStub func(string, string) (resources.Package, ccv3.Warnings, error) copyPackageMutex sync.RWMutex copyPackageArgsForCall []struct { @@ -108,11 +121,10 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } - CreateApplicationDeploymentStub func(string, string) (string, ccv3.Warnings, error) + CreateApplicationDeploymentStub func(resources.Deployment) (string, ccv3.Warnings, error) createApplicationDeploymentMutex sync.RWMutex createApplicationDeploymentArgsForCall []struct { - arg1 string - arg2 string + arg1 resources.Deployment } createApplicationDeploymentReturns struct { result1 string @@ -124,22 +136,6 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } - CreateApplicationDeploymentByRevisionStub func(string, string) (string, ccv3.Warnings, error) - createApplicationDeploymentByRevisionMutex sync.RWMutex - createApplicationDeploymentByRevisionArgsForCall []struct { - arg1 string - arg2 string - } - createApplicationDeploymentByRevisionReturns struct { - result1 string - result2 ccv3.Warnings - result3 error - } - createApplicationDeploymentByRevisionReturnsOnCall map[int]struct { - result1 string - result2 ccv3.Warnings - result3 error - } CreateApplicationProcessScaleStub func(string, resources.Process) (resources.Process, ccv3.Warnings, error) createApplicationProcessScaleMutex sync.RWMutex createApplicationProcessScaleArgsForCall []struct { @@ -1105,6 +1101,21 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + GetEnvironmentVariablesByURLStub func(string) (resources.EnvironmentVariables, ccv3.Warnings, error) + getEnvironmentVariablesByURLMutex sync.RWMutex + getEnvironmentVariablesByURLArgsForCall []struct { + arg1 string + } + getEnvironmentVariablesByURLReturns struct { + result1 resources.EnvironmentVariables + result2 ccv3.Warnings + result3 error + } + getEnvironmentVariablesByURLReturnsOnCall map[int]struct { + result1 resources.EnvironmentVariables + result2 ccv3.Warnings + result3 error + } GetEventsStub func(...ccv3.Query) ([]ccv3.Event, ccv3.Warnings, error) getEventsMutex sync.RWMutex getEventsArgsForCall []struct { @@ -1438,6 +1449,20 @@ type FakeCloudControllerClient struct { result3 ccv3.Warnings result4 error } + GetRootStub func() (ccv3.Root, ccv3.Warnings, error) + getRootMutex sync.RWMutex + getRootArgsForCall []struct { + } + getRootReturns struct { + result1 ccv3.Root + result2 ccv3.Warnings + result3 error + } + getRootReturnsOnCall map[int]struct { + result1 ccv3.Root + result2 ccv3.Warnings + result3 error + } GetRouteBindingsStub func(...ccv3.Query) ([]resources.RouteBinding, ccv3.IncludedResources, ccv3.Warnings, error) getRouteBindingsMutex sync.RWMutex getRouteBindingsArgsForCall []struct { @@ -1903,6 +1928,21 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + GetTaskStub func(string) (resources.Task, ccv3.Warnings, error) + getTaskMutex sync.RWMutex + getTaskArgsForCall []struct { + arg1 string + } + getTaskReturns struct { + result1 resources.Task + result2 ccv3.Warnings + result3 error + } + getTaskReturnsOnCall map[int]struct { + result1 resources.Task + result2 ccv3.Warnings + result3 error + } GetUserStub func(string) (resources.User, ccv3.Warnings, error) getUserMutex sync.RWMutex getUserArgsForCall []struct { @@ -1966,6 +2006,20 @@ type FakeCloudControllerClient struct { result1 ccv3.Warnings result2 error } + MoveRouteStub func(string, string) (ccv3.Warnings, error) + moveRouteMutex sync.RWMutex + moveRouteArgsForCall []struct { + arg1 string + arg2 string + } + moveRouteReturns struct { + result1 ccv3.Warnings + result2 error + } + moveRouteReturnsOnCall map[int]struct { + result1 ccv3.Warnings + result2 error + } PollJobStub func(ccv3.JobURL) (ccv3.Warnings, error) pollJobMutex sync.RWMutex pollJobArgsForCall []struct { @@ -2032,17 +2086,17 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } - RootResponseStub func() (ccv3.Info, ccv3.Warnings, error) + RootResponseStub func() (ccv3.Root, ccv3.Warnings, error) rootResponseMutex sync.RWMutex rootResponseArgsForCall []struct { } rootResponseReturns struct { - result1 ccv3.Info + result1 ccv3.Root result2 ccv3.Warnings result3 error } rootResponseReturnsOnCall map[int]struct { - result1 ccv3.Info + result1 ccv3.Root result2 ccv3.Warnings result3 error } @@ -2076,6 +2130,20 @@ type FakeCloudControllerClient struct { result1 ccv3.Warnings result2 error } + ShareRouteStub func(string, string) (ccv3.Warnings, error) + shareRouteMutex sync.RWMutex + shareRouteArgsForCall []struct { + arg1 string + arg2 string + } + shareRouteReturns struct { + result1 ccv3.Warnings + result2 error + } + shareRouteReturnsOnCall map[int]struct { + result1 ccv3.Warnings + result2 error + } ShareServiceInstanceToSpacesStub func(string, []string) (resources.RelationshipList, ccv3.Warnings, error) shareServiceInstanceToSpacesMutex sync.RWMutex shareServiceInstanceToSpacesArgsForCall []struct { @@ -2167,6 +2235,20 @@ type FakeCloudControllerClient struct { result1 ccv3.Warnings result2 error } + UnshareRouteStub func(string, string) (ccv3.Warnings, error) + unshareRouteMutex sync.RWMutex + unshareRouteArgsForCall []struct { + arg1 string + arg2 string + } + unshareRouteReturns struct { + result1 ccv3.Warnings + result2 error + } + unshareRouteReturnsOnCall map[int]struct { + result1 ccv3.Warnings + result2 error + } UnshareServiceInstanceFromSpaceStub func(string, string) (ccv3.Warnings, error) unshareServiceInstanceFromSpaceMutex sync.RWMutex unshareServiceInstanceFromSpaceArgsForCall []struct { @@ -2243,6 +2325,22 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + UpdateApplicationNameStub func(string, string) (resources.Application, ccv3.Warnings, error) + updateApplicationNameMutex sync.RWMutex + updateApplicationNameArgsForCall []struct { + arg1 string + arg2 string + } + updateApplicationNameReturns struct { + result1 resources.Application + result2 ccv3.Warnings + result3 error + } + updateApplicationNameReturnsOnCall map[int]struct { + result1 resources.Application + result2 ccv3.Warnings + result3 error + } UpdateApplicationRestartStub func(string) (resources.Application, ccv3.Warnings, error) updateApplicationRestartMutex sync.RWMutex updateApplicationRestartArgsForCall []struct { @@ -2303,6 +2401,21 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + UpdateDestinationStub func(string, string, string) (ccv3.Warnings, error) + updateDestinationMutex sync.RWMutex + updateDestinationArgsForCall []struct { + arg1 string + arg2 string + arg3 string + } + updateDestinationReturns struct { + result1 ccv3.Warnings + result2 error + } + updateDestinationReturnsOnCall map[int]struct { + result1 ccv3.Warnings + result2 error + } UpdateEnvironmentVariableGroupStub func(constant.EnvironmentVariableGroupName, resources.EnvironmentVariables) (resources.EnvironmentVariables, ccv3.Warnings, error) updateEnvironmentVariableGroupMutex sync.RWMutex updateEnvironmentVariableGroupArgsForCall []struct { @@ -2412,6 +2525,22 @@ type FakeCloudControllerClient struct { result2 ccv3.Warnings result3 error } + UpdateRouteStub func(string, map[string]*string) (resources.Route, ccv3.Warnings, error) + updateRouteMutex sync.RWMutex + updateRouteArgsForCall []struct { + arg1 string + arg2 map[string]*string + } + updateRouteReturns struct { + result1 resources.Route + result2 ccv3.Warnings + result3 error + } + updateRouteReturnsOnCall map[int]struct { + result1 resources.Route + result2 ccv3.Warnings + result3 error + } UpdateSecurityGroupStub func(resources.SecurityGroup) (resources.SecurityGroup, ccv3.Warnings, error) updateSecurityGroupMutex sync.RWMutex updateSecurityGroupArgsForCall []struct { @@ -2690,15 +2819,16 @@ func (fake *FakeCloudControllerClient) ApplyOrganizationQuota(arg1 string, arg2 arg1 string arg2 string }{arg1, arg2}) + stub := fake.ApplyOrganizationQuotaStub + fakeReturns := fake.applyOrganizationQuotaReturns fake.recordInvocation("ApplyOrganizationQuota", []interface{}{arg1, arg2}) fake.applyOrganizationQuotaMutex.Unlock() - if fake.ApplyOrganizationQuotaStub != nil { - return fake.ApplyOrganizationQuotaStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.applyOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2757,15 +2887,16 @@ func (fake *FakeCloudControllerClient) ApplySpaceQuota(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.ApplySpaceQuotaStub + fakeReturns := fake.applySpaceQuotaReturns fake.recordInvocation("ApplySpaceQuota", []interface{}{arg1, arg2}) fake.applySpaceQuotaMutex.Unlock() - if fake.ApplySpaceQuotaStub != nil { - return fake.ApplySpaceQuotaStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.applySpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2823,15 +2954,16 @@ func (fake *FakeCloudControllerClient) CancelDeployment(arg1 string) (ccv3.Warni fake.cancelDeploymentArgsForCall = append(fake.cancelDeploymentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CancelDeploymentStub + fakeReturns := fake.cancelDeploymentReturns fake.recordInvocation("CancelDeployment", []interface{}{arg1}) fake.cancelDeploymentMutex.Unlock() - if fake.CancelDeploymentStub != nil { - return fake.CancelDeploymentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.cancelDeploymentReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2889,15 +3021,16 @@ func (fake *FakeCloudControllerClient) CheckRoute(arg1 string, arg2 string, arg3 arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.CheckRouteStub + fakeReturns := fake.checkRouteReturns fake.recordInvocation("CheckRoute", []interface{}{arg1, arg2, arg3, arg4}) fake.checkRouteMutex.Unlock() - if fake.CheckRouteStub != nil { - return fake.CheckRouteStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.checkRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2949,6 +3082,70 @@ func (fake *FakeCloudControllerClient) CheckRouteReturnsOnCall(i int, result1 bo }{result1, result2, result3} } +func (fake *FakeCloudControllerClient) ContinueDeployment(arg1 string) (ccv3.Warnings, error) { + fake.continueDeploymentMutex.Lock() + ret, specificReturn := fake.continueDeploymentReturnsOnCall[len(fake.continueDeploymentArgsForCall)] + fake.continueDeploymentArgsForCall = append(fake.continueDeploymentArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.ContinueDeploymentStub + fakeReturns := fake.continueDeploymentReturns + fake.recordInvocation("ContinueDeployment", []interface{}{arg1}) + fake.continueDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCloudControllerClient) ContinueDeploymentCallCount() int { + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() + return len(fake.continueDeploymentArgsForCall) +} + +func (fake *FakeCloudControllerClient) ContinueDeploymentCalls(stub func(string) (ccv3.Warnings, error)) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = stub +} + +func (fake *FakeCloudControllerClient) ContinueDeploymentArgsForCall(i int) string { + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() + argsForCall := fake.continueDeploymentArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeCloudControllerClient) ContinueDeploymentReturns(result1 ccv3.Warnings, result2 error) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = nil + fake.continueDeploymentReturns = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeCloudControllerClient) ContinueDeploymentReturnsOnCall(i int, result1 ccv3.Warnings, result2 error) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = nil + if fake.continueDeploymentReturnsOnCall == nil { + fake.continueDeploymentReturnsOnCall = make(map[int]struct { + result1 ccv3.Warnings + result2 error + }) + } + fake.continueDeploymentReturnsOnCall[i] = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeCloudControllerClient) CopyPackage(arg1 string, arg2 string) (resources.Package, ccv3.Warnings, error) { fake.copyPackageMutex.Lock() ret, specificReturn := fake.copyPackageReturnsOnCall[len(fake.copyPackageArgsForCall)] @@ -2956,15 +3153,16 @@ func (fake *FakeCloudControllerClient) CopyPackage(arg1 string, arg2 string) (re arg1 string arg2 string }{arg1, arg2}) + stub := fake.CopyPackageStub + fakeReturns := fake.copyPackageReturns fake.recordInvocation("CopyPackage", []interface{}{arg1, arg2}) fake.copyPackageMutex.Unlock() - if fake.CopyPackageStub != nil { - return fake.CopyPackageStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.copyPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3022,15 +3220,16 @@ func (fake *FakeCloudControllerClient) CreateApplication(arg1 resources.Applicat fake.createApplicationArgsForCall = append(fake.createApplicationArgsForCall, struct { arg1 resources.Application }{arg1}) + stub := fake.CreateApplicationStub + fakeReturns := fake.createApplicationReturns fake.recordInvocation("CreateApplication", []interface{}{arg1}) fake.createApplicationMutex.Unlock() - if fake.CreateApplicationStub != nil { - return fake.CreateApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3082,22 +3281,22 @@ func (fake *FakeCloudControllerClient) CreateApplicationReturnsOnCall(i int, res }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) CreateApplicationDeployment(arg1 string, arg2 string) (string, ccv3.Warnings, error) { +func (fake *FakeCloudControllerClient) CreateApplicationDeployment(arg1 resources.Deployment) (string, ccv3.Warnings, error) { fake.createApplicationDeploymentMutex.Lock() ret, specificReturn := fake.createApplicationDeploymentReturnsOnCall[len(fake.createApplicationDeploymentArgsForCall)] fake.createApplicationDeploymentArgsForCall = append(fake.createApplicationDeploymentArgsForCall, struct { - arg1 string - arg2 string - }{arg1, arg2}) - fake.recordInvocation("CreateApplicationDeployment", []interface{}{arg1, arg2}) + arg1 resources.Deployment + }{arg1}) + stub := fake.CreateApplicationDeploymentStub + fakeReturns := fake.createApplicationDeploymentReturns + fake.recordInvocation("CreateApplicationDeployment", []interface{}{arg1}) fake.createApplicationDeploymentMutex.Unlock() - if fake.CreateApplicationDeploymentStub != nil { - return fake.CreateApplicationDeploymentStub(arg1, arg2) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationDeploymentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3107,17 +3306,17 @@ func (fake *FakeCloudControllerClient) CreateApplicationDeploymentCallCount() in return len(fake.createApplicationDeploymentArgsForCall) } -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentCalls(stub func(string, string) (string, ccv3.Warnings, error)) { +func (fake *FakeCloudControllerClient) CreateApplicationDeploymentCalls(stub func(resources.Deployment) (string, ccv3.Warnings, error)) { fake.createApplicationDeploymentMutex.Lock() defer fake.createApplicationDeploymentMutex.Unlock() fake.CreateApplicationDeploymentStub = stub } -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentArgsForCall(i int) (string, string) { +func (fake *FakeCloudControllerClient) CreateApplicationDeploymentArgsForCall(i int) resources.Deployment { fake.createApplicationDeploymentMutex.RLock() defer fake.createApplicationDeploymentMutex.RUnlock() argsForCall := fake.createApplicationDeploymentArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1 } func (fake *FakeCloudControllerClient) CreateApplicationDeploymentReturns(result1 string, result2 ccv3.Warnings, result3 error) { @@ -3149,73 +3348,6 @@ func (fake *FakeCloudControllerClient) CreateApplicationDeploymentReturnsOnCall( }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevision(arg1 string, arg2 string) (string, ccv3.Warnings, error) { - fake.createApplicationDeploymentByRevisionMutex.Lock() - ret, specificReturn := fake.createApplicationDeploymentByRevisionReturnsOnCall[len(fake.createApplicationDeploymentByRevisionArgsForCall)] - fake.createApplicationDeploymentByRevisionArgsForCall = append(fake.createApplicationDeploymentByRevisionArgsForCall, struct { - arg1 string - arg2 string - }{arg1, arg2}) - fake.recordInvocation("CreateApplicationDeploymentByRevision", []interface{}{arg1, arg2}) - fake.createApplicationDeploymentByRevisionMutex.Unlock() - if fake.CreateApplicationDeploymentByRevisionStub != nil { - return fake.CreateApplicationDeploymentByRevisionStub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - fakeReturns := fake.createApplicationDeploymentByRevisionReturns - return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 -} - -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevisionCallCount() int { - fake.createApplicationDeploymentByRevisionMutex.RLock() - defer fake.createApplicationDeploymentByRevisionMutex.RUnlock() - return len(fake.createApplicationDeploymentByRevisionArgsForCall) -} - -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevisionCalls(stub func(string, string) (string, ccv3.Warnings, error)) { - fake.createApplicationDeploymentByRevisionMutex.Lock() - defer fake.createApplicationDeploymentByRevisionMutex.Unlock() - fake.CreateApplicationDeploymentByRevisionStub = stub -} - -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevisionArgsForCall(i int) (string, string) { - fake.createApplicationDeploymentByRevisionMutex.RLock() - defer fake.createApplicationDeploymentByRevisionMutex.RUnlock() - argsForCall := fake.createApplicationDeploymentByRevisionArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevisionReturns(result1 string, result2 ccv3.Warnings, result3 error) { - fake.createApplicationDeploymentByRevisionMutex.Lock() - defer fake.createApplicationDeploymentByRevisionMutex.Unlock() - fake.CreateApplicationDeploymentByRevisionStub = nil - fake.createApplicationDeploymentByRevisionReturns = struct { - result1 string - result2 ccv3.Warnings - result3 error - }{result1, result2, result3} -} - -func (fake *FakeCloudControllerClient) CreateApplicationDeploymentByRevisionReturnsOnCall(i int, result1 string, result2 ccv3.Warnings, result3 error) { - fake.createApplicationDeploymentByRevisionMutex.Lock() - defer fake.createApplicationDeploymentByRevisionMutex.Unlock() - fake.CreateApplicationDeploymentByRevisionStub = nil - if fake.createApplicationDeploymentByRevisionReturnsOnCall == nil { - fake.createApplicationDeploymentByRevisionReturnsOnCall = make(map[int]struct { - result1 string - result2 ccv3.Warnings - result3 error - }) - } - fake.createApplicationDeploymentByRevisionReturnsOnCall[i] = struct { - result1 string - result2 ccv3.Warnings - result3 error - }{result1, result2, result3} -} - func (fake *FakeCloudControllerClient) CreateApplicationProcessScale(arg1 string, arg2 resources.Process) (resources.Process, ccv3.Warnings, error) { fake.createApplicationProcessScaleMutex.Lock() ret, specificReturn := fake.createApplicationProcessScaleReturnsOnCall[len(fake.createApplicationProcessScaleArgsForCall)] @@ -3223,15 +3355,16 @@ func (fake *FakeCloudControllerClient) CreateApplicationProcessScale(arg1 string arg1 string arg2 resources.Process }{arg1, arg2}) + stub := fake.CreateApplicationProcessScaleStub + fakeReturns := fake.createApplicationProcessScaleReturns fake.recordInvocation("CreateApplicationProcessScale", []interface{}{arg1, arg2}) fake.createApplicationProcessScaleMutex.Unlock() - if fake.CreateApplicationProcessScaleStub != nil { - return fake.CreateApplicationProcessScaleStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationProcessScaleReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3290,15 +3423,16 @@ func (fake *FakeCloudControllerClient) CreateApplicationTask(arg1 string, arg2 r arg1 string arg2 resources.Task }{arg1, arg2}) + stub := fake.CreateApplicationTaskStub + fakeReturns := fake.createApplicationTaskReturns fake.recordInvocation("CreateApplicationTask", []interface{}{arg1, arg2}) fake.createApplicationTaskMutex.Unlock() - if fake.CreateApplicationTaskStub != nil { - return fake.CreateApplicationTaskStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationTaskReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3356,15 +3490,16 @@ func (fake *FakeCloudControllerClient) CreateBuild(arg1 resources.Build) (resour fake.createBuildArgsForCall = append(fake.createBuildArgsForCall, struct { arg1 resources.Build }{arg1}) + stub := fake.CreateBuildStub + fakeReturns := fake.createBuildReturns fake.recordInvocation("CreateBuild", []interface{}{arg1}) fake.createBuildMutex.Unlock() - if fake.CreateBuildStub != nil { - return fake.CreateBuildStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBuildReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3422,15 +3557,16 @@ func (fake *FakeCloudControllerClient) CreateBuildpack(arg1 resources.Buildpack) fake.createBuildpackArgsForCall = append(fake.createBuildpackArgsForCall, struct { arg1 resources.Buildpack }{arg1}) + stub := fake.CreateBuildpackStub + fakeReturns := fake.createBuildpackReturns fake.recordInvocation("CreateBuildpack", []interface{}{arg1}) fake.createBuildpackMutex.Unlock() - if fake.CreateBuildpackStub != nil { - return fake.CreateBuildpackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3488,15 +3624,16 @@ func (fake *FakeCloudControllerClient) CreateDomain(arg1 resources.Domain) (reso fake.createDomainArgsForCall = append(fake.createDomainArgsForCall, struct { arg1 resources.Domain }{arg1}) + stub := fake.CreateDomainStub + fakeReturns := fake.createDomainReturns fake.recordInvocation("CreateDomain", []interface{}{arg1}) fake.createDomainMutex.Unlock() - if fake.CreateDomainStub != nil { - return fake.CreateDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3554,15 +3691,16 @@ func (fake *FakeCloudControllerClient) CreateDroplet(arg1 string) (resources.Dro fake.createDropletArgsForCall = append(fake.createDropletArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateDropletStub + fakeReturns := fake.createDropletReturns fake.recordInvocation("CreateDroplet", []interface{}{arg1}) fake.createDropletMutex.Unlock() - if fake.CreateDropletStub != nil { - return fake.CreateDropletStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3620,15 +3758,16 @@ func (fake *FakeCloudControllerClient) CreateIsolationSegment(arg1 resources.Iso fake.createIsolationSegmentArgsForCall = append(fake.createIsolationSegmentArgsForCall, struct { arg1 resources.IsolationSegment }{arg1}) + stub := fake.CreateIsolationSegmentStub + fakeReturns := fake.createIsolationSegmentReturns fake.recordInvocation("CreateIsolationSegment", []interface{}{arg1}) fake.createIsolationSegmentMutex.Unlock() - if fake.CreateIsolationSegmentStub != nil { - return fake.CreateIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3686,15 +3825,16 @@ func (fake *FakeCloudControllerClient) CreateOrganization(arg1 string) (resource fake.createOrganizationArgsForCall = append(fake.createOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateOrganizationStub + fakeReturns := fake.createOrganizationReturns fake.recordInvocation("CreateOrganization", []interface{}{arg1}) fake.createOrganizationMutex.Unlock() - if fake.CreateOrganizationStub != nil { - return fake.CreateOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3752,15 +3892,16 @@ func (fake *FakeCloudControllerClient) CreateOrganizationQuota(arg1 resources.Or fake.createOrganizationQuotaArgsForCall = append(fake.createOrganizationQuotaArgsForCall, struct { arg1 resources.OrganizationQuota }{arg1}) + stub := fake.CreateOrganizationQuotaStub + fakeReturns := fake.createOrganizationQuotaReturns fake.recordInvocation("CreateOrganizationQuota", []interface{}{arg1}) fake.createOrganizationQuotaMutex.Unlock() - if fake.CreateOrganizationQuotaStub != nil { - return fake.CreateOrganizationQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3818,15 +3959,16 @@ func (fake *FakeCloudControllerClient) CreatePackage(arg1 resources.Package) (re fake.createPackageArgsForCall = append(fake.createPackageArgsForCall, struct { arg1 resources.Package }{arg1}) + stub := fake.CreatePackageStub + fakeReturns := fake.createPackageReturns fake.recordInvocation("CreatePackage", []interface{}{arg1}) fake.createPackageMutex.Unlock() - if fake.CreatePackageStub != nil { - return fake.CreatePackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3884,15 +4026,16 @@ func (fake *FakeCloudControllerClient) CreateRole(arg1 resources.Role) (resource fake.createRoleArgsForCall = append(fake.createRoleArgsForCall, struct { arg1 resources.Role }{arg1}) + stub := fake.CreateRoleStub + fakeReturns := fake.createRoleReturns fake.recordInvocation("CreateRole", []interface{}{arg1}) fake.createRoleMutex.Unlock() - if fake.CreateRoleStub != nil { - return fake.CreateRoleStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRoleReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -3950,15 +4093,16 @@ func (fake *FakeCloudControllerClient) CreateRoute(arg1 resources.Route) (resour fake.createRouteArgsForCall = append(fake.createRouteArgsForCall, struct { arg1 resources.Route }{arg1}) + stub := fake.CreateRouteStub + fakeReturns := fake.createRouteReturns fake.recordInvocation("CreateRoute", []interface{}{arg1}) fake.createRouteMutex.Unlock() - if fake.CreateRouteStub != nil { - return fake.CreateRouteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4016,15 +4160,16 @@ func (fake *FakeCloudControllerClient) CreateRouteBinding(arg1 resources.RouteBi fake.createRouteBindingArgsForCall = append(fake.createRouteBindingArgsForCall, struct { arg1 resources.RouteBinding }{arg1}) + stub := fake.CreateRouteBindingStub + fakeReturns := fake.createRouteBindingReturns fake.recordInvocation("CreateRouteBinding", []interface{}{arg1}) fake.createRouteBindingMutex.Unlock() - if fake.CreateRouteBindingStub != nil { - return fake.CreateRouteBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRouteBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4082,15 +4227,16 @@ func (fake *FakeCloudControllerClient) CreateSecurityGroup(arg1 resources.Securi fake.createSecurityGroupArgsForCall = append(fake.createSecurityGroupArgsForCall, struct { arg1 resources.SecurityGroup }{arg1}) + stub := fake.CreateSecurityGroupStub + fakeReturns := fake.createSecurityGroupReturns fake.recordInvocation("CreateSecurityGroup", []interface{}{arg1}) fake.createSecurityGroupMutex.Unlock() - if fake.CreateSecurityGroupStub != nil { - return fake.CreateSecurityGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4148,15 +4294,16 @@ func (fake *FakeCloudControllerClient) CreateServiceBroker(arg1 resources.Servic fake.createServiceBrokerArgsForCall = append(fake.createServiceBrokerArgsForCall, struct { arg1 resources.ServiceBroker }{arg1}) + stub := fake.CreateServiceBrokerStub + fakeReturns := fake.createServiceBrokerReturns fake.recordInvocation("CreateServiceBroker", []interface{}{arg1}) fake.createServiceBrokerMutex.Unlock() - if fake.CreateServiceBrokerStub != nil { - return fake.CreateServiceBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4214,15 +4361,16 @@ func (fake *FakeCloudControllerClient) CreateServiceCredentialBinding(arg1 resou fake.createServiceCredentialBindingArgsForCall = append(fake.createServiceCredentialBindingArgsForCall, struct { arg1 resources.ServiceCredentialBinding }{arg1}) + stub := fake.CreateServiceCredentialBindingStub + fakeReturns := fake.createServiceCredentialBindingReturns fake.recordInvocation("CreateServiceCredentialBinding", []interface{}{arg1}) fake.createServiceCredentialBindingMutex.Unlock() - if fake.CreateServiceCredentialBindingStub != nil { - return fake.CreateServiceCredentialBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createServiceCredentialBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4280,15 +4428,16 @@ func (fake *FakeCloudControllerClient) CreateServiceInstance(arg1 resources.Serv fake.createServiceInstanceArgsForCall = append(fake.createServiceInstanceArgsForCall, struct { arg1 resources.ServiceInstance }{arg1}) + stub := fake.CreateServiceInstanceStub + fakeReturns := fake.createServiceInstanceReturns fake.recordInvocation("CreateServiceInstance", []interface{}{arg1}) fake.createServiceInstanceMutex.Unlock() - if fake.CreateServiceInstanceStub != nil { - return fake.CreateServiceInstanceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4346,15 +4495,16 @@ func (fake *FakeCloudControllerClient) CreateSpace(arg1 resources.Space) (resour fake.createSpaceArgsForCall = append(fake.createSpaceArgsForCall, struct { arg1 resources.Space }{arg1}) + stub := fake.CreateSpaceStub + fakeReturns := fake.createSpaceReturns fake.recordInvocation("CreateSpace", []interface{}{arg1}) fake.createSpaceMutex.Unlock() - if fake.CreateSpaceStub != nil { - return fake.CreateSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4412,15 +4562,16 @@ func (fake *FakeCloudControllerClient) CreateSpaceQuota(arg1 resources.SpaceQuot fake.createSpaceQuotaArgsForCall = append(fake.createSpaceQuotaArgsForCall, struct { arg1 resources.SpaceQuota }{arg1}) + stub := fake.CreateSpaceQuotaStub + fakeReturns := fake.createSpaceQuotaReturns fake.recordInvocation("CreateSpaceQuota", []interface{}{arg1}) fake.createSpaceQuotaMutex.Unlock() - if fake.CreateSpaceQuotaStub != nil { - return fake.CreateSpaceQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4478,15 +4629,16 @@ func (fake *FakeCloudControllerClient) CreateUser(arg1 string) (resources.User, fake.createUserArgsForCall = append(fake.createUserArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateUserStub + fakeReturns := fake.createUserReturns fake.recordInvocation("CreateUser", []interface{}{arg1}) fake.createUserMutex.Unlock() - if fake.CreateUserStub != nil { - return fake.CreateUserStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createUserReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4544,15 +4696,16 @@ func (fake *FakeCloudControllerClient) DeleteApplication(arg1 string) (ccv3.JobU fake.deleteApplicationArgsForCall = append(fake.deleteApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteApplicationStub + fakeReturns := fake.deleteApplicationReturns fake.recordInvocation("DeleteApplication", []interface{}{arg1}) fake.deleteApplicationMutex.Unlock() - if fake.DeleteApplicationStub != nil { - return fake.DeleteApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4612,15 +4765,16 @@ func (fake *FakeCloudControllerClient) DeleteApplicationProcessInstance(arg1 str arg2 string arg3 int }{arg1, arg2, arg3}) + stub := fake.DeleteApplicationProcessInstanceStub + fakeReturns := fake.deleteApplicationProcessInstanceReturns fake.recordInvocation("DeleteApplicationProcessInstance", []interface{}{arg1, arg2, arg3}) fake.deleteApplicationProcessInstanceMutex.Unlock() - if fake.DeleteApplicationProcessInstanceStub != nil { - return fake.DeleteApplicationProcessInstanceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteApplicationProcessInstanceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -4675,15 +4829,16 @@ func (fake *FakeCloudControllerClient) DeleteBuildpack(arg1 string) (ccv3.JobURL fake.deleteBuildpackArgsForCall = append(fake.deleteBuildpackArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteBuildpackStub + fakeReturns := fake.deleteBuildpackReturns fake.recordInvocation("DeleteBuildpack", []interface{}{arg1}) fake.deleteBuildpackMutex.Unlock() - if fake.DeleteBuildpackStub != nil { - return fake.DeleteBuildpackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4741,15 +4896,16 @@ func (fake *FakeCloudControllerClient) DeleteDomain(arg1 string) (ccv3.JobURL, c fake.deleteDomainArgsForCall = append(fake.deleteDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteDomainStub + fakeReturns := fake.deleteDomainReturns fake.recordInvocation("DeleteDomain", []interface{}{arg1}) fake.deleteDomainMutex.Unlock() - if fake.DeleteDomainStub != nil { - return fake.DeleteDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4807,15 +4963,16 @@ func (fake *FakeCloudControllerClient) DeleteIsolationSegment(arg1 string) (ccv3 fake.deleteIsolationSegmentArgsForCall = append(fake.deleteIsolationSegmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteIsolationSegmentStub + fakeReturns := fake.deleteIsolationSegmentReturns fake.recordInvocation("DeleteIsolationSegment", []interface{}{arg1}) fake.deleteIsolationSegmentMutex.Unlock() - if fake.DeleteIsolationSegmentStub != nil { - return fake.DeleteIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2 } @@ -4871,15 +5028,16 @@ func (fake *FakeCloudControllerClient) DeleteIsolationSegmentOrganization(arg1 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteIsolationSegmentOrganizationStub + fakeReturns := fake.deleteIsolationSegmentOrganizationReturns fake.recordInvocation("DeleteIsolationSegmentOrganization", []interface{}{arg1, arg2}) fake.deleteIsolationSegmentOrganizationMutex.Unlock() - if fake.DeleteIsolationSegmentOrganizationStub != nil { - return fake.DeleteIsolationSegmentOrganizationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteIsolationSegmentOrganizationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -4934,15 +5092,16 @@ func (fake *FakeCloudControllerClient) DeleteOrganization(arg1 string) (ccv3.Job fake.deleteOrganizationArgsForCall = append(fake.deleteOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrganizationStub + fakeReturns := fake.deleteOrganizationReturns fake.recordInvocation("DeleteOrganization", []interface{}{arg1}) fake.deleteOrganizationMutex.Unlock() - if fake.DeleteOrganizationStub != nil { - return fake.DeleteOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5000,15 +5159,16 @@ func (fake *FakeCloudControllerClient) DeleteOrganizationQuota(arg1 string) (ccv fake.deleteOrganizationQuotaArgsForCall = append(fake.deleteOrganizationQuotaArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrganizationQuotaStub + fakeReturns := fake.deleteOrganizationQuotaReturns fake.recordInvocation("DeleteOrganizationQuota", []interface{}{arg1}) fake.deleteOrganizationQuotaMutex.Unlock() - if fake.DeleteOrganizationQuotaStub != nil { - return fake.DeleteOrganizationQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5066,15 +5226,16 @@ func (fake *FakeCloudControllerClient) DeleteOrphanedRoutes(arg1 string) (ccv3.J fake.deleteOrphanedRoutesArgsForCall = append(fake.deleteOrphanedRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrphanedRoutesStub + fakeReturns := fake.deleteOrphanedRoutesReturns fake.recordInvocation("DeleteOrphanedRoutes", []interface{}{arg1}) fake.deleteOrphanedRoutesMutex.Unlock() - if fake.DeleteOrphanedRoutesStub != nil { - return fake.DeleteOrphanedRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteOrphanedRoutesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5132,15 +5293,16 @@ func (fake *FakeCloudControllerClient) DeleteRole(arg1 string) (ccv3.JobURL, ccv fake.deleteRoleArgsForCall = append(fake.deleteRoleArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteRoleStub + fakeReturns := fake.deleteRoleReturns fake.recordInvocation("DeleteRole", []interface{}{arg1}) fake.deleteRoleMutex.Unlock() - if fake.DeleteRoleStub != nil { - return fake.DeleteRoleStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteRoleReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5198,15 +5360,16 @@ func (fake *FakeCloudControllerClient) DeleteRoute(arg1 string) (ccv3.JobURL, cc fake.deleteRouteArgsForCall = append(fake.deleteRouteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteRouteStub + fakeReturns := fake.deleteRouteReturns fake.recordInvocation("DeleteRoute", []interface{}{arg1}) fake.deleteRouteMutex.Unlock() - if fake.DeleteRouteStub != nil { - return fake.DeleteRouteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5264,15 +5427,16 @@ func (fake *FakeCloudControllerClient) DeleteRouteBinding(arg1 string) (ccv3.Job fake.deleteRouteBindingArgsForCall = append(fake.deleteRouteBindingArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteRouteBindingStub + fakeReturns := fake.deleteRouteBindingReturns fake.recordInvocation("DeleteRouteBinding", []interface{}{arg1}) fake.deleteRouteBindingMutex.Unlock() - if fake.DeleteRouteBindingStub != nil { - return fake.DeleteRouteBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteRouteBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5330,15 +5494,16 @@ func (fake *FakeCloudControllerClient) DeleteSecurityGroup(arg1 string) (ccv3.Jo fake.deleteSecurityGroupArgsForCall = append(fake.deleteSecurityGroupArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteSecurityGroupStub + fakeReturns := fake.deleteSecurityGroupReturns fake.recordInvocation("DeleteSecurityGroup", []interface{}{arg1}) fake.deleteSecurityGroupMutex.Unlock() - if fake.DeleteSecurityGroupStub != nil { - return fake.DeleteSecurityGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5396,15 +5561,16 @@ func (fake *FakeCloudControllerClient) DeleteServiceBroker(arg1 string) (ccv3.Jo fake.deleteServiceBrokerArgsForCall = append(fake.deleteServiceBrokerArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteServiceBrokerStub + fakeReturns := fake.deleteServiceBrokerReturns fake.recordInvocation("DeleteServiceBroker", []interface{}{arg1}) fake.deleteServiceBrokerMutex.Unlock() - if fake.DeleteServiceBrokerStub != nil { - return fake.DeleteServiceBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5462,15 +5628,16 @@ func (fake *FakeCloudControllerClient) DeleteServiceCredentialBinding(arg1 strin fake.deleteServiceCredentialBindingArgsForCall = append(fake.deleteServiceCredentialBindingArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteServiceCredentialBindingStub + fakeReturns := fake.deleteServiceCredentialBindingReturns fake.recordInvocation("DeleteServiceCredentialBinding", []interface{}{arg1}) fake.deleteServiceCredentialBindingMutex.Unlock() - if fake.DeleteServiceCredentialBindingStub != nil { - return fake.DeleteServiceCredentialBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceCredentialBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5529,15 +5696,16 @@ func (fake *FakeCloudControllerClient) DeleteServiceInstance(arg1 string, arg2 . arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.DeleteServiceInstanceStub + fakeReturns := fake.deleteServiceInstanceReturns fake.recordInvocation("DeleteServiceInstance", []interface{}{arg1, arg2}) fake.deleteServiceInstanceMutex.Unlock() - if fake.DeleteServiceInstanceStub != nil { - return fake.DeleteServiceInstanceStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5596,15 +5764,16 @@ func (fake *FakeCloudControllerClient) DeleteServicePlanVisibility(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteServicePlanVisibilityStub + fakeReturns := fake.deleteServicePlanVisibilityReturns fake.recordInvocation("DeleteServicePlanVisibility", []interface{}{arg1, arg2}) fake.deleteServicePlanVisibilityMutex.Unlock() - if fake.DeleteServicePlanVisibilityStub != nil { - return fake.DeleteServicePlanVisibilityStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteServicePlanVisibilityReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5659,15 +5828,16 @@ func (fake *FakeCloudControllerClient) DeleteSpace(arg1 string) (ccv3.JobURL, cc fake.deleteSpaceArgsForCall = append(fake.deleteSpaceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteSpaceStub + fakeReturns := fake.deleteSpaceReturns fake.recordInvocation("DeleteSpace", []interface{}{arg1}) fake.deleteSpaceMutex.Unlock() - if fake.DeleteSpaceStub != nil { - return fake.DeleteSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5725,15 +5895,16 @@ func (fake *FakeCloudControllerClient) DeleteSpaceQuota(arg1 string) (ccv3.JobUR fake.deleteSpaceQuotaArgsForCall = append(fake.deleteSpaceQuotaArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteSpaceQuotaStub + fakeReturns := fake.deleteSpaceQuotaReturns fake.recordInvocation("DeleteSpaceQuota", []interface{}{arg1}) fake.deleteSpaceQuotaMutex.Unlock() - if fake.DeleteSpaceQuotaStub != nil { - return fake.DeleteSpaceQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5791,15 +5962,16 @@ func (fake *FakeCloudControllerClient) DeleteUser(arg1 string) (ccv3.JobURL, ccv fake.deleteUserArgsForCall = append(fake.deleteUserArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteUserStub + fakeReturns := fake.deleteUserReturns fake.recordInvocation("DeleteUser", []interface{}{arg1}) fake.deleteUserMutex.Unlock() - if fake.DeleteUserStub != nil { - return fake.DeleteUserStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteUserReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5857,15 +6029,16 @@ func (fake *FakeCloudControllerClient) DownloadDroplet(arg1 string) ([]byte, ccv fake.downloadDropletArgsForCall = append(fake.downloadDropletArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DownloadDropletStub + fakeReturns := fake.downloadDropletReturns fake.recordInvocation("DownloadDroplet", []interface{}{arg1}) fake.downloadDropletMutex.Unlock() - if fake.DownloadDropletStub != nil { - return fake.DownloadDropletStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.downloadDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5929,15 +6102,16 @@ func (fake *FakeCloudControllerClient) EntitleIsolationSegmentToOrganizations(ar arg1 string arg2 []string }{arg1, arg2Copy}) + stub := fake.EntitleIsolationSegmentToOrganizationsStub + fakeReturns := fake.entitleIsolationSegmentToOrganizationsReturns fake.recordInvocation("EntitleIsolationSegmentToOrganizations", []interface{}{arg1, arg2Copy}) fake.entitleIsolationSegmentToOrganizationsMutex.Unlock() - if fake.EntitleIsolationSegmentToOrganizationsStub != nil { - return fake.EntitleIsolationSegmentToOrganizationsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.entitleIsolationSegmentToOrganizationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5996,15 +6170,16 @@ func (fake *FakeCloudControllerClient) GetAppFeature(arg1 string, arg2 string) ( arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetAppFeatureStub + fakeReturns := fake.getAppFeatureReturns fake.recordInvocation("GetAppFeature", []interface{}{arg1, arg2}) fake.getAppFeatureMutex.Unlock() - if fake.GetAppFeatureStub != nil { - return fake.GetAppFeatureStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getAppFeatureReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6063,15 +6238,16 @@ func (fake *FakeCloudControllerClient) GetApplicationByNameAndSpace(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationByNameAndSpaceStub + fakeReturns := fake.getApplicationByNameAndSpaceReturns fake.recordInvocation("GetApplicationByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationByNameAndSpaceMutex.Unlock() - if fake.GetApplicationByNameAndSpaceStub != nil { - return fake.GetApplicationByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6129,15 +6305,16 @@ func (fake *FakeCloudControllerClient) GetApplicationDropletCurrent(arg1 string) fake.getApplicationDropletCurrentArgsForCall = append(fake.getApplicationDropletCurrentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationDropletCurrentStub + fakeReturns := fake.getApplicationDropletCurrentReturns fake.recordInvocation("GetApplicationDropletCurrent", []interface{}{arg1}) fake.getApplicationDropletCurrentMutex.Unlock() - if fake.GetApplicationDropletCurrentStub != nil { - return fake.GetApplicationDropletCurrentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationDropletCurrentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6195,15 +6372,16 @@ func (fake *FakeCloudControllerClient) GetApplicationEnvironment(arg1 string) (c fake.getApplicationEnvironmentArgsForCall = append(fake.getApplicationEnvironmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationEnvironmentStub + fakeReturns := fake.getApplicationEnvironmentReturns fake.recordInvocation("GetApplicationEnvironment", []interface{}{arg1}) fake.getApplicationEnvironmentMutex.Unlock() - if fake.GetApplicationEnvironmentStub != nil { - return fake.GetApplicationEnvironmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationEnvironmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6261,15 +6439,16 @@ func (fake *FakeCloudControllerClient) GetApplicationManifest(arg1 string) ([]by fake.getApplicationManifestArgsForCall = append(fake.getApplicationManifestArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationManifestStub + fakeReturns := fake.getApplicationManifestReturns fake.recordInvocation("GetApplicationManifest", []interface{}{arg1}) fake.getApplicationManifestMutex.Unlock() - if fake.GetApplicationManifestStub != nil { - return fake.GetApplicationManifestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationManifestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6328,15 +6507,16 @@ func (fake *FakeCloudControllerClient) GetApplicationProcessByType(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationProcessByTypeStub + fakeReturns := fake.getApplicationProcessByTypeReturns fake.recordInvocation("GetApplicationProcessByType", []interface{}{arg1, arg2}) fake.getApplicationProcessByTypeMutex.Unlock() - if fake.GetApplicationProcessByTypeStub != nil { - return fake.GetApplicationProcessByTypeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationProcessByTypeReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6394,15 +6574,16 @@ func (fake *FakeCloudControllerClient) GetApplicationProcesses(arg1 string) ([]r fake.getApplicationProcessesArgsForCall = append(fake.getApplicationProcessesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationProcessesStub + fakeReturns := fake.getApplicationProcessesReturns fake.recordInvocation("GetApplicationProcesses", []interface{}{arg1}) fake.getApplicationProcessesMutex.Unlock() - if fake.GetApplicationProcessesStub != nil { - return fake.GetApplicationProcessesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationProcessesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6461,15 +6642,16 @@ func (fake *FakeCloudControllerClient) GetApplicationRevisions(arg1 string, arg2 arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetApplicationRevisionsStub + fakeReturns := fake.getApplicationRevisionsReturns fake.recordInvocation("GetApplicationRevisions", []interface{}{arg1, arg2}) fake.getApplicationRevisionsMutex.Unlock() - if fake.GetApplicationRevisionsStub != nil { - return fake.GetApplicationRevisionsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRevisionsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6527,15 +6709,16 @@ func (fake *FakeCloudControllerClient) GetApplicationRevisionsDeployed(arg1 stri fake.getApplicationRevisionsDeployedArgsForCall = append(fake.getApplicationRevisionsDeployedArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationRevisionsDeployedStub + fakeReturns := fake.getApplicationRevisionsDeployedReturns fake.recordInvocation("GetApplicationRevisionsDeployed", []interface{}{arg1}) fake.getApplicationRevisionsDeployedMutex.Unlock() - if fake.GetApplicationRevisionsDeployedStub != nil { - return fake.GetApplicationRevisionsDeployedStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRevisionsDeployedReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6593,15 +6776,16 @@ func (fake *FakeCloudControllerClient) GetApplicationRoutes(arg1 string) ([]reso fake.getApplicationRoutesArgsForCall = append(fake.getApplicationRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationRoutesStub + fakeReturns := fake.getApplicationRoutesReturns fake.recordInvocation("GetApplicationRoutes", []interface{}{arg1}) fake.getApplicationRoutesMutex.Unlock() - if fake.GetApplicationRoutesStub != nil { - return fake.GetApplicationRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRoutesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6660,15 +6844,16 @@ func (fake *FakeCloudControllerClient) GetApplicationTasks(arg1 string, arg2 ... arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetApplicationTasksStub + fakeReturns := fake.getApplicationTasksReturns fake.recordInvocation("GetApplicationTasks", []interface{}{arg1, arg2}) fake.getApplicationTasksMutex.Unlock() - if fake.GetApplicationTasksStub != nil { - return fake.GetApplicationTasksStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationTasksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6726,15 +6911,16 @@ func (fake *FakeCloudControllerClient) GetApplications(arg1 ...ccv3.Query) ([]re fake.getApplicationsArgsForCall = append(fake.getApplicationsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetApplicationsStub + fakeReturns := fake.getApplicationsReturns fake.recordInvocation("GetApplications", []interface{}{arg1}) fake.getApplicationsMutex.Unlock() - if fake.GetApplicationsStub != nil { - return fake.GetApplicationsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6792,15 +6978,16 @@ func (fake *FakeCloudControllerClient) GetBuild(arg1 string) (resources.Build, c fake.getBuildArgsForCall = append(fake.getBuildArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetBuildStub + fakeReturns := fake.getBuildReturns fake.recordInvocation("GetBuild", []interface{}{arg1}) fake.getBuildMutex.Unlock() - if fake.GetBuildStub != nil { - return fake.GetBuildStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getBuildReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6858,15 +7045,16 @@ func (fake *FakeCloudControllerClient) GetBuildpacks(arg1 ...ccv3.Query) ([]reso fake.getBuildpacksArgsForCall = append(fake.getBuildpacksArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetBuildpacksStub + fakeReturns := fake.getBuildpacksReturns fake.recordInvocation("GetBuildpacks", []interface{}{arg1}) fake.getBuildpacksMutex.Unlock() - if fake.GetBuildpacksStub != nil { - return fake.GetBuildpacksStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getBuildpacksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6924,15 +7112,16 @@ func (fake *FakeCloudControllerClient) GetDefaultDomain(arg1 string) (resources. fake.getDefaultDomainArgsForCall = append(fake.getDefaultDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDefaultDomainStub + fakeReturns := fake.getDefaultDomainReturns fake.recordInvocation("GetDefaultDomain", []interface{}{arg1}) fake.getDefaultDomainMutex.Unlock() - if fake.GetDefaultDomainStub != nil { - return fake.GetDefaultDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDefaultDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6990,15 +7179,16 @@ func (fake *FakeCloudControllerClient) GetDeployment(arg1 string) (resources.Dep fake.getDeploymentArgsForCall = append(fake.getDeploymentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDeploymentStub + fakeReturns := fake.getDeploymentReturns fake.recordInvocation("GetDeployment", []interface{}{arg1}) fake.getDeploymentMutex.Unlock() - if fake.GetDeploymentStub != nil { - return fake.GetDeploymentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDeploymentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7056,15 +7246,16 @@ func (fake *FakeCloudControllerClient) GetDeployments(arg1 ...ccv3.Query) ([]res fake.getDeploymentsArgsForCall = append(fake.getDeploymentsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetDeploymentsStub + fakeReturns := fake.getDeploymentsReturns fake.recordInvocation("GetDeployments", []interface{}{arg1}) fake.getDeploymentsMutex.Unlock() - if fake.GetDeploymentsStub != nil { - return fake.GetDeploymentsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDeploymentsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7122,15 +7313,16 @@ func (fake *FakeCloudControllerClient) GetDomain(arg1 string) (resources.Domain, fake.getDomainArgsForCall = append(fake.getDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDomainStub + fakeReturns := fake.getDomainReturns fake.recordInvocation("GetDomain", []interface{}{arg1}) fake.getDomainMutex.Unlock() - if fake.GetDomainStub != nil { - return fake.GetDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7188,15 +7380,16 @@ func (fake *FakeCloudControllerClient) GetDomains(arg1 ...ccv3.Query) ([]resourc fake.getDomainsArgsForCall = append(fake.getDomainsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetDomainsStub + fakeReturns := fake.getDomainsReturns fake.recordInvocation("GetDomains", []interface{}{arg1}) fake.getDomainsMutex.Unlock() - if fake.GetDomainsStub != nil { - return fake.GetDomainsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7254,15 +7447,16 @@ func (fake *FakeCloudControllerClient) GetDroplet(arg1 string) (resources.Drople fake.getDropletArgsForCall = append(fake.getDropletArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDropletStub + fakeReturns := fake.getDropletReturns fake.recordInvocation("GetDroplet", []interface{}{arg1}) fake.getDropletMutex.Unlock() - if fake.GetDropletStub != nil { - return fake.GetDropletStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7320,15 +7514,16 @@ func (fake *FakeCloudControllerClient) GetDroplets(arg1 ...ccv3.Query) ([]resour fake.getDropletsArgsForCall = append(fake.getDropletsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetDropletsStub + fakeReturns := fake.getDropletsReturns fake.recordInvocation("GetDroplets", []interface{}{arg1}) fake.getDropletsMutex.Unlock() - if fake.GetDropletsStub != nil { - return fake.GetDropletsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDropletsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7386,15 +7581,16 @@ func (fake *FakeCloudControllerClient) GetEnvironmentVariableGroup(arg1 constant fake.getEnvironmentVariableGroupArgsForCall = append(fake.getEnvironmentVariableGroupArgsForCall, struct { arg1 constant.EnvironmentVariableGroupName }{arg1}) + stub := fake.GetEnvironmentVariableGroupStub + fakeReturns := fake.getEnvironmentVariableGroupReturns fake.recordInvocation("GetEnvironmentVariableGroup", []interface{}{arg1}) fake.getEnvironmentVariableGroupMutex.Unlock() - if fake.GetEnvironmentVariableGroupStub != nil { - return fake.GetEnvironmentVariableGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getEnvironmentVariableGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7446,21 +7642,89 @@ func (fake *FakeCloudControllerClient) GetEnvironmentVariableGroupReturnsOnCall( }{result1, result2, result3} } +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURL(arg1 string) (resources.EnvironmentVariables, ccv3.Warnings, error) { + fake.getEnvironmentVariablesByURLMutex.Lock() + ret, specificReturn := fake.getEnvironmentVariablesByURLReturnsOnCall[len(fake.getEnvironmentVariablesByURLArgsForCall)] + fake.getEnvironmentVariablesByURLArgsForCall = append(fake.getEnvironmentVariablesByURLArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.GetEnvironmentVariablesByURLStub + fakeReturns := fake.getEnvironmentVariablesByURLReturns + fake.recordInvocation("GetEnvironmentVariablesByURL", []interface{}{arg1}) + fake.getEnvironmentVariablesByURLMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURLCallCount() int { + fake.getEnvironmentVariablesByURLMutex.RLock() + defer fake.getEnvironmentVariablesByURLMutex.RUnlock() + return len(fake.getEnvironmentVariablesByURLArgsForCall) +} + +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURLCalls(stub func(string) (resources.EnvironmentVariables, ccv3.Warnings, error)) { + fake.getEnvironmentVariablesByURLMutex.Lock() + defer fake.getEnvironmentVariablesByURLMutex.Unlock() + fake.GetEnvironmentVariablesByURLStub = stub +} + +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURLArgsForCall(i int) string { + fake.getEnvironmentVariablesByURLMutex.RLock() + defer fake.getEnvironmentVariablesByURLMutex.RUnlock() + argsForCall := fake.getEnvironmentVariablesByURLArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURLReturns(result1 resources.EnvironmentVariables, result2 ccv3.Warnings, result3 error) { + fake.getEnvironmentVariablesByURLMutex.Lock() + defer fake.getEnvironmentVariablesByURLMutex.Unlock() + fake.GetEnvironmentVariablesByURLStub = nil + fake.getEnvironmentVariablesByURLReturns = struct { + result1 resources.EnvironmentVariables + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) GetEnvironmentVariablesByURLReturnsOnCall(i int, result1 resources.EnvironmentVariables, result2 ccv3.Warnings, result3 error) { + fake.getEnvironmentVariablesByURLMutex.Lock() + defer fake.getEnvironmentVariablesByURLMutex.Unlock() + fake.GetEnvironmentVariablesByURLStub = nil + if fake.getEnvironmentVariablesByURLReturnsOnCall == nil { + fake.getEnvironmentVariablesByURLReturnsOnCall = make(map[int]struct { + result1 resources.EnvironmentVariables + result2 ccv3.Warnings + result3 error + }) + } + fake.getEnvironmentVariablesByURLReturnsOnCall[i] = struct { + result1 resources.EnvironmentVariables + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeCloudControllerClient) GetEvents(arg1 ...ccv3.Query) ([]ccv3.Event, ccv3.Warnings, error) { fake.getEventsMutex.Lock() ret, specificReturn := fake.getEventsReturnsOnCall[len(fake.getEventsArgsForCall)] fake.getEventsArgsForCall = append(fake.getEventsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetEventsStub + fakeReturns := fake.getEventsReturns fake.recordInvocation("GetEvents", []interface{}{arg1}) fake.getEventsMutex.Unlock() - if fake.GetEventsStub != nil { - return fake.GetEventsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getEventsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7518,15 +7782,16 @@ func (fake *FakeCloudControllerClient) GetFeatureFlag(arg1 string) (resources.Fe fake.getFeatureFlagArgsForCall = append(fake.getFeatureFlagArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetFeatureFlagStub + fakeReturns := fake.getFeatureFlagReturns fake.recordInvocation("GetFeatureFlag", []interface{}{arg1}) fake.getFeatureFlagMutex.Unlock() - if fake.GetFeatureFlagStub != nil { - return fake.GetFeatureFlagStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getFeatureFlagReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7583,15 +7848,16 @@ func (fake *FakeCloudControllerClient) GetFeatureFlags() ([]resources.FeatureFla ret, specificReturn := fake.getFeatureFlagsReturnsOnCall[len(fake.getFeatureFlagsArgsForCall)] fake.getFeatureFlagsArgsForCall = append(fake.getFeatureFlagsArgsForCall, struct { }{}) + stub := fake.GetFeatureFlagsStub + fakeReturns := fake.getFeatureFlagsReturns fake.recordInvocation("GetFeatureFlags", []interface{}{}) fake.getFeatureFlagsMutex.Unlock() - if fake.GetFeatureFlagsStub != nil { - return fake.GetFeatureFlagsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getFeatureFlagsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7641,15 +7907,16 @@ func (fake *FakeCloudControllerClient) GetInfo() (ccv3.Info, ccv3.Warnings, erro ret, specificReturn := fake.getInfoReturnsOnCall[len(fake.getInfoArgsForCall)] fake.getInfoArgsForCall = append(fake.getInfoArgsForCall, struct { }{}) + stub := fake.GetInfoStub + fakeReturns := fake.getInfoReturns fake.recordInvocation("GetInfo", []interface{}{}) fake.getInfoMutex.Unlock() - if fake.GetInfoStub != nil { - return fake.GetInfoStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getInfoReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7700,15 +7967,16 @@ func (fake *FakeCloudControllerClient) GetIsolationSegment(arg1 string) (resourc fake.getIsolationSegmentArgsForCall = append(fake.getIsolationSegmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetIsolationSegmentStub + fakeReturns := fake.getIsolationSegmentReturns fake.recordInvocation("GetIsolationSegment", []interface{}{arg1}) fake.getIsolationSegmentMutex.Unlock() - if fake.GetIsolationSegmentStub != nil { - return fake.GetIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7766,15 +8034,16 @@ func (fake *FakeCloudControllerClient) GetIsolationSegmentOrganizations(arg1 str fake.getIsolationSegmentOrganizationsArgsForCall = append(fake.getIsolationSegmentOrganizationsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetIsolationSegmentOrganizationsStub + fakeReturns := fake.getIsolationSegmentOrganizationsReturns fake.recordInvocation("GetIsolationSegmentOrganizations", []interface{}{arg1}) fake.getIsolationSegmentOrganizationsMutex.Unlock() - if fake.GetIsolationSegmentOrganizationsStub != nil { - return fake.GetIsolationSegmentOrganizationsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getIsolationSegmentOrganizationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7832,15 +8101,16 @@ func (fake *FakeCloudControllerClient) GetIsolationSegments(arg1 ...ccv3.Query) fake.getIsolationSegmentsArgsForCall = append(fake.getIsolationSegmentsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetIsolationSegmentsStub + fakeReturns := fake.getIsolationSegmentsReturns fake.recordInvocation("GetIsolationSegments", []interface{}{arg1}) fake.getIsolationSegmentsMutex.Unlock() - if fake.GetIsolationSegmentsStub != nil { - return fake.GetIsolationSegmentsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getIsolationSegmentsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7899,15 +8169,16 @@ func (fake *FakeCloudControllerClient) GetNewApplicationProcesses(arg1 string, a arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetNewApplicationProcessesStub + fakeReturns := fake.getNewApplicationProcessesReturns fake.recordInvocation("GetNewApplicationProcesses", []interface{}{arg1, arg2}) fake.getNewApplicationProcessesMutex.Unlock() - if fake.GetNewApplicationProcessesStub != nil { - return fake.GetNewApplicationProcessesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getNewApplicationProcessesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7965,15 +8236,16 @@ func (fake *FakeCloudControllerClient) GetOrganization(arg1 string) (resources.O fake.getOrganizationArgsForCall = append(fake.getOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationStub + fakeReturns := fake.getOrganizationReturns fake.recordInvocation("GetOrganization", []interface{}{arg1}) fake.getOrganizationMutex.Unlock() - if fake.GetOrganizationStub != nil { - return fake.GetOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8031,15 +8303,16 @@ func (fake *FakeCloudControllerClient) GetOrganizationDefaultIsolationSegment(ar fake.getOrganizationDefaultIsolationSegmentArgsForCall = append(fake.getOrganizationDefaultIsolationSegmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationDefaultIsolationSegmentStub + fakeReturns := fake.getOrganizationDefaultIsolationSegmentReturns fake.recordInvocation("GetOrganizationDefaultIsolationSegment", []interface{}{arg1}) fake.getOrganizationDefaultIsolationSegmentMutex.Unlock() - if fake.GetOrganizationDefaultIsolationSegmentStub != nil { - return fake.GetOrganizationDefaultIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationDefaultIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8098,15 +8371,16 @@ func (fake *FakeCloudControllerClient) GetOrganizationDomains(arg1 string, arg2 arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetOrganizationDomainsStub + fakeReturns := fake.getOrganizationDomainsReturns fake.recordInvocation("GetOrganizationDomains", []interface{}{arg1, arg2}) fake.getOrganizationDomainsMutex.Unlock() - if fake.GetOrganizationDomainsStub != nil { - return fake.GetOrganizationDomainsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationDomainsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8164,15 +8438,16 @@ func (fake *FakeCloudControllerClient) GetOrganizationQuota(arg1 string) (resour fake.getOrganizationQuotaArgsForCall = append(fake.getOrganizationQuotaArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationQuotaStub + fakeReturns := fake.getOrganizationQuotaReturns fake.recordInvocation("GetOrganizationQuota", []interface{}{arg1}) fake.getOrganizationQuotaMutex.Unlock() - if fake.GetOrganizationQuotaStub != nil { - return fake.GetOrganizationQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8230,15 +8505,16 @@ func (fake *FakeCloudControllerClient) GetOrganizationQuotas(arg1 ...ccv3.Query) fake.getOrganizationQuotasArgsForCall = append(fake.getOrganizationQuotasArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetOrganizationQuotasStub + fakeReturns := fake.getOrganizationQuotasReturns fake.recordInvocation("GetOrganizationQuotas", []interface{}{arg1}) fake.getOrganizationQuotasMutex.Unlock() - if fake.GetOrganizationQuotasStub != nil { - return fake.GetOrganizationQuotasStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationQuotasReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8296,15 +8572,16 @@ func (fake *FakeCloudControllerClient) GetOrganizations(arg1 ...ccv3.Query) ([]r fake.getOrganizationsArgsForCall = append(fake.getOrganizationsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetOrganizationsStub + fakeReturns := fake.getOrganizationsReturns fake.recordInvocation("GetOrganizations", []interface{}{arg1}) fake.getOrganizationsMutex.Unlock() - if fake.GetOrganizationsStub != nil { - return fake.GetOrganizationsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8362,15 +8639,16 @@ func (fake *FakeCloudControllerClient) GetPackage(arg1 string) (resources.Packag fake.getPackageArgsForCall = append(fake.getPackageArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPackageStub + fakeReturns := fake.getPackageReturns fake.recordInvocation("GetPackage", []interface{}{arg1}) fake.getPackageMutex.Unlock() - if fake.GetPackageStub != nil { - return fake.GetPackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8429,15 +8707,16 @@ func (fake *FakeCloudControllerClient) GetPackageDroplets(arg1 string, arg2 ...c arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetPackageDropletsStub + fakeReturns := fake.getPackageDropletsReturns fake.recordInvocation("GetPackageDroplets", []interface{}{arg1, arg2}) fake.getPackageDropletsMutex.Unlock() - if fake.GetPackageDropletsStub != nil { - return fake.GetPackageDropletsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getPackageDropletsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8495,15 +8774,16 @@ func (fake *FakeCloudControllerClient) GetPackages(arg1 ...ccv3.Query) ([]resour fake.getPackagesArgsForCall = append(fake.getPackagesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetPackagesStub + fakeReturns := fake.getPackagesReturns fake.recordInvocation("GetPackages", []interface{}{arg1}) fake.getPackagesMutex.Unlock() - if fake.GetPackagesStub != nil { - return fake.GetPackagesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getPackagesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8561,15 +8841,16 @@ func (fake *FakeCloudControllerClient) GetProcess(arg1 string) (resources.Proces fake.getProcessArgsForCall = append(fake.getProcessArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetProcessStub + fakeReturns := fake.getProcessReturns fake.recordInvocation("GetProcess", []interface{}{arg1}) fake.getProcessMutex.Unlock() - if fake.GetProcessStub != nil { - return fake.GetProcessStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getProcessReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8627,15 +8908,16 @@ func (fake *FakeCloudControllerClient) GetProcessInstances(arg1 string) ([]ccv3. fake.getProcessInstancesArgsForCall = append(fake.getProcessInstancesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetProcessInstancesStub + fakeReturns := fake.getProcessInstancesReturns fake.recordInvocation("GetProcessInstances", []interface{}{arg1}) fake.getProcessInstancesMutex.Unlock() - if fake.GetProcessInstancesStub != nil { - return fake.GetProcessInstancesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getProcessInstancesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8693,15 +8975,16 @@ func (fake *FakeCloudControllerClient) GetProcessSidecars(arg1 string) ([]resour fake.getProcessSidecarsArgsForCall = append(fake.getProcessSidecarsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetProcessSidecarsStub + fakeReturns := fake.getProcessSidecarsReturns fake.recordInvocation("GetProcessSidecars", []interface{}{arg1}) fake.getProcessSidecarsMutex.Unlock() - if fake.GetProcessSidecarsStub != nil { - return fake.GetProcessSidecarsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getProcessSidecarsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8759,15 +9042,16 @@ func (fake *FakeCloudControllerClient) GetProcesses(arg1 ...ccv3.Query) ([]resou fake.getProcessesArgsForCall = append(fake.getProcessesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetProcessesStub + fakeReturns := fake.getProcessesReturns fake.recordInvocation("GetProcesses", []interface{}{arg1}) fake.getProcessesMutex.Unlock() - if fake.GetProcessesStub != nil { - return fake.GetProcessesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getProcessesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8825,15 +9109,16 @@ func (fake *FakeCloudControllerClient) GetRoles(arg1 ...ccv3.Query) ([]resources fake.getRolesArgsForCall = append(fake.getRolesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetRolesStub + fakeReturns := fake.getRolesReturns fake.recordInvocation("GetRoles", []interface{}{arg1}) fake.getRolesMutex.Unlock() - if fake.GetRolesStub != nil { - return fake.GetRolesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getRolesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -8888,21 +9173,81 @@ func (fake *FakeCloudControllerClient) GetRolesReturnsOnCall(i int, result1 []re }{result1, result2, result3, result4} } +func (fake *FakeCloudControllerClient) GetRoot() (ccv3.Root, ccv3.Warnings, error) { + fake.getRootMutex.Lock() + ret, specificReturn := fake.getRootReturnsOnCall[len(fake.getRootArgsForCall)] + fake.getRootArgsForCall = append(fake.getRootArgsForCall, struct { + }{}) + stub := fake.GetRootStub + fakeReturns := fake.getRootReturns + fake.recordInvocation("GetRoot", []interface{}{}) + fake.getRootMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeCloudControllerClient) GetRootCallCount() int { + fake.getRootMutex.RLock() + defer fake.getRootMutex.RUnlock() + return len(fake.getRootArgsForCall) +} + +func (fake *FakeCloudControllerClient) GetRootCalls(stub func() (ccv3.Root, ccv3.Warnings, error)) { + fake.getRootMutex.Lock() + defer fake.getRootMutex.Unlock() + fake.GetRootStub = stub +} + +func (fake *FakeCloudControllerClient) GetRootReturns(result1 ccv3.Root, result2 ccv3.Warnings, result3 error) { + fake.getRootMutex.Lock() + defer fake.getRootMutex.Unlock() + fake.GetRootStub = nil + fake.getRootReturns = struct { + result1 ccv3.Root + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) GetRootReturnsOnCall(i int, result1 ccv3.Root, result2 ccv3.Warnings, result3 error) { + fake.getRootMutex.Lock() + defer fake.getRootMutex.Unlock() + fake.GetRootStub = nil + if fake.getRootReturnsOnCall == nil { + fake.getRootReturnsOnCall = make(map[int]struct { + result1 ccv3.Root + result2 ccv3.Warnings + result3 error + }) + } + fake.getRootReturnsOnCall[i] = struct { + result1 ccv3.Root + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeCloudControllerClient) GetRouteBindings(arg1 ...ccv3.Query) ([]resources.RouteBinding, ccv3.IncludedResources, ccv3.Warnings, error) { fake.getRouteBindingsMutex.Lock() ret, specificReturn := fake.getRouteBindingsReturnsOnCall[len(fake.getRouteBindingsArgsForCall)] fake.getRouteBindingsArgsForCall = append(fake.getRouteBindingsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetRouteBindingsStub + fakeReturns := fake.getRouteBindingsReturns fake.recordInvocation("GetRouteBindings", []interface{}{arg1}) fake.getRouteBindingsMutex.Unlock() - if fake.GetRouteBindingsStub != nil { - return fake.GetRouteBindingsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getRouteBindingsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -8963,15 +9308,16 @@ func (fake *FakeCloudControllerClient) GetRouteDestinations(arg1 string) ([]reso fake.getRouteDestinationsArgsForCall = append(fake.getRouteDestinationsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetRouteDestinationsStub + fakeReturns := fake.getRouteDestinationsReturns fake.recordInvocation("GetRouteDestinations", []interface{}{arg1}) fake.getRouteDestinationsMutex.Unlock() - if fake.GetRouteDestinationsStub != nil { - return fake.GetRouteDestinationsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRouteDestinationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9029,15 +9375,16 @@ func (fake *FakeCloudControllerClient) GetRoutes(arg1 ...ccv3.Query) ([]resource fake.getRoutesArgsForCall = append(fake.getRoutesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetRoutesStub + fakeReturns := fake.getRoutesReturns fake.recordInvocation("GetRoutes", []interface{}{arg1}) fake.getRoutesMutex.Unlock() - if fake.GetRoutesStub != nil { - return fake.GetRoutesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRoutesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9096,15 +9443,16 @@ func (fake *FakeCloudControllerClient) GetRunningSecurityGroups(arg1 string, arg arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetRunningSecurityGroupsStub + fakeReturns := fake.getRunningSecurityGroupsReturns fake.recordInvocation("GetRunningSecurityGroups", []interface{}{arg1, arg2}) fake.getRunningSecurityGroupsMutex.Unlock() - if fake.GetRunningSecurityGroupsStub != nil { - return fake.GetRunningSecurityGroupsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRunningSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9162,15 +9510,16 @@ func (fake *FakeCloudControllerClient) GetSSHEnabled(arg1 string) (ccv3.SSHEnabl fake.getSSHEnabledArgsForCall = append(fake.getSSHEnabledArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSSHEnabledStub + fakeReturns := fake.getSSHEnabledReturns fake.recordInvocation("GetSSHEnabled", []interface{}{arg1}) fake.getSSHEnabledMutex.Unlock() - if fake.GetSSHEnabledStub != nil { - return fake.GetSSHEnabledStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSSHEnabledReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9228,15 +9577,16 @@ func (fake *FakeCloudControllerClient) GetSecurityGroups(arg1 ...ccv3.Query) ([] fake.getSecurityGroupsArgsForCall = append(fake.getSecurityGroupsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetSecurityGroupsStub + fakeReturns := fake.getSecurityGroupsReturns fake.recordInvocation("GetSecurityGroups", []interface{}{arg1}) fake.getSecurityGroupsMutex.Unlock() - if fake.GetSecurityGroupsStub != nil { - return fake.GetSecurityGroupsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9294,15 +9644,16 @@ func (fake *FakeCloudControllerClient) GetServiceBrokers(arg1 ...ccv3.Query) ([] fake.getServiceBrokersArgsForCall = append(fake.getServiceBrokersArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServiceBrokersStub + fakeReturns := fake.getServiceBrokersReturns fake.recordInvocation("GetServiceBrokers", []interface{}{arg1}) fake.getServiceBrokersMutex.Unlock() - if fake.GetServiceBrokersStub != nil { - return fake.GetServiceBrokersStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceBrokersReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9360,15 +9711,16 @@ func (fake *FakeCloudControllerClient) GetServiceCredentialBindingDetails(arg1 s fake.getServiceCredentialBindingDetailsArgsForCall = append(fake.getServiceCredentialBindingDetailsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceCredentialBindingDetailsStub + fakeReturns := fake.getServiceCredentialBindingDetailsReturns fake.recordInvocation("GetServiceCredentialBindingDetails", []interface{}{arg1}) fake.getServiceCredentialBindingDetailsMutex.Unlock() - if fake.GetServiceCredentialBindingDetailsStub != nil { - return fake.GetServiceCredentialBindingDetailsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceCredentialBindingDetailsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9426,15 +9778,16 @@ func (fake *FakeCloudControllerClient) GetServiceCredentialBindings(arg1 ...ccv3 fake.getServiceCredentialBindingsArgsForCall = append(fake.getServiceCredentialBindingsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServiceCredentialBindingsStub + fakeReturns := fake.getServiceCredentialBindingsReturns fake.recordInvocation("GetServiceCredentialBindings", []interface{}{arg1}) fake.getServiceCredentialBindingsMutex.Unlock() - if fake.GetServiceCredentialBindingsStub != nil { - return fake.GetServiceCredentialBindingsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceCredentialBindingsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9494,15 +9847,16 @@ func (fake *FakeCloudControllerClient) GetServiceInstanceByNameAndSpace(arg1 str arg2 string arg3 []ccv3.Query }{arg1, arg2, arg3}) + stub := fake.GetServiceInstanceByNameAndSpaceStub + fakeReturns := fake.getServiceInstanceByNameAndSpaceReturns fake.recordInvocation("GetServiceInstanceByNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.getServiceInstanceByNameAndSpaceMutex.Unlock() - if fake.GetServiceInstanceByNameAndSpaceStub != nil { - return fake.GetServiceInstanceByNameAndSpaceStub(arg1, arg2, arg3...) + if stub != nil { + return stub(arg1, arg2, arg3...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getServiceInstanceByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -9563,15 +9917,16 @@ func (fake *FakeCloudControllerClient) GetServiceInstanceParameters(arg1 string) fake.getServiceInstanceParametersArgsForCall = append(fake.getServiceInstanceParametersArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceInstanceParametersStub + fakeReturns := fake.getServiceInstanceParametersReturns fake.recordInvocation("GetServiceInstanceParameters", []interface{}{arg1}) fake.getServiceInstanceParametersMutex.Unlock() - if fake.GetServiceInstanceParametersStub != nil { - return fake.GetServiceInstanceParametersStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceParametersReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9629,15 +9984,16 @@ func (fake *FakeCloudControllerClient) GetServiceInstanceSharedSpaces(arg1 strin fake.getServiceInstanceSharedSpacesArgsForCall = append(fake.getServiceInstanceSharedSpacesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceInstanceSharedSpacesStub + fakeReturns := fake.getServiceInstanceSharedSpacesReturns fake.recordInvocation("GetServiceInstanceSharedSpaces", []interface{}{arg1}) fake.getServiceInstanceSharedSpacesMutex.Unlock() - if fake.GetServiceInstanceSharedSpacesStub != nil { - return fake.GetServiceInstanceSharedSpacesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceSharedSpacesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9695,15 +10051,16 @@ func (fake *FakeCloudControllerClient) GetServiceInstanceUsageSummary(arg1 strin fake.getServiceInstanceUsageSummaryArgsForCall = append(fake.getServiceInstanceUsageSummaryArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceInstanceUsageSummaryStub + fakeReturns := fake.getServiceInstanceUsageSummaryReturns fake.recordInvocation("GetServiceInstanceUsageSummary", []interface{}{arg1}) fake.getServiceInstanceUsageSummaryMutex.Unlock() - if fake.GetServiceInstanceUsageSummaryStub != nil { - return fake.GetServiceInstanceUsageSummaryStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceUsageSummaryReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9761,15 +10118,16 @@ func (fake *FakeCloudControllerClient) GetServiceInstances(arg1 ...ccv3.Query) ( fake.getServiceInstancesArgsForCall = append(fake.getServiceInstancesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServiceInstancesStub + fakeReturns := fake.getServiceInstancesReturns fake.recordInvocation("GetServiceInstances", []interface{}{arg1}) fake.getServiceInstancesMutex.Unlock() - if fake.GetServiceInstancesStub != nil { - return fake.GetServiceInstancesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getServiceInstancesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -9830,15 +10188,16 @@ func (fake *FakeCloudControllerClient) GetServiceOfferingByGUID(arg1 string) (re fake.getServiceOfferingByGUIDArgsForCall = append(fake.getServiceOfferingByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceOfferingByGUIDStub + fakeReturns := fake.getServiceOfferingByGUIDReturns fake.recordInvocation("GetServiceOfferingByGUID", []interface{}{arg1}) fake.getServiceOfferingByGUIDMutex.Unlock() - if fake.GetServiceOfferingByGUIDStub != nil { - return fake.GetServiceOfferingByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceOfferingByGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9897,15 +10256,16 @@ func (fake *FakeCloudControllerClient) GetServiceOfferingByNameAndBroker(arg1 st arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceOfferingByNameAndBrokerStub + fakeReturns := fake.getServiceOfferingByNameAndBrokerReturns fake.recordInvocation("GetServiceOfferingByNameAndBroker", []interface{}{arg1, arg2}) fake.getServiceOfferingByNameAndBrokerMutex.Unlock() - if fake.GetServiceOfferingByNameAndBrokerStub != nil { - return fake.GetServiceOfferingByNameAndBrokerStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceOfferingByNameAndBrokerReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9963,15 +10323,16 @@ func (fake *FakeCloudControllerClient) GetServiceOfferings(arg1 ...ccv3.Query) ( fake.getServiceOfferingsArgsForCall = append(fake.getServiceOfferingsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServiceOfferingsStub + fakeReturns := fake.getServiceOfferingsReturns fake.recordInvocation("GetServiceOfferings", []interface{}{arg1}) fake.getServiceOfferingsMutex.Unlock() - if fake.GetServiceOfferingsStub != nil { - return fake.GetServiceOfferingsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceOfferingsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10029,15 +10390,16 @@ func (fake *FakeCloudControllerClient) GetServicePlanByGUID(arg1 string) (resour fake.getServicePlanByGUIDArgsForCall = append(fake.getServicePlanByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicePlanByGUIDStub + fakeReturns := fake.getServicePlanByGUIDReturns fake.recordInvocation("GetServicePlanByGUID", []interface{}{arg1}) fake.getServicePlanByGUIDMutex.Unlock() - if fake.GetServicePlanByGUIDStub != nil { - return fake.GetServicePlanByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlanByGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10095,15 +10457,16 @@ func (fake *FakeCloudControllerClient) GetServicePlanVisibility(arg1 string) (re fake.getServicePlanVisibilityArgsForCall = append(fake.getServicePlanVisibilityArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicePlanVisibilityStub + fakeReturns := fake.getServicePlanVisibilityReturns fake.recordInvocation("GetServicePlanVisibility", []interface{}{arg1}) fake.getServicePlanVisibilityMutex.Unlock() - if fake.GetServicePlanVisibilityStub != nil { - return fake.GetServicePlanVisibilityStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlanVisibilityReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10161,15 +10524,16 @@ func (fake *FakeCloudControllerClient) GetServicePlans(arg1 ...ccv3.Query) ([]re fake.getServicePlansArgsForCall = append(fake.getServicePlansArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServicePlansStub + fakeReturns := fake.getServicePlansReturns fake.recordInvocation("GetServicePlans", []interface{}{arg1}) fake.getServicePlansMutex.Unlock() - if fake.GetServicePlansStub != nil { - return fake.GetServicePlansStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlansReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10227,15 +10591,16 @@ func (fake *FakeCloudControllerClient) GetServicePlansWithOfferings(arg1 ...ccv3 fake.getServicePlansWithOfferingsArgsForCall = append(fake.getServicePlansWithOfferingsArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServicePlansWithOfferingsStub + fakeReturns := fake.getServicePlansWithOfferingsReturns fake.recordInvocation("GetServicePlansWithOfferings", []interface{}{arg1}) fake.getServicePlansWithOfferingsMutex.Unlock() - if fake.GetServicePlansWithOfferingsStub != nil { - return fake.GetServicePlansWithOfferingsStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlansWithOfferingsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10293,15 +10658,16 @@ func (fake *FakeCloudControllerClient) GetServicePlansWithSpaceAndOrganization(a fake.getServicePlansWithSpaceAndOrganizationArgsForCall = append(fake.getServicePlansWithSpaceAndOrganizationArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetServicePlansWithSpaceAndOrganizationStub + fakeReturns := fake.getServicePlansWithSpaceAndOrganizationReturns fake.recordInvocation("GetServicePlansWithSpaceAndOrganization", []interface{}{arg1}) fake.getServicePlansWithSpaceAndOrganizationMutex.Unlock() - if fake.GetServicePlansWithSpaceAndOrganizationStub != nil { - return fake.GetServicePlansWithSpaceAndOrganizationStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlansWithSpaceAndOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10360,15 +10726,16 @@ func (fake *FakeCloudControllerClient) GetSpaceFeature(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceFeatureStub + fakeReturns := fake.getSpaceFeatureReturns fake.recordInvocation("GetSpaceFeature", []interface{}{arg1, arg2}) fake.getSpaceFeatureMutex.Unlock() - if fake.GetSpaceFeatureStub != nil { - return fake.GetSpaceFeatureStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceFeatureReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10426,15 +10793,16 @@ func (fake *FakeCloudControllerClient) GetSpaceIsolationSegment(arg1 string) (re fake.getSpaceIsolationSegmentArgsForCall = append(fake.getSpaceIsolationSegmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSpaceIsolationSegmentStub + fakeReturns := fake.getSpaceIsolationSegmentReturns fake.recordInvocation("GetSpaceIsolationSegment", []interface{}{arg1}) fake.getSpaceIsolationSegmentMutex.Unlock() - if fake.GetSpaceIsolationSegmentStub != nil { - return fake.GetSpaceIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10498,15 +10866,16 @@ func (fake *FakeCloudControllerClient) GetSpaceManifestDiff(arg1 string, arg2 [] arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.GetSpaceManifestDiffStub + fakeReturns := fake.getSpaceManifestDiffReturns fake.recordInvocation("GetSpaceManifestDiff", []interface{}{arg1, arg2Copy}) fake.getSpaceManifestDiffMutex.Unlock() - if fake.GetSpaceManifestDiffStub != nil { - return fake.GetSpaceManifestDiffStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceManifestDiffReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10564,15 +10933,16 @@ func (fake *FakeCloudControllerClient) GetSpaceQuota(arg1 string) (resources.Spa fake.getSpaceQuotaArgsForCall = append(fake.getSpaceQuotaArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSpaceQuotaStub + fakeReturns := fake.getSpaceQuotaReturns fake.recordInvocation("GetSpaceQuota", []interface{}{arg1}) fake.getSpaceQuotaMutex.Unlock() - if fake.GetSpaceQuotaStub != nil { - return fake.GetSpaceQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10630,15 +11000,16 @@ func (fake *FakeCloudControllerClient) GetSpaceQuotas(arg1 ...ccv3.Query) ([]res fake.getSpaceQuotasArgsForCall = append(fake.getSpaceQuotasArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetSpaceQuotasStub + fakeReturns := fake.getSpaceQuotasReturns fake.recordInvocation("GetSpaceQuotas", []interface{}{arg1}) fake.getSpaceQuotasMutex.Unlock() - if fake.GetSpaceQuotasStub != nil { - return fake.GetSpaceQuotasStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceQuotasReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10696,15 +11067,16 @@ func (fake *FakeCloudControllerClient) GetSpaces(arg1 ...ccv3.Query) ([]resource fake.getSpacesArgsForCall = append(fake.getSpacesArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetSpacesStub + fakeReturns := fake.getSpacesReturns fake.recordInvocation("GetSpaces", []interface{}{arg1}) fake.getSpacesMutex.Unlock() - if fake.GetSpacesStub != nil { - return fake.GetSpacesStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.getSpacesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -10765,15 +11137,16 @@ func (fake *FakeCloudControllerClient) GetStacks(arg1 ...ccv3.Query) ([]resource fake.getStacksArgsForCall = append(fake.getStacksArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetStacksStub + fakeReturns := fake.getStacksReturns fake.recordInvocation("GetStacks", []interface{}{arg1}) fake.getStacksMutex.Unlock() - if fake.GetStacksStub != nil { - return fake.GetStacksStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getStacksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10832,15 +11205,16 @@ func (fake *FakeCloudControllerClient) GetStagingSecurityGroups(arg1 string, arg arg1 string arg2 []ccv3.Query }{arg1, arg2}) + stub := fake.GetStagingSecurityGroupsStub + fakeReturns := fake.getStagingSecurityGroupsReturns fake.recordInvocation("GetStagingSecurityGroups", []interface{}{arg1, arg2}) fake.getStagingSecurityGroupsMutex.Unlock() - if fake.GetStagingSecurityGroupsStub != nil { - return fake.GetStagingSecurityGroupsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getStagingSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10892,57 +11266,125 @@ func (fake *FakeCloudControllerClient) GetStagingSecurityGroupsReturnsOnCall(i i }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) GetUser(arg1 string) (resources.User, ccv3.Warnings, error) { - fake.getUserMutex.Lock() - ret, specificReturn := fake.getUserReturnsOnCall[len(fake.getUserArgsForCall)] - fake.getUserArgsForCall = append(fake.getUserArgsForCall, struct { +func (fake *FakeCloudControllerClient) GetTask(arg1 string) (resources.Task, ccv3.Warnings, error) { + fake.getTaskMutex.Lock() + ret, specificReturn := fake.getTaskReturnsOnCall[len(fake.getTaskArgsForCall)] + fake.getTaskArgsForCall = append(fake.getTaskArgsForCall, struct { arg1 string }{arg1}) - fake.recordInvocation("GetUser", []interface{}{arg1}) - fake.getUserMutex.Unlock() - if fake.GetUserStub != nil { - return fake.GetUserStub(arg1) + stub := fake.GetTaskStub + fakeReturns := fake.getTaskReturns + fake.recordInvocation("GetTask", []interface{}{arg1}) + fake.getTaskMutex.Unlock() + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getUserReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeCloudControllerClient) GetUserCallCount() int { - fake.getUserMutex.RLock() - defer fake.getUserMutex.RUnlock() - return len(fake.getUserArgsForCall) +func (fake *FakeCloudControllerClient) GetTaskCallCount() int { + fake.getTaskMutex.RLock() + defer fake.getTaskMutex.RUnlock() + return len(fake.getTaskArgsForCall) } -func (fake *FakeCloudControllerClient) GetUserCalls(stub func(string) (resources.User, ccv3.Warnings, error)) { - fake.getUserMutex.Lock() - defer fake.getUserMutex.Unlock() - fake.GetUserStub = stub +func (fake *FakeCloudControllerClient) GetTaskCalls(stub func(string) (resources.Task, ccv3.Warnings, error)) { + fake.getTaskMutex.Lock() + defer fake.getTaskMutex.Unlock() + fake.GetTaskStub = stub } -func (fake *FakeCloudControllerClient) GetUserArgsForCall(i int) string { - fake.getUserMutex.RLock() - defer fake.getUserMutex.RUnlock() - argsForCall := fake.getUserArgsForCall[i] +func (fake *FakeCloudControllerClient) GetTaskArgsForCall(i int) string { + fake.getTaskMutex.RLock() + defer fake.getTaskMutex.RUnlock() + argsForCall := fake.getTaskArgsForCall[i] return argsForCall.arg1 } -func (fake *FakeCloudControllerClient) GetUserReturns(result1 resources.User, result2 ccv3.Warnings, result3 error) { - fake.getUserMutex.Lock() - defer fake.getUserMutex.Unlock() - fake.GetUserStub = nil - fake.getUserReturns = struct { - result1 resources.User +func (fake *FakeCloudControllerClient) GetTaskReturns(result1 resources.Task, result2 ccv3.Warnings, result3 error) { + fake.getTaskMutex.Lock() + defer fake.getTaskMutex.Unlock() + fake.GetTaskStub = nil + fake.getTaskReturns = struct { + result1 resources.Task result2 ccv3.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) GetUserReturnsOnCall(i int, result1 resources.User, result2 ccv3.Warnings, result3 error) { - fake.getUserMutex.Lock() - defer fake.getUserMutex.Unlock() +func (fake *FakeCloudControllerClient) GetTaskReturnsOnCall(i int, result1 resources.Task, result2 ccv3.Warnings, result3 error) { + fake.getTaskMutex.Lock() + defer fake.getTaskMutex.Unlock() + fake.GetTaskStub = nil + if fake.getTaskReturnsOnCall == nil { + fake.getTaskReturnsOnCall = make(map[int]struct { + result1 resources.Task + result2 ccv3.Warnings + result3 error + }) + } + fake.getTaskReturnsOnCall[i] = struct { + result1 resources.Task + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) GetUser(arg1 string) (resources.User, ccv3.Warnings, error) { + fake.getUserMutex.Lock() + ret, specificReturn := fake.getUserReturnsOnCall[len(fake.getUserArgsForCall)] + fake.getUserArgsForCall = append(fake.getUserArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.GetUserStub + fakeReturns := fake.getUserReturns + fake.recordInvocation("GetUser", []interface{}{arg1}) + fake.getUserMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeCloudControllerClient) GetUserCallCount() int { + fake.getUserMutex.RLock() + defer fake.getUserMutex.RUnlock() + return len(fake.getUserArgsForCall) +} + +func (fake *FakeCloudControllerClient) GetUserCalls(stub func(string) (resources.User, ccv3.Warnings, error)) { + fake.getUserMutex.Lock() + defer fake.getUserMutex.Unlock() + fake.GetUserStub = stub +} + +func (fake *FakeCloudControllerClient) GetUserArgsForCall(i int) string { + fake.getUserMutex.RLock() + defer fake.getUserMutex.RUnlock() + argsForCall := fake.getUserArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeCloudControllerClient) GetUserReturns(result1 resources.User, result2 ccv3.Warnings, result3 error) { + fake.getUserMutex.Lock() + defer fake.getUserMutex.Unlock() + fake.GetUserStub = nil + fake.getUserReturns = struct { + result1 resources.User + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) GetUserReturnsOnCall(i int, result1 resources.User, result2 ccv3.Warnings, result3 error) { + fake.getUserMutex.Lock() + defer fake.getUserMutex.Unlock() fake.GetUserStub = nil if fake.getUserReturnsOnCall == nil { fake.getUserReturnsOnCall = make(map[int]struct { @@ -10964,15 +11406,16 @@ func (fake *FakeCloudControllerClient) GetUsers(arg1 ...ccv3.Query) ([]resources fake.getUsersArgsForCall = append(fake.getUsersArgsForCall, struct { arg1 []ccv3.Query }{arg1}) + stub := fake.GetUsersStub + fakeReturns := fake.getUsersReturns fake.recordInvocation("GetUsers", []interface{}{arg1}) fake.getUsersMutex.Unlock() - if fake.GetUsersStub != nil { - return fake.GetUsersStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getUsersReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11038,15 +11481,16 @@ func (fake *FakeCloudControllerClient) MakeRequestSendReceiveRaw(arg1 string, ar arg3 http.Header arg4 []byte }{arg1, arg2, arg3, arg4Copy}) + stub := fake.MakeRequestSendReceiveRawStub + fakeReturns := fake.makeRequestSendReceiveRawReturns fake.recordInvocation("MakeRequestSendReceiveRaw", []interface{}{arg1, arg2, arg3, arg4Copy}) fake.makeRequestSendReceiveRawMutex.Unlock() - if fake.MakeRequestSendReceiveRawStub != nil { - return fake.MakeRequestSendReceiveRawStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestSendReceiveRawReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11106,15 +11550,16 @@ func (fake *FakeCloudControllerClient) MapRoute(arg1 string, arg2 string, arg3 s arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.MapRouteStub + fakeReturns := fake.mapRouteReturns fake.recordInvocation("MapRoute", []interface{}{arg1, arg2, arg3}) fake.mapRouteMutex.Unlock() - if fake.MapRouteStub != nil { - return fake.MapRouteStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.mapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11163,21 +11608,87 @@ func (fake *FakeCloudControllerClient) MapRouteReturnsOnCall(i int, result1 ccv3 }{result1, result2} } +func (fake *FakeCloudControllerClient) MoveRoute(arg1 string, arg2 string) (ccv3.Warnings, error) { + fake.moveRouteMutex.Lock() + ret, specificReturn := fake.moveRouteReturnsOnCall[len(fake.moveRouteArgsForCall)] + fake.moveRouteArgsForCall = append(fake.moveRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.MoveRouteStub + fakeReturns := fake.moveRouteReturns + fake.recordInvocation("MoveRoute", []interface{}{arg1, arg2}) + fake.moveRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCloudControllerClient) MoveRouteCallCount() int { + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() + return len(fake.moveRouteArgsForCall) +} + +func (fake *FakeCloudControllerClient) MoveRouteCalls(stub func(string, string) (ccv3.Warnings, error)) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = stub +} + +func (fake *FakeCloudControllerClient) MoveRouteArgsForCall(i int) (string, string) { + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() + argsForCall := fake.moveRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCloudControllerClient) MoveRouteReturns(result1 ccv3.Warnings, result2 error) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = nil + fake.moveRouteReturns = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeCloudControllerClient) MoveRouteReturnsOnCall(i int, result1 ccv3.Warnings, result2 error) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = nil + if fake.moveRouteReturnsOnCall == nil { + fake.moveRouteReturnsOnCall = make(map[int]struct { + result1 ccv3.Warnings + result2 error + }) + } + fake.moveRouteReturnsOnCall[i] = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeCloudControllerClient) PollJob(arg1 ccv3.JobURL) (ccv3.Warnings, error) { fake.pollJobMutex.Lock() ret, specificReturn := fake.pollJobReturnsOnCall[len(fake.pollJobArgsForCall)] fake.pollJobArgsForCall = append(fake.pollJobArgsForCall, struct { arg1 ccv3.JobURL }{arg1}) + stub := fake.PollJobStub + fakeReturns := fake.pollJobReturns fake.recordInvocation("PollJob", []interface{}{arg1}) fake.pollJobMutex.Unlock() - if fake.PollJobStub != nil { - return fake.PollJobStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollJobReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11233,15 +11744,16 @@ func (fake *FakeCloudControllerClient) PollJobForState(arg1 ccv3.JobURL, arg2 co arg1 ccv3.JobURL arg2 constant.JobState }{arg1, arg2}) + stub := fake.PollJobForStateStub + fakeReturns := fake.pollJobForStateReturns fake.recordInvocation("PollJobForState", []interface{}{arg1, arg2}) fake.pollJobForStateMutex.Unlock() - if fake.PollJobForStateStub != nil { - return fake.PollJobForStateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollJobForStateReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11296,15 +11808,16 @@ func (fake *FakeCloudControllerClient) PollJobToEventStream(arg1 ccv3.JobURL) ch fake.pollJobToEventStreamArgsForCall = append(fake.pollJobToEventStreamArgsForCall, struct { arg1 ccv3.JobURL }{arg1}) + stub := fake.PollJobToEventStreamStub + fakeReturns := fake.pollJobToEventStreamReturns fake.recordInvocation("PollJobToEventStream", []interface{}{arg1}) fake.pollJobToEventStreamMutex.Unlock() - if fake.PollJobToEventStreamStub != nil { - return fake.PollJobToEventStreamStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.pollJobToEventStreamReturns return fakeReturns.result1 } @@ -11356,15 +11869,16 @@ func (fake *FakeCloudControllerClient) PurgeServiceOffering(arg1 string) (ccv3.W fake.purgeServiceOfferingArgsForCall = append(fake.purgeServiceOfferingArgsForCall, struct { arg1 string }{arg1}) + stub := fake.PurgeServiceOfferingStub + fakeReturns := fake.purgeServiceOfferingReturns fake.recordInvocation("PurgeServiceOffering", []interface{}{arg1}) fake.purgeServiceOfferingMutex.Unlock() - if fake.PurgeServiceOfferingStub != nil { - return fake.PurgeServiceOfferingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.purgeServiceOfferingReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11424,15 +11938,16 @@ func (fake *FakeCloudControllerClient) ResourceMatch(arg1 []ccv3.Resource) ([]cc fake.resourceMatchArgsForCall = append(fake.resourceMatchArgsForCall, struct { arg1 []ccv3.Resource }{arg1Copy}) + stub := fake.ResourceMatchStub + fakeReturns := fake.resourceMatchReturns fake.recordInvocation("ResourceMatch", []interface{}{arg1Copy}) fake.resourceMatchMutex.Unlock() - if fake.ResourceMatchStub != nil { - return fake.ResourceMatchStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.resourceMatchReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11484,20 +11999,21 @@ func (fake *FakeCloudControllerClient) ResourceMatchReturnsOnCall(i int, result1 }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) RootResponse() (ccv3.Info, ccv3.Warnings, error) { +func (fake *FakeCloudControllerClient) RootResponse() (ccv3.Root, ccv3.Warnings, error) { fake.rootResponseMutex.Lock() ret, specificReturn := fake.rootResponseReturnsOnCall[len(fake.rootResponseArgsForCall)] fake.rootResponseArgsForCall = append(fake.rootResponseArgsForCall, struct { }{}) + stub := fake.RootResponseStub + fakeReturns := fake.rootResponseReturns fake.recordInvocation("RootResponse", []interface{}{}) fake.rootResponseMutex.Unlock() - if fake.RootResponseStub != nil { - return fake.RootResponseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.rootResponseReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11507,36 +12023,36 @@ func (fake *FakeCloudControllerClient) RootResponseCallCount() int { return len(fake.rootResponseArgsForCall) } -func (fake *FakeCloudControllerClient) RootResponseCalls(stub func() (ccv3.Info, ccv3.Warnings, error)) { +func (fake *FakeCloudControllerClient) RootResponseCalls(stub func() (ccv3.Root, ccv3.Warnings, error)) { fake.rootResponseMutex.Lock() defer fake.rootResponseMutex.Unlock() fake.RootResponseStub = stub } -func (fake *FakeCloudControllerClient) RootResponseReturns(result1 ccv3.Info, result2 ccv3.Warnings, result3 error) { +func (fake *FakeCloudControllerClient) RootResponseReturns(result1 ccv3.Root, result2 ccv3.Warnings, result3 error) { fake.rootResponseMutex.Lock() defer fake.rootResponseMutex.Unlock() fake.RootResponseStub = nil fake.rootResponseReturns = struct { - result1 ccv3.Info + result1 ccv3.Root result2 ccv3.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeCloudControllerClient) RootResponseReturnsOnCall(i int, result1 ccv3.Info, result2 ccv3.Warnings, result3 error) { +func (fake *FakeCloudControllerClient) RootResponseReturnsOnCall(i int, result1 ccv3.Root, result2 ccv3.Warnings, result3 error) { fake.rootResponseMutex.Lock() defer fake.rootResponseMutex.Unlock() fake.RootResponseStub = nil if fake.rootResponseReturnsOnCall == nil { fake.rootResponseReturnsOnCall = make(map[int]struct { - result1 ccv3.Info + result1 ccv3.Root result2 ccv3.Warnings result3 error }) } fake.rootResponseReturnsOnCall[i] = struct { - result1 ccv3.Info + result1 ccv3.Root result2 ccv3.Warnings result3 error }{result1, result2, result3} @@ -11549,15 +12065,16 @@ func (fake *FakeCloudControllerClient) SetApplicationDroplet(arg1 string, arg2 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetApplicationDropletStub + fakeReturns := fake.setApplicationDropletReturns fake.recordInvocation("SetApplicationDroplet", []interface{}{arg1, arg2}) fake.setApplicationDropletMutex.Unlock() - if fake.SetApplicationDropletStub != nil { - return fake.SetApplicationDropletStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.setApplicationDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11616,15 +12133,16 @@ func (fake *FakeCloudControllerClient) SharePrivateDomainToOrgs(arg1 string, arg arg1 string arg2 ccv3.SharedOrgs }{arg1, arg2}) + stub := fake.SharePrivateDomainToOrgsStub + fakeReturns := fake.sharePrivateDomainToOrgsReturns fake.recordInvocation("SharePrivateDomainToOrgs", []interface{}{arg1, arg2}) fake.sharePrivateDomainToOrgsMutex.Unlock() - if fake.SharePrivateDomainToOrgsStub != nil { - return fake.SharePrivateDomainToOrgsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.sharePrivateDomainToOrgsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11673,6 +12191,71 @@ func (fake *FakeCloudControllerClient) SharePrivateDomainToOrgsReturnsOnCall(i i }{result1, result2} } +func (fake *FakeCloudControllerClient) ShareRoute(arg1 string, arg2 string) (ccv3.Warnings, error) { + fake.shareRouteMutex.Lock() + ret, specificReturn := fake.shareRouteReturnsOnCall[len(fake.shareRouteArgsForCall)] + fake.shareRouteArgsForCall = append(fake.shareRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.ShareRouteStub + fakeReturns := fake.shareRouteReturns + fake.recordInvocation("ShareRoute", []interface{}{arg1, arg2}) + fake.shareRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCloudControllerClient) ShareRouteCallCount() int { + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() + return len(fake.shareRouteArgsForCall) +} + +func (fake *FakeCloudControllerClient) ShareRouteCalls(stub func(string, string) (ccv3.Warnings, error)) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = stub +} + +func (fake *FakeCloudControllerClient) ShareRouteArgsForCall(i int) (string, string) { + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() + argsForCall := fake.shareRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCloudControllerClient) ShareRouteReturns(result1 ccv3.Warnings, result2 error) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = nil + fake.shareRouteReturns = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeCloudControllerClient) ShareRouteReturnsOnCall(i int, result1 ccv3.Warnings, result2 error) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = nil + if fake.shareRouteReturnsOnCall == nil { + fake.shareRouteReturnsOnCall = make(map[int]struct { + result1 ccv3.Warnings + result2 error + }) + } + fake.shareRouteReturnsOnCall[i] = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeCloudControllerClient) ShareServiceInstanceToSpaces(arg1 string, arg2 []string) (resources.RelationshipList, ccv3.Warnings, error) { var arg2Copy []string if arg2 != nil { @@ -11685,15 +12268,16 @@ func (fake *FakeCloudControllerClient) ShareServiceInstanceToSpaces(arg1 string, arg1 string arg2 []string }{arg1, arg2Copy}) + stub := fake.ShareServiceInstanceToSpacesStub + fakeReturns := fake.shareServiceInstanceToSpacesReturns fake.recordInvocation("ShareServiceInstanceToSpaces", []interface{}{arg1, arg2Copy}) fake.shareServiceInstanceToSpacesMutex.Unlock() - if fake.ShareServiceInstanceToSpacesStub != nil { - return fake.ShareServiceInstanceToSpacesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.shareServiceInstanceToSpacesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11750,9 +12334,10 @@ func (fake *FakeCloudControllerClient) TargetCF(arg1 ccv3.TargetSettings) { fake.targetCFArgsForCall = append(fake.targetCFArgsForCall, struct { arg1 ccv3.TargetSettings }{arg1}) + stub := fake.TargetCFStub fake.recordInvocation("TargetCF", []interface{}{arg1}) fake.targetCFMutex.Unlock() - if fake.TargetCFStub != nil { + if stub != nil { fake.TargetCFStub(arg1) } } @@ -11783,15 +12368,16 @@ func (fake *FakeCloudControllerClient) UnbindSecurityGroupRunningSpace(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnbindSecurityGroupRunningSpaceStub + fakeReturns := fake.unbindSecurityGroupRunningSpaceReturns fake.recordInvocation("UnbindSecurityGroupRunningSpace", []interface{}{arg1, arg2}) fake.unbindSecurityGroupRunningSpaceMutex.Unlock() - if fake.UnbindSecurityGroupRunningSpaceStub != nil { - return fake.UnbindSecurityGroupRunningSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unbindSecurityGroupRunningSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11847,15 +12433,16 @@ func (fake *FakeCloudControllerClient) UnbindSecurityGroupStagingSpace(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnbindSecurityGroupStagingSpaceStub + fakeReturns := fake.unbindSecurityGroupStagingSpaceReturns fake.recordInvocation("UnbindSecurityGroupStagingSpace", []interface{}{arg1, arg2}) fake.unbindSecurityGroupStagingSpaceMutex.Unlock() - if fake.UnbindSecurityGroupStagingSpaceStub != nil { - return fake.UnbindSecurityGroupStagingSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unbindSecurityGroupStagingSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11911,15 +12498,16 @@ func (fake *FakeCloudControllerClient) UnmapRoute(arg1 string, arg2 string) (ccv arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnmapRouteStub + fakeReturns := fake.unmapRouteReturns fake.recordInvocation("UnmapRoute", []interface{}{arg1, arg2}) fake.unmapRouteMutex.Unlock() - if fake.UnmapRouteStub != nil { - return fake.UnmapRouteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unmapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11975,15 +12563,16 @@ func (fake *FakeCloudControllerClient) UnsetSpaceQuota(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnsetSpaceQuotaStub + fakeReturns := fake.unsetSpaceQuotaReturns fake.recordInvocation("UnsetSpaceQuota", []interface{}{arg1, arg2}) fake.unsetSpaceQuotaMutex.Unlock() - if fake.UnsetSpaceQuotaStub != nil { - return fake.UnsetSpaceQuotaStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unsetSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -12039,15 +12628,16 @@ func (fake *FakeCloudControllerClient) UnsharePrivateDomainFromOrg(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnsharePrivateDomainFromOrgStub + fakeReturns := fake.unsharePrivateDomainFromOrgReturns fake.recordInvocation("UnsharePrivateDomainFromOrg", []interface{}{arg1, arg2}) fake.unsharePrivateDomainFromOrgMutex.Unlock() - if fake.UnsharePrivateDomainFromOrgStub != nil { - return fake.UnsharePrivateDomainFromOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unsharePrivateDomainFromOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -12096,6 +12686,71 @@ func (fake *FakeCloudControllerClient) UnsharePrivateDomainFromOrgReturnsOnCall( }{result1, result2} } +func (fake *FakeCloudControllerClient) UnshareRoute(arg1 string, arg2 string) (ccv3.Warnings, error) { + fake.unshareRouteMutex.Lock() + ret, specificReturn := fake.unshareRouteReturnsOnCall[len(fake.unshareRouteArgsForCall)] + fake.unshareRouteArgsForCall = append(fake.unshareRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.UnshareRouteStub + fakeReturns := fake.unshareRouteReturns + fake.recordInvocation("UnshareRoute", []interface{}{arg1, arg2}) + fake.unshareRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCloudControllerClient) UnshareRouteCallCount() int { + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() + return len(fake.unshareRouteArgsForCall) +} + +func (fake *FakeCloudControllerClient) UnshareRouteCalls(stub func(string, string) (ccv3.Warnings, error)) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = stub +} + +func (fake *FakeCloudControllerClient) UnshareRouteArgsForCall(i int) (string, string) { + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() + argsForCall := fake.unshareRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCloudControllerClient) UnshareRouteReturns(result1 ccv3.Warnings, result2 error) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = nil + fake.unshareRouteReturns = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeCloudControllerClient) UnshareRouteReturnsOnCall(i int, result1 ccv3.Warnings, result2 error) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = nil + if fake.unshareRouteReturnsOnCall == nil { + fake.unshareRouteReturnsOnCall = make(map[int]struct { + result1 ccv3.Warnings + result2 error + }) + } + fake.unshareRouteReturnsOnCall[i] = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeCloudControllerClient) UnshareServiceInstanceFromSpace(arg1 string, arg2 string) (ccv3.Warnings, error) { fake.unshareServiceInstanceFromSpaceMutex.Lock() ret, specificReturn := fake.unshareServiceInstanceFromSpaceReturnsOnCall[len(fake.unshareServiceInstanceFromSpaceArgsForCall)] @@ -12103,15 +12758,16 @@ func (fake *FakeCloudControllerClient) UnshareServiceInstanceFromSpace(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnshareServiceInstanceFromSpaceStub + fakeReturns := fake.unshareServiceInstanceFromSpaceReturns fake.recordInvocation("UnshareServiceInstanceFromSpace", []interface{}{arg1, arg2}) fake.unshareServiceInstanceFromSpaceMutex.Unlock() - if fake.UnshareServiceInstanceFromSpaceStub != nil { - return fake.UnshareServiceInstanceFromSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unshareServiceInstanceFromSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -12168,15 +12824,16 @@ func (fake *FakeCloudControllerClient) UpdateAppFeature(arg1 string, arg2 bool, arg2 bool arg3 string }{arg1, arg2, arg3}) + stub := fake.UpdateAppFeatureStub + fakeReturns := fake.updateAppFeatureReturns fake.recordInvocation("UpdateAppFeature", []interface{}{arg1, arg2, arg3}) fake.updateAppFeatureMutex.Unlock() - if fake.UpdateAppFeatureStub != nil { - return fake.UpdateAppFeatureStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateAppFeatureReturns return fakeReturns.result1, fakeReturns.result2 } @@ -12231,15 +12888,16 @@ func (fake *FakeCloudControllerClient) UpdateApplication(arg1 resources.Applicat fake.updateApplicationArgsForCall = append(fake.updateApplicationArgsForCall, struct { arg1 resources.Application }{arg1}) + stub := fake.UpdateApplicationStub + fakeReturns := fake.updateApplicationReturns fake.recordInvocation("UpdateApplication", []interface{}{arg1}) fake.updateApplicationMutex.Unlock() - if fake.UpdateApplicationStub != nil { - return fake.UpdateApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12303,15 +12961,16 @@ func (fake *FakeCloudControllerClient) UpdateApplicationApplyManifest(arg1 strin arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.UpdateApplicationApplyManifestStub + fakeReturns := fake.updateApplicationApplyManifestReturns fake.recordInvocation("UpdateApplicationApplyManifest", []interface{}{arg1, arg2Copy}) fake.updateApplicationApplyManifestMutex.Unlock() - if fake.UpdateApplicationApplyManifestStub != nil { - return fake.UpdateApplicationApplyManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationApplyManifestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12370,15 +13029,16 @@ func (fake *FakeCloudControllerClient) UpdateApplicationEnvironmentVariables(arg arg1 string arg2 resources.EnvironmentVariables }{arg1, arg2}) + stub := fake.UpdateApplicationEnvironmentVariablesStub + fakeReturns := fake.updateApplicationEnvironmentVariablesReturns fake.recordInvocation("UpdateApplicationEnvironmentVariables", []interface{}{arg1, arg2}) fake.updateApplicationEnvironmentVariablesMutex.Unlock() - if fake.UpdateApplicationEnvironmentVariablesStub != nil { - return fake.UpdateApplicationEnvironmentVariablesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationEnvironmentVariablesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12430,21 +13090,90 @@ func (fake *FakeCloudControllerClient) UpdateApplicationEnvironmentVariablesRetu }{result1, result2, result3} } +func (fake *FakeCloudControllerClient) UpdateApplicationName(arg1 string, arg2 string) (resources.Application, ccv3.Warnings, error) { + fake.updateApplicationNameMutex.Lock() + ret, specificReturn := fake.updateApplicationNameReturnsOnCall[len(fake.updateApplicationNameArgsForCall)] + fake.updateApplicationNameArgsForCall = append(fake.updateApplicationNameArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.UpdateApplicationNameStub + fakeReturns := fake.updateApplicationNameReturns + fake.recordInvocation("UpdateApplicationName", []interface{}{arg1, arg2}) + fake.updateApplicationNameMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeCloudControllerClient) UpdateApplicationNameCallCount() int { + fake.updateApplicationNameMutex.RLock() + defer fake.updateApplicationNameMutex.RUnlock() + return len(fake.updateApplicationNameArgsForCall) +} + +func (fake *FakeCloudControllerClient) UpdateApplicationNameCalls(stub func(string, string) (resources.Application, ccv3.Warnings, error)) { + fake.updateApplicationNameMutex.Lock() + defer fake.updateApplicationNameMutex.Unlock() + fake.UpdateApplicationNameStub = stub +} + +func (fake *FakeCloudControllerClient) UpdateApplicationNameArgsForCall(i int) (string, string) { + fake.updateApplicationNameMutex.RLock() + defer fake.updateApplicationNameMutex.RUnlock() + argsForCall := fake.updateApplicationNameArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCloudControllerClient) UpdateApplicationNameReturns(result1 resources.Application, result2 ccv3.Warnings, result3 error) { + fake.updateApplicationNameMutex.Lock() + defer fake.updateApplicationNameMutex.Unlock() + fake.UpdateApplicationNameStub = nil + fake.updateApplicationNameReturns = struct { + result1 resources.Application + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) UpdateApplicationNameReturnsOnCall(i int, result1 resources.Application, result2 ccv3.Warnings, result3 error) { + fake.updateApplicationNameMutex.Lock() + defer fake.updateApplicationNameMutex.Unlock() + fake.UpdateApplicationNameStub = nil + if fake.updateApplicationNameReturnsOnCall == nil { + fake.updateApplicationNameReturnsOnCall = make(map[int]struct { + result1 resources.Application + result2 ccv3.Warnings + result3 error + }) + } + fake.updateApplicationNameReturnsOnCall[i] = struct { + result1 resources.Application + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeCloudControllerClient) UpdateApplicationRestart(arg1 string) (resources.Application, ccv3.Warnings, error) { fake.updateApplicationRestartMutex.Lock() ret, specificReturn := fake.updateApplicationRestartReturnsOnCall[len(fake.updateApplicationRestartArgsForCall)] fake.updateApplicationRestartArgsForCall = append(fake.updateApplicationRestartArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UpdateApplicationRestartStub + fakeReturns := fake.updateApplicationRestartReturns fake.recordInvocation("UpdateApplicationRestart", []interface{}{arg1}) fake.updateApplicationRestartMutex.Unlock() - if fake.UpdateApplicationRestartStub != nil { - return fake.UpdateApplicationRestartStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationRestartReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12502,15 +13231,16 @@ func (fake *FakeCloudControllerClient) UpdateApplicationStart(arg1 string) (reso fake.updateApplicationStartArgsForCall = append(fake.updateApplicationStartArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UpdateApplicationStartStub + fakeReturns := fake.updateApplicationStartReturns fake.recordInvocation("UpdateApplicationStart", []interface{}{arg1}) fake.updateApplicationStartMutex.Unlock() - if fake.UpdateApplicationStartStub != nil { - return fake.UpdateApplicationStartStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationStartReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12568,15 +13298,16 @@ func (fake *FakeCloudControllerClient) UpdateApplicationStop(arg1 string) (resou fake.updateApplicationStopArgsForCall = append(fake.updateApplicationStopArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UpdateApplicationStopStub + fakeReturns := fake.updateApplicationStopReturns fake.recordInvocation("UpdateApplicationStop", []interface{}{arg1}) fake.updateApplicationStopMutex.Unlock() - if fake.UpdateApplicationStopStub != nil { - return fake.UpdateApplicationStopStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationStopReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12634,15 +13365,16 @@ func (fake *FakeCloudControllerClient) UpdateBuildpack(arg1 resources.Buildpack) fake.updateBuildpackArgsForCall = append(fake.updateBuildpackArgsForCall, struct { arg1 resources.Buildpack }{arg1}) + stub := fake.UpdateBuildpackStub + fakeReturns := fake.updateBuildpackReturns fake.recordInvocation("UpdateBuildpack", []interface{}{arg1}) fake.updateBuildpackMutex.Unlock() - if fake.UpdateBuildpackStub != nil { - return fake.UpdateBuildpackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12694,6 +13426,72 @@ func (fake *FakeCloudControllerClient) UpdateBuildpackReturnsOnCall(i int, resul }{result1, result2, result3} } +func (fake *FakeCloudControllerClient) UpdateDestination(arg1 string, arg2 string, arg3 string) (ccv3.Warnings, error) { + fake.updateDestinationMutex.Lock() + ret, specificReturn := fake.updateDestinationReturnsOnCall[len(fake.updateDestinationArgsForCall)] + fake.updateDestinationArgsForCall = append(fake.updateDestinationArgsForCall, struct { + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + stub := fake.UpdateDestinationStub + fakeReturns := fake.updateDestinationReturns + fake.recordInvocation("UpdateDestination", []interface{}{arg1, arg2, arg3}) + fake.updateDestinationMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCloudControllerClient) UpdateDestinationCallCount() int { + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() + return len(fake.updateDestinationArgsForCall) +} + +func (fake *FakeCloudControllerClient) UpdateDestinationCalls(stub func(string, string, string) (ccv3.Warnings, error)) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = stub +} + +func (fake *FakeCloudControllerClient) UpdateDestinationArgsForCall(i int) (string, string, string) { + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() + argsForCall := fake.updateDestinationArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeCloudControllerClient) UpdateDestinationReturns(result1 ccv3.Warnings, result2 error) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = nil + fake.updateDestinationReturns = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeCloudControllerClient) UpdateDestinationReturnsOnCall(i int, result1 ccv3.Warnings, result2 error) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = nil + if fake.updateDestinationReturnsOnCall == nil { + fake.updateDestinationReturnsOnCall = make(map[int]struct { + result1 ccv3.Warnings + result2 error + }) + } + fake.updateDestinationReturnsOnCall[i] = struct { + result1 ccv3.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeCloudControllerClient) UpdateEnvironmentVariableGroup(arg1 constant.EnvironmentVariableGroupName, arg2 resources.EnvironmentVariables) (resources.EnvironmentVariables, ccv3.Warnings, error) { fake.updateEnvironmentVariableGroupMutex.Lock() ret, specificReturn := fake.updateEnvironmentVariableGroupReturnsOnCall[len(fake.updateEnvironmentVariableGroupArgsForCall)] @@ -12701,15 +13499,16 @@ func (fake *FakeCloudControllerClient) UpdateEnvironmentVariableGroup(arg1 const arg1 constant.EnvironmentVariableGroupName arg2 resources.EnvironmentVariables }{arg1, arg2}) + stub := fake.UpdateEnvironmentVariableGroupStub + fakeReturns := fake.updateEnvironmentVariableGroupReturns fake.recordInvocation("UpdateEnvironmentVariableGroup", []interface{}{arg1, arg2}) fake.updateEnvironmentVariableGroupMutex.Unlock() - if fake.UpdateEnvironmentVariableGroupStub != nil { - return fake.UpdateEnvironmentVariableGroupStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateEnvironmentVariableGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12767,15 +13566,16 @@ func (fake *FakeCloudControllerClient) UpdateFeatureFlag(arg1 resources.FeatureF fake.updateFeatureFlagArgsForCall = append(fake.updateFeatureFlagArgsForCall, struct { arg1 resources.FeatureFlag }{arg1}) + stub := fake.UpdateFeatureFlagStub + fakeReturns := fake.updateFeatureFlagReturns fake.recordInvocation("UpdateFeatureFlag", []interface{}{arg1}) fake.updateFeatureFlagMutex.Unlock() - if fake.UpdateFeatureFlagStub != nil { - return fake.UpdateFeatureFlagStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateFeatureFlagReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12833,15 +13633,16 @@ func (fake *FakeCloudControllerClient) UpdateOrganization(arg1 resources.Organiz fake.updateOrganizationArgsForCall = append(fake.updateOrganizationArgsForCall, struct { arg1 resources.Organization }{arg1}) + stub := fake.UpdateOrganizationStub + fakeReturns := fake.updateOrganizationReturns fake.recordInvocation("UpdateOrganization", []interface{}{arg1}) fake.updateOrganizationMutex.Unlock() - if fake.UpdateOrganizationStub != nil { - return fake.UpdateOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12900,15 +13701,16 @@ func (fake *FakeCloudControllerClient) UpdateOrganizationDefaultIsolationSegment arg1 string arg2 string }{arg1, arg2}) + stub := fake.UpdateOrganizationDefaultIsolationSegmentRelationshipStub + fakeReturns := fake.updateOrganizationDefaultIsolationSegmentRelationshipReturns fake.recordInvocation("UpdateOrganizationDefaultIsolationSegmentRelationship", []interface{}{arg1, arg2}) fake.updateOrganizationDefaultIsolationSegmentRelationshipMutex.Unlock() - if fake.UpdateOrganizationDefaultIsolationSegmentRelationshipStub != nil { - return fake.UpdateOrganizationDefaultIsolationSegmentRelationshipStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateOrganizationDefaultIsolationSegmentRelationshipReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12966,15 +13768,16 @@ func (fake *FakeCloudControllerClient) UpdateOrganizationQuota(arg1 resources.Or fake.updateOrganizationQuotaArgsForCall = append(fake.updateOrganizationQuotaArgsForCall, struct { arg1 resources.OrganizationQuota }{arg1}) + stub := fake.UpdateOrganizationQuotaStub + fakeReturns := fake.updateOrganizationQuotaReturns fake.recordInvocation("UpdateOrganizationQuota", []interface{}{arg1}) fake.updateOrganizationQuotaMutex.Unlock() - if fake.UpdateOrganizationQuotaStub != nil { - return fake.UpdateOrganizationQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13032,15 +13835,16 @@ func (fake *FakeCloudControllerClient) UpdateProcess(arg1 resources.Process) (re fake.updateProcessArgsForCall = append(fake.updateProcessArgsForCall, struct { arg1 resources.Process }{arg1}) + stub := fake.UpdateProcessStub + fakeReturns := fake.updateProcessReturns fake.recordInvocation("UpdateProcess", []interface{}{arg1}) fake.updateProcessMutex.Unlock() - if fake.UpdateProcessStub != nil { - return fake.UpdateProcessStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateProcessReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13100,15 +13904,16 @@ func (fake *FakeCloudControllerClient) UpdateResourceMetadata(arg1 string, arg2 arg2 string arg3 resources.Metadata }{arg1, arg2, arg3}) + stub := fake.UpdateResourceMetadataStub + fakeReturns := fake.updateResourceMetadataReturns fake.recordInvocation("UpdateResourceMetadata", []interface{}{arg1, arg2, arg3}) fake.updateResourceMetadataMutex.Unlock() - if fake.UpdateResourceMetadataStub != nil { - return fake.UpdateResourceMetadataStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateResourceMetadataReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13160,21 +13965,90 @@ func (fake *FakeCloudControllerClient) UpdateResourceMetadataReturnsOnCall(i int }{result1, result2, result3} } +func (fake *FakeCloudControllerClient) UpdateRoute(arg1 string, arg2 map[string]*string) (resources.Route, ccv3.Warnings, error) { + fake.updateRouteMutex.Lock() + ret, specificReturn := fake.updateRouteReturnsOnCall[len(fake.updateRouteArgsForCall)] + fake.updateRouteArgsForCall = append(fake.updateRouteArgsForCall, struct { + arg1 string + arg2 map[string]*string + }{arg1, arg2}) + stub := fake.UpdateRouteStub + fakeReturns := fake.updateRouteReturns + fake.recordInvocation("UpdateRoute", []interface{}{arg1, arg2}) + fake.updateRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeCloudControllerClient) UpdateRouteCallCount() int { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + return len(fake.updateRouteArgsForCall) +} + +func (fake *FakeCloudControllerClient) UpdateRouteCalls(stub func(string, map[string]*string) (resources.Route, ccv3.Warnings, error)) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = stub +} + +func (fake *FakeCloudControllerClient) UpdateRouteArgsForCall(i int) (string, map[string]*string) { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + argsForCall := fake.updateRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCloudControllerClient) UpdateRouteReturns(result1 resources.Route, result2 ccv3.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + fake.updateRouteReturns = struct { + result1 resources.Route + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeCloudControllerClient) UpdateRouteReturnsOnCall(i int, result1 resources.Route, result2 ccv3.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + if fake.updateRouteReturnsOnCall == nil { + fake.updateRouteReturnsOnCall = make(map[int]struct { + result1 resources.Route + result2 ccv3.Warnings + result3 error + }) + } + fake.updateRouteReturnsOnCall[i] = struct { + result1 resources.Route + result2 ccv3.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeCloudControllerClient) UpdateSecurityGroup(arg1 resources.SecurityGroup) (resources.SecurityGroup, ccv3.Warnings, error) { fake.updateSecurityGroupMutex.Lock() ret, specificReturn := fake.updateSecurityGroupReturnsOnCall[len(fake.updateSecurityGroupArgsForCall)] fake.updateSecurityGroupArgsForCall = append(fake.updateSecurityGroupArgsForCall, struct { arg1 resources.SecurityGroup }{arg1}) + stub := fake.UpdateSecurityGroupStub + fakeReturns := fake.updateSecurityGroupReturns fake.recordInvocation("UpdateSecurityGroup", []interface{}{arg1}) fake.updateSecurityGroupMutex.Unlock() - if fake.UpdateSecurityGroupStub != nil { - return fake.UpdateSecurityGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13238,15 +14112,16 @@ func (fake *FakeCloudControllerClient) UpdateSecurityGroupRunningSpace(arg1 stri arg1 string arg2 []string }{arg1, arg2Copy}) + stub := fake.UpdateSecurityGroupRunningSpaceStub + fakeReturns := fake.updateSecurityGroupRunningSpaceReturns fake.recordInvocation("UpdateSecurityGroupRunningSpace", []interface{}{arg1, arg2Copy}) fake.updateSecurityGroupRunningSpaceMutex.Unlock() - if fake.UpdateSecurityGroupRunningSpaceStub != nil { - return fake.UpdateSecurityGroupRunningSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSecurityGroupRunningSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -13307,15 +14182,16 @@ func (fake *FakeCloudControllerClient) UpdateSecurityGroupStagingSpace(arg1 stri arg1 string arg2 []string }{arg1, arg2Copy}) + stub := fake.UpdateSecurityGroupStagingSpaceStub + fakeReturns := fake.updateSecurityGroupStagingSpaceReturns fake.recordInvocation("UpdateSecurityGroupStagingSpace", []interface{}{arg1, arg2Copy}) fake.updateSecurityGroupStagingSpaceMutex.Unlock() - if fake.UpdateSecurityGroupStagingSpaceStub != nil { - return fake.UpdateSecurityGroupStagingSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSecurityGroupStagingSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -13371,15 +14247,16 @@ func (fake *FakeCloudControllerClient) UpdateServiceBroker(arg1 string, arg2 res arg1 string arg2 resources.ServiceBroker }{arg1, arg2}) + stub := fake.UpdateServiceBrokerStub + fakeReturns := fake.updateServiceBrokerReturns fake.recordInvocation("UpdateServiceBroker", []interface{}{arg1, arg2}) fake.updateServiceBrokerMutex.Unlock() - if fake.UpdateServiceBrokerStub != nil { - return fake.UpdateServiceBrokerStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13438,15 +14315,16 @@ func (fake *FakeCloudControllerClient) UpdateServiceInstance(arg1 string, arg2 r arg1 string arg2 resources.ServiceInstance }{arg1, arg2}) + stub := fake.UpdateServiceInstanceStub + fakeReturns := fake.updateServiceInstanceReturns fake.recordInvocation("UpdateServiceInstance", []interface{}{arg1, arg2}) fake.updateServiceInstanceMutex.Unlock() - if fake.UpdateServiceInstanceStub != nil { - return fake.UpdateServiceInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13505,15 +14383,16 @@ func (fake *FakeCloudControllerClient) UpdateServicePlanVisibility(arg1 string, arg1 string arg2 resources.ServicePlanVisibility }{arg1, arg2}) + stub := fake.UpdateServicePlanVisibilityStub + fakeReturns := fake.updateServicePlanVisibilityReturns fake.recordInvocation("UpdateServicePlanVisibility", []interface{}{arg1, arg2}) fake.updateServicePlanVisibilityMutex.Unlock() - if fake.UpdateServicePlanVisibilityStub != nil { - return fake.UpdateServicePlanVisibilityStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateServicePlanVisibilityReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13571,15 +14450,16 @@ func (fake *FakeCloudControllerClient) UpdateSpace(arg1 resources.Space) (resour fake.updateSpaceArgsForCall = append(fake.updateSpaceArgsForCall, struct { arg1 resources.Space }{arg1}) + stub := fake.UpdateSpaceStub + fakeReturns := fake.updateSpaceReturns fake.recordInvocation("UpdateSpace", []interface{}{arg1}) fake.updateSpaceMutex.Unlock() - if fake.UpdateSpaceStub != nil { - return fake.UpdateSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13643,15 +14523,16 @@ func (fake *FakeCloudControllerClient) UpdateSpaceApplyManifest(arg1 string, arg arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.UpdateSpaceApplyManifestStub + fakeReturns := fake.updateSpaceApplyManifestReturns fake.recordInvocation("UpdateSpaceApplyManifest", []interface{}{arg1, arg2Copy}) fake.updateSpaceApplyManifestMutex.Unlock() - if fake.UpdateSpaceApplyManifestStub != nil { - return fake.UpdateSpaceApplyManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateSpaceApplyManifestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13711,15 +14592,16 @@ func (fake *FakeCloudControllerClient) UpdateSpaceFeature(arg1 string, arg2 bool arg2 bool arg3 string }{arg1, arg2, arg3}) + stub := fake.UpdateSpaceFeatureStub + fakeReturns := fake.updateSpaceFeatureReturns fake.recordInvocation("UpdateSpaceFeature", []interface{}{arg1, arg2, arg3}) fake.updateSpaceFeatureMutex.Unlock() - if fake.UpdateSpaceFeatureStub != nil { - return fake.UpdateSpaceFeatureStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSpaceFeatureReturns return fakeReturns.result1, fakeReturns.result2 } @@ -13775,15 +14657,16 @@ func (fake *FakeCloudControllerClient) UpdateSpaceIsolationSegmentRelationship(a arg1 string arg2 string }{arg1, arg2}) + stub := fake.UpdateSpaceIsolationSegmentRelationshipStub + fakeReturns := fake.updateSpaceIsolationSegmentRelationshipReturns fake.recordInvocation("UpdateSpaceIsolationSegmentRelationship", []interface{}{arg1, arg2}) fake.updateSpaceIsolationSegmentRelationshipMutex.Unlock() - if fake.UpdateSpaceIsolationSegmentRelationshipStub != nil { - return fake.UpdateSpaceIsolationSegmentRelationshipStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateSpaceIsolationSegmentRelationshipReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13841,15 +14724,16 @@ func (fake *FakeCloudControllerClient) UpdateSpaceQuota(arg1 resources.SpaceQuot fake.updateSpaceQuotaArgsForCall = append(fake.updateSpaceQuotaArgsForCall, struct { arg1 resources.SpaceQuota }{arg1}) + stub := fake.UpdateSpaceQuotaStub + fakeReturns := fake.updateSpaceQuotaReturns fake.recordInvocation("UpdateSpaceQuota", []interface{}{arg1}) fake.updateSpaceQuotaMutex.Unlock() - if fake.UpdateSpaceQuotaStub != nil { - return fake.UpdateSpaceQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13907,15 +14791,16 @@ func (fake *FakeCloudControllerClient) UpdateTaskCancel(arg1 string) (resources. fake.updateTaskCancelArgsForCall = append(fake.updateTaskCancelArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UpdateTaskCancelStub + fakeReturns := fake.updateTaskCancelReturns fake.recordInvocation("UpdateTaskCancel", []interface{}{arg1}) fake.updateTaskCancelMutex.Unlock() - if fake.UpdateTaskCancelStub != nil { - return fake.UpdateTaskCancelStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateTaskCancelReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13981,15 +14866,16 @@ func (fake *FakeCloudControllerClient) UploadBitsPackage(arg1 resources.Package, arg3 io.Reader arg4 int64 }{arg1, arg2Copy, arg3, arg4}) + stub := fake.UploadBitsPackageStub + fakeReturns := fake.uploadBitsPackageReturns fake.recordInvocation("UploadBitsPackage", []interface{}{arg1, arg2Copy, arg3, arg4}) fake.uploadBitsPackageMutex.Unlock() - if fake.UploadBitsPackageStub != nil { - return fake.UploadBitsPackageStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadBitsPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14050,15 +14936,16 @@ func (fake *FakeCloudControllerClient) UploadBuildpack(arg1 string, arg2 string, arg3 io.Reader arg4 int64 }{arg1, arg2, arg3, arg4}) + stub := fake.UploadBuildpackStub + fakeReturns := fake.uploadBuildpackReturns fake.recordInvocation("UploadBuildpack", []interface{}{arg1, arg2, arg3, arg4}) fake.uploadBuildpackMutex.Unlock() - if fake.UploadBuildpackStub != nil { - return fake.UploadBuildpackStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14119,15 +15006,16 @@ func (fake *FakeCloudControllerClient) UploadDropletBits(arg1 string, arg2 strin arg3 io.Reader arg4 int64 }{arg1, arg2, arg3, arg4}) + stub := fake.UploadDropletBitsStub + fakeReturns := fake.uploadDropletBitsReturns fake.recordInvocation("UploadDropletBits", []interface{}{arg1, arg2, arg3, arg4}) fake.uploadDropletBitsMutex.Unlock() - if fake.UploadDropletBitsStub != nil { - return fake.UploadDropletBitsStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadDropletBitsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14186,15 +15074,16 @@ func (fake *FakeCloudControllerClient) UploadPackage(arg1 resources.Package, arg arg1 resources.Package arg2 string }{arg1, arg2}) + stub := fake.UploadPackageStub + fakeReturns := fake.uploadPackageReturns fake.recordInvocation("UploadPackage", []interface{}{arg1, arg2}) fake.uploadPackageMutex.Unlock() - if fake.UploadPackageStub != nil { - return fake.UploadPackageStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14251,15 +15140,16 @@ func (fake *FakeCloudControllerClient) WhoAmI() (resources.K8sUser, ccv3.Warning ret, specificReturn := fake.whoAmIReturnsOnCall[len(fake.whoAmIArgsForCall)] fake.whoAmIArgsForCall = append(fake.whoAmIArgsForCall, struct { }{}) + stub := fake.WhoAmIStub + fakeReturns := fake.whoAmIReturns fake.recordInvocation("WhoAmI", []interface{}{}) fake.whoAmIMutex.Unlock() - if fake.WhoAmIStub != nil { - return fake.WhoAmIStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.whoAmIReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14315,14 +15205,14 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.cancelDeploymentMutex.RUnlock() fake.checkRouteMutex.RLock() defer fake.checkRouteMutex.RUnlock() + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() fake.copyPackageMutex.RLock() defer fake.copyPackageMutex.RUnlock() fake.createApplicationMutex.RLock() defer fake.createApplicationMutex.RUnlock() fake.createApplicationDeploymentMutex.RLock() defer fake.createApplicationDeploymentMutex.RUnlock() - fake.createApplicationDeploymentByRevisionMutex.RLock() - defer fake.createApplicationDeploymentByRevisionMutex.RUnlock() fake.createApplicationProcessScaleMutex.RLock() defer fake.createApplicationProcessScaleMutex.RUnlock() fake.createApplicationTaskMutex.RLock() @@ -14451,6 +15341,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.getDropletsMutex.RUnlock() fake.getEnvironmentVariableGroupMutex.RLock() defer fake.getEnvironmentVariableGroupMutex.RUnlock() + fake.getEnvironmentVariablesByURLMutex.RLock() + defer fake.getEnvironmentVariablesByURLMutex.RUnlock() fake.getEventsMutex.RLock() defer fake.getEventsMutex.RUnlock() fake.getFeatureFlagMutex.RLock() @@ -14495,6 +15387,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.getProcessesMutex.RUnlock() fake.getRolesMutex.RLock() defer fake.getRolesMutex.RUnlock() + fake.getRootMutex.RLock() + defer fake.getRootMutex.RUnlock() fake.getRouteBindingsMutex.RLock() defer fake.getRouteBindingsMutex.RUnlock() fake.getRouteDestinationsMutex.RLock() @@ -14555,6 +15449,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.getStacksMutex.RUnlock() fake.getStagingSecurityGroupsMutex.RLock() defer fake.getStagingSecurityGroupsMutex.RUnlock() + fake.getTaskMutex.RLock() + defer fake.getTaskMutex.RUnlock() fake.getUserMutex.RLock() defer fake.getUserMutex.RUnlock() fake.getUsersMutex.RLock() @@ -14563,6 +15459,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.makeRequestSendReceiveRawMutex.RUnlock() fake.mapRouteMutex.RLock() defer fake.mapRouteMutex.RUnlock() + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() fake.pollJobMutex.RLock() defer fake.pollJobMutex.RUnlock() fake.pollJobForStateMutex.RLock() @@ -14579,6 +15477,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.setApplicationDropletMutex.RUnlock() fake.sharePrivateDomainToOrgsMutex.RLock() defer fake.sharePrivateDomainToOrgsMutex.RUnlock() + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() fake.shareServiceInstanceToSpacesMutex.RLock() defer fake.shareServiceInstanceToSpacesMutex.RUnlock() fake.targetCFMutex.RLock() @@ -14593,6 +15493,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.unsetSpaceQuotaMutex.RUnlock() fake.unsharePrivateDomainFromOrgMutex.RLock() defer fake.unsharePrivateDomainFromOrgMutex.RUnlock() + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() fake.unshareServiceInstanceFromSpaceMutex.RLock() defer fake.unshareServiceInstanceFromSpaceMutex.RUnlock() fake.updateAppFeatureMutex.RLock() @@ -14603,6 +15505,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.updateApplicationApplyManifestMutex.RUnlock() fake.updateApplicationEnvironmentVariablesMutex.RLock() defer fake.updateApplicationEnvironmentVariablesMutex.RUnlock() + fake.updateApplicationNameMutex.RLock() + defer fake.updateApplicationNameMutex.RUnlock() fake.updateApplicationRestartMutex.RLock() defer fake.updateApplicationRestartMutex.RUnlock() fake.updateApplicationStartMutex.RLock() @@ -14611,6 +15515,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.updateApplicationStopMutex.RUnlock() fake.updateBuildpackMutex.RLock() defer fake.updateBuildpackMutex.RUnlock() + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() fake.updateEnvironmentVariableGroupMutex.RLock() defer fake.updateEnvironmentVariableGroupMutex.RUnlock() fake.updateFeatureFlagMutex.RLock() @@ -14625,6 +15531,8 @@ func (fake *FakeCloudControllerClient) Invocations() map[string][][]interface{} defer fake.updateProcessMutex.RUnlock() fake.updateResourceMetadataMutex.RLock() defer fake.updateResourceMetadataMutex.RUnlock() + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() fake.updateSecurityGroupMutex.RLock() defer fake.updateSecurityGroupMutex.RUnlock() fake.updateSecurityGroupRunningSpaceMutex.RLock() diff --git a/actor/v7action/v7actionfakes/fake_config.go b/actor/v7action/v7actionfakes/fake_config.go index 9bbf83bc714..26de81b43b1 100644 --- a/actor/v7action/v7actionfakes/fake_config.go +++ b/actor/v7action/v7actionfakes/fake_config.go @@ -5,8 +5,8 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeConfig struct { @@ -193,15 +193,16 @@ func (fake *FakeConfig) APIVersion() string { ret, specificReturn := fake.aPIVersionReturnsOnCall[len(fake.aPIVersionArgsForCall)] fake.aPIVersionArgsForCall = append(fake.aPIVersionArgsForCall, struct { }{}) + stub := fake.APIVersionStub + fakeReturns := fake.aPIVersionReturns fake.recordInvocation("APIVersion", []interface{}{}) fake.aPIVersionMutex.Unlock() - if fake.APIVersionStub != nil { - return fake.APIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIVersionReturns return fakeReturns.result1 } @@ -245,15 +246,16 @@ func (fake *FakeConfig) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -297,15 +299,16 @@ func (fake *FakeConfig) CurrentUser() (configv3.User, error) { ret, specificReturn := fake.currentUserReturnsOnCall[len(fake.currentUserArgsForCall)] fake.currentUserArgsForCall = append(fake.currentUserArgsForCall, struct { }{}) + stub := fake.CurrentUserStub + fakeReturns := fake.currentUserReturns fake.recordInvocation("CurrentUser", []interface{}{}) fake.currentUserMutex.Unlock() - if fake.CurrentUserStub != nil { - return fake.CurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -352,15 +355,16 @@ func (fake *FakeConfig) DialTimeout() time.Duration { ret, specificReturn := fake.dialTimeoutReturnsOnCall[len(fake.dialTimeoutArgsForCall)] fake.dialTimeoutArgsForCall = append(fake.dialTimeoutArgsForCall, struct { }{}) + stub := fake.DialTimeoutStub + fakeReturns := fake.dialTimeoutReturns fake.recordInvocation("DialTimeout", []interface{}{}) fake.dialTimeoutMutex.Unlock() - if fake.DialTimeoutStub != nil { - return fake.DialTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dialTimeoutReturns return fakeReturns.result1 } @@ -404,15 +408,16 @@ func (fake *FakeConfig) IsCFOnK8s() bool { ret, specificReturn := fake.isCFOnK8sReturnsOnCall[len(fake.isCFOnK8sArgsForCall)] fake.isCFOnK8sArgsForCall = append(fake.isCFOnK8sArgsForCall, struct { }{}) + stub := fake.IsCFOnK8sStub + fakeReturns := fake.isCFOnK8sReturns fake.recordInvocation("IsCFOnK8s", []interface{}{}) fake.isCFOnK8sMutex.Unlock() - if fake.IsCFOnK8sStub != nil { - return fake.IsCFOnK8sStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isCFOnK8sReturns return fakeReturns.result1 } @@ -456,15 +461,16 @@ func (fake *FakeConfig) PollingInterval() time.Duration { ret, specificReturn := fake.pollingIntervalReturnsOnCall[len(fake.pollingIntervalArgsForCall)] fake.pollingIntervalArgsForCall = append(fake.pollingIntervalArgsForCall, struct { }{}) + stub := fake.PollingIntervalStub + fakeReturns := fake.pollingIntervalReturns fake.recordInvocation("PollingInterval", []interface{}{}) fake.pollingIntervalMutex.Unlock() - if fake.PollingIntervalStub != nil { - return fake.PollingIntervalStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pollingIntervalReturns return fakeReturns.result1 } @@ -508,15 +514,16 @@ func (fake *FakeConfig) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -560,15 +567,16 @@ func (fake *FakeConfig) SSHOAuthClient() string { ret, specificReturn := fake.sSHOAuthClientReturnsOnCall[len(fake.sSHOAuthClientArgsForCall)] fake.sSHOAuthClientArgsForCall = append(fake.sSHOAuthClientArgsForCall, struct { }{}) + stub := fake.SSHOAuthClientStub + fakeReturns := fake.sSHOAuthClientReturns fake.recordInvocation("SSHOAuthClient", []interface{}{}) fake.sSHOAuthClientMutex.Unlock() - if fake.SSHOAuthClientStub != nil { - return fake.SSHOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.sSHOAuthClientReturns return fakeReturns.result1 } @@ -612,9 +620,10 @@ func (fake *FakeConfig) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -643,9 +652,10 @@ func (fake *FakeConfig) SetKubernetesAuthInfo(arg1 string) { fake.setKubernetesAuthInfoArgsForCall = append(fake.setKubernetesAuthInfoArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetKubernetesAuthInfoStub fake.recordInvocation("SetKubernetesAuthInfo", []interface{}{arg1}) fake.setKubernetesAuthInfoMutex.Unlock() - if fake.SetKubernetesAuthInfoStub != nil { + if stub != nil { fake.SetKubernetesAuthInfoStub(arg1) } } @@ -674,9 +684,10 @@ func (fake *FakeConfig) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } @@ -705,9 +716,10 @@ func (fake *FakeConfig) SetTargetInformation(arg1 configv3.TargetInformationArgs fake.setTargetInformationArgsForCall = append(fake.setTargetInformationArgsForCall, struct { arg1 configv3.TargetInformationArgs }{arg1}) + stub := fake.SetTargetInformationStub fake.recordInvocation("SetTargetInformation", []interface{}{arg1}) fake.setTargetInformationMutex.Unlock() - if fake.SetTargetInformationStub != nil { + if stub != nil { fake.SetTargetInformationStub(arg1) } } @@ -738,9 +750,10 @@ func (fake *FakeConfig) SetTokenInformation(arg1 string, arg2 string, arg3 strin arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.SetTokenInformationStub fake.recordInvocation("SetTokenInformation", []interface{}{arg1, arg2, arg3}) fake.setTokenInformationMutex.Unlock() - if fake.SetTokenInformationStub != nil { + if stub != nil { fake.SetTokenInformationStub(arg1, arg2, arg3) } } @@ -770,9 +783,10 @@ func (fake *FakeConfig) SetUAAClientCredentials(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetUAAClientCredentialsStub fake.recordInvocation("SetUAAClientCredentials", []interface{}{arg1, arg2}) fake.setUAAClientCredentialsMutex.Unlock() - if fake.SetUAAClientCredentialsStub != nil { + if stub != nil { fake.SetUAAClientCredentialsStub(arg1, arg2) } } @@ -801,9 +815,10 @@ func (fake *FakeConfig) SetUAAGrantType(arg1 string) { fake.setUAAGrantTypeArgsForCall = append(fake.setUAAGrantTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAGrantTypeStub fake.recordInvocation("SetUAAGrantType", []interface{}{arg1}) fake.setUAAGrantTypeMutex.Unlock() - if fake.SetUAAGrantTypeStub != nil { + if stub != nil { fake.SetUAAGrantTypeStub(arg1) } } @@ -832,15 +847,16 @@ func (fake *FakeConfig) SkipSSLValidation() bool { ret, specificReturn := fake.skipSSLValidationReturnsOnCall[len(fake.skipSSLValidationArgsForCall)] fake.skipSSLValidationArgsForCall = append(fake.skipSSLValidationArgsForCall, struct { }{}) + stub := fake.SkipSSLValidationStub + fakeReturns := fake.skipSSLValidationReturns fake.recordInvocation("SkipSSLValidation", []interface{}{}) fake.skipSSLValidationMutex.Unlock() - if fake.SkipSSLValidationStub != nil { - return fake.SkipSSLValidationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.skipSSLValidationReturns return fakeReturns.result1 } @@ -884,15 +900,16 @@ func (fake *FakeConfig) StagingTimeout() time.Duration { ret, specificReturn := fake.stagingTimeoutReturnsOnCall[len(fake.stagingTimeoutArgsForCall)] fake.stagingTimeoutArgsForCall = append(fake.stagingTimeoutArgsForCall, struct { }{}) + stub := fake.StagingTimeoutStub + fakeReturns := fake.stagingTimeoutReturns fake.recordInvocation("StagingTimeout", []interface{}{}) fake.stagingTimeoutMutex.Unlock() - if fake.StagingTimeoutStub != nil { - return fake.StagingTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stagingTimeoutReturns return fakeReturns.result1 } @@ -936,15 +953,16 @@ func (fake *FakeConfig) StartupTimeout() time.Duration { ret, specificReturn := fake.startupTimeoutReturnsOnCall[len(fake.startupTimeoutArgsForCall)] fake.startupTimeoutArgsForCall = append(fake.startupTimeoutArgsForCall, struct { }{}) + stub := fake.StartupTimeoutStub + fakeReturns := fake.startupTimeoutReturns fake.recordInvocation("StartupTimeout", []interface{}{}) fake.startupTimeoutMutex.Unlock() - if fake.StartupTimeoutStub != nil { - return fake.StartupTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startupTimeoutReturns return fakeReturns.result1 } @@ -988,15 +1006,16 @@ func (fake *FakeConfig) Target() string { ret, specificReturn := fake.targetReturnsOnCall[len(fake.targetArgsForCall)] fake.targetArgsForCall = append(fake.targetArgsForCall, struct { }{}) + stub := fake.TargetStub + fakeReturns := fake.targetReturns fake.recordInvocation("Target", []interface{}{}) fake.targetMutex.Unlock() - if fake.TargetStub != nil { - return fake.TargetStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetReturns return fakeReturns.result1 } @@ -1040,15 +1059,16 @@ func (fake *FakeConfig) UAAGrantType() string { ret, specificReturn := fake.uAAGrantTypeReturnsOnCall[len(fake.uAAGrantTypeArgsForCall)] fake.uAAGrantTypeArgsForCall = append(fake.uAAGrantTypeArgsForCall, struct { }{}) + stub := fake.UAAGrantTypeStub + fakeReturns := fake.uAAGrantTypeReturns fake.recordInvocation("UAAGrantType", []interface{}{}) fake.uAAGrantTypeMutex.Unlock() - if fake.UAAGrantTypeStub != nil { - return fake.UAAGrantTypeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAGrantTypeReturns return fakeReturns.result1 } @@ -1091,9 +1111,10 @@ func (fake *FakeConfig) UnsetOrganizationAndSpaceInformation() { fake.unsetOrganizationAndSpaceInformationMutex.Lock() fake.unsetOrganizationAndSpaceInformationArgsForCall = append(fake.unsetOrganizationAndSpaceInformationArgsForCall, struct { }{}) + stub := fake.UnsetOrganizationAndSpaceInformationStub fake.recordInvocation("UnsetOrganizationAndSpaceInformation", []interface{}{}) fake.unsetOrganizationAndSpaceInformationMutex.Unlock() - if fake.UnsetOrganizationAndSpaceInformationStub != nil { + if stub != nil { fake.UnsetOrganizationAndSpaceInformationStub() } } diff --git a/actor/v7action/v7actionfakes/fake_downloader.go b/actor/v7action/v7actionfakes/fake_downloader.go index f0cb1f7590e..5f174c815bd 100644 --- a/actor/v7action/v7actionfakes/fake_downloader.go +++ b/actor/v7action/v7actionfakes/fake_downloader.go @@ -4,7 +4,7 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" ) type FakeDownloader struct { @@ -33,15 +33,16 @@ func (fake *FakeDownloader) Download(arg1 string, arg2 string) (string, error) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.DownloadStub + fakeReturns := fake.downloadReturns fake.recordInvocation("Download", []interface{}{arg1, arg2}) fake.downloadMutex.Unlock() - if fake.DownloadStub != nil { - return fake.DownloadStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.downloadReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7action/v7actionfakes/fake_kubernetes_config_getter.go b/actor/v7action/v7actionfakes/fake_kubernetes_config_getter.go index f22933d1bb8..f97237f43a9 100644 --- a/actor/v7action/v7actionfakes/fake_kubernetes_config_getter.go +++ b/actor/v7action/v7actionfakes/fake_kubernetes_config_getter.go @@ -4,7 +4,7 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" "k8s.io/client-go/tools/clientcmd/api" ) @@ -30,15 +30,16 @@ func (fake *FakeKubernetesConfigGetter) Get() (*api.Config, error) { ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] fake.getArgsForCall = append(fake.getArgsForCall, struct { }{}) + stub := fake.GetStub + fakeReturns := fake.getReturns fake.recordInvocation("Get", []interface{}{}) fake.getMutex.Unlock() - if fake.GetStub != nil { - return fake.GetStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7action/v7actionfakes/fake_manifest_parser.go b/actor/v7action/v7actionfakes/fake_manifest_parser.go index 6f0275be7b1..e5185f5d1a1 100644 --- a/actor/v7action/v7actionfakes/fake_manifest_parser.go +++ b/actor/v7action/v7actionfakes/fake_manifest_parser.go @@ -4,7 +4,7 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" ) type FakeManifestParser struct { @@ -40,15 +40,16 @@ func (fake *FakeManifestParser) AppNames() []string { ret, specificReturn := fake.appNamesReturnsOnCall[len(fake.appNamesArgsForCall)] fake.appNamesArgsForCall = append(fake.appNamesArgsForCall, struct { }{}) + stub := fake.AppNamesStub + fakeReturns := fake.appNamesReturns fake.recordInvocation("AppNames", []interface{}{}) fake.appNamesMutex.Unlock() - if fake.AppNamesStub != nil { - return fake.AppNamesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.appNamesReturns return fakeReturns.result1 } @@ -93,15 +94,16 @@ func (fake *FakeManifestParser) RawAppManifest(arg1 string) ([]byte, error) { fake.rawAppManifestArgsForCall = append(fake.rawAppManifestArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RawAppManifestStub + fakeReturns := fake.rawAppManifestReturns fake.recordInvocation("RawAppManifest", []interface{}{arg1}) fake.rawAppManifestMutex.Unlock() - if fake.RawAppManifestStub != nil { - return fake.RawAppManifestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.rawAppManifestReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7action/v7actionfakes/fake_routing_client.go b/actor/v7action/v7actionfakes/fake_routing_client.go index 873d4834a35..f5423383ed0 100644 --- a/actor/v7action/v7actionfakes/fake_routing_client.go +++ b/actor/v7action/v7actionfakes/fake_routing_client.go @@ -4,8 +4,8 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/router" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/router" ) type FakeRoutingClient struct { @@ -44,15 +44,16 @@ func (fake *FakeRoutingClient) GetRouterGroupByName(arg1 string) (router.RouterG fake.getRouterGroupByNameArgsForCall = append(fake.getRouterGroupByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetRouterGroupByNameStub + fakeReturns := fake.getRouterGroupByNameReturns fake.recordInvocation("GetRouterGroupByName", []interface{}{arg1}) fake.getRouterGroupByNameMutex.Unlock() - if fake.GetRouterGroupByNameStub != nil { - return fake.GetRouterGroupByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getRouterGroupByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -106,15 +107,16 @@ func (fake *FakeRoutingClient) GetRouterGroups() ([]router.RouterGroup, error) { ret, specificReturn := fake.getRouterGroupsReturnsOnCall[len(fake.getRouterGroupsArgsForCall)] fake.getRouterGroupsArgsForCall = append(fake.getRouterGroupsArgsForCall, struct { }{}) + stub := fake.GetRouterGroupsStub + fakeReturns := fake.getRouterGroupsReturns fake.recordInvocation("GetRouterGroups", []interface{}{}) fake.getRouterGroupsMutex.Unlock() - if fake.GetRouterGroupsStub != nil { - return fake.GetRouterGroupsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getRouterGroupsReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7action/v7actionfakes/fake_shared_actor.go b/actor/v7action/v7actionfakes/fake_shared_actor.go index 5a2ff877ab6..ad4cd1e79c8 100644 --- a/actor/v7action/v7actionfakes/fake_shared_actor.go +++ b/actor/v7action/v7actionfakes/fake_shared_actor.go @@ -4,8 +4,8 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" ) type FakeSharedActor struct { @@ -73,15 +73,16 @@ func (fake *FakeSharedActor) GatherArchiveResources(arg1 string) ([]sharedaction fake.gatherArchiveResourcesArgsForCall = append(fake.gatherArchiveResourcesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GatherArchiveResourcesStub + fakeReturns := fake.gatherArchiveResourcesReturns fake.recordInvocation("GatherArchiveResources", []interface{}{arg1}) fake.gatherArchiveResourcesMutex.Unlock() - if fake.GatherArchiveResourcesStub != nil { - return fake.GatherArchiveResourcesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.gatherArchiveResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -136,15 +137,16 @@ func (fake *FakeSharedActor) GatherDirectoryResources(arg1 string) ([]sharedacti fake.gatherDirectoryResourcesArgsForCall = append(fake.gatherDirectoryResourcesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GatherDirectoryResourcesStub + fakeReturns := fake.gatherDirectoryResourcesReturns fake.recordInvocation("GatherDirectoryResources", []interface{}{arg1}) fake.gatherDirectoryResourcesMutex.Unlock() - if fake.GatherDirectoryResourcesStub != nil { - return fake.GatherDirectoryResourcesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.gatherDirectoryResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -205,15 +207,16 @@ func (fake *FakeSharedActor) ZipArchiveResources(arg1 string, arg2 []sharedactio arg1 string arg2 []sharedaction.Resource }{arg1, arg2Copy}) + stub := fake.ZipArchiveResourcesStub + fakeReturns := fake.zipArchiveResourcesReturns fake.recordInvocation("ZipArchiveResources", []interface{}{arg1, arg2Copy}) fake.zipArchiveResourcesMutex.Unlock() - if fake.ZipArchiveResourcesStub != nil { - return fake.ZipArchiveResourcesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.zipArchiveResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -274,15 +277,16 @@ func (fake *FakeSharedActor) ZipDirectoryResources(arg1 string, arg2 []sharedact arg1 string arg2 []sharedaction.Resource }{arg1, arg2Copy}) + stub := fake.ZipDirectoryResourcesStub + fakeReturns := fake.zipDirectoryResourcesReturns fake.recordInvocation("ZipDirectoryResources", []interface{}{arg1, arg2Copy}) fake.zipDirectoryResourcesMutex.Unlock() - if fake.ZipDirectoryResourcesStub != nil { - return fake.ZipDirectoryResourcesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.zipDirectoryResourcesReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7action/v7actionfakes/fake_simple_progress_bar.go b/actor/v7action/v7actionfakes/fake_simple_progress_bar.go index 41cf5a49c6c..c312d00bc16 100644 --- a/actor/v7action/v7actionfakes/fake_simple_progress_bar.go +++ b/actor/v7action/v7actionfakes/fake_simple_progress_bar.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" ) type FakeSimpleProgressBar struct { @@ -38,15 +38,16 @@ func (fake *FakeSimpleProgressBar) Initialize(arg1 string) (io.Reader, int64, er fake.initializeArgsForCall = append(fake.initializeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.InitializeStub + fakeReturns := fake.initializeReturns fake.recordInvocation("Initialize", []interface{}{arg1}) fake.initializeMutex.Unlock() - if fake.InitializeStub != nil { - return fake.InitializeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.initializeReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -102,9 +103,10 @@ func (fake *FakeSimpleProgressBar) Terminate() { fake.terminateMutex.Lock() fake.terminateArgsForCall = append(fake.terminateArgsForCall, struct { }{}) + stub := fake.TerminateStub fake.recordInvocation("Terminate", []interface{}{}) fake.terminateMutex.Unlock() - if fake.TerminateStub != nil { + if stub != nil { fake.TerminateStub() } } diff --git a/actor/v7action/v7actionfakes/fake_sshactor.go b/actor/v7action/v7actionfakes/fake_sshactor.go index c3179aa0a07..d88367e0afb 100644 --- a/actor/v7action/v7actionfakes/fake_sshactor.go +++ b/actor/v7action/v7actionfakes/fake_sshactor.go @@ -4,8 +4,8 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" ) type FakeSSHActor struct { @@ -30,15 +30,16 @@ func (fake *FakeSSHActor) ExecuteSecureShell(arg1 sharedaction.SSHOptions) error fake.executeSecureShellArgsForCall = append(fake.executeSecureShellArgsForCall, struct { arg1 sharedaction.SSHOptions }{arg1}) + stub := fake.ExecuteSecureShellStub + fakeReturns := fake.executeSecureShellReturns fake.recordInvocation("ExecuteSecureShell", []interface{}{arg1}) fake.executeSecureShellMutex.Unlock() - if fake.ExecuteSecureShellStub != nil { - return fake.ExecuteSecureShellStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeSecureShellReturns return fakeReturns.result1 } diff --git a/actor/v7action/v7actionfakes/fake_uaaclient.go b/actor/v7action/v7actionfakes/fake_uaaclient.go index 2924db85154..92e769962ab 100644 --- a/actor/v7action/v7actionfakes/fake_uaaclient.go +++ b/actor/v7action/v7actionfakes/fake_uaaclient.go @@ -4,9 +4,9 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" ) type FakeUAAClient struct { @@ -167,15 +167,16 @@ func (fake *FakeUAAClient) Authenticate(arg1 map[string]string, arg2 string, arg arg2 string arg3 constant.GrantType }{arg1, arg2, arg3}) + stub := fake.AuthenticateStub + fakeReturns := fake.authenticateReturns fake.recordInvocation("Authenticate", []interface{}{arg1, arg2, arg3}) fake.authenticateMutex.Unlock() - if fake.AuthenticateStub != nil { - return fake.AuthenticateStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.authenticateReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -235,15 +236,16 @@ func (fake *FakeUAAClient) CreateUser(arg1 string, arg2 string, arg3 string) (ua arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.CreateUserStub + fakeReturns := fake.createUserReturns fake.recordInvocation("CreateUser", []interface{}{arg1, arg2, arg3}) fake.createUserMutex.Unlock() - if fake.CreateUserStub != nil { - return fake.CreateUserStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -298,15 +300,16 @@ func (fake *FakeUAAClient) DeleteUser(arg1 string) (uaa.User, error) { fake.deleteUserArgsForCall = append(fake.deleteUserArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteUserStub + fakeReturns := fake.deleteUserReturns fake.recordInvocation("DeleteUser", []interface{}{arg1}) fake.deleteUserMutex.Unlock() - if fake.DeleteUserStub != nil { - return fake.DeleteUserStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -360,15 +363,16 @@ func (fake *FakeUAAClient) GetAPIVersion() (string, error) { ret, specificReturn := fake.getAPIVersionReturnsOnCall[len(fake.getAPIVersionArgsForCall)] fake.getAPIVersionArgsForCall = append(fake.getAPIVersionArgsForCall, struct { }{}) + stub := fake.GetAPIVersionStub + fakeReturns := fake.getAPIVersionReturns fake.recordInvocation("GetAPIVersion", []interface{}{}) fake.getAPIVersionMutex.Unlock() - if fake.GetAPIVersionStub != nil { - return fake.GetAPIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAPIVersionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -415,15 +419,16 @@ func (fake *FakeUAAClient) GetLoginPrompts() (map[string][]string, error) { ret, specificReturn := fake.getLoginPromptsReturnsOnCall[len(fake.getLoginPromptsArgsForCall)] fake.getLoginPromptsArgsForCall = append(fake.getLoginPromptsArgsForCall, struct { }{}) + stub := fake.GetLoginPromptsStub + fakeReturns := fake.getLoginPromptsReturns fake.recordInvocation("GetLoginPrompts", []interface{}{}) fake.getLoginPromptsMutex.Unlock() - if fake.GetLoginPromptsStub != nil { - return fake.GetLoginPromptsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getLoginPromptsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -472,15 +477,16 @@ func (fake *FakeUAAClient) GetSSHPasscode(arg1 string, arg2 string) (string, err arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSSHPasscodeStub + fakeReturns := fake.getSSHPasscodeReturns fake.recordInvocation("GetSSHPasscode", []interface{}{arg1, arg2}) fake.getSSHPasscodeMutex.Unlock() - if fake.GetSSHPasscodeStub != nil { - return fake.GetSSHPasscodeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSSHPasscodeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -536,15 +542,16 @@ func (fake *FakeUAAClient) ListUsers(arg1 string, arg2 string) ([]uaa.User, erro arg1 string arg2 string }{arg1, arg2}) + stub := fake.ListUsersStub + fakeReturns := fake.listUsersReturns fake.recordInvocation("ListUsers", []interface{}{arg1, arg2}) fake.listUsersMutex.Unlock() - if fake.ListUsersStub != nil { - return fake.ListUsersStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listUsersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -599,15 +606,16 @@ func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } @@ -662,15 +670,16 @@ func (fake *FakeUAAClient) Revoke(arg1 string) error { fake.revokeArgsForCall = append(fake.revokeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RevokeStub + fakeReturns := fake.revokeReturns fake.recordInvocation("Revoke", []interface{}{arg1}) fake.revokeMutex.Unlock() - if fake.RevokeStub != nil { - return fake.RevokeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.revokeReturns return fakeReturns.result1 } @@ -724,15 +733,16 @@ func (fake *FakeUAAClient) UpdatePassword(arg1 string, arg2 string, arg3 string) arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.UpdatePasswordStub + fakeReturns := fake.updatePasswordReturns fake.recordInvocation("UpdatePassword", []interface{}{arg1, arg2, arg3}) fake.updatePasswordMutex.Unlock() - if fake.UpdatePasswordStub != nil { - return fake.UpdatePasswordStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.updatePasswordReturns return fakeReturns.result1 } @@ -784,15 +794,16 @@ func (fake *FakeUAAClient) ValidateClientUser(arg1 string) error { fake.validateClientUserArgsForCall = append(fake.validateClientUserArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ValidateClientUserStub + fakeReturns := fake.validateClientUserReturns fake.recordInvocation("ValidateClientUser", []interface{}{arg1}) fake.validateClientUserMutex.Unlock() - if fake.ValidateClientUserStub != nil { - return fake.ValidateClientUserStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.validateClientUserReturns return fakeReturns.result1 } diff --git a/actor/v7action/v7actionfakes/fake_who_am_ier.go b/actor/v7action/v7actionfakes/fake_who_am_ier.go index 0d1eb42bacc..8859bbc5806 100644 --- a/actor/v7action/v7actionfakes/fake_who_am_ier.go +++ b/actor/v7action/v7actionfakes/fake_who_am_ier.go @@ -4,9 +4,9 @@ package v7actionfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeWhoAmIer struct { @@ -33,15 +33,16 @@ func (fake *FakeWhoAmIer) WhoAmI() (resources.K8sUser, ccv3.Warnings, error) { ret, specificReturn := fake.whoAmIReturnsOnCall[len(fake.whoAmIArgsForCall)] fake.whoAmIArgsForCall = append(fake.whoAmIArgsForCall, struct { }{}) + stub := fake.WhoAmIStub + fakeReturns := fake.whoAmIReturns fake.recordInvocation("WhoAmI", []interface{}{}) fake.whoAmIMutex.Unlock() - if fake.WhoAmIStub != nil { - return fake.WhoAmIStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.whoAmIReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/actor/v7action/version_test.go b/actor/v7action/version_test.go index 5cc8ee83251..2d6f8a5d1d7 100644 --- a/actor/v7action/version_test.go +++ b/actor/v7action/version_test.go @@ -1,9 +1,9 @@ package v7action_test import ( - . "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/actor.go b/actor/v7pushaction/actor.go index 00438dea3b2..53abbd200f0 100644 --- a/actor/v7pushaction/actor.go +++ b/actor/v7pushaction/actor.go @@ -14,12 +14,12 @@ type Actor struct { SharedActor SharedActor V7Actor V7Actor - PreparePushPlanSequence []UpdatePushPlanFunc - ChangeApplicationSequence func(plan PushPlan) []ChangeApplicationFunc - TransformManifestSequence []HandleFlagOverrideFunc - - startWithProtocol *regexp.Regexp - urlValidator *regexp.Regexp + PreparePushPlanSequence []UpdatePushPlanFunc + ChangeApplicationSequence func(plan PushPlan) []ChangeApplicationFunc + TransformManifestSequence []HandleFlagOverrideFunc + TransformManifestSequenceForDeployment []HandleFlagOverrideFunc + startWithProtocol *regexp.Regexp + urlValidator *regexp.Regexp } const ProtocolRegexp = "^https?://|^tcp://" @@ -42,6 +42,9 @@ func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor { HandleInstancesOverride, HandleStartCommandOverride, + HandleCNBCredentialsOverride, + + HandleLifecycleOverride, // Type must come before endpoint because endpoint validates against type HandleHealthCheckTypeOverride, @@ -50,6 +53,7 @@ func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor { HandleHealthCheckTimeoutOverride, HandleMemoryOverride, HandleDiskOverride, + HandleLogRateLimitOverride, HandleNoRouteOverride, HandleRandomRouteOverride, HandleTaskOverride, @@ -65,12 +69,17 @@ func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor { HandleAppPathOverride, HandleDropletPathOverride, } - + actor.TransformManifestSequenceForDeployment = []HandleFlagOverrideFunc{ + HandleInstancesOverrideForDeployment, + HandleMemoryOverrideForDeployment, + HandleDiskOverrideForDeployment, + HandleLogRateLimitOverrideForDeployment, + } actor.PreparePushPlanSequence = []UpdatePushPlanFunc{ SetDefaultBitsPathForPushPlan, SetupDropletPathForPushPlan, actor.SetupAllResourcesForPushPlan, - SetupDeploymentStrategyForPushPlan, + SetupDeploymentInformationForPushPlan, SetupNoStartForPushPlan, SetupNoWaitForPushPlan, SetupTaskAppForPushPlan, diff --git a/actor/v7pushaction/actor_test.go b/actor/v7pushaction/actor_test.go index 88d00aba0e1..70f5a884bca 100644 --- a/actor/v7pushaction/actor_test.go +++ b/actor/v7pushaction/actor_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -22,11 +22,22 @@ var _ = Describe("Actor", func() { SetDefaultBitsPathForPushPlan, SetupDropletPathForPushPlan, actor.SetupAllResourcesForPushPlan, - SetupDeploymentStrategyForPushPlan, + SetupDeploymentInformationForPushPlan, SetupNoStartForPushPlan, SetupNoWaitForPushPlan, SetupTaskAppForPushPlan, )) }) }) + + Describe("TransformManifestSequenceForDeployment", func() { + It("is a list of functions for preparing the push plan", func() { + Expect(actor.TransformManifestSequenceForDeployment).To(matchers.MatchFuncsByName( + HandleInstancesOverrideForDeployment, + HandleMemoryOverrideForDeployment, + HandleDiskOverrideForDeployment, + HandleLogRateLimitOverrideForDeployment, + )) + }) + }) }) diff --git a/actor/v7pushaction/actualize_test.go b/actor/v7pushaction/actualize_test.go index 4130d35697d..434a6d01b68 100644 --- a/actor/v7pushaction/actualize_test.go +++ b/actor/v7pushaction/actualize_test.go @@ -4,12 +4,12 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/sharedaction" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/create_bits_package_for_application.go b/actor/v7pushaction/create_bits_package_for_application.go index bc40f05f58a..811d56888e4 100644 --- a/actor/v7pushaction/create_bits_package_for_application.go +++ b/actor/v7pushaction/create_bits_package_for_application.go @@ -3,11 +3,11 @@ package v7pushaction import ( "os" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" log "github.com/sirupsen/logrus" ) diff --git a/actor/v7pushaction/create_bits_package_for_application_test.go b/actor/v7pushaction/create_bits_package_for_application_test.go index dfde7e8cce7..946636434fb 100644 --- a/actor/v7pushaction/create_bits_package_for_application_test.go +++ b/actor/v7pushaction/create_bits_package_for_application_test.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/create_deployment_for_push_plan.go b/actor/v7pushaction/create_deployment_for_push_plan.go index 7d5b7ce1a27..7a9998587b0 100644 --- a/actor/v7pushaction/create_deployment_for_push_plan.go +++ b/actor/v7pushaction/create_deployment_for_push_plan.go @@ -1,9 +1,36 @@ package v7pushaction +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" +) + func (actor Actor) CreateDeploymentForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error) { eventStream <- &PushEvent{Plan: pushPlan, Event: StartingDeployment} - deploymentGUID, warnings, err := actor.V7Actor.CreateDeploymentByApplicationAndDroplet(pushPlan.Application.GUID, pushPlan.DropletGUID) + dep := resources.Deployment{ + Strategy: pushPlan.Strategy, + DropletGUID: pushPlan.DropletGUID, + Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: pushPlan.Application.GUID}}, + } + + if pushPlan.MaxInFlight > 0 { + dep.Options = resources.DeploymentOpts{MaxInFlight: pushPlan.MaxInFlight} + } + + if len(pushPlan.InstanceSteps) > 0 { + dep.Options.CanaryDeploymentOptions = &resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{}} + for _, w := range pushPlan.InstanceSteps { + dep.Options.CanaryDeploymentOptions.Steps = append(dep.Options.CanaryDeploymentOptions.Steps, resources.CanaryStep{InstanceWeight: w}) + } + } + + dep.Options.Instances = pushPlan.Instances + dep.Options.MemoryInMB = pushPlan.MemoryInMB + dep.Options.DiskInMB = pushPlan.DiskInMB + dep.Options.LogRateLimitInBPS = pushPlan.LogRateLimitInBPS + + deploymentGUID, warnings, err := actor.V7Actor.CreateDeployment(dep) if err != nil { return pushPlan, Warnings(warnings), err @@ -19,7 +46,7 @@ func (actor Actor) CreateDeploymentForApplication(pushPlan PushPlan, eventStream } } - pollWarnings, err := actor.V7Actor.PollStartForRolling(pushPlan.Application, deploymentGUID, pushPlan.NoWait, handleInstanceDetails) + pollWarnings, err := actor.V7Actor.PollStartForDeployment(pushPlan.Application, deploymentGUID, pushPlan.NoWait, handleInstanceDetails) warnings = append(warnings, pollWarnings...) return pushPlan, Warnings(warnings), err diff --git a/actor/v7pushaction/create_deployment_for_push_plan_test.go b/actor/v7pushaction/create_deployment_for_push_plan_test.go index 3004c6c6246..91b2f9a5d31 100644 --- a/actor/v7pushaction/create_deployment_for_push_plan_test.go +++ b/actor/v7pushaction/create_deployment_for_push_plan_test.go @@ -3,11 +3,13 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -47,12 +49,12 @@ var _ = Describe("CreateDeploymentForApplication()", func() { Describe("creating deployment", func() { When("creating the deployment is successful", func() { BeforeEach(func() { - fakeV7Actor.PollStartForRollingCalls(func(_ resources.Application, _ string, _ bool, handleInstanceDetails func(string)) (warnings v7action.Warnings, err error) { + fakeV7Actor.PollStartForDeploymentCalls(func(_ resources.Application, _ string, _ bool, handleInstanceDetails func(string)) (warnings v7action.Warnings, err error) { handleInstanceDetails("Instances starting...") return nil, nil }) - fakeV7Actor.CreateDeploymentByApplicationAndDropletReturns( + fakeV7Actor.CreateDeploymentReturns( "some-deployment-guid", v7action.Warnings{"some-deployment-warning"}, nil, @@ -60,8 +62,8 @@ var _ = Describe("CreateDeploymentForApplication()", func() { }) It("waits for the app to start", func() { - Expect(fakeV7Actor.PollStartForRollingCallCount()).To(Equal(1)) - givenApp, givenDeploymentGUID, noWait, _ := fakeV7Actor.PollStartForRollingArgsForCall(0) + Expect(fakeV7Actor.PollStartForDeploymentCallCount()).To(Equal(1)) + givenApp, givenDeploymentGUID, noWait, _ := fakeV7Actor.PollStartForDeploymentArgsForCall(0) Expect(givenApp).To(Equal(resources.Application{GUID: "some-app-guid"})) Expect(givenDeploymentGUID).To(Equal("some-deployment-guid")) Expect(noWait).To(Equal(false)) @@ -85,7 +87,7 @@ var _ = Describe("CreateDeploymentForApplication()", func() { BeforeEach(func() { someErr = errors.New("failed to create deployment") - fakeV7Actor.CreateDeploymentByApplicationAndDropletReturns( + fakeV7Actor.CreateDeploymentReturns( "", v7action.Warnings{"some-deployment-warning"}, someErr, @@ -93,7 +95,7 @@ var _ = Describe("CreateDeploymentForApplication()", func() { }) It("does not wait for the app to start", func() { - Expect(fakeV7Actor.PollStartForRollingCallCount()).To(Equal(0)) + Expect(fakeV7Actor.PollStartForDeploymentCallCount()).To(Equal(0)) }) It("returns errors and warnings", func() { @@ -106,12 +108,104 @@ var _ = Describe("CreateDeploymentForApplication()", func() { Expect(events).To(ConsistOf(StartingDeployment)) }) }) + + When("strategy is provided", func() { + BeforeEach(func() { + fakeV7Actor.PollStartForDeploymentCalls(func(_ resources.Application, _ string, _ bool, handleInstanceDetails func(string)) (warnings v7action.Warnings, err error) { + handleInstanceDetails("Instances starting...") + return nil, nil + }) + + fakeV7Actor.CreateDeploymentReturns( + "some-deployment-guid", + v7action.Warnings{"some-deployment-warning"}, + nil, + ) + paramPlan.Strategy = "rolling" + paramPlan.MaxInFlight = 10 + paramPlan.Instances = types.NullInt{IsSet: true, Value: 3} + paramPlan.MemoryInMB = types.NullUint64{IsSet: true, Value: 10} + paramPlan.DiskInMB = types.NullUint64{IsSet: true, Value: 20} + paramPlan.LogRateLimitInBPS = types.NullInt{IsSet: true, Value: 30} + }) + + It("waits for the app to start", func() { + Expect(fakeV7Actor.PollStartForDeploymentCallCount()).To(Equal(1)) + givenApp, givenDeploymentGUID, noWait, _ := fakeV7Actor.PollStartForDeploymentArgsForCall(0) + Expect(givenApp).To(Equal(resources.Application{GUID: "some-app-guid"})) + Expect(givenDeploymentGUID).To(Equal("some-deployment-guid")) + Expect(noWait).To(Equal(false)) + Expect(events).To(ConsistOf(StartingDeployment, InstanceDetails, WaitingForDeployment)) + Expect(fakeV7Actor.CreateDeploymentCallCount()).To(Equal(1)) + dep := fakeV7Actor.CreateDeploymentArgsForCall(0) + Expect(dep).To(Equal(resources.Deployment{ + Strategy: "rolling", + Options: resources.DeploymentOpts{MaxInFlight: 10, + Instances: types.NullInt{IsSet: true, Value: 3}, + MemoryInMB: types.NullUint64{IsSet: true, Value: 10}, + DiskInMB: types.NullUint64{IsSet: true, Value: 20}, + LogRateLimitInBPS: types.NullInt{IsSet: true, Value: 30}, + }, + Relationships: resources.Relationships{ + constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}, + }, + })) + }) + + It("returns errors and warnings", func() { + Expect(returnedPushPlan).To(Equal(paramPlan)) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("some-deployment-warning")) + }) + + It("records deployment events", func() { + Expect(events).To(ConsistOf(StartingDeployment, InstanceDetails, WaitingForDeployment)) + }) + }) + + When("canary weights are provided", func() { + BeforeEach(func() { + fakeV7Actor.PollStartForDeploymentCalls(func(_ resources.Application, _ string, _ bool, handleInstanceDetails func(string)) (warnings v7action.Warnings, err error) { + handleInstanceDetails("Instances starting...") + return nil, nil + }) + + fakeV7Actor.CreateDeploymentReturns( + "some-deployment-guid", + v7action.Warnings{"some-deployment-warning"}, + nil, + ) + paramPlan.Strategy = "canary" + paramPlan.InstanceSteps = []int64{1, 2, 3, 4} + }) + + It("creates the correct deployment from the object", func() { + Expect(fakeV7Actor.CreateDeploymentCallCount()).To(Equal(1)) + dep := fakeV7Actor.CreateDeploymentArgsForCall(0) + Expect(dep).To(Equal(resources.Deployment{ + Strategy: "canary", + Options: resources.DeploymentOpts{ + CanaryDeploymentOptions: &resources.CanaryDeploymentOptions{ + Steps: []resources.CanaryStep{ + {InstanceWeight: 1}, + {InstanceWeight: 2}, + {InstanceWeight: 3}, + {InstanceWeight: 4}, + }, + }, + }, + Relationships: resources.Relationships{ + constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}, + }, + })) + }) + }) }) Describe("waiting for app to start", func() { When("the the polling is successful", func() { BeforeEach(func() { - fakeV7Actor.PollStartForRollingReturns(v7action.Warnings{"some-poll-start-warning"}, nil) + fakeV7Actor.PollStartForDeploymentReturns(v7action.Warnings{"some-poll-start-warning"}, nil) }) It("returns warnings and unchanged push plan", func() { @@ -129,7 +223,7 @@ var _ = Describe("CreateDeploymentForApplication()", func() { BeforeEach(func() { someErr = errors.New("app failed to start") - fakeV7Actor.PollStartForRollingReturns(v7action.Warnings{"some-poll-start-warning"}, someErr) + fakeV7Actor.PollStartForDeploymentReturns(v7action.Warnings{"some-poll-start-warning"}, someErr) }) It("returns errors and warnings", func() { @@ -148,7 +242,7 @@ var _ = Describe("CreateDeploymentForApplication()", func() { }) It("passes in the noWait flag", func() { - _, _, noWait, _ := fakeV7Actor.PollStartForRollingArgsForCall(0) + _, _, noWait, _ := fakeV7Actor.PollStartForDeploymentArgsForCall(0) Expect(noWait).To(Equal(true)) }) }) diff --git a/actor/v7pushaction/create_docker_package_for_application_test.go b/actor/v7pushaction/create_docker_package_for_application_test.go index 6b85891691b..9870378cf75 100644 --- a/actor/v7pushaction/create_docker_package_for_application_test.go +++ b/actor/v7pushaction/create_docker_package_for_application_test.go @@ -3,12 +3,12 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" ) diff --git a/actor/v7pushaction/create_droplet_for_application.go b/actor/v7pushaction/create_droplet_for_application.go index 705d8227cc3..a2186883d9c 100644 --- a/actor/v7pushaction/create_droplet_for_application.go +++ b/actor/v7pushaction/create_droplet_for_application.go @@ -1,9 +1,9 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" ) const UploadRetries = 3 diff --git a/actor/v7pushaction/create_droplet_for_application_test.go b/actor/v7pushaction/create_droplet_for_application_test.go index 42e1a83b142..af1d2593646 100644 --- a/actor/v7pushaction/create_droplet_for_application_test.go +++ b/actor/v7pushaction/create_droplet_for_application_test.go @@ -4,13 +4,13 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/create_push_plans.go b/actor/v7pushaction/create_push_plans.go index 0b9efcf2af2..9158dfea7fb 100644 --- a/actor/v7pushaction/create_push_plans.go +++ b/actor/v7pushaction/create_push_plans.go @@ -1,9 +1,9 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) // CreatePushPlans returns a set of PushPlan objects based off the inputs @@ -31,6 +31,18 @@ func (actor Actor) CreatePushPlans( BitsPath: manifestApplication.Path, } + if manifestApplication.Lifecycle != "" { + plan.Application.LifecycleType = manifestApplication.Lifecycle + } + + if overrides.Lifecycle != "" { + plan.Application.LifecycleType = overrides.Lifecycle + } + + if overrides.CNBCredentials != nil { + plan.Application.Credentials = overrides.CNBCredentials + } + if manifestApplication.Docker != nil { plan.DockerImageCredentials = v7action.DockerImageCredentials{ Path: manifestApplication.Docker.Image, diff --git a/actor/v7pushaction/create_push_plans_test.go b/actor/v7pushaction/create_push_plans_test.go index b15fa64da9d..a64668f7429 100644 --- a/actor/v7pushaction/create_push_plans_test.go +++ b/actor/v7pushaction/create_push_plans_test.go @@ -4,12 +4,12 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/manifestparser" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -41,7 +41,7 @@ var _ = Describe("CreatePushPlans", func() { manifest = manifestparser.Manifest{ Applications: []manifestparser.Application{ - {Name: "name-1", Path: "path1"}, + {Name: "name-1", Path: "path1", Lifecycle: "cnb"}, {Name: "name-2", Path: "path2", Docker: &manifestparser.Docker{Image: "image", Username: "uname"}}, }, } @@ -49,6 +49,9 @@ var _ = Describe("CreatePushPlans", func() { spaceGUID = "space" flagOverrides = FlagOverrides{ DockerPassword: "passwd", + CNBCredentials: map[string]interface{}{ + "foo": "bar", + }, } testUpdatePlanCount = 0 @@ -120,6 +123,10 @@ var _ = Describe("CreatePushPlans", func() { Expect(pushPlans[0].DockerImageCredentials.Username).To(Equal("")) Expect(pushPlans[0].DockerImageCredentials.Password).To(Equal("")) Expect(pushPlans[0].BitsPath).To(Equal("path1")) + Expect(pushPlans[0].Application.LifecycleType).To(BeEquivalentTo("cnb")) + Expect(pushPlans[0].Application.Credentials).To(Equal(map[string]interface{}{ + "foo": "bar", + })) Expect(pushPlans[1].Application.Name).To(Equal("name-2")) Expect(pushPlans[1].Application.GUID).To(Equal("app-guid-2")) Expect(pushPlans[1].SpaceGUID).To(Equal(spaceGUID)) @@ -128,7 +135,20 @@ var _ = Describe("CreatePushPlans", func() { Expect(pushPlans[1].DockerImageCredentials.Username).To(Equal("uname")) Expect(pushPlans[1].DockerImageCredentials.Password).To(Equal("passwd")) Expect(pushPlans[1].BitsPath).To(Equal("path2")) + Expect(pushPlans[1].Application.LifecycleType).To(BeEquivalentTo("")) }) + }) + When("lifecycle is overwritten", func() { + BeforeEach(func() { + flagOverrides = FlagOverrides{ + Lifecycle: "buildpack", + } + }) + + It("uses the lifecycle from the command line", func() { + Expect(pushPlans[0].Application.LifecycleType).To(BeEquivalentTo("buildpack")) + }) }) + }) diff --git a/actor/v7pushaction/handle_app_name_override.go b/actor/v7pushaction/handle_app_name_override.go index 329a3129347..2236e358913 100644 --- a/actor/v7pushaction/handle_app_name_override.go +++ b/actor/v7pushaction/handle_app_name_override.go @@ -1,9 +1,9 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleAppNameOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_app_name_override_test.go b/actor/v7pushaction/handle_app_name_override_test.go index 7c87fad455f..0e99ffb59cc 100644 --- a/actor/v7pushaction/handle_app_name_override_test.go +++ b/actor/v7pushaction/handle_app_name_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_app_path_override.go b/actor/v7pushaction/handle_app_path_override.go index c10ace982d8..ff2a2e8e5fb 100644 --- a/actor/v7pushaction/handle_app_path_override.go +++ b/actor/v7pushaction/handle_app_path_override.go @@ -4,8 +4,8 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) // Overrides the path if path is given. Changes empty paths to pwd. Validates paths diff --git a/actor/v7pushaction/handle_app_path_override_test.go b/actor/v7pushaction/handle_app_path_override_test.go index 60376947d79..8baca7cb5fa 100644 --- a/actor/v7pushaction/handle_app_path_override_test.go +++ b/actor/v7pushaction/handle_app_path_override_test.go @@ -1,16 +1,16 @@ package v7pushaction_test import ( - "io/ioutil" "os" "path/filepath" + "runtime" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -41,7 +41,7 @@ var _ = Describe("HandleAppPathOverride", func() { var relativeAppFilePath string BeforeEach(func() { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) relativeAppFilePath = file.Name() defer file.Close() @@ -91,10 +91,14 @@ var _ = Describe("HandleAppPathOverride", func() { var cwd string var absoluteAppFilehandle *os.File BeforeEach(func() { - absoluteAppFilehandle, err = ioutil.TempFile("", "") + absoluteAppFilehandle, err = os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) defer absoluteAppFilehandle.Close() - relativeAppFilePath = filepath.Join(".", absoluteAppFilehandle.Name()) + if runtime.GOOS == "windows" { + relativeAppFilePath = absoluteAppFilehandle.Name() + } else { + relativeAppFilePath = filepath.Join(filepath.Dir("/"), absoluteAppFilehandle.Name()) + } flagOverrides.ProvidedAppPath = relativeAppFilePath // TODO: Do NOT use Chdir! it affects ALL other threads @@ -138,7 +142,7 @@ var _ = Describe("HandleAppPathOverride", func() { parsedManifest = manifestparser.Manifest{ Applications: []manifestparser.Application{ { - Path: "some-non-existent-path", + Path: "some-nonexistent-path", }, }, } @@ -146,7 +150,7 @@ var _ = Describe("HandleAppPathOverride", func() { It("returns an error", func() { Expect(executeErr).To(MatchError(manifestparser.InvalidManifestApplicationPathError{ - Path: "some-non-existent-path", + Path: "some-nonexistent-path", })) }) }) diff --git a/actor/v7pushaction/handle_buildpacks_override.go b/actor/v7pushaction/handle_buildpacks_override.go index 669d04ab016..4408a1c8874 100644 --- a/actor/v7pushaction/handle_buildpacks_override.go +++ b/actor/v7pushaction/handle_buildpacks_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleBuildpacksOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_buildpacks_override_test.go b/actor/v7pushaction/handle_buildpacks_override_test.go index 6942dfa5681..762d40a3535 100644 --- a/actor/v7pushaction/handle_buildpacks_override_test.go +++ b/actor/v7pushaction/handle_buildpacks_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_cnb_credentials_override.go b/actor/v7pushaction/handle_cnb_credentials_override.go new file mode 100644 index 00000000000..85adf2d3c70 --- /dev/null +++ b/actor/v7pushaction/handle_cnb_credentials_override.go @@ -0,0 +1,23 @@ +package v7pushaction + +import ( + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" +) + +func HandleCNBCredentialsOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.CNBCredentials != nil { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + app := manifest.GetFirstApp() + if app.RemainingManifestFields == nil { + app.RemainingManifestFields = map[string]interface{}{} + } + + app.RemainingManifestFields["cnb-credentials"] = overrides.CNBCredentials + } + + return manifest, nil +} diff --git a/actor/v7pushaction/handle_cnb_credentials_override_test.go b/actor/v7pushaction/handle_cnb_credentials_override_test.go new file mode 100644 index 00000000000..878fb8e3639 --- /dev/null +++ b/actor/v7pushaction/handle_cnb_credentials_override_test.go @@ -0,0 +1,66 @@ +package v7pushaction_test + +import ( + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("HandleCNBCredentialsOverride", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{ + Applications: []manifestparser.Application{{}}, + } + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleCNBCredentialsOverride(originalManifest, overrides) + }) + + When("the cnb credentials are present", func() { + BeforeEach(func() { + overrides.CNBCredentials = map[string]interface{}{ + "foo": "bar", + } + }) + + It("add it to the raw manifest", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(transformedManifest).To(Equal(manifestparser.Manifest{ + Applications: []manifestparser.Application{{ + RemainingManifestFields: map[string]interface{}{ + "cnb-credentials": map[string]interface{}{ + "foo": "bar", + }, + }, + }}, + })) + }) + + }) + + When("the credentials are not present", func() { + BeforeEach(func() { + overrides.CNBCredentials = nil + }) + + It("does not add it to the raw manifest", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(transformedManifest).To(Equal(manifestparser.Manifest{ + Applications: []manifestparser.Application{{}}, + })) + + }) + + }) +}) diff --git a/actor/v7pushaction/handle_default_route_override.go b/actor/v7pushaction/handle_default_route_override.go index fb664ea0c38..da907e868ec 100644 --- a/actor/v7pushaction/handle_default_route_override.go +++ b/actor/v7pushaction/handle_default_route_override.go @@ -1,7 +1,7 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleDefaultRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_default_route_override_test.go b/actor/v7pushaction/handle_default_route_override_test.go index 3fed099f086..b9486f69537 100644 --- a/actor/v7pushaction/handle_default_route_override_test.go +++ b/actor/v7pushaction/handle_default_route_override_test.go @@ -1,15 +1,15 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) -var _ = Describe("HandleDefualtRouteOverride", func() { +var _ = Describe("HandleDefaultRouteOverride", func() { var ( originalManifest manifestparser.Manifest transformedManifest manifestparser.Manifest @@ -57,8 +57,8 @@ var _ = Describe("HandleDefualtRouteOverride", func() { }) - // CLI doesnt know about the routes field but CAPI ignores defualt route if routes is specified - // so we are ok adding defualt route even with the presence of a routes field + // CLI doesnt know about the routes field but CAPI ignores default route if routes is specified + // so we are ok adding default route even with the presence of a routes field When("the manifest has no routing fields", func() { BeforeEach(func() { diff --git a/actor/v7pushaction/handle_deployment_scale_flag_overrides.go b/actor/v7pushaction/handle_deployment_scale_flag_overrides.go new file mode 100644 index 00000000000..68f93e5901b --- /dev/null +++ b/actor/v7pushaction/handle_deployment_scale_flag_overrides.go @@ -0,0 +1,22 @@ +package v7pushaction + +import ( + "code.cloudfoundry.org/cli/v8/util/manifestparser" +) + +func (actor Actor) HandleDeploymentScaleFlagOverrides( + baseManifest manifestparser.Manifest, + flagOverrides FlagOverrides, +) (manifestparser.Manifest, error) { + newManifest := baseManifest + + for _, transformPlan := range actor.TransformManifestSequenceForDeployment { + var err error + newManifest, err = transformPlan(newManifest, flagOverrides) + if err != nil { + return manifestparser.Manifest{}, err + } + } + + return newManifest, nil +} diff --git a/actor/v7pushaction/handle_deployment_scale_flag_overrides_test.go b/actor/v7pushaction/handle_deployment_scale_flag_overrides_test.go new file mode 100644 index 00000000000..94c5f997a0c --- /dev/null +++ b/actor/v7pushaction/handle_deployment_scale_flag_overrides_test.go @@ -0,0 +1,46 @@ +package v7pushaction_test + +import ( + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("HandleDeploymentScaleFlagOverrides", func() { + var ( + pushActor *Actor + baseManifest manifestparser.Manifest + flagOverrides FlagOverrides + transformedManifest manifestparser.Manifest + executeErr error + + testFuncCallCount int + ) + + testTransformManifestFunc := func(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + testFuncCallCount += 1 + return manifest, nil + } + + BeforeEach(func() { + baseManifest = manifestparser.Manifest{} + flagOverrides = FlagOverrides{} + testFuncCallCount = 0 + + pushActor, _, _ = getTestPushActor() + pushActor.TransformManifestSequenceForDeployment = []HandleFlagOverrideFunc{ + testTransformManifestFunc, + } + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = pushActor.HandleDeploymentScaleFlagOverrides(baseManifest, flagOverrides) + }) + + It("calls each transform-manifest-for-deployment function", func() { + Expect(testFuncCallCount).To(Equal(1)) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(transformedManifest).To(Equal(baseManifest)) + }) +}) diff --git a/actor/v7pushaction/handle_disk_override.go b/actor/v7pushaction/handle_disk_override.go index 47adb500fd4..ea1a2c493f6 100644 --- a/actor/v7pushaction/handle_disk_override.go +++ b/actor/v7pushaction/handle_disk_override.go @@ -1,11 +1,38 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleDiskOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != "" { + return manifest, nil + } + + if overrides.Disk != "" { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + webProcess := manifest.GetFirstAppWebProcess() + if webProcess != nil { + webProcess.DiskQuota = overrides.Disk + } else { + app := manifest.GetFirstApp() + app.DiskQuota = overrides.Disk + } + } + + return manifest, nil +} + +func HandleDiskOverrideForDeployment(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != constant.DeploymentStrategyRolling && overrides.Strategy != constant.DeploymentStrategyCanary { + return manifest, nil + } + if overrides.Disk != "" { if manifest.ContainsMultipleApps() { return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} diff --git a/actor/v7pushaction/handle_disk_override_test.go b/actor/v7pushaction/handle_disk_override_test.go index c87f7749253..0a3d2e22571 100644 --- a/actor/v7pushaction/handle_disk_override_test.go +++ b/actor/v7pushaction/handle_disk_override_test.go @@ -1,12 +1,13 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -51,6 +52,42 @@ var _ = Describe("HandleDiskOverride", func() { }) }) + When("disk is set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("disk is set, and strategy is set to canary on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + When("disk is set on the flag overrides", func() { BeforeEach(func() { overrides.Disk = "5MB" @@ -144,3 +181,230 @@ var _ = Describe("HandleDiskOverride", func() { }) }) }) + +var _ = Describe("HandleDiskOverrideForDeployment", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleDiskOverrideForDeployment(originalManifest, overrides) + }) + + When("manifest web process does not specify disk", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + When("disk is not set on the flag overrides", func() { + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("disk is set, and strategy is not set on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("disk is set, and strategy is set on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + It("changes the disk of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + { + Type: "web", + DiskQuota: "5MB", + }, + }, + }, + )) + }) + }) + }) + When("disk flag is set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the disk of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + DiskQuota: "5MB", + Processes: []manifestparser.Process{ + { + Type: "worker", + }, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker", DiskQuota: "2MB"}, + {Type: "web", DiskQuota: "3MB"}, + }, + DiskQuota: "1MB", + }, + } + }) + + It("changes the disk of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker", DiskQuota: "2MB"}, + {Type: "web", DiskQuota: "5MB"}, + }, + DiskQuota: "1MB", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + + When("disk flag is set, and strategy is set to canary on the flag overrides", func() { + BeforeEach(func() { + overrides.Disk = "5MB" + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the disk of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + DiskQuota: "5MB", + Processes: []manifestparser.Process{ + { + Type: "worker", + }, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker", DiskQuota: "2MB"}, + {Type: "web", DiskQuota: "3MB"}, + }, + DiskQuota: "1MB", + }, + } + }) + + It("changes the disk of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker", DiskQuota: "2MB"}, + {Type: "web", DiskQuota: "5MB"}, + }, + DiskQuota: "1MB", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + +}) diff --git a/actor/v7pushaction/handle_docker_image_override.go b/actor/v7pushaction/handle_docker_image_override.go index 9190bca816d..715f18c84c7 100644 --- a/actor/v7pushaction/handle_docker_image_override.go +++ b/actor/v7pushaction/handle_docker_image_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleDockerImageOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_docker_image_override_test.go b/actor/v7pushaction/handle_docker_image_override_test.go index 77591dc5fb5..13e10f73299 100644 --- a/actor/v7pushaction/handle_docker_image_override_test.go +++ b/actor/v7pushaction/handle_docker_image_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_docker_username_override.go b/actor/v7pushaction/handle_docker_username_override.go index b9c31ad3e59..5c0eb29d022 100644 --- a/actor/v7pushaction/handle_docker_username_override.go +++ b/actor/v7pushaction/handle_docker_username_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleDockerUsernameOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_docker_username_override_test.go b/actor/v7pushaction/handle_docker_username_override_test.go index 2322b087c0b..13a82341010 100644 --- a/actor/v7pushaction/handle_docker_username_override_test.go +++ b/actor/v7pushaction/handle_docker_username_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_droplet_path_override.go b/actor/v7pushaction/handle_droplet_path_override.go index 8a5e97e8a7d..46971f8e120 100644 --- a/actor/v7pushaction/handle_droplet_path_override.go +++ b/actor/v7pushaction/handle_droplet_path_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleDropletPathOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_droplet_path_override_test.go b/actor/v7pushaction/handle_droplet_path_override_test.go index 98dd997f20a..5985960a684 100644 --- a/actor/v7pushaction/handle_droplet_path_override_test.go +++ b/actor/v7pushaction/handle_droplet_path_override_test.go @@ -1,11 +1,11 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_flag_override_func.go b/actor/v7pushaction/handle_flag_override_func.go index dc382117c9a..f5507b2f2b1 100644 --- a/actor/v7pushaction/handle_flag_override_func.go +++ b/actor/v7pushaction/handle_flag_override_func.go @@ -1,5 +1,5 @@ package v7pushaction -import "code.cloudfoundry.org/cli/util/manifestparser" +import "code.cloudfoundry.org/cli/v8/util/manifestparser" type HandleFlagOverrideFunc func(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) diff --git a/actor/v7pushaction/handle_flag_overrides.go b/actor/v7pushaction/handle_flag_overrides.go index 0b140d98b76..5b23a943252 100644 --- a/actor/v7pushaction/handle_flag_overrides.go +++ b/actor/v7pushaction/handle_flag_overrides.go @@ -1,7 +1,7 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func (actor Actor) HandleFlagOverrides( diff --git a/actor/v7pushaction/handle_flag_overrides_test.go b/actor/v7pushaction/handle_flag_overrides_test.go index 88f0135463e..8e944cba32d 100644 --- a/actor/v7pushaction/handle_flag_overrides_test.go +++ b/actor/v7pushaction/handle_flag_overrides_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/util/manifestparser" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_health_check_endpoint_override.go b/actor/v7pushaction/handle_health_check_endpoint_override.go index ab9659ac7dd..fe101ae0d41 100644 --- a/actor/v7pushaction/handle_health_check_endpoint_override.go +++ b/actor/v7pushaction/handle_health_check_endpoint_override.go @@ -1,9 +1,9 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleHealthCheckEndpointOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_health_check_endpoint_override_test.go b/actor/v7pushaction/handle_health_check_endpoint_override_test.go index 8313357eb83..f117da6513c 100644 --- a/actor/v7pushaction/handle_health_check_endpoint_override_test.go +++ b/actor/v7pushaction/handle_health_check_endpoint_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_health_check_timeout_override.go b/actor/v7pushaction/handle_health_check_timeout_override.go index b4c6f977182..77616ec9f5a 100644 --- a/actor/v7pushaction/handle_health_check_timeout_override.go +++ b/actor/v7pushaction/handle_health_check_timeout_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleHealthCheckTimeoutOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_health_check_timeout_override_test.go b/actor/v7pushaction/handle_health_check_timeout_override_test.go index 6292c4897d3..6a47c22f747 100644 --- a/actor/v7pushaction/handle_health_check_timeout_override_test.go +++ b/actor/v7pushaction/handle_health_check_timeout_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_health_check_type_override.go b/actor/v7pushaction/handle_health_check_type_override.go index e9f0d4091c8..29acc84c4eb 100644 --- a/actor/v7pushaction/handle_health_check_type_override.go +++ b/actor/v7pushaction/handle_health_check_type_override.go @@ -1,9 +1,9 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleHealthCheckTypeOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_health_check_type_override_test.go b/actor/v7pushaction/handle_health_check_type_override_test.go index 03a353e83fc..cdbfc7ce1f5 100644 --- a/actor/v7pushaction/handle_health_check_type_override_test.go +++ b/actor/v7pushaction/handle_health_check_type_override_test.go @@ -1,13 +1,13 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_instances_override.go b/actor/v7pushaction/handle_instances_override.go index 018ab02e8a4..a6a50a40218 100644 --- a/actor/v7pushaction/handle_instances_override.go +++ b/actor/v7pushaction/handle_instances_override.go @@ -1,11 +1,38 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleInstancesOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != "" { + return manifest, nil + } + + if overrides.Instances.IsSet { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + webProcess := manifest.GetFirstAppWebProcess() + if webProcess != nil { + webProcess.Instances = &overrides.Instances.Value + } else { + app := manifest.GetFirstApp() + app.Instances = &overrides.Instances.Value + } + } + + return manifest, nil +} + +func HandleInstancesOverrideForDeployment(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != constant.DeploymentStrategyRolling && overrides.Strategy != constant.DeploymentStrategyCanary { + return manifest, nil + } + if overrides.Instances.IsSet { if manifest.ContainsMultipleApps() { return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} diff --git a/actor/v7pushaction/handle_instances_override_test.go b/actor/v7pushaction/handle_instances_override_test.go index b036eddc2f3..1ed32772e1a 100644 --- a/actor/v7pushaction/handle_instances_override_test.go +++ b/actor/v7pushaction/handle_instances_override_test.go @@ -1,13 +1,14 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -46,6 +47,30 @@ var _ = Describe("HandleInstancesOverride", func() { }) }) + When("instances are set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest).To(Equal(originalManifest)) + }) + }) + + When("instances are set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest).To(Equal(originalManifest)) + }) + }) + When("instances are set on the flag overrides", func() { BeforeEach(func() { overrides.Instances = types.NullInt{IsSet: true, Value: 4} @@ -136,3 +161,214 @@ var _ = Describe("HandleInstancesOverride", func() { }) }) }) + +var _ = Describe("HandleInstancesOverrideForDeployment", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleInstancesOverrideForDeployment(originalManifest, overrides) + }) + + When("manifest web process does not specify instances", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + When("instances are not set on the flag overrides", func() { + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest).To(Equal(originalManifest)) + }) + }) + + When("instances are set, and strategy is not set on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest).To(Equal(originalManifest)) + }) + }) + + When("instances are set, and strategy is set on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + It("changes the instances of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web", Instances: &overrides.Instances.Value}, + }, + }, + )) + }) + }) + }) + When("instances flag is set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the instances of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Instances: &overrides.Instances.Value, + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + var instances = 5 + + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + Instances: &instances, + }, + } + }) + + It("changes the instances of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", Instances: &overrides.Instances.Value}, + }, + Instances: &instances, + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + When("instances flag is set, and strategy is set to canary on the flag overrides", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 4} + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the instances of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Instances: &overrides.Instances.Value, + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + var instances = 5 + + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + Instances: &instances, + }, + } + }) + + It("changes the instances of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", Instances: &overrides.Instances.Value}, + }, + Instances: &instances, + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + +}) diff --git a/actor/v7pushaction/handle_lifecycle_override.go b/actor/v7pushaction/handle_lifecycle_override.go new file mode 100644 index 00000000000..befa869b015 --- /dev/null +++ b/actor/v7pushaction/handle_lifecycle_override.go @@ -0,0 +1,19 @@ +package v7pushaction + +import ( + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" +) + +func HandleLifecycleOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Lifecycle != "" { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + app := manifest.GetFirstApp() + app.Lifecycle = overrides.Lifecycle + } + + return manifest, nil +} diff --git a/actor/v7pushaction/handle_log_rate_limit_override.go b/actor/v7pushaction/handle_log_rate_limit_override.go new file mode 100644 index 00000000000..fe321a73151 --- /dev/null +++ b/actor/v7pushaction/handle_log_rate_limit_override.go @@ -0,0 +1,51 @@ +package v7pushaction + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" +) + +func HandleLogRateLimitOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != "" { + return manifest, nil + } + + if overrides.LogRateLimit != "" { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + webProcess := manifest.GetFirstAppWebProcess() + if webProcess != nil { + webProcess.LogRateLimit = overrides.LogRateLimit + } else { + app := manifest.GetFirstApp() + app.LogRateLimit = overrides.LogRateLimit + } + } + + return manifest, nil +} + +func HandleLogRateLimitOverrideForDeployment(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != constant.DeploymentStrategyRolling && overrides.Strategy != constant.DeploymentStrategyCanary { + return manifest, nil + } + + if overrides.LogRateLimit != "" { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + webProcess := manifest.GetFirstAppWebProcess() + if webProcess != nil { + webProcess.LogRateLimit = overrides.LogRateLimit + } else { + app := manifest.GetFirstApp() + app.LogRateLimit = overrides.LogRateLimit + } + } + + return manifest, nil +} diff --git a/actor/v7pushaction/handle_log_rate_limit_override_test.go b/actor/v7pushaction/handle_log_rate_limit_override_test.go new file mode 100644 index 00000000000..87f221b1499 --- /dev/null +++ b/actor/v7pushaction/handle_log_rate_limit_override_test.go @@ -0,0 +1,412 @@ +package v7pushaction_test + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("HandleLogRateLimitOverride", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleLogRateLimitOverride(originalManifest, overrides) + }) + + When("log rate limit is not set on a flag override", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + {Type: "worker", LogRateLimit: "1B"}, + }, + }, + } + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + {Type: "worker", LogRateLimit: "1B"}, + }, + }, + )) + }) + }) + + When("manifest web process does not specify log rate limit", func() { + BeforeEach(func() { + overrides.LogRateLimit = "64K" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + It("changes the log rate limit of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web", LogRateLimit: "64K"}, + }, + }, + )) + }) + }) + + When("log rate limit is set, and strategy is set", func() { + BeforeEach(func() { + overrides.LogRateLimit = "64K" + overrides.Strategy = constant.DeploymentStrategyRolling + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("manifest app has only non-web processes", func() { + BeforeEach(func() { + overrides.LogRateLimit = "32B" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the log rate limit of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + LogRateLimit: "32B", + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + overrides.LogRateLimit = "4MB" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + LogRateLimit: "1GB", + }, + } + }) + + It("changes the log rate limit of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", LogRateLimit: "4MB"}, + }, + LogRateLimit: "1GB", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + overrides.LogRateLimit = "64M" + + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) +}) + +var _ = Describe("HandleLogRateLimitOverrideForDeployment", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleLogRateLimitOverrideForDeployment(originalManifest, overrides) + }) + + When("log rate limit is not set on a flag override", func() { + BeforeEach(func() { + overrides.Strategy = constant.DeploymentStrategyRolling + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + {Type: "worker", LogRateLimit: "1B"}, + }, + }, + } + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + {Type: "worker", LogRateLimit: "1B"}, + }, + }, + )) + }) + }) + + When("manifest web process does not specify log rate limit", func() { + BeforeEach(func() { + overrides.LogRateLimit = "64K" + overrides.Strategy = constant.DeploymentStrategyCanary + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + It("changes the log rate limit of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web", LogRateLimit: "64K"}, + }, + }, + )) + }) + }) + + When("log rate limit is set, and strategy is not set", func() { + BeforeEach(func() { + overrides.LogRateLimit = "64K" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + When("log rate limit flag is set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.LogRateLimit = "32B" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + When("manifest app has only non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the log rate limit of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + LogRateLimit: "32B", + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + LogRateLimit: "1GB", + }, + } + }) + + It("changes the log rate limit of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", LogRateLimit: "32B"}, + }, + LogRateLimit: "1GB", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + + When("log rate limit flag is set, and strategy is set to canary on the flag overrides", func() { + BeforeEach(func() { + overrides.LogRateLimit = "32B" + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + When("manifest app has only non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the log rate limit of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + LogRateLimit: "32B", + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + LogRateLimit: "1GB", + }, + } + }) + + It("changes the log rate limit of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", LogRateLimit: "32B"}, + }, + LogRateLimit: "1GB", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) +}) diff --git a/actor/v7pushaction/handle_memory_override.go b/actor/v7pushaction/handle_memory_override.go index 82944bba6eb..812037030d1 100644 --- a/actor/v7pushaction/handle_memory_override.go +++ b/actor/v7pushaction/handle_memory_override.go @@ -1,12 +1,38 @@ package v7pushaction import ( - //"code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleMemoryOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != "" { + return manifest, nil + } + + if overrides.Memory != "" { + if manifest.ContainsMultipleApps() { + return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} + } + + webProcess := manifest.GetFirstAppWebProcess() + if webProcess != nil { + webProcess.Memory = overrides.Memory + } else { + app := manifest.GetFirstApp() + app.Memory = overrides.Memory + } + } + + return manifest, nil +} + +func HandleMemoryOverrideForDeployment(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { + if overrides.Strategy != constant.DeploymentStrategyRolling && overrides.Strategy != constant.DeploymentStrategyCanary { + return manifest, nil + } + if overrides.Memory != "" { if manifest.ContainsMultipleApps() { return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} diff --git a/actor/v7pushaction/handle_memory_override_test.go b/actor/v7pushaction/handle_memory_override_test.go index ff1c7c3e2e1..1fe6ff1f9fe 100644 --- a/actor/v7pushaction/handle_memory_override_test.go +++ b/actor/v7pushaction/handle_memory_override_test.go @@ -1,12 +1,13 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -51,6 +52,24 @@ var _ = Describe("HandleMemoryOverride", func() { }) }) + When("memory are set,and strategy is set on the flag overrides", func() { + BeforeEach(func() { + overrides.Memory = "64M" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + When("memory are set on the flag overrides", func() { BeforeEach(func() { overrides.Memory = "64M" @@ -139,3 +158,231 @@ var _ = Describe("HandleMemoryOverride", func() { }) }) }) + +var _ = Describe("HandleMemoryOverrideForDeployment", func() { + var ( + originalManifest manifestparser.Manifest + transformedManifest manifestparser.Manifest + overrides FlagOverrides + executeErr error + ) + + BeforeEach(func() { + originalManifest = manifestparser.Manifest{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + transformedManifest, executeErr = HandleMemoryOverrideForDeployment(originalManifest, overrides) + }) + + When("manifest web process does not specify memory", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + } + }) + + When("memory are not set on the flag overrides", func() { + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("memory are set,and strategy is not set on the flag overrides", func() { + BeforeEach(func() { + overrides.Memory = "64M" + }) + + It("does not change the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web"}, + }, + }, + )) + }) + }) + + When("memory are set, and strategy is set on the flag overrides", func() { + BeforeEach(func() { + overrides.Memory = "64M" + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + It("changes the memory of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "web", Memory: "64M"}, + }, + }, + )) + }) + }) + }) + + When("memory flag is set, and strategy is set to rolling on the flag overrides", func() { + BeforeEach(func() { + overrides.Memory = "64M" + overrides.Strategy = constant.DeploymentStrategyRolling + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the memory of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Memory: "64M", + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + overrides.Memory = "64M" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + Memory: "8M", + }, + } + }) + + It("changes the memory of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", Memory: "64M"}, + }, + Memory: "8M", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + overrides.Memory = "64M" + + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) + + When("memory flag is set, and strategy is set to canary on the flag overrides", func() { + BeforeEach(func() { + overrides.Memory = "64M" + overrides.Strategy = constant.DeploymentStrategyCanary + }) + + When("manifest app has non-web processes", func() { + BeforeEach(func() { + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + } + }) + + It("changes the memory of the app in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Memory: "64M", + Processes: []manifestparser.Process{ + {Type: "worker"}, + }, + }, + )) + }) + }) + + When("manifest app has web and non-web processes", func() { + BeforeEach(func() { + overrides.Memory = "64M" + + originalManifest.Applications = []manifestparser.Application{ + { + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web"}, + }, + Memory: "8M", + }, + } + }) + + It("changes the memory of the web process in the manifest", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(transformedManifest.Applications).To(ConsistOf( + manifestparser.Application{ + Processes: []manifestparser.Process{ + {Type: "worker"}, + {Type: "web", Memory: "64M"}, + }, + Memory: "8M", + }, + )) + }) + }) + + When("there are multiple apps in the manifest", func() { + BeforeEach(func() { + overrides.Memory = "64M" + + originalManifest.Applications = []manifestparser.Application{ + {}, + {}, + } + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) + }) + }) + }) +}) diff --git a/actor/v7pushaction/handle_no_route_override.go b/actor/v7pushaction/handle_no_route_override.go index 10d5c170cda..11ff5744f82 100644 --- a/actor/v7pushaction/handle_no_route_override.go +++ b/actor/v7pushaction/handle_no_route_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleNoRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_no_route_override_test.go b/actor/v7pushaction/handle_no_route_override_test.go index 385c0469c88..daffcb78d01 100644 --- a/actor/v7pushaction/handle_no_route_override_test.go +++ b/actor/v7pushaction/handle_no_route_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_random_route_override.go b/actor/v7pushaction/handle_random_route_override.go index ba18805c21e..a3f069b560d 100644 --- a/actor/v7pushaction/handle_random_route_override.go +++ b/actor/v7pushaction/handle_random_route_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleRandomRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_random_route_override_test.go b/actor/v7pushaction/handle_random_route_override_test.go index 30ccd9fbd21..d4e7c95e3ae 100644 --- a/actor/v7pushaction/handle_random_route_override_test.go +++ b/actor/v7pushaction/handle_random_route_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_stack_override.go b/actor/v7pushaction/handle_stack_override.go index 3087e67ccee..4741052d4c0 100644 --- a/actor/v7pushaction/handle_stack_override.go +++ b/actor/v7pushaction/handle_stack_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleStackOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_stack_override_test.go b/actor/v7pushaction/handle_stack_override_test.go index 9c6d3e18752..af2191a72c3 100644 --- a/actor/v7pushaction/handle_stack_override_test.go +++ b/actor/v7pushaction/handle_stack_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -37,7 +37,7 @@ var _ = Describe("HandleStackOverride", func() { } }) - It("will retain the origional stack value", func() { + It("will retain the original stack value", func() { Expect(executeErr).To(Not(HaveOccurred())) Expect(transformedManifest.Applications[0].Stack).To(Equal("og_cflinuxfs")) }) @@ -51,7 +51,7 @@ var _ = Describe("HandleStackOverride", func() { originalManifest.Applications = []manifestparser.Application{ { - Stack: "cflinuxfs3", + Stack: "cflinuxfs4", }, } }) diff --git a/actor/v7pushaction/handle_start_command_override.go b/actor/v7pushaction/handle_start_command_override.go index 45dbe8838b4..be6a1de2b09 100644 --- a/actor/v7pushaction/handle_start_command_override.go +++ b/actor/v7pushaction/handle_start_command_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleStartCommandOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_start_command_override_test.go b/actor/v7pushaction/handle_start_command_override_test.go index 577efc58242..b1143bca4d4 100644 --- a/actor/v7pushaction/handle_start_command_override_test.go +++ b/actor/v7pushaction/handle_start_command_override_test.go @@ -1,13 +1,13 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_strategy_override.go b/actor/v7pushaction/handle_strategy_override.go index 7501a024278..55ab81bf8ad 100644 --- a/actor/v7pushaction/handle_strategy_override.go +++ b/actor/v7pushaction/handle_strategy_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleStrategyOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_strategy_override_test.go b/actor/v7pushaction/handle_strategy_override_test.go index 57bb0fe6ad4..f716b65c8b9 100644 --- a/actor/v7pushaction/handle_strategy_override_test.go +++ b/actor/v7pushaction/handle_strategy_override_test.go @@ -1,11 +1,11 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/handle_task_override.go b/actor/v7pushaction/handle_task_override.go index 6d369d8b828..6ab978f7ecb 100644 --- a/actor/v7pushaction/handle_task_override.go +++ b/actor/v7pushaction/handle_task_override.go @@ -1,8 +1,8 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) func HandleTaskOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { diff --git a/actor/v7pushaction/handle_task_override_test.go b/actor/v7pushaction/handle_task_override_test.go index 7848d9334f2..85e004f385e 100644 --- a/actor/v7pushaction/handle_task_override_test.go +++ b/actor/v7pushaction/handle_task_override_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/push_plan.go b/actor/v7pushaction/push_plan.go index 19d4a32d298..41e4c18722b 100644 --- a/actor/v7pushaction/push_plan.go +++ b/actor/v7pushaction/push_plan.go @@ -3,11 +3,11 @@ package v7pushaction import ( "fmt" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" "github.com/cloudfoundry/bosh-cli/director/template" ) @@ -20,7 +20,13 @@ type PushPlan struct { NoStart bool NoWait bool Strategy constant.DeploymentStrategy + MaxInFlight int + Instances types.NullInt + MemoryInMB types.NullUint64 + DiskInMB types.NullUint64 + LogRateLimitInBPS types.NullInt TaskTypeApplication bool + InstanceSteps []int64 DockerImageCredentials v7action.DockerImageCredentials @@ -42,11 +48,14 @@ type FlagOverrides struct { DockerImage string DockerPassword string DockerUsername string + CNBCredentials map[string]interface{} HealthCheckEndpoint string HealthCheckTimeout int64 HealthCheckType constant.HealthCheckType Instances types.NullInt + InstanceSteps []int64 Memory string + MaxInFlight *int NoStart bool NoWait bool ProvidedAppPath string @@ -59,6 +68,8 @@ type FlagOverrides struct { Vars []template.VarKV NoManifest bool Task bool + LogRateLimit string + Lifecycle constant.AppLifecycleType } func (state PushPlan) String() string { diff --git a/actor/v7pushaction/resource_match.go b/actor/v7pushaction/resource_match.go index dcfb1ebafd2..af2e4dabeee 100644 --- a/actor/v7pushaction/resource_match.go +++ b/actor/v7pushaction/resource_match.go @@ -1,6 +1,6 @@ package v7pushaction -import "code.cloudfoundry.org/cli/actor/sharedaction" +import "code.cloudfoundry.org/cli/v8/actor/sharedaction" // MatchResources returns back a list of matched and unmatched resources for the provided resources. func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) { diff --git a/actor/v7pushaction/resource_match_test.go b/actor/v7pushaction/resource_match_test.go index 9471a83578a..e4fb9a55862 100644 --- a/actor/v7pushaction/resource_match_test.go +++ b/actor/v7pushaction/resource_match_test.go @@ -3,12 +3,12 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/restart_application_test.go b/actor/v7pushaction/restart_application_test.go index 33c1fee4c0d..72ccf245eac 100644 --- a/actor/v7pushaction/restart_application_test.go +++ b/actor/v7pushaction/restart_application_test.go @@ -3,12 +3,12 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/sequence.go b/actor/v7pushaction/sequence.go index b8e4608fe70..b45290174a6 100644 --- a/actor/v7pushaction/sequence.go +++ b/actor/v7pushaction/sequence.go @@ -1,7 +1,7 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) func ShouldCreateBitsPackage(plan PushPlan) bool { @@ -21,7 +21,7 @@ func ShouldStagePackage(plan PushPlan) bool { } func ShouldCreateDeployment(plan PushPlan) bool { - return plan.Strategy == constant.DeploymentStrategyRolling + return plan.Strategy != "" } func ShouldStopApplication(plan PushPlan) bool { diff --git a/actor/v7pushaction/sequence_test.go b/actor/v7pushaction/sequence_test.go index 0acfffd35df..756611989fa 100644 --- a/actor/v7pushaction/sequence_test.go +++ b/actor/v7pushaction/sequence_test.go @@ -1,12 +1,12 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -113,6 +113,18 @@ var _ = Describe("Actor", func() { }) }) + When("the plan has strategy 'canary'", func() { + BeforeEach(func() { + plan = PushPlan{ + Strategy: constant.DeploymentStrategyCanary, + } + }) + + It("returns a sequence that creates a canary deployment", func() { + Expect(sequence).To(matchers.MatchFuncsByName(actor.StagePackageForApplication, actor.CreateDeploymentForApplication)) + }) + }) + When("the plan has task application type", func() { BeforeEach(func() { plan = PushPlan{ diff --git a/actor/v7pushaction/set_default_bits_path_for_push_plan_test.go b/actor/v7pushaction/set_default_bits_path_for_push_plan_test.go index d5db9e80885..2f9c3f727cc 100644 --- a/actor/v7pushaction/set_default_bits_path_for_push_plan_test.go +++ b/actor/v7pushaction/set_default_bits_path_for_push_plan_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/set_droplet_for_application_test.go b/actor/v7pushaction/set_droplet_for_application_test.go index f28e9be8428..ac2c94901b3 100644 --- a/actor/v7pushaction/set_droplet_for_application_test.go +++ b/actor/v7pushaction/set_droplet_for_application_test.go @@ -3,11 +3,11 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/setup_all_resources_for_push_plan.go b/actor/v7pushaction/setup_all_resources_for_push_plan.go index e58b9ed5461..9c743b056b6 100644 --- a/actor/v7pushaction/setup_all_resources_for_push_plan.go +++ b/actor/v7pushaction/setup_all_resources_for_push_plan.go @@ -4,8 +4,8 @@ import ( "errors" "os" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) func (actor Actor) SetupAllResourcesForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) { diff --git a/actor/v7pushaction/setup_all_resources_for_push_plan_test.go b/actor/v7pushaction/setup_all_resources_for_push_plan_test.go index 628f2ff82d0..373a22b90c7 100644 --- a/actor/v7pushaction/setup_all_resources_for_push_plan_test.go +++ b/actor/v7pushaction/setup_all_resources_for_push_plan_test.go @@ -2,16 +2,15 @@ package v7pushaction_test import ( "errors" - "io/ioutil" "os" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -126,7 +125,7 @@ var _ = Describe("SetupAllResourcesForPushPlan", func() { var archivePath string BeforeEach(func() { - archive, err := ioutil.TempFile("", "push-plan-archive") + archive, err := os.CreateTemp("", "push-plan-archive") Expect(err).ToNot(HaveOccurred()) defer archive.Close() diff --git a/actor/v7pushaction/setup_deployment_information_for_push_plan.go b/actor/v7pushaction/setup_deployment_information_for_push_plan.go new file mode 100644 index 00000000000..6024b4b94e0 --- /dev/null +++ b/actor/v7pushaction/setup_deployment_information_for_push_plan.go @@ -0,0 +1,50 @@ +package v7pushaction + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" +) + +func SetupDeploymentInformationForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) { + pushPlan.Strategy = overrides.Strategy + + if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.MaxInFlight != nil { + pushPlan.MaxInFlight = *overrides.MaxInFlight + } + + if overrides.Strategy == constant.DeploymentStrategyCanary && overrides.InstanceSteps != nil { + pushPlan.InstanceSteps = overrides.InstanceSteps + } + + if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.Instances.IsSet { + pushPlan.Instances = overrides.Instances + } + + if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.Memory != "" { + size, err := flag.ConvertToMb(overrides.Memory) + if err != nil { + return PushPlan{}, errors.New(err.Error()) + } + pushPlan.MemoryInMB.Value = size + pushPlan.MemoryInMB.IsSet = true + } + if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.Disk != "" { + size, err := flag.ConvertToMb(overrides.Disk) + if err != nil { + return PushPlan{}, errors.New(err.Error()) + } + pushPlan.DiskInMB.Value = size + pushPlan.DiskInMB.IsSet = true + } + + if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.LogRateLimit != "" { + logRateLimit := flag.BytesWithUnlimited{} + if err := logRateLimit.IsValidValue(overrides.LogRateLimit); err != nil { + return PushPlan{}, errors.New(err.Error()) + } + pushPlan.LogRateLimitInBPS = types.NullInt(logRateLimit) + } + return pushPlan, nil +} diff --git a/actor/v7pushaction/setup_deployment_information_for_push_plan_test.go b/actor/v7pushaction/setup_deployment_information_for_push_plan_test.go new file mode 100644 index 00000000000..5c0747708c3 --- /dev/null +++ b/actor/v7pushaction/setup_deployment_information_for_push_plan_test.go @@ -0,0 +1,279 @@ +package v7pushaction_test + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/types" + + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("SetupDeploymentInformationForPushPlan", func() { + var ( + pushPlan PushPlan + overrides FlagOverrides + + expectedPushPlan PushPlan + executeErr error + ) + + // A helper function to encapsulate the common flag override tests. + // This function will be called within the context of different strategy tests. + runCommonFlagOverrideTests := func() { + When("instance overrides is specified", func() { + BeforeEach(func() { + overrides.Instances = types.NullInt{IsSet: true, Value: 3} + }) + It("should set the instances", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Instances).To(Equal(types.NullInt{IsSet: true, Value: 3})) + }) + }) + + When("memory overrides is specified with incorrect unit", func() { + var expectedErr error + BeforeEach(func() { + overrides.Memory = "10k" + expectedErr = errors.New("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB") + }) + It("should return error", func() { + Expect(executeErr).To(HaveOccurred()) + Expect(executeErr).To(MatchError(expectedErr)) + }) + }) + + When("memory overrides is specified in GB", func() { + BeforeEach(func() { + overrides.Memory = "1GB" + }) + It("should set the memory in MB", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MemoryInMB).To(Equal(types.NullUint64{IsSet: true, Value: 1 * 1024})) + }) + }) + + When("memory overrides is specified in MB", func() { + BeforeEach(func() { + overrides.Memory = "1M" + }) + It("should set the memory in MB", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MemoryInMB).To(Equal(types.NullUint64{IsSet: true, Value: 1})) + }) + }) + + When("disk overrides is specified with incorrect unit", func() { + var expectedErr error + BeforeEach(func() { + overrides.Disk = "10k" + expectedErr = errors.New("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB") + }) + It("should return error", func() { + Expect(executeErr).To(HaveOccurred()) + Expect(executeErr).To(MatchError(expectedErr)) + }) + }) + + When("disk overrides is specified in GB", func() { + BeforeEach(func() { + overrides.Disk = "2GB" + }) + It("should set the disk in MB", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.DiskInMB).To(Equal(types.NullUint64{IsSet: true, Value: 2 * 1024})) + }) + }) + + When("disk overrides is specified in MB", func() { + BeforeEach(func() { + overrides.Disk = "1M" + }) + It("should set the disk in MB", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.DiskInMB).To(Equal(types.NullUint64{IsSet: true, Value: 1})) + }) + }) + + When("log rate limit is specified with incorrect unit", func() { + var expectedErr error + BeforeEach(func() { + overrides.LogRateLimit = "10A" + expectedErr = errors.New("Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB") + }) + It("should return error", func() { + Expect(executeErr).To(HaveOccurred()) + Expect(executeErr).To(MatchError(expectedErr)) + }) + }) + + When("unlimited log rate limit is specified", func() { + BeforeEach(func() { + overrides.LogRateLimit = "-1" + }) + It("should set the log rate limit", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: true, Value: -1})) + }) + }) + + When("log rate limit overrides is specified in Bytes", func() { // Original comment was "disk overrides", corrected + BeforeEach(func() { + overrides.LogRateLimit = "10B" + }) + It("should set the log rate limit in Bytes", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: true, Value: 10})) + }) + }) + + When("log rate limit overrides is specified in KB", func() { + BeforeEach(func() { + overrides.LogRateLimit = "2K" + }) + It("should set the log rate limit in Bytes", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: true, Value: 2 * 1024})) + }) + }) + + When("log rate limit overrides is specified in MB", func() { // Original comment was "disk overrides", corrected + BeforeEach(func() { + overrides.LogRateLimit = "1MB" + }) + It("should set the log rate limit in Bytes", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: true, Value: 1 * 1024 * 1024})) + }) + }) + } + + BeforeEach(func() { + pushPlan = PushPlan{} + overrides = FlagOverrides{} + }) + + JustBeforeEach(func() { + expectedPushPlan, executeErr = SetupDeploymentInformationForPushPlan(pushPlan, overrides) + }) + + When("flag overrides specifies strategy", func() { + BeforeEach(func() { + // These values are common for both rolling and canary when a strategy is specified + maxInFlight := 5 + overrides.MaxInFlight = &maxInFlight + overrides.InstanceSteps = []int64{1, 2, 3, 4} + }) + + DescribeTableSubtree("sets strategy and related options correctly", + func(strategy constant.DeploymentStrategy, expectedDeploymentStrategy constant.DeploymentStrategy, expectedInstanceSteps []int64) { + BeforeEach(func() { + overrides.Strategy = strategy + }) + + It("sets the strategy on the push plan", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Strategy).To(Equal(expectedDeploymentStrategy)) + }) + + It("sets the max in flight on the push plan", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MaxInFlight).To(Equal(5)) + }) + + It("sets the instance steps correctly", func() { + Expect(executeErr).ToNot(HaveOccurred()) + if len(expectedInstanceSteps) > 0 { + Expect(expectedPushPlan.InstanceSteps).To(ContainElements(expectedInstanceSteps)) + } else { + Expect(expectedPushPlan.InstanceSteps).To(BeEmpty()) + } + }) + + runCommonFlagOverrideTests() + }, + Entry("when strategy is rolling", constant.DeploymentStrategyRolling, constant.DeploymentStrategyRolling, []int64{}), // No instance steps for rolling + Entry("when strategy is canary", constant.DeploymentStrategyCanary, constant.DeploymentStrategyCanary, []int64{1, 2, 3, 4}), + ) + }) + + When("flag overrides does not specify strategy", func() { + BeforeEach(func() { + maxInFlight := 10 + overrides.MaxInFlight = &maxInFlight + overrides.InstanceSteps = []int64{1, 2, 3, 4} + overrides.Instances = types.NullInt{IsSet: true, Value: 3} + overrides.Memory = "10k" + overrides.Disk = "20K" + overrides.LogRateLimit = "20K" + }) + + It("leaves the strategy as its default value on the push plan", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + }) + + It("does not set MaxInFlight", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MaxInFlight).To(Equal(0)) + }) + + It("does not set canary steps", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.InstanceSteps).To(BeEmpty()) + }) + + It("does not set instances", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Instances).To(Equal(types.NullInt{IsSet: false, Value: 0})) + }) + It("does not set Memory", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MemoryInMB).To(Equal(types.NullUint64{IsSet: false, Value: 0})) + }) + It("does not set Disk", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.DiskInMB).To(Equal(types.NullUint64{IsSet: false, Value: 0})) + }) + It("does not set log rate limit", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: false, Value: 0})) + }) + }) + + When("no flag overrides are provided", func() { + BeforeEach(func() { + overrides = FlagOverrides{} + }) + It("does not set MaxInFlight", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MaxInFlight).To(Equal(0)) + }) + It("does not set the canary steps", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.InstanceSteps).To(BeEmpty()) + }) + It("does not set instances", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Instances).To(Equal(types.NullInt{IsSet: false, Value: 0})) + }) + It("does not set Memory", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.MemoryInMB).To(Equal(types.NullUint64{IsSet: false, Value: 0})) + }) + It("does not set Disk", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.DiskInMB).To(Equal(types.NullUint64{IsSet: false, Value: 0})) + }) + It("does not set log rate limit", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.LogRateLimitInBPS).To(Equal(types.NullInt{IsSet: false, Value: 0})) + }) + It("leaves the strategy as its default value on the push plan", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(expectedPushPlan.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + }) + }) +}) diff --git a/actor/v7pushaction/setup_deployment_strategy_for_push_plan.go b/actor/v7pushaction/setup_deployment_strategy_for_push_plan.go deleted file mode 100644 index 0e6c2526342..00000000000 --- a/actor/v7pushaction/setup_deployment_strategy_for_push_plan.go +++ /dev/null @@ -1,7 +0,0 @@ -package v7pushaction - -func SetupDeploymentStrategyForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) { - pushPlan.Strategy = overrides.Strategy - - return pushPlan, nil -} diff --git a/actor/v7pushaction/setup_deployment_strategy_for_push_plan_test.go b/actor/v7pushaction/setup_deployment_strategy_for_push_plan_test.go deleted file mode 100644 index 238dc007729..00000000000 --- a/actor/v7pushaction/setup_deployment_strategy_for_push_plan_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package v7pushaction_test - -import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - - . "code.cloudfoundry.org/cli/actor/v7pushaction" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("SetupDeploymentStrategyForPushPlan", func() { - var ( - pushPlan PushPlan - overrides FlagOverrides - - expectedPushPlan PushPlan - executeErr error - ) - - BeforeEach(func() { - pushPlan = PushPlan{} - overrides = FlagOverrides{} - }) - - JustBeforeEach(func() { - expectedPushPlan, executeErr = SetupDeploymentStrategyForPushPlan(pushPlan, overrides) - }) - - When("flag overrides specifies strategy", func() { - BeforeEach(func() { - overrides.Strategy = "rolling" - }) - - It("sets the strategy on the push plan", func() { - Expect(executeErr).ToNot(HaveOccurred()) - Expect(expectedPushPlan.Strategy).To(Equal(constant.DeploymentStrategyRolling)) - }) - }) - - When("flag overrides does not specify strategy", func() { - It("leaves the strategy as its default value on the push plan", func() { - Expect(executeErr).ToNot(HaveOccurred()) - Expect(expectedPushPlan.Strategy).To(Equal(constant.DeploymentStrategyDefault)) - }) - }) -}) diff --git a/actor/v7pushaction/setup_droplet_path_for_push_plan_test.go b/actor/v7pushaction/setup_droplet_path_for_push_plan_test.go index d2866b08247..e714110064d 100644 --- a/actor/v7pushaction/setup_droplet_path_for_push_plan_test.go +++ b/actor/v7pushaction/setup_droplet_path_for_push_plan_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/setup_no_start_for_push_plan_test.go b/actor/v7pushaction/setup_no_start_for_push_plan_test.go index 19902e9aa10..ae224fdf806 100644 --- a/actor/v7pushaction/setup_no_start_for_push_plan_test.go +++ b/actor/v7pushaction/setup_no_start_for_push_plan_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/setup_no_wait_for_push_plan_test.go b/actor/v7pushaction/setup_no_wait_for_push_plan_test.go index e0f5b3ad62c..be6366f4b7e 100644 --- a/actor/v7pushaction/setup_no_wait_for_push_plan_test.go +++ b/actor/v7pushaction/setup_no_wait_for_push_plan_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/setup_task_app_for_push_plan_test.go b/actor/v7pushaction/setup_task_app_for_push_plan_test.go index 988a206c13a..5f2963274de 100644 --- a/actor/v7pushaction/setup_task_app_for_push_plan_test.go +++ b/actor/v7pushaction/setup_task_app_for_push_plan_test.go @@ -1,9 +1,9 @@ package v7pushaction_test import ( - . "code.cloudfoundry.org/cli/actor/v7pushaction" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/shared_actor.go b/actor/v7pushaction/shared_actor.go index cd4efca31b5..dc8f9259be9 100644 --- a/actor/v7pushaction/shared_actor.go +++ b/actor/v7pushaction/shared_actor.go @@ -3,7 +3,7 @@ package v7pushaction import ( "io" - "code.cloudfoundry.org/cli/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 io.ReadCloser diff --git a/actor/v7pushaction/stage_package_for_application_test.go b/actor/v7pushaction/stage_package_for_application_test.go index b0a5154380c..bd09bb9b8ae 100644 --- a/actor/v7pushaction/stage_package_for_application_test.go +++ b/actor/v7pushaction/stage_package_for_application_test.go @@ -3,11 +3,11 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/stop_application.go b/actor/v7pushaction/stop_application.go index b6865a2f16c..947dbe7f5fc 100644 --- a/actor/v7pushaction/stop_application.go +++ b/actor/v7pushaction/stop_application.go @@ -1,7 +1,7 @@ package v7pushaction import ( - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" log "github.com/sirupsen/logrus" ) diff --git a/actor/v7pushaction/stop_application_test.go b/actor/v7pushaction/stop_application_test.go index e380b43d9dd..1fc37ccd12d 100644 --- a/actor/v7pushaction/stop_application_test.go +++ b/actor/v7pushaction/stop_application_test.go @@ -3,12 +3,12 @@ package v7pushaction_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/v7pushaction/v7_actor.go b/actor/v7pushaction/v7_actor.go index db59052da50..9f0ebd5a34b 100644 --- a/actor/v7pushaction/v7_actor.go +++ b/actor/v7pushaction/v7_actor.go @@ -3,9 +3,9 @@ package v7pushaction import ( "io" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . V7Actor @@ -14,9 +14,9 @@ type V7Actor interface { CreateApplicationDroplet(appGUID string) (resources.Droplet, v7action.Warnings, error) CreateApplicationInSpace(app resources.Application, spaceGUID string) (resources.Application, v7action.Warnings, error) CreateBitsPackageByApplication(appGUID string) (resources.Package, v7action.Warnings, error) - CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, v7action.Warnings, error) + CreateDeployment(dep resources.Deployment) (string, v7action.Warnings, error) CreateDockerPackageByApplication(appGUID string, dockerImageCredentials v7action.DockerImageCredentials) (resources.Package, v7action.Warnings, error) - CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, v7action.Warnings, error) + CreateRoute(spaceGUID, domainName, hostname, path string, port int, options map[string]*string) (resources.Route, v7action.Warnings, error) GetApplicationByNameAndSpace(appName string, spaceGUID string) (resources.Application, v7action.Warnings, error) GetApplicationDroplets(appName string, spaceGUID string) ([]resources.Droplet, v7action.Warnings, error) GetApplicationRoutes(appGUID string) ([]resources.Route, v7action.Warnings, error) @@ -29,7 +29,7 @@ type V7Actor interface { PollBuild(buildGUID string, appName string) (resources.Droplet, v7action.Warnings, error) PollPackage(pkg resources.Package) (resources.Package, v7action.Warnings, error) PollStart(app resources.Application, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) - PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) + PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) ResourceMatch(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, v7action.Warnings, error) RestartApplication(appGUID string, noWait bool) (v7action.Warnings, error) ScaleProcessByApplication(appGUID string, process resources.Process) (v7action.Warnings, error) @@ -41,6 +41,7 @@ type V7Actor interface { UnmapRoute(routeGUID string, destinationGUID string) (v7action.Warnings, error) UpdateApplication(app resources.Application) (resources.Application, v7action.Warnings, error) UpdateProcessByTypeAndApplication(processType string, appGUID string, updatedProcess resources.Process) (v7action.Warnings, error) + UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, v7action.Warnings, error) UploadBitsPackage(pkg resources.Package, matchedResources []sharedaction.V3Resource, newResources io.Reader, newResourcesLength int64) (resources.Package, v7action.Warnings, error) UploadDroplet(dropletGUID string, dropletPath string, progressReader io.Reader, fileSize int64) (v7action.Warnings, error) } diff --git a/actor/v7pushaction/v7pushaction_suite_test.go b/actor/v7pushaction/v7pushaction_suite_test.go index 8a41f84bf3a..050a13f6f4c 100644 --- a/actor/v7pushaction/v7pushaction_suite_test.go +++ b/actor/v7pushaction/v7pushaction_suite_test.go @@ -2,13 +2,12 @@ package v7pushaction_test import ( "os" - "time" - "testing" + "time" - . "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction/v7pushactionfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" diff --git a/actor/v7pushaction/v7pushactionfakes/fake_progress_bar.go b/actor/v7pushaction/v7pushactionfakes/fake_progress_bar.go index 9b0a3aa81cd..6a827cd59e5 100644 --- a/actor/v7pushaction/v7pushactionfakes/fake_progress_bar.go +++ b/actor/v7pushaction/v7pushactionfakes/fake_progress_bar.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" ) type FakeProgressBar struct { @@ -32,15 +32,16 @@ func (fake *FakeProgressBar) NewProgressBarWrapper(arg1 io.Reader, arg2 int64) i arg1 io.Reader arg2 int64 }{arg1, arg2}) + stub := fake.NewProgressBarWrapperStub + fakeReturns := fake.newProgressBarWrapperReturns fake.recordInvocation("NewProgressBarWrapper", []interface{}{arg1, arg2}) fake.newProgressBarWrapperMutex.Unlock() - if fake.NewProgressBarWrapperStub != nil { - return fake.NewProgressBarWrapperStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newProgressBarWrapperReturns return fakeReturns.result1 } diff --git a/actor/v7pushaction/v7pushactionfakes/fake_read_closer.go b/actor/v7pushaction/v7pushactionfakes/fake_read_closer.go index 22f42a76ee4..2adfd1e23bc 100644 --- a/actor/v7pushaction/v7pushactionfakes/fake_read_closer.go +++ b/actor/v7pushaction/v7pushactionfakes/fake_read_closer.go @@ -39,15 +39,16 @@ func (fake *FakeReadCloser) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -97,15 +98,16 @@ func (fake *FakeReadCloser) Read(arg1 []byte) (int, error) { fake.readArgsForCall = append(fake.readArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.ReadStub + fakeReturns := fake.readReturns fake.recordInvocation("Read", []interface{}{arg1Copy}) fake.readMutex.Unlock() - if fake.ReadStub != nil { - return fake.ReadStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7pushaction/v7pushactionfakes/fake_shared_actor.go b/actor/v7pushaction/v7pushactionfakes/fake_shared_actor.go index 63ba72df441..b408a192675 100644 --- a/actor/v7pushaction/v7pushactionfakes/fake_shared_actor.go +++ b/actor/v7pushaction/v7pushactionfakes/fake_shared_actor.go @@ -5,8 +5,8 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" ) type FakeSharedActor struct { @@ -89,15 +89,16 @@ func (fake *FakeSharedActor) GatherArchiveResources(arg1 string) ([]sharedaction fake.gatherArchiveResourcesArgsForCall = append(fake.gatherArchiveResourcesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GatherArchiveResourcesStub + fakeReturns := fake.gatherArchiveResourcesReturns fake.recordInvocation("GatherArchiveResources", []interface{}{arg1}) fake.gatherArchiveResourcesMutex.Unlock() - if fake.GatherArchiveResourcesStub != nil { - return fake.GatherArchiveResourcesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.gatherArchiveResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -152,15 +153,16 @@ func (fake *FakeSharedActor) GatherDirectoryResources(arg1 string) ([]sharedacti fake.gatherDirectoryResourcesArgsForCall = append(fake.gatherDirectoryResourcesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GatherDirectoryResourcesStub + fakeReturns := fake.gatherDirectoryResourcesReturns fake.recordInvocation("GatherDirectoryResources", []interface{}{arg1}) fake.gatherDirectoryResourcesMutex.Unlock() - if fake.GatherDirectoryResourcesStub != nil { - return fake.GatherDirectoryResourcesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.gatherDirectoryResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -215,15 +217,16 @@ func (fake *FakeSharedActor) ReadArchive(arg1 string) (io.ReadCloser, int64, err fake.readArchiveArgsForCall = append(fake.readArchiveArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ReadArchiveStub + fakeReturns := fake.readArchiveReturns fake.recordInvocation("ReadArchive", []interface{}{arg1}) fake.readArchiveMutex.Unlock() - if fake.ReadArchiveStub != nil { - return fake.ReadArchiveStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.readArchiveReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -287,15 +290,16 @@ func (fake *FakeSharedActor) ZipArchiveResources(arg1 string, arg2 []sharedactio arg1 string arg2 []sharedaction.Resource }{arg1, arg2Copy}) + stub := fake.ZipArchiveResourcesStub + fakeReturns := fake.zipArchiveResourcesReturns fake.recordInvocation("ZipArchiveResources", []interface{}{arg1, arg2Copy}) fake.zipArchiveResourcesMutex.Unlock() - if fake.ZipArchiveResourcesStub != nil { - return fake.ZipArchiveResourcesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.zipArchiveResourcesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -356,15 +360,16 @@ func (fake *FakeSharedActor) ZipDirectoryResources(arg1 string, arg2 []sharedact arg1 string arg2 []sharedaction.Resource }{arg1, arg2Copy}) + stub := fake.ZipDirectoryResourcesStub + fakeReturns := fake.zipDirectoryResourcesReturns fake.recordInvocation("ZipDirectoryResources", []interface{}{arg1, arg2Copy}) fake.zipDirectoryResourcesMutex.Unlock() - if fake.ZipDirectoryResourcesStub != nil { - return fake.ZipDirectoryResourcesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.zipDirectoryResourcesReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/actor/v7pushaction/v7pushactionfakes/fake_v7actor.go b/actor/v7pushaction/v7pushactionfakes/fake_v7actor.go index c9e8539321e..ce878c727ea 100644 --- a/actor/v7pushaction/v7pushactionfakes/fake_v7actor.go +++ b/actor/v7pushaction/v7pushactionfakes/fake_v7actor.go @@ -5,10 +5,10 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeV7Actor struct { @@ -58,18 +58,17 @@ type FakeV7Actor struct { result2 v7action.Warnings result3 error } - CreateDeploymentByApplicationAndDropletStub func(string, string) (string, v7action.Warnings, error) - createDeploymentByApplicationAndDropletMutex sync.RWMutex - createDeploymentByApplicationAndDropletArgsForCall []struct { - arg1 string - arg2 string + CreateDeploymentStub func(resources.Deployment) (string, v7action.Warnings, error) + createDeploymentMutex sync.RWMutex + createDeploymentArgsForCall []struct { + arg1 resources.Deployment } - createDeploymentByApplicationAndDropletReturns struct { + createDeploymentReturns struct { result1 string result2 v7action.Warnings result3 error } - createDeploymentByApplicationAndDropletReturnsOnCall map[int]struct { + createDeploymentReturnsOnCall map[int]struct { result1 string result2 v7action.Warnings result3 error @@ -90,7 +89,7 @@ type FakeV7Actor struct { result2 v7action.Warnings result3 error } - CreateRouteStub func(string, string, string, string, int) (resources.Route, v7action.Warnings, error) + CreateRouteStub func(string, string, string, string, int, map[string]*string) (resources.Route, v7action.Warnings, error) createRouteMutex sync.RWMutex createRouteArgsForCall []struct { arg1 string @@ -98,6 +97,7 @@ type FakeV7Actor struct { arg3 string arg4 string arg5 int + arg6 map[string]*string } createRouteReturns struct { result1 resources.Route @@ -295,19 +295,19 @@ type FakeV7Actor struct { result1 v7action.Warnings result2 error } - PollStartForRollingStub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error) - pollStartForRollingMutex sync.RWMutex - pollStartForRollingArgsForCall []struct { + PollStartForDeploymentStub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error) + pollStartForDeploymentMutex sync.RWMutex + pollStartForDeploymentArgsForCall []struct { arg1 resources.Application arg2 string arg3 bool arg4 func(string) } - pollStartForRollingReturns struct { + pollStartForDeploymentReturns struct { result1 v7action.Warnings result2 error } - pollStartForRollingReturnsOnCall map[int]struct { + pollStartForDeploymentReturnsOnCall map[int]struct { result1 v7action.Warnings result2 error } @@ -468,6 +468,22 @@ type FakeV7Actor struct { result1 v7action.Warnings result2 error } + UpdateRouteStub func(string, map[string]*string) (resources.Route, v7action.Warnings, error) + updateRouteMutex sync.RWMutex + updateRouteArgsForCall []struct { + arg1 string + arg2 map[string]*string + } + updateRouteReturns struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + } + updateRouteReturnsOnCall map[int]struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + } UploadBitsPackageStub func(resources.Package, []sharedaction.V3Resource, io.Reader, int64) (resources.Package, v7action.Warnings, error) uploadBitsPackageMutex sync.RWMutex uploadBitsPackageArgsForCall []struct { @@ -512,15 +528,16 @@ func (fake *FakeV7Actor) CreateApplicationDroplet(arg1 string) (resources.Drople fake.createApplicationDropletArgsForCall = append(fake.createApplicationDropletArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateApplicationDropletStub + fakeReturns := fake.createApplicationDropletReturns fake.recordInvocation("CreateApplicationDroplet", []interface{}{arg1}) fake.createApplicationDropletMutex.Unlock() - if fake.CreateApplicationDropletStub != nil { - return fake.CreateApplicationDropletStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -579,15 +596,16 @@ func (fake *FakeV7Actor) CreateApplicationInSpace(arg1 resources.Application, ar arg1 resources.Application arg2 string }{arg1, arg2}) + stub := fake.CreateApplicationInSpaceStub + fakeReturns := fake.createApplicationInSpaceReturns fake.recordInvocation("CreateApplicationInSpace", []interface{}{arg1, arg2}) fake.createApplicationInSpaceMutex.Unlock() - if fake.CreateApplicationInSpaceStub != nil { - return fake.CreateApplicationInSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationInSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -645,15 +663,16 @@ func (fake *FakeV7Actor) CreateBitsPackageByApplication(arg1 string) (resources. fake.createBitsPackageByApplicationArgsForCall = append(fake.createBitsPackageByApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateBitsPackageByApplicationStub + fakeReturns := fake.createBitsPackageByApplicationReturns fake.recordInvocation("CreateBitsPackageByApplication", []interface{}{arg1}) fake.createBitsPackageByApplicationMutex.Unlock() - if fake.CreateBitsPackageByApplicationStub != nil { - return fake.CreateBitsPackageByApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBitsPackageByApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -705,67 +724,67 @@ func (fake *FakeV7Actor) CreateBitsPackageByApplicationReturnsOnCall(i int, resu }{result1, result2, result3} } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDroplet(arg1 string, arg2 string) (string, v7action.Warnings, error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - ret, specificReturn := fake.createDeploymentByApplicationAndDropletReturnsOnCall[len(fake.createDeploymentByApplicationAndDropletArgsForCall)] - fake.createDeploymentByApplicationAndDropletArgsForCall = append(fake.createDeploymentByApplicationAndDropletArgsForCall, struct { - arg1 string - arg2 string - }{arg1, arg2}) - fake.recordInvocation("CreateDeploymentByApplicationAndDroplet", []interface{}{arg1, arg2}) - fake.createDeploymentByApplicationAndDropletMutex.Unlock() - if fake.CreateDeploymentByApplicationAndDropletStub != nil { - return fake.CreateDeploymentByApplicationAndDropletStub(arg1, arg2) +func (fake *FakeV7Actor) CreateDeployment(arg1 resources.Deployment) (string, v7action.Warnings, error) { + fake.createDeploymentMutex.Lock() + ret, specificReturn := fake.createDeploymentReturnsOnCall[len(fake.createDeploymentArgsForCall)] + fake.createDeploymentArgsForCall = append(fake.createDeploymentArgsForCall, struct { + arg1 resources.Deployment + }{arg1}) + stub := fake.CreateDeploymentStub + fakeReturns := fake.createDeploymentReturns + fake.recordInvocation("CreateDeployment", []interface{}{arg1}) + fake.createDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDeploymentByApplicationAndDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDropletCallCount() int { - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() - return len(fake.createDeploymentByApplicationAndDropletArgsForCall) +func (fake *FakeV7Actor) CreateDeploymentCallCount() int { + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() + return len(fake.createDeploymentArgsForCall) } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDropletCalls(stub func(string, string) (string, v7action.Warnings, error)) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = stub +func (fake *FakeV7Actor) CreateDeploymentCalls(stub func(resources.Deployment) (string, v7action.Warnings, error)) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = stub } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDropletArgsForCall(i int) (string, string) { - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() - argsForCall := fake.createDeploymentByApplicationAndDropletArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 +func (fake *FakeV7Actor) CreateDeploymentArgsForCall(i int) resources.Deployment { + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() + argsForCall := fake.createDeploymentArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDropletReturns(result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = nil - fake.createDeploymentByApplicationAndDropletReturns = struct { +func (fake *FakeV7Actor) CreateDeploymentReturns(result1 string, result2 v7action.Warnings, result3 error) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = nil + fake.createDeploymentReturns = struct { result1 string result2 v7action.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeV7Actor) CreateDeploymentByApplicationAndDropletReturnsOnCall(i int, result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = nil - if fake.createDeploymentByApplicationAndDropletReturnsOnCall == nil { - fake.createDeploymentByApplicationAndDropletReturnsOnCall = make(map[int]struct { +func (fake *FakeV7Actor) CreateDeploymentReturnsOnCall(i int, result1 string, result2 v7action.Warnings, result3 error) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = nil + if fake.createDeploymentReturnsOnCall == nil { + fake.createDeploymentReturnsOnCall = make(map[int]struct { result1 string result2 v7action.Warnings result3 error }) } - fake.createDeploymentByApplicationAndDropletReturnsOnCall[i] = struct { + fake.createDeploymentReturnsOnCall[i] = struct { result1 string result2 v7action.Warnings result3 error @@ -779,15 +798,16 @@ func (fake *FakeV7Actor) CreateDockerPackageByApplication(arg1 string, arg2 v7ac arg1 string arg2 v7action.DockerImageCredentials }{arg1, arg2}) + stub := fake.CreateDockerPackageByApplicationStub + fakeReturns := fake.createDockerPackageByApplicationReturns fake.recordInvocation("CreateDockerPackageByApplication", []interface{}{arg1, arg2}) fake.createDockerPackageByApplicationMutex.Unlock() - if fake.CreateDockerPackageByApplicationStub != nil { - return fake.CreateDockerPackageByApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDockerPackageByApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -839,7 +859,7 @@ func (fake *FakeV7Actor) CreateDockerPackageByApplicationReturnsOnCall(i int, re }{result1, result2, result3} } -func (fake *FakeV7Actor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 string, arg5 int) (resources.Route, v7action.Warnings, error) { +func (fake *FakeV7Actor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 string, arg5 int, arg6 map[string]*string) (resources.Route, v7action.Warnings, error) { fake.createRouteMutex.Lock() ret, specificReturn := fake.createRouteReturnsOnCall[len(fake.createRouteArgsForCall)] fake.createRouteArgsForCall = append(fake.createRouteArgsForCall, struct { @@ -848,16 +868,18 @@ func (fake *FakeV7Actor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 arg3 string arg4 string arg5 int - }{arg1, arg2, arg3, arg4, arg5}) - fake.recordInvocation("CreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5}) + arg6 map[string]*string + }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.CreateRouteStub + fakeReturns := fake.createRouteReturns + fake.recordInvocation("CreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.createRouteMutex.Unlock() - if fake.CreateRouteStub != nil { - return fake.CreateRouteStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -867,17 +889,17 @@ func (fake *FakeV7Actor) CreateRouteCallCount() int { return len(fake.createRouteArgsForCall) } -func (fake *FakeV7Actor) CreateRouteCalls(stub func(string, string, string, string, int) (resources.Route, v7action.Warnings, error)) { +func (fake *FakeV7Actor) CreateRouteCalls(stub func(string, string, string, string, int, map[string]*string) (resources.Route, v7action.Warnings, error)) { fake.createRouteMutex.Lock() defer fake.createRouteMutex.Unlock() fake.CreateRouteStub = stub } -func (fake *FakeV7Actor) CreateRouteArgsForCall(i int) (string, string, string, string, int) { +func (fake *FakeV7Actor) CreateRouteArgsForCall(i int) (string, string, string, string, int, map[string]*string) { fake.createRouteMutex.RLock() defer fake.createRouteMutex.RUnlock() argsForCall := fake.createRouteArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 } func (fake *FakeV7Actor) CreateRouteReturns(result1 resources.Route, result2 v7action.Warnings, result3 error) { @@ -916,15 +938,16 @@ func (fake *FakeV7Actor) GetApplicationByNameAndSpace(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationByNameAndSpaceStub + fakeReturns := fake.getApplicationByNameAndSpaceReturns fake.recordInvocation("GetApplicationByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationByNameAndSpaceMutex.Unlock() - if fake.GetApplicationByNameAndSpaceStub != nil { - return fake.GetApplicationByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -983,15 +1006,16 @@ func (fake *FakeV7Actor) GetApplicationDroplets(arg1 string, arg2 string) ([]res arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationDropletsStub + fakeReturns := fake.getApplicationDropletsReturns fake.recordInvocation("GetApplicationDroplets", []interface{}{arg1, arg2}) fake.getApplicationDropletsMutex.Unlock() - if fake.GetApplicationDropletsStub != nil { - return fake.GetApplicationDropletsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationDropletsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1049,15 +1073,16 @@ func (fake *FakeV7Actor) GetApplicationRoutes(arg1 string) ([]resources.Route, v fake.getApplicationRoutesArgsForCall = append(fake.getApplicationRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationRoutesStub + fakeReturns := fake.getApplicationRoutesReturns fake.recordInvocation("GetApplicationRoutes", []interface{}{arg1}) fake.getApplicationRoutesMutex.Unlock() - if fake.GetApplicationRoutesStub != nil { - return fake.GetApplicationRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRoutesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1121,15 +1146,16 @@ func (fake *FakeV7Actor) GetApplicationsByNamesAndSpace(arg1 []string, arg2 stri arg1 []string arg2 string }{arg1Copy, arg2}) + stub := fake.GetApplicationsByNamesAndSpaceStub + fakeReturns := fake.getApplicationsByNamesAndSpaceReturns fake.recordInvocation("GetApplicationsByNamesAndSpace", []interface{}{arg1Copy, arg2}) fake.getApplicationsByNamesAndSpaceMutex.Unlock() - if fake.GetApplicationsByNamesAndSpaceStub != nil { - return fake.GetApplicationsByNamesAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationsByNamesAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1187,15 +1213,16 @@ func (fake *FakeV7Actor) GetDefaultDomain(arg1 string) (resources.Domain, v7acti fake.getDefaultDomainArgsForCall = append(fake.getDefaultDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDefaultDomainStub + fakeReturns := fake.getDefaultDomainReturns fake.recordInvocation("GetDefaultDomain", []interface{}{arg1}) fake.getDefaultDomainMutex.Unlock() - if fake.GetDefaultDomainStub != nil { - return fake.GetDefaultDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDefaultDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1253,15 +1280,16 @@ func (fake *FakeV7Actor) GetDomain(arg1 string) (resources.Domain, v7action.Warn fake.getDomainArgsForCall = append(fake.getDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDomainStub + fakeReturns := fake.getDomainReturns fake.recordInvocation("GetDomain", []interface{}{arg1}) fake.getDomainMutex.Unlock() - if fake.GetDomainStub != nil { - return fake.GetDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1322,15 +1350,16 @@ func (fake *FakeV7Actor) GetRouteByAttributes(arg1 resources.Domain, arg2 string arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.GetRouteByAttributesStub + fakeReturns := fake.getRouteByAttributesReturns fake.recordInvocation("GetRouteByAttributes", []interface{}{arg1, arg2, arg3, arg4}) fake.getRouteByAttributesMutex.Unlock() - if fake.GetRouteByAttributesStub != nil { - return fake.GetRouteByAttributesStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRouteByAttributesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1389,15 +1418,16 @@ func (fake *FakeV7Actor) GetRouteDestinationByAppGUID(arg1 resources.Route, arg2 arg1 resources.Route arg2 string }{arg1, arg2}) + stub := fake.GetRouteDestinationByAppGUIDStub + fakeReturns := fake.getRouteDestinationByAppGUIDReturns fake.recordInvocation("GetRouteDestinationByAppGUID", []interface{}{arg1, arg2}) fake.getRouteDestinationByAppGUIDMutex.Unlock() - if fake.GetRouteDestinationByAppGUIDStub != nil { - return fake.GetRouteDestinationByAppGUIDStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getRouteDestinationByAppGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1454,15 +1484,16 @@ func (fake *FakeV7Actor) MapRoute(arg1 string, arg2 string, arg3 string) (v7acti arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.MapRouteStub + fakeReturns := fake.mapRouteReturns fake.recordInvocation("MapRoute", []interface{}{arg1, arg2, arg3}) fake.mapRouteMutex.Unlock() - if fake.MapRouteStub != nil { - return fake.MapRouteStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.mapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1518,15 +1549,16 @@ func (fake *FakeV7Actor) PollBuild(arg1 string, arg2 string) (resources.Droplet, arg1 string arg2 string }{arg1, arg2}) + stub := fake.PollBuildStub + fakeReturns := fake.pollBuildReturns fake.recordInvocation("PollBuild", []interface{}{arg1, arg2}) fake.pollBuildMutex.Unlock() - if fake.PollBuildStub != nil { - return fake.PollBuildStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.pollBuildReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1584,15 +1616,16 @@ func (fake *FakeV7Actor) PollPackage(arg1 resources.Package) (resources.Package, fake.pollPackageArgsForCall = append(fake.pollPackageArgsForCall, struct { arg1 resources.Package }{arg1}) + stub := fake.PollPackageStub + fakeReturns := fake.pollPackageReturns fake.recordInvocation("PollPackage", []interface{}{arg1}) fake.pollPackageMutex.Unlock() - if fake.PollPackageStub != nil { - return fake.PollPackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.pollPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1652,15 +1685,16 @@ func (fake *FakeV7Actor) PollStart(arg1 resources.Application, arg2 bool, arg3 f arg2 bool arg3 func(string) }{arg1, arg2, arg3}) + stub := fake.PollStartStub + fakeReturns := fake.pollStartReturns fake.recordInvocation("PollStart", []interface{}{arg1, arg2, arg3}) fake.pollStartMutex.Unlock() - if fake.PollStartStub != nil { - return fake.PollStartStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollStartReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1709,67 +1743,68 @@ func (fake *FakeV7Actor) PollStartReturnsOnCall(i int, result1 v7action.Warnings }{result1, result2} } -func (fake *FakeV7Actor) PollStartForRolling(arg1 resources.Application, arg2 string, arg3 bool, arg4 func(string)) (v7action.Warnings, error) { - fake.pollStartForRollingMutex.Lock() - ret, specificReturn := fake.pollStartForRollingReturnsOnCall[len(fake.pollStartForRollingArgsForCall)] - fake.pollStartForRollingArgsForCall = append(fake.pollStartForRollingArgsForCall, struct { +func (fake *FakeV7Actor) PollStartForDeployment(arg1 resources.Application, arg2 string, arg3 bool, arg4 func(string)) (v7action.Warnings, error) { + fake.pollStartForDeploymentMutex.Lock() + ret, specificReturn := fake.pollStartForDeploymentReturnsOnCall[len(fake.pollStartForDeploymentArgsForCall)] + fake.pollStartForDeploymentArgsForCall = append(fake.pollStartForDeploymentArgsForCall, struct { arg1 resources.Application arg2 string arg3 bool arg4 func(string) }{arg1, arg2, arg3, arg4}) - fake.recordInvocation("PollStartForRolling", []interface{}{arg1, arg2, arg3, arg4}) - fake.pollStartForRollingMutex.Unlock() - if fake.PollStartForRollingStub != nil { - return fake.PollStartForRollingStub(arg1, arg2, arg3, arg4) + stub := fake.PollStartForDeploymentStub + fakeReturns := fake.pollStartForDeploymentReturns + fake.recordInvocation("PollStartForDeployment", []interface{}{arg1, arg2, arg3, arg4}) + fake.pollStartForDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollStartForRollingReturns return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeV7Actor) PollStartForRollingCallCount() int { - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() - return len(fake.pollStartForRollingArgsForCall) +func (fake *FakeV7Actor) PollStartForDeploymentCallCount() int { + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() + return len(fake.pollStartForDeploymentArgsForCall) } -func (fake *FakeV7Actor) PollStartForRollingCalls(stub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error)) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = stub +func (fake *FakeV7Actor) PollStartForDeploymentCalls(stub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error)) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = stub } -func (fake *FakeV7Actor) PollStartForRollingArgsForCall(i int) (resources.Application, string, bool, func(string)) { - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() - argsForCall := fake.pollStartForRollingArgsForCall[i] +func (fake *FakeV7Actor) PollStartForDeploymentArgsForCall(i int) (resources.Application, string, bool, func(string)) { + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() + argsForCall := fake.pollStartForDeploymentArgsForCall[i] return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } -func (fake *FakeV7Actor) PollStartForRollingReturns(result1 v7action.Warnings, result2 error) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = nil - fake.pollStartForRollingReturns = struct { +func (fake *FakeV7Actor) PollStartForDeploymentReturns(result1 v7action.Warnings, result2 error) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = nil + fake.pollStartForDeploymentReturns = struct { result1 v7action.Warnings result2 error }{result1, result2} } -func (fake *FakeV7Actor) PollStartForRollingReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = nil - if fake.pollStartForRollingReturnsOnCall == nil { - fake.pollStartForRollingReturnsOnCall = make(map[int]struct { +func (fake *FakeV7Actor) PollStartForDeploymentReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = nil + if fake.pollStartForDeploymentReturnsOnCall == nil { + fake.pollStartForDeploymentReturnsOnCall = make(map[int]struct { result1 v7action.Warnings result2 error }) } - fake.pollStartForRollingReturnsOnCall[i] = struct { + fake.pollStartForDeploymentReturnsOnCall[i] = struct { result1 v7action.Warnings result2 error }{result1, result2} @@ -1786,15 +1821,16 @@ func (fake *FakeV7Actor) ResourceMatch(arg1 []sharedaction.V3Resource) ([]shared fake.resourceMatchArgsForCall = append(fake.resourceMatchArgsForCall, struct { arg1 []sharedaction.V3Resource }{arg1Copy}) + stub := fake.ResourceMatchStub + fakeReturns := fake.resourceMatchReturns fake.recordInvocation("ResourceMatch", []interface{}{arg1Copy}) fake.resourceMatchMutex.Unlock() - if fake.ResourceMatchStub != nil { - return fake.ResourceMatchStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.resourceMatchReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -1853,15 +1889,16 @@ func (fake *FakeV7Actor) RestartApplication(arg1 string, arg2 bool) (v7action.Wa arg1 string arg2 bool }{arg1, arg2}) + stub := fake.RestartApplicationStub + fakeReturns := fake.restartApplicationReturns fake.recordInvocation("RestartApplication", []interface{}{arg1, arg2}) fake.restartApplicationMutex.Unlock() - if fake.RestartApplicationStub != nil { - return fake.RestartApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.restartApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1917,15 +1954,16 @@ func (fake *FakeV7Actor) ScaleProcessByApplication(arg1 string, arg2 resources.P arg1 string arg2 resources.Process }{arg1, arg2}) + stub := fake.ScaleProcessByApplicationStub + fakeReturns := fake.scaleProcessByApplicationReturns fake.recordInvocation("ScaleProcessByApplication", []interface{}{arg1, arg2}) fake.scaleProcessByApplicationMutex.Unlock() - if fake.ScaleProcessByApplicationStub != nil { - return fake.ScaleProcessByApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.scaleProcessByApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1981,15 +2019,16 @@ func (fake *FakeV7Actor) SetApplicationDroplet(arg1 string, arg2 string) (v7acti arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetApplicationDropletStub + fakeReturns := fake.setApplicationDropletReturns fake.recordInvocation("SetApplicationDroplet", []interface{}{arg1, arg2}) fake.setApplicationDropletMutex.Unlock() - if fake.SetApplicationDropletStub != nil { - return fake.SetApplicationDropletStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setApplicationDropletReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2050,15 +2089,16 @@ func (fake *FakeV7Actor) SetApplicationManifest(arg1 string, arg2 []byte) (v7act arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.SetApplicationManifestStub + fakeReturns := fake.setApplicationManifestReturns fake.recordInvocation("SetApplicationManifest", []interface{}{arg1, arg2Copy}) fake.setApplicationManifestMutex.Unlock() - if fake.SetApplicationManifestStub != nil { - return fake.SetApplicationManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setApplicationManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2119,15 +2159,16 @@ func (fake *FakeV7Actor) SetSpaceManifest(arg1 string, arg2 []byte) (v7action.Wa arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.SetSpaceManifestStub + fakeReturns := fake.setSpaceManifestReturns fake.recordInvocation("SetSpaceManifest", []interface{}{arg1, arg2Copy}) fake.setSpaceManifestMutex.Unlock() - if fake.SetSpaceManifestStub != nil { - return fake.SetSpaceManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setSpaceManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2182,15 +2223,16 @@ func (fake *FakeV7Actor) StageApplicationPackage(arg1 string) (resources.Build, fake.stageApplicationPackageArgsForCall = append(fake.stageApplicationPackageArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StageApplicationPackageStub + fakeReturns := fake.stageApplicationPackageReturns fake.recordInvocation("StageApplicationPackage", []interface{}{arg1}) fake.stageApplicationPackageMutex.Unlock() - if fake.StageApplicationPackageStub != nil { - return fake.StageApplicationPackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.stageApplicationPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2248,15 +2290,16 @@ func (fake *FakeV7Actor) StopApplication(arg1 string) (v7action.Warnings, error) fake.stopApplicationArgsForCall = append(fake.stopApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StopApplicationStub + fakeReturns := fake.stopApplicationReturns fake.recordInvocation("StopApplication", []interface{}{arg1}) fake.stopApplicationMutex.Unlock() - if fake.StopApplicationStub != nil { - return fake.StopApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stopApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2312,15 +2355,16 @@ func (fake *FakeV7Actor) UnmapRoute(arg1 string, arg2 string) (v7action.Warnings arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnmapRouteStub + fakeReturns := fake.unmapRouteReturns fake.recordInvocation("UnmapRoute", []interface{}{arg1, arg2}) fake.unmapRouteMutex.Unlock() - if fake.UnmapRouteStub != nil { - return fake.UnmapRouteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unmapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2375,15 +2419,16 @@ func (fake *FakeV7Actor) UpdateApplication(arg1 resources.Application) (resource fake.updateApplicationArgsForCall = append(fake.updateApplicationArgsForCall, struct { arg1 resources.Application }{arg1}) + stub := fake.UpdateApplicationStub + fakeReturns := fake.updateApplicationReturns fake.recordInvocation("UpdateApplication", []interface{}{arg1}) fake.updateApplicationMutex.Unlock() - if fake.UpdateApplicationStub != nil { - return fake.UpdateApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2443,15 +2488,16 @@ func (fake *FakeV7Actor) UpdateProcessByTypeAndApplication(arg1 string, arg2 str arg2 string arg3 resources.Process }{arg1, arg2, arg3}) + stub := fake.UpdateProcessByTypeAndApplicationStub + fakeReturns := fake.updateProcessByTypeAndApplicationReturns fake.recordInvocation("UpdateProcessByTypeAndApplication", []interface{}{arg1, arg2, arg3}) fake.updateProcessByTypeAndApplicationMutex.Unlock() - if fake.UpdateProcessByTypeAndApplicationStub != nil { - return fake.UpdateProcessByTypeAndApplicationStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateProcessByTypeAndApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2500,6 +2546,74 @@ func (fake *FakeV7Actor) UpdateProcessByTypeAndApplicationReturnsOnCall(i int, r }{result1, result2} } +func (fake *FakeV7Actor) UpdateRoute(arg1 string, arg2 map[string]*string) (resources.Route, v7action.Warnings, error) { + fake.updateRouteMutex.Lock() + ret, specificReturn := fake.updateRouteReturnsOnCall[len(fake.updateRouteArgsForCall)] + fake.updateRouteArgsForCall = append(fake.updateRouteArgsForCall, struct { + arg1 string + arg2 map[string]*string + }{arg1, arg2}) + stub := fake.UpdateRouteStub + fakeReturns := fake.updateRouteReturns + fake.recordInvocation("UpdateRoute", []interface{}{arg1, arg2}) + fake.updateRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeV7Actor) UpdateRouteCallCount() int { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + return len(fake.updateRouteArgsForCall) +} + +func (fake *FakeV7Actor) UpdateRouteCalls(stub func(string, map[string]*string) (resources.Route, v7action.Warnings, error)) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = stub +} + +func (fake *FakeV7Actor) UpdateRouteArgsForCall(i int) (string, map[string]*string) { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + argsForCall := fake.updateRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeV7Actor) UpdateRouteReturns(result1 resources.Route, result2 v7action.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + fake.updateRouteReturns = struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeV7Actor) UpdateRouteReturnsOnCall(i int, result1 resources.Route, result2 v7action.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + if fake.updateRouteReturnsOnCall == nil { + fake.updateRouteReturnsOnCall = make(map[int]struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }) + } + fake.updateRouteReturnsOnCall[i] = struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeV7Actor) UploadBitsPackage(arg1 resources.Package, arg2 []sharedaction.V3Resource, arg3 io.Reader, arg4 int64) (resources.Package, v7action.Warnings, error) { var arg2Copy []sharedaction.V3Resource if arg2 != nil { @@ -2514,15 +2628,16 @@ func (fake *FakeV7Actor) UploadBitsPackage(arg1 resources.Package, arg2 []shared arg3 io.Reader arg4 int64 }{arg1, arg2Copy, arg3, arg4}) + stub := fake.UploadBitsPackageStub + fakeReturns := fake.uploadBitsPackageReturns fake.recordInvocation("UploadBitsPackage", []interface{}{arg1, arg2Copy, arg3, arg4}) fake.uploadBitsPackageMutex.Unlock() - if fake.UploadBitsPackageStub != nil { - return fake.UploadBitsPackageStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadBitsPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -2583,15 +2698,16 @@ func (fake *FakeV7Actor) UploadDroplet(arg1 string, arg2 string, arg3 io.Reader, arg3 io.Reader arg4 int64 }{arg1, arg2, arg3, arg4}) + stub := fake.UploadDropletStub + fakeReturns := fake.uploadDropletReturns fake.recordInvocation("UploadDroplet", []interface{}{arg1, arg2, arg3, arg4}) fake.uploadDropletMutex.Unlock() - if fake.UploadDropletStub != nil { - return fake.UploadDropletStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.uploadDropletReturns return fakeReturns.result1, fakeReturns.result2 } @@ -2649,8 +2765,8 @@ func (fake *FakeV7Actor) Invocations() map[string][][]interface{} { defer fake.createApplicationInSpaceMutex.RUnlock() fake.createBitsPackageByApplicationMutex.RLock() defer fake.createBitsPackageByApplicationMutex.RUnlock() - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() fake.createDockerPackageByApplicationMutex.RLock() defer fake.createDockerPackageByApplicationMutex.RUnlock() fake.createRouteMutex.RLock() @@ -2679,8 +2795,8 @@ func (fake *FakeV7Actor) Invocations() map[string][][]interface{} { defer fake.pollPackageMutex.RUnlock() fake.pollStartMutex.RLock() defer fake.pollStartMutex.RUnlock() - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() fake.resourceMatchMutex.RLock() defer fake.resourceMatchMutex.RUnlock() fake.restartApplicationMutex.RLock() @@ -2703,6 +2819,8 @@ func (fake *FakeV7Actor) Invocations() map[string][][]interface{} { defer fake.updateApplicationMutex.RUnlock() fake.updateProcessByTypeAndApplicationMutex.RLock() defer fake.updateProcessByTypeAndApplicationMutex.RUnlock() + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() fake.uploadBitsPackageMutex.RLock() defer fake.uploadBitsPackageMutex.RUnlock() fake.uploadDropletMutex.RLock() diff --git a/actor/versioncheck/minimum_version_check.go b/actor/versioncheck/minimum_version_check.go index 2d9e3eb1452..535d8acbd52 100644 --- a/actor/versioncheck/minimum_version_check.go +++ b/actor/versioncheck/minimum_version_check.go @@ -1,7 +1,7 @@ package versioncheck import ( - "github.com/blang/semver" + "github.com/blang/semver/v4" ) func IsMinimumAPIVersionMet(current string, minimum string) (bool, error) { diff --git a/actor/versioncheck/minimum_version_check_test.go b/actor/versioncheck/minimum_version_check_test.go index f2a3a8f0bc6..3f4743e3fc5 100644 --- a/actor/versioncheck/minimum_version_check_test.go +++ b/actor/versioncheck/minimum_version_check_test.go @@ -1,9 +1,9 @@ package versioncheck_test import ( - . "code.cloudfoundry.org/cli/actor/versioncheck" + . "code.cloudfoundry.org/cli/v8/actor/versioncheck" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/actor/versioncheck/versioncheck_suite_test.go b/actor/versioncheck/versioncheck_suite_test.go index 87e59420d36..d85639d4fff 100644 --- a/actor/versioncheck/versioncheck_suite_test.go +++ b/actor/versioncheck/versioncheck_suite_test.go @@ -3,7 +3,7 @@ package versioncheck_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cfnetworking/cfnetv1/cfnetv1_suite_test.go b/api/cfnetworking/cfnetv1/cfnetv1_suite_test.go new file mode 100644 index 00000000000..abc09445426 --- /dev/null +++ b/api/cfnetworking/cfnetv1/cfnetv1_suite_test.go @@ -0,0 +1,55 @@ +package cfnetv1_test + +import ( + "bytes" + "log" + "testing" + + . "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +func TestCFNetV1(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "CF Networking V1 Client Suite") +} + +var server *Server + +var _ = SynchronizedBeforeSuite(func() []byte { + return []byte{} +}, func(data []byte) { + server = NewTLSServer() + + // Suppresses ginkgo server logs + server.HTTPTestServer.Config.ErrorLog = log.New(&bytes.Buffer{}, "", 0) +}) + +var _ = SynchronizedAfterSuite(func() { + server.Close() +}, func() {}) + +var _ = BeforeEach(func() { + server.Reset() +}) + +func NewTestClient(passed ...Config) *Client { + var config Config + if len(passed) > 0 { + config = passed[0] + } else { + config = Config{} + } + config.AppName = "CF Networking V1 Test" + config.AppVersion = "Unknown" + config.SkipSSLValidation = true + + if config.URL == "" { + config.URL = server.URL() + } + + return NewClient(config) +} diff --git a/api/cfnetworking/cfnetv1/cfnetv1fakes/fake_connection_wrapper.go b/api/cfnetworking/cfnetv1/cfnetv1fakes/fake_connection_wrapper.go new file mode 100644 index 00000000000..58444b2871f --- /dev/null +++ b/api/cfnetworking/cfnetv1/cfnetv1fakes/fake_connection_wrapper.go @@ -0,0 +1,188 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package cfnetv1fakes + +import ( + "sync" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" +) + +type FakeConnectionWrapper struct { + MakeStub func(*cfnetworking.Request, *cfnetworking.Response) error + makeMutex sync.RWMutex + makeArgsForCall []struct { + arg1 *cfnetworking.Request + arg2 *cfnetworking.Response + } + makeReturns struct { + result1 error + } + makeReturnsOnCall map[int]struct { + result1 error + } + WrapStub func(cfnetworking.Connection) cfnetworking.Connection + wrapMutex sync.RWMutex + wrapArgsForCall []struct { + arg1 cfnetworking.Connection + } + wrapReturns struct { + result1 cfnetworking.Connection + } + wrapReturnsOnCall map[int]struct { + result1 cfnetworking.Connection + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeConnectionWrapper) Make(arg1 *cfnetworking.Request, arg2 *cfnetworking.Response) error { + fake.makeMutex.Lock() + ret, specificReturn := fake.makeReturnsOnCall[len(fake.makeArgsForCall)] + fake.makeArgsForCall = append(fake.makeArgsForCall, struct { + arg1 *cfnetworking.Request + arg2 *cfnetworking.Response + }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns + fake.recordInvocation("Make", []interface{}{arg1, arg2}) + fake.makeMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeConnectionWrapper) MakeCallCount() int { + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + return len(fake.makeArgsForCall) +} + +func (fake *FakeConnectionWrapper) MakeCalls(stub func(*cfnetworking.Request, *cfnetworking.Response) error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = stub +} + +func (fake *FakeConnectionWrapper) MakeArgsForCall(i int) (*cfnetworking.Request, *cfnetworking.Response) { + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + argsForCall := fake.makeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeConnectionWrapper) MakeReturns(result1 error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = nil + fake.makeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnectionWrapper) MakeReturnsOnCall(i int, result1 error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = nil + if fake.makeReturnsOnCall == nil { + fake.makeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.makeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnectionWrapper) Wrap(arg1 cfnetworking.Connection) cfnetworking.Connection { + fake.wrapMutex.Lock() + ret, specificReturn := fake.wrapReturnsOnCall[len(fake.wrapArgsForCall)] + fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { + arg1 cfnetworking.Connection + }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns + fake.recordInvocation("Wrap", []interface{}{arg1}) + fake.wrapMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeConnectionWrapper) WrapCallCount() int { + fake.wrapMutex.RLock() + defer fake.wrapMutex.RUnlock() + return len(fake.wrapArgsForCall) +} + +func (fake *FakeConnectionWrapper) WrapCalls(stub func(cfnetworking.Connection) cfnetworking.Connection) { + fake.wrapMutex.Lock() + defer fake.wrapMutex.Unlock() + fake.WrapStub = stub +} + +func (fake *FakeConnectionWrapper) WrapArgsForCall(i int) cfnetworking.Connection { + fake.wrapMutex.RLock() + defer fake.wrapMutex.RUnlock() + argsForCall := fake.wrapArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeConnectionWrapper) WrapReturns(result1 cfnetworking.Connection) { + fake.wrapMutex.Lock() + defer fake.wrapMutex.Unlock() + fake.WrapStub = nil + fake.wrapReturns = struct { + result1 cfnetworking.Connection + }{result1} +} + +func (fake *FakeConnectionWrapper) WrapReturnsOnCall(i int, result1 cfnetworking.Connection) { + fake.wrapMutex.Lock() + defer fake.wrapMutex.Unlock() + fake.WrapStub = nil + if fake.wrapReturnsOnCall == nil { + fake.wrapReturnsOnCall = make(map[int]struct { + result1 cfnetworking.Connection + }) + } + fake.wrapReturnsOnCall[i] = struct { + result1 cfnetworking.Connection + }{result1} +} + +func (fake *FakeConnectionWrapper) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + fake.wrapMutex.RLock() + defer fake.wrapMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeConnectionWrapper) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ cfnetv1.ConnectionWrapper = new(FakeConnectionWrapper) diff --git a/api/cfnetworking/cfnetv1/cfvnetv1.go b/api/cfnetworking/cfnetv1/cfvnetv1.go new file mode 100644 index 00000000000..c80661d5e30 --- /dev/null +++ b/api/cfnetworking/cfnetv1/cfvnetv1.go @@ -0,0 +1,3 @@ +package cfnetv1 + +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/api/cfnetworking/cfnetv1/client.go b/api/cfnetworking/cfnetv1/client.go new file mode 100644 index 00000000000..b0862d96376 --- /dev/null +++ b/api/cfnetworking/cfnetv1/client.go @@ -0,0 +1,138 @@ +// Package cfnetv1 represents a CF Networking V1 client. +// +// These sets of packages are still under development/pre-pre-pre...alpha. Use +// at your own risk! Functionality and design may change without warning. +// +// For more information on the CF Networking API see +// https://github.com/cloudfoundry-incubator/cf-networking-release/blob/develop/docs/API.md +// +// # Method Naming Conventions +// +// The client takes a '' +// approach to method names. If the and +// are similar, they do not need to be repeated. If a GUID is required for the +// , the pluralization is removed from said endpoint in the +// method name. +// +// For Example: +// +// Method Name: GetApplication +// Endpoint: /v2/applications/:guid +// Action Name: Get +// Top Level Endpoint: applications +// Return Value: Application +// +// Method Name: GetServiceInstances +// Endpoint: /v2/service_instances +// Action Name: Get +// Top Level Endpoint: service_instances +// Return Value: []ServiceInstance +// +// Method Name: GetSpaceServiceInstances +// Endpoint: /v2/spaces/:guid/service_instances +// Action Name: Get +// Top Level Endpoint: spaces +// Return Value: []ServiceInstance +// +// Use the following table to determine which HTTP Command equates to which +// Action Name: +// +// HTTP Command -> Action Name +// POST -> Create +// GET -> Get +// PUT -> Update +// DELETE -> Delete +// +// # Method Locations +// +// Methods exist in the same file as their return type, regardless of which +// endpoint they use. +// +// # Error Handling +// +// All error handling that requires parsing the error_code/code returned back +// from the Cloud Controller should be placed in the errorWrapper. Everything +// else can be handled in the individual operations. All parsed cloud +// controller errors should exist in errors.go, all generic HTTP errors should +// exist in the cloudcontroller's errors.go. Errors related to the individaul +// operation should exist at the top of that operation's file. +// +// # No inline-relations-depth And summary Endpoints +// +// This package will not use ever use 'inline-relations-depth' or the +// '/summary' endpoints for any operations. These requests can be extremely +// taxing on the Cloud Controller and are avoided at all costs. Additionally, +// the objects returned back from these requests can become extremely +// inconsistant across versions and are problematic to deal with in general. +package cfnetv1 + +import ( + "fmt" + "runtime" + "time" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1/internal" + + "github.com/tedsuo/rata" +) + +// Client is a client that can be used to talk to a CF Networking API. +type Client struct { + connection cfnetworking.Connection + router *rata.RequestGenerator + url string + userAgent string +} + +// Config allows the Client to be configured +type Config struct { + // AppName is the name of the application/process using the client. + AppName string + + // AppVersion is the version of the application/process using the client. + AppVersion string + + // DialTimeout is the DNS timeout used to make all requests to the Cloud + // Controller. + DialTimeout time.Duration + + // SkipSSLValidation controls whether a client verifies the server's + // certificate chain and host name. If SkipSSLValidation is true, TLS accepts + // any certificate presented by the server and any host name in that + // certificate for *all* client requests going forward. + // + // In this mode, TLS is susceptible to man-in-the-middle attacks. This should + // be used only for testing. + SkipSSLValidation bool + + // URL is a fully qualified URL to the CF Networking API. + URL string + + // Wrappers that apply to the client connection. + Wrappers []ConnectionWrapper +} + +// NewClient returns a new CF Networking client. +func NewClient(config Config) *Client { + userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS) + + connection := cfnetworking.NewConnection(cfnetworking.Config{ + DialTimeout: config.DialTimeout, + SkipSSLValidation: config.SkipSSLValidation, + }) + + wrappedConnection := cfnetworking.NewErrorWrapper().Wrap(connection) + for _, wrapper := range config.Wrappers { + wrappedConnection = wrapper.Wrap(wrappedConnection) + } + + client := &Client{ + connection: wrappedConnection, + router: rata.NewRequestGenerator(config.URL, internal.Routes), + url: config.URL, + userAgent: userAgent, + } + + return client +} diff --git a/api/cfnetworking/cfnetv1/connection_wrapper.go b/api/cfnetworking/cfnetv1/connection_wrapper.go new file mode 100644 index 00000000000..52cd4269430 --- /dev/null +++ b/api/cfnetworking/cfnetv1/connection_wrapper.go @@ -0,0 +1,17 @@ +package cfnetv1 + +import "code.cloudfoundry.org/cli/v8/api/cfnetworking" + +// ConnectionWrapper can wrap a given connection allowing the wrapper to modify +// all requests going in and out of the given connection. +// +//counterfeiter:generate . ConnectionWrapper +type ConnectionWrapper interface { + cfnetworking.Connection + Wrap(innerconnection cfnetworking.Connection) cfnetworking.Connection +} + +// WrapConnection wraps the current Client connection in the wrapper. +func (client *Client) WrapConnection(wrapper ConnectionWrapper) { + client.connection = wrapper.Wrap(client.connection) +} diff --git a/api/cfnetworking/cfnetv1/internal/routes.go b/api/cfnetworking/cfnetv1/internal/routes.go new file mode 100644 index 00000000000..69cf937ca4f --- /dev/null +++ b/api/cfnetworking/cfnetv1/internal/routes.go @@ -0,0 +1,21 @@ +package internal + +import ( + "net/http" + + "github.com/tedsuo/rata" +) + +const ( + CreatePolicies = "PostPolicies" + DeletePolicies = "DeletePolicies" + ListPolicies = "ListPolicies" +) + +// Routes is a list of routes used by the rata library to construct request +// URLs. +var Routes = rata.Routes{ + {Path: "/policies", Method: http.MethodPost, Name: CreatePolicies}, + {Path: "/policies/delete", Method: http.MethodPost, Name: DeletePolicies}, + {Path: "/policies", Method: http.MethodGet, Name: ListPolicies}, +} diff --git a/api/cfnetworking/cfnetv1/policy.go b/api/cfnetworking/cfnetv1/policy.go new file mode 100644 index 00000000000..68589888ea2 --- /dev/null +++ b/api/cfnetworking/cfnetv1/policy.go @@ -0,0 +1,104 @@ +package cfnetv1 + +import ( + "bytes" + "encoding/json" + "strings" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1/internal" +) + +type PolicyProtocol string + +const ( + PolicyProtocolTCP PolicyProtocol = "tcp" + PolicyProtocolUDP PolicyProtocol = "udp" +) + +type PolicyList struct { + TotalPolicies int `json:"total_policies,omitempty"` + Policies []Policy `json:"policies"` +} + +type Policy struct { + Source PolicySource `json:"source"` + Destination PolicyDestination `json:"destination"` +} + +type PolicySource struct { + ID string `json:"id"` +} + +type PolicyDestination struct { + ID string `json:"id"` + Protocol PolicyProtocol `json:"protocol"` + Ports Ports `json:"ports"` +} + +// CreatePolicies will create the network policy with the given parameters. +func (client *Client) CreatePolicies(policies []Policy) error { + rawJSON, err := json.Marshal(PolicyList{Policies: policies}) + if err != nil { + return err + } + + request, err := client.newHTTPRequest(requestOptions{ + RequestName: internal.CreatePolicies, + Body: bytes.NewReader(rawJSON), + }) + if err != nil { + return err + } + + return client.connection.Make(request, &cfnetworking.Response{}) +} + +// ListPolicies will list the policies with the app guids in either the source or destination. +func (client *Client) ListPolicies(appGUIDs ...string) ([]Policy, error) { + var request *cfnetworking.Request + var err error + if len(appGUIDs) == 0 { + request, err = client.newHTTPRequest(requestOptions{ + RequestName: internal.ListPolicies, + }) + } else { + request, err = client.newHTTPRequest(requestOptions{ + RequestName: internal.ListPolicies, + Query: map[string][]string{ + "id": {strings.Join(appGUIDs, ",")}, + }, + }) + } + if err != nil { + return []Policy{}, err + } + + policies := PolicyList{} + response := &cfnetworking.Response{} + + err = client.connection.Make(request, response) + if err != nil { + return []Policy{}, err + } + + err = json.Unmarshal(response.RawResponse, &policies) + if err != nil { + return []Policy{}, err + } + + return policies.Policies, nil +} + +// RemovePolicies will remove the network policy with the given parameters. +func (client *Client) RemovePolicies(policies []Policy) error { + rawJSON, err := json.Marshal(PolicyList{Policies: policies}) + if err != nil { + return err + } + request, err := client.newHTTPRequest(requestOptions{ + RequestName: internal.DeletePolicies, + Body: bytes.NewReader(rawJSON), + }) + return client.connection.Make(request, &cfnetworking.Response{}) +} diff --git a/api/cfnetworking/cfnetv1/policy_test.go b/api/cfnetworking/cfnetv1/policy_test.go new file mode 100644 index 00000000000..ac8320a094c --- /dev/null +++ b/api/cfnetworking/cfnetv1/policy_test.go @@ -0,0 +1,339 @@ +package cfnetv1_test + +import ( + "net/http" + + . "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +var _ = Describe("Policy", func() { + var client *Client + BeforeEach(func() { + client = NewTestClient() + }) + + Describe("CreatePolicies", func() { + Context("when the stack is found", func() { + BeforeEach(func() { + expectedBody := `{ + "policies": [ + { + "source": { + "id": "source-id-1" + }, + "destination": { + "id": "destination-id-1", + "protocol": "tcp", + "ports": { + "start": 1234, + "end": 1235 + } + } + }, + { + "source": { + "id": "source-id-2" + }, + "destination": { + "id": "destination-id-2", + "protocol": "udp", + "ports": { + "start": 1234, + "end": 1235 + } + } + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPost, "/policies"), + VerifyJSON(expectedBody), + RespondWith(http.StatusOK, ""), + ), + ) + }) + + It("passes the body correctly", func() { + err := client.CreatePolicies([]Policy{ + { + Source: PolicySource{ + ID: "source-id-1", + }, + Destination: PolicyDestination{ + ID: "destination-id-1", + Protocol: PolicyProtocolTCP, + Ports: Ports{ + Start: 1234, + End: 1235, + }, + }, + }, + { + Source: PolicySource{ + ID: "source-id-2", + }, + Destination: PolicyDestination{ + ID: "destination-id-2", + Protocol: PolicyProtocolUDP, + Ports: Ports{ + Start: 1234, + End: 1235, + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + }) + + Context("when the client returns an error", func() { + BeforeEach(func() { + response := `{ + "error": "Oh Noes" + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPost, "/policies"), + RespondWith(http.StatusBadRequest, response), + ), + ) + }) + + It("returns the error and warnings", func() { + err := client.CreatePolicies(nil) + Expect(err).To(MatchError(networkerror.BadRequestError{ + Message: "Oh Noes", + })) + }) + }) + }) + + Describe("ListPolicies", func() { + var expectedPolicies []Policy + Context("when the policies are found", func() { + BeforeEach(func() { + response := `{ + "policies": [ + { + "source": { + "id": "source-id-1" + }, + "destination": { + "id": "destination-id-1", + "protocol": "tcp", + "ports": { + "start": 1234, + "end": 1235 + } + } + }, + { + "source": { + "id": "source-id-2" + }, + "destination": { + "id": "destination-id-2", + "protocol": "tcp", + "ports": { + "start": 4321, + "end": 5321 + } + } + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/policies"), + RespondWith(http.StatusOK, response), + ), + ) + expectedPolicies = []Policy{ + { + Source: PolicySource{ + ID: "source-id-1", + }, + Destination: PolicyDestination{ + ID: "destination-id-1", + Protocol: "tcp", + Ports: Ports{ + Start: 1234, + End: 1235, + }, + }, + }, + { + Source: PolicySource{ + ID: "source-id-2", + }, + Destination: PolicyDestination{ + ID: "destination-id-2", + Protocol: "tcp", + Ports: Ports{ + Start: 4321, + End: 5321, + }, + }, + }, + } + }) + + It("returns the policies correctly", func() { + policies, err := client.ListPolicies() + Expect(policies).To(Equal(expectedPolicies)) + Expect(err).ToNot(HaveOccurred()) + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + + Context("when an app guid is passed", func() { + It("makes the query correctly", func() { + policies, err := client.ListPolicies("source-id-1") + Expect(policies).To(Equal(expectedPolicies)) + Expect(err).ToNot(HaveOccurred()) + + requests := server.ReceivedRequests() + Expect(requests).To(HaveLen(1)) + Expect(requests[0].RequestURI).To(Equal("/policies?id=source-id-1")) + }) + }) + + Context("when multiple app guid are passed", func() { + It("makes the query correctly", func() { + policies, err := client.ListPolicies("source-id-1", "source-id-2") + Expect(policies).To(Equal(expectedPolicies)) + Expect(err).ToNot(HaveOccurred()) + + requests := server.ReceivedRequests() + Expect(requests).To(HaveLen(1)) + Expect(requests[0].RequestURI).To(Equal("/policies?id=source-id-1%2Csource-id-2")) + }) + }) + + }) + + Context("when the client returns an error", func() { + BeforeEach(func() { + response := `{ + "error": "Oh Noes" + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/policies"), + RespondWith(http.StatusBadRequest, response), + ), + ) + }) + + It("returns the error", func() { + _, err := client.ListPolicies() + Expect(err).To(MatchError(networkerror.BadRequestError{ + Message: "Oh Noes", + })) + }) + }) + }) + + Describe("RemovePolicies", func() { + Context("when the policy is found", func() { + BeforeEach(func() { + expectedBody := `{ + "policies": [ + { + "source": { + "id": "source-id-1" + }, + "destination": { + "id": "destination-id-1", + "protocol": "tcp", + "ports": { + "start": 1234, + "end": 1235 + } + } + }, + { + "source": { + "id": "source-id-2" + }, + "destination": { + "id": "destination-id-2", + "protocol": "udp", + "ports": { + "start": 1234, + "end": 1235 + } + } + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPost, "/policies/delete"), + VerifyJSON(expectedBody), + RespondWith(http.StatusOK, ""), + ), + ) + }) + + It("passes the body correctly", func() { + err := client.RemovePolicies([]Policy{ + { + Source: PolicySource{ + ID: "source-id-1", + }, + Destination: PolicyDestination{ + ID: "destination-id-1", + Protocol: PolicyProtocolTCP, + Ports: Ports{ + Start: 1234, + End: 1235, + }, + }, + }, + { + Source: PolicySource{ + ID: "source-id-2", + }, + Destination: PolicyDestination{ + ID: "destination-id-2", + Protocol: PolicyProtocolUDP, + Ports: Ports{ + Start: 1234, + End: 1235, + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + }) + + Context("when the client returns an error", func() { + BeforeEach(func() { + response := `{ + "error": "Oh Noes" + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPost, "/policies/delete"), + RespondWith(http.StatusBadRequest, response), + ), + ) + }) + + It("returns the error", func() { + err := client.RemovePolicies(nil) + Expect(err).To(MatchError(networkerror.BadRequestError{ + Message: "Oh Noes", + })) + }) + }) + }) +}) diff --git a/api/cfnetworking/cfnetv1/ports.go b/api/cfnetworking/cfnetv1/ports.go new file mode 100644 index 00000000000..d684f64418b --- /dev/null +++ b/api/cfnetworking/cfnetv1/ports.go @@ -0,0 +1,6 @@ +package cfnetv1 + +type Ports struct { + Start int `json:"start"` + End int `json:"end"` +} diff --git a/api/cfnetworking/cfnetv1/request.go b/api/cfnetworking/cfnetv1/request.go new file mode 100644 index 00000000000..122b8ef5c20 --- /dev/null +++ b/api/cfnetworking/cfnetv1/request.go @@ -0,0 +1,70 @@ +package cfnetv1 + +import ( + "fmt" + "io" + "net/http" + "net/url" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" +) + +// Params represents URI parameters for a request. +type Params map[string]string + +// requestOptions contains all the options to create an HTTP request. +type requestOptions struct { + // URIParams are the list URI route parameters + URIParams Params + + // Query is a list of HTTP query parameters + Query url.Values + + // RequestName is the name of the request (see routes) + RequestName string + + // URI is the URI of the request. + URI string + // Method is the HTTP method of the request. + Method string + + // Body is the request body + Body io.ReadSeeker +} + +// newHTTPRequest returns a constructed HTTP.Request with some defaults. +// Defaults are applied when Request fields are not filled in. +func (client Client) newHTTPRequest(passedRequest requestOptions) (*cfnetworking.Request, error) { + var request *http.Request + var err error + if passedRequest.URI != "" { + request, err = http.NewRequest( + passedRequest.Method, + fmt.Sprintf("%s%s", client.url, passedRequest.URI), + passedRequest.Body, + ) + } else { + request, err = client.router.CreateRequest( + passedRequest.RequestName, + map[string]string(passedRequest.URIParams), + passedRequest.Body, + ) + if err == nil { + request.URL.RawQuery = passedRequest.Query.Encode() + } + } + if err != nil { + return nil, err + } + + request.Header = http.Header{} + request.Header.Set("Accept", "application/json") + request.Header.Set("User-Agent", client.userAgent) + + if passedRequest.Body != nil { + request.Header.Set("Content-Type", "application/json") + } + + // Make sure the body is the same as the one in the request + return cfnetworking.NewRequest(request, passedRequest.Body), nil +} diff --git a/api/cfnetworking/cfnetworking.go b/api/cfnetworking/cfnetworking.go new file mode 100644 index 00000000000..93b0cacabd5 --- /dev/null +++ b/api/cfnetworking/cfnetworking.go @@ -0,0 +1,6 @@ +// CF networking API. Copied from code.cloudfoundry.org/cfnetworking-cli-api +// to reduce recursive dependencies and allow proper go module management. + +package cfnetworking + +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/api/cfnetworking/cfnetworking_suite_test.go b/api/cfnetworking/cfnetworking_suite_test.go new file mode 100644 index 00000000000..b434160e526 --- /dev/null +++ b/api/cfnetworking/cfnetworking_suite_test.go @@ -0,0 +1,35 @@ +package cfnetworking_test + +import ( + "bytes" + "log" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +func TestUaa(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "CF Networking Suite") +} + +var server *Server + +var _ = SynchronizedBeforeSuite(func() []byte { + return []byte{} +}, func(data []byte) { + server = NewTLSServer() + + // Suppresses ginkgo server logs + server.HTTPTestServer.Config.ErrorLog = log.New(&bytes.Buffer{}, "", 0) +}) + +var _ = SynchronizedAfterSuite(func() { + server.Close() +}, func() {}) + +var _ = BeforeEach(func() { + server.Reset() +}) diff --git a/api/cfnetworking/cfnetworkingfakes/fake_connection.go b/api/cfnetworking/cfnetworkingfakes/fake_connection.go new file mode 100644 index 00000000000..76952cd561b --- /dev/null +++ b/api/cfnetworking/cfnetworkingfakes/fake_connection.go @@ -0,0 +1,113 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package cfnetworkingfakes + +import ( + "sync" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" +) + +type FakeConnection struct { + MakeStub func(*cfnetworking.Request, *cfnetworking.Response) error + makeMutex sync.RWMutex + makeArgsForCall []struct { + arg1 *cfnetworking.Request + arg2 *cfnetworking.Response + } + makeReturns struct { + result1 error + } + makeReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeConnection) Make(arg1 *cfnetworking.Request, arg2 *cfnetworking.Response) error { + fake.makeMutex.Lock() + ret, specificReturn := fake.makeReturnsOnCall[len(fake.makeArgsForCall)] + fake.makeArgsForCall = append(fake.makeArgsForCall, struct { + arg1 *cfnetworking.Request + arg2 *cfnetworking.Response + }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns + fake.recordInvocation("Make", []interface{}{arg1, arg2}) + fake.makeMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeConnection) MakeCallCount() int { + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + return len(fake.makeArgsForCall) +} + +func (fake *FakeConnection) MakeCalls(stub func(*cfnetworking.Request, *cfnetworking.Response) error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = stub +} + +func (fake *FakeConnection) MakeArgsForCall(i int) (*cfnetworking.Request, *cfnetworking.Response) { + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + argsForCall := fake.makeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeConnection) MakeReturns(result1 error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = nil + fake.makeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnection) MakeReturnsOnCall(i int, result1 error) { + fake.makeMutex.Lock() + defer fake.makeMutex.Unlock() + fake.MakeStub = nil + if fake.makeReturnsOnCall == nil { + fake.makeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.makeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnection) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.makeMutex.RLock() + defer fake.makeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeConnection) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ cfnetworking.Connection = new(FakeConnection) diff --git a/api/cfnetworking/cfnetworkingfakes/fake_read_seeker.go b/api/cfnetworking/cfnetworkingfakes/fake_read_seeker.go new file mode 100644 index 00000000000..ef98c43a164 --- /dev/null +++ b/api/cfnetworking/cfnetworkingfakes/fake_read_seeker.go @@ -0,0 +1,202 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package cfnetworkingfakes + +import ( + "sync" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" +) + +type FakeReadSeeker struct { + ReadStub func([]byte) (int, error) + readMutex sync.RWMutex + readArgsForCall []struct { + arg1 []byte + } + readReturns struct { + result1 int + result2 error + } + readReturnsOnCall map[int]struct { + result1 int + result2 error + } + SeekStub func(int64, int) (int64, error) + seekMutex sync.RWMutex + seekArgsForCall []struct { + arg1 int64 + arg2 int + } + seekReturns struct { + result1 int64 + result2 error + } + seekReturnsOnCall map[int]struct { + result1 int64 + result2 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeReadSeeker) Read(arg1 []byte) (int, error) { + var arg1Copy []byte + if arg1 != nil { + arg1Copy = make([]byte, len(arg1)) + copy(arg1Copy, arg1) + } + fake.readMutex.Lock() + ret, specificReturn := fake.readReturnsOnCall[len(fake.readArgsForCall)] + fake.readArgsForCall = append(fake.readArgsForCall, struct { + arg1 []byte + }{arg1Copy}) + stub := fake.ReadStub + fakeReturns := fake.readReturns + fake.recordInvocation("Read", []interface{}{arg1Copy}) + fake.readMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeReadSeeker) ReadCallCount() int { + fake.readMutex.RLock() + defer fake.readMutex.RUnlock() + return len(fake.readArgsForCall) +} + +func (fake *FakeReadSeeker) ReadCalls(stub func([]byte) (int, error)) { + fake.readMutex.Lock() + defer fake.readMutex.Unlock() + fake.ReadStub = stub +} + +func (fake *FakeReadSeeker) ReadArgsForCall(i int) []byte { + fake.readMutex.RLock() + defer fake.readMutex.RUnlock() + argsForCall := fake.readArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeReadSeeker) ReadReturns(result1 int, result2 error) { + fake.readMutex.Lock() + defer fake.readMutex.Unlock() + fake.ReadStub = nil + fake.readReturns = struct { + result1 int + result2 error + }{result1, result2} +} + +func (fake *FakeReadSeeker) ReadReturnsOnCall(i int, result1 int, result2 error) { + fake.readMutex.Lock() + defer fake.readMutex.Unlock() + fake.ReadStub = nil + if fake.readReturnsOnCall == nil { + fake.readReturnsOnCall = make(map[int]struct { + result1 int + result2 error + }) + } + fake.readReturnsOnCall[i] = struct { + result1 int + result2 error + }{result1, result2} +} + +func (fake *FakeReadSeeker) Seek(arg1 int64, arg2 int) (int64, error) { + fake.seekMutex.Lock() + ret, specificReturn := fake.seekReturnsOnCall[len(fake.seekArgsForCall)] + fake.seekArgsForCall = append(fake.seekArgsForCall, struct { + arg1 int64 + arg2 int + }{arg1, arg2}) + stub := fake.SeekStub + fakeReturns := fake.seekReturns + fake.recordInvocation("Seek", []interface{}{arg1, arg2}) + fake.seekMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeReadSeeker) SeekCallCount() int { + fake.seekMutex.RLock() + defer fake.seekMutex.RUnlock() + return len(fake.seekArgsForCall) +} + +func (fake *FakeReadSeeker) SeekCalls(stub func(int64, int) (int64, error)) { + fake.seekMutex.Lock() + defer fake.seekMutex.Unlock() + fake.SeekStub = stub +} + +func (fake *FakeReadSeeker) SeekArgsForCall(i int) (int64, int) { + fake.seekMutex.RLock() + defer fake.seekMutex.RUnlock() + argsForCall := fake.seekArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeReadSeeker) SeekReturns(result1 int64, result2 error) { + fake.seekMutex.Lock() + defer fake.seekMutex.Unlock() + fake.SeekStub = nil + fake.seekReturns = struct { + result1 int64 + result2 error + }{result1, result2} +} + +func (fake *FakeReadSeeker) SeekReturnsOnCall(i int, result1 int64, result2 error) { + fake.seekMutex.Lock() + defer fake.seekMutex.Unlock() + fake.SeekStub = nil + if fake.seekReturnsOnCall == nil { + fake.seekReturnsOnCall = make(map[int]struct { + result1 int64 + result2 error + }) + } + fake.seekReturnsOnCall[i] = struct { + result1 int64 + result2 error + }{result1, result2} +} + +func (fake *FakeReadSeeker) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.readMutex.RLock() + defer fake.readMutex.RUnlock() + fake.seekMutex.RLock() + defer fake.seekMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeReadSeeker) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ cfnetworking.ReadSeeker = new(FakeReadSeeker) diff --git a/api/cfnetworking/connection.go b/api/cfnetworking/connection.go new file mode 100644 index 00000000000..96958130dcf --- /dev/null +++ b/api/cfnetworking/connection.go @@ -0,0 +1,8 @@ +package cfnetworking + +// Connection creates and executes http requests +// +//counterfeiter:generate . Connection +type Connection interface { + Make(request *Request, passedResponse *Response) error +} diff --git a/api/cfnetworking/errors.go b/api/cfnetworking/errors.go new file mode 100644 index 00000000000..2be1e1a0864 --- /dev/null +++ b/api/cfnetworking/errors.go @@ -0,0 +1,64 @@ +package cfnetworking + +import ( + "encoding/json" + "net/http" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" +) + +// errorWrapper is the wrapper that converts responses with 4xx and 5xx status +// codes to an error. +type errorWrapper struct { + connection Connection +} + +func NewErrorWrapper() *errorWrapper { + return new(errorWrapper) +} + +// Wrap wraps a Cloud Controller connection in this error handling wrapper. +func (e *errorWrapper) Wrap(innerconnection Connection) Connection { + e.connection = innerconnection + return e +} + +// Make converts RawHTTPStatusError, which represents responses with 4xx and +// 5xx status codes, to specific errors. +func (e *errorWrapper) Make(request *Request, passedResponse *Response) error { + err := e.connection.Make(request, passedResponse) + + if rawHTTPStatusErr, ok := err.(networkerror.RawHTTPStatusError); ok { + return convert(rawHTTPStatusErr) + } + return err +} + +func convert(rawHTTPStatusErr networkerror.RawHTTPStatusError) error { + // Try to unmarshal the raw error into a CC error. If unmarshaling fails, + // return the raw error. + var errorResponse networkerror.ErrorResponse + err := json.Unmarshal(rawHTTPStatusErr.RawResponse, &errorResponse) + if err != nil { + return rawHTTPStatusErr + } + + switch rawHTTPStatusErr.StatusCode { + case http.StatusBadRequest: // 400 + return networkerror.BadRequestError(errorResponse) + case http.StatusUnauthorized: // 401 + return networkerror.UnauthorizedError(errorResponse) + case http.StatusForbidden: // 403 + return networkerror.ForbiddenError(errorResponse) + case http.StatusNotAcceptable: // 406 + return networkerror.NotAcceptableError(errorResponse) + case http.StatusConflict: // 409 + return networkerror.ConflictError(errorResponse) + default: + return networkerror.UnexpectedResponseError{ + ErrorResponse: errorResponse, + RequestIDs: rawHTTPStatusErr.RequestIDs, + ResponseCode: rawHTTPStatusErr.StatusCode, + } + } +} diff --git a/api/cfnetworking/errors_test.go b/api/cfnetworking/errors_test.go new file mode 100644 index 00000000000..65e9d86f5a6 --- /dev/null +++ b/api/cfnetworking/errors_test.go @@ -0,0 +1,36 @@ +package cfnetworking_test + +import ( + "fmt" + "net/http" + + . "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetworkingfakes" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Error Wrapper", func() { + const errorMessage = "I am an error" + + DescribeTable("Make", + func(statusCode int, expectedError error) { + fakeConnection := new(cfnetworkingfakes.FakeConnection) + fakeConnection.MakeReturns(networkerror.RawHTTPStatusError{ + StatusCode: statusCode, + RawResponse: []byte(fmt.Sprintf(`{"error":"%s"}`, errorMessage)), + }) + + errorWrapper := NewErrorWrapper().Wrap(fakeConnection) + err := errorWrapper.Make(nil, nil) + Expect(err).To(MatchError(expectedError)) + }, + Entry("400 -> BadRequestError", http.StatusBadRequest, networkerror.BadRequestError{Message: errorMessage}), + Entry("401 -> UnauthorizedError", http.StatusUnauthorized, networkerror.UnauthorizedError{Message: errorMessage}), + Entry("403 -> ForbiddenError", http.StatusForbidden, networkerror.ForbiddenError{Message: errorMessage}), + Entry("406 -> NotAcceptable", http.StatusNotAcceptable, networkerror.NotAcceptableError{Message: errorMessage}), + Entry("409 -> ConflictError", http.StatusConflict, networkerror.ConflictError{Message: errorMessage}), + ) +}) diff --git a/api/cfnetworking/networkerror/bad_request_error.go b/api/cfnetworking/networkerror/bad_request_error.go new file mode 100644 index 00000000000..16db7bd925c --- /dev/null +++ b/api/cfnetworking/networkerror/bad_request_error.go @@ -0,0 +1,9 @@ +package networkerror + +type BadRequestError struct { + Message string `json:"error"` +} + +func (e BadRequestError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/conflict_error.go b/api/cfnetworking/networkerror/conflict_error.go new file mode 100644 index 00000000000..807ac313642 --- /dev/null +++ b/api/cfnetworking/networkerror/conflict_error.go @@ -0,0 +1,9 @@ +package networkerror + +type ConflictError struct { + Message string `json:"error"` +} + +func (e ConflictError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/error_response.go b/api/cfnetworking/networkerror/error_response.go new file mode 100644 index 00000000000..a3ff4659f9a --- /dev/null +++ b/api/cfnetworking/networkerror/error_response.go @@ -0,0 +1,9 @@ +package networkerror + +type ErrorResponse struct { + Message string `json:"error"` +} + +func (e ErrorResponse) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/forbidden_error.go b/api/cfnetworking/networkerror/forbidden_error.go new file mode 100644 index 00000000000..d780a34cb8f --- /dev/null +++ b/api/cfnetworking/networkerror/forbidden_error.go @@ -0,0 +1,9 @@ +package networkerror + +type ForbiddenError struct { + Message string `json:"error"` +} + +func (e ForbiddenError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/invalid_auth_token_error.go b/api/cfnetworking/networkerror/invalid_auth_token_error.go new file mode 100644 index 00000000000..3e3178c39ad --- /dev/null +++ b/api/cfnetworking/networkerror/invalid_auth_token_error.go @@ -0,0 +1,11 @@ +package networkerror + +// InvalidAuthTokenError is returned when the client has an invalid +// authorization header. +type InvalidAuthTokenError struct { + Message string +} + +func (e InvalidAuthTokenError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/not_acceptable_error.go b/api/cfnetworking/networkerror/not_acceptable_error.go new file mode 100644 index 00000000000..002a73df304 --- /dev/null +++ b/api/cfnetworking/networkerror/not_acceptable_error.go @@ -0,0 +1,9 @@ +package networkerror + +type NotAcceptableError struct { + Message string `json:"error"` +} + +func (e NotAcceptableError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/not_found_error.go b/api/cfnetworking/networkerror/not_found_error.go new file mode 100644 index 00000000000..a69d3030854 --- /dev/null +++ b/api/cfnetworking/networkerror/not_found_error.go @@ -0,0 +1,10 @@ +package networkerror + +// NotFoundError wraps a generic 404 error. +type NotFoundError struct { + Message string +} + +func (e NotFoundError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/raw_http_status_error.go b/api/cfnetworking/networkerror/raw_http_status_error.go new file mode 100644 index 00000000000..fea62dcd7fd --- /dev/null +++ b/api/cfnetworking/networkerror/raw_http_status_error.go @@ -0,0 +1,14 @@ +package networkerror + +import "fmt" + +// RawHTTPStatusError represents any response with a 4xx or 5xx status code. +type RawHTTPStatusError struct { + StatusCode int + RawResponse []byte + RequestIDs []string +} + +func (r RawHTTPStatusError) Error() string { + return fmt.Sprintf("Error Code: %d\nRaw Response: %s", r.StatusCode, r.RawResponse) +} diff --git a/api/cfnetworking/networkerror/request_error.go b/api/cfnetworking/networkerror/request_error.go new file mode 100644 index 00000000000..0a4c17a6f72 --- /dev/null +++ b/api/cfnetworking/networkerror/request_error.go @@ -0,0 +1,11 @@ +package networkerror + +// RequestError represents a generic error encountered while performing the +// HTTP request. This generic error occurs before an HTTP response is obtained. +type RequestError struct { + Err error +} + +func (e RequestError) Error() string { + return e.Err.Error() +} diff --git a/api/cfnetworking/networkerror/ssl_validation_hostname_error.go b/api/cfnetworking/networkerror/ssl_validation_hostname_error.go new file mode 100644 index 00000000000..a583abcff0e --- /dev/null +++ b/api/cfnetworking/networkerror/ssl_validation_hostname_error.go @@ -0,0 +1,13 @@ +package networkerror + +import "fmt" + +// SSLValidationHostnameError replaces x509.HostnameError when the server has +// SSL certificate that does not match the hostname. +type SSLValidationHostnameError struct { + Message string +} + +func (e SSLValidationHostnameError) Error() string { + return fmt.Sprintf("Hostname does not match SSL Certificate (%s)", e.Message) +} diff --git a/api/cfnetworking/networkerror/unauthorized_error.go b/api/cfnetworking/networkerror/unauthorized_error.go new file mode 100644 index 00000000000..513c6de40cb --- /dev/null +++ b/api/cfnetworking/networkerror/unauthorized_error.go @@ -0,0 +1,9 @@ +package networkerror + +type UnauthorizedError struct { + Message string `json:"error"` +} + +func (e UnauthorizedError) Error() string { + return e.Message +} diff --git a/api/cfnetworking/networkerror/unexpected_response_error.go b/api/cfnetworking/networkerror/unexpected_response_error.go new file mode 100644 index 00000000000..e337d7a7954 --- /dev/null +++ b/api/cfnetworking/networkerror/unexpected_response_error.go @@ -0,0 +1,20 @@ +package networkerror + +import "fmt" + +// UnexpectedResponseError is returned when the client gets an error that has +// not been accounted for. +type UnexpectedResponseError struct { + ErrorResponse + + RequestIDs []string + ResponseCode int +} + +func (e UnexpectedResponseError) Error() string { + message := fmt.Sprintf("Unexpected Response\nResponse code: %d", e.ResponseCode) + for _, id := range e.RequestIDs { + message = fmt.Sprintf("%s\nRequest ID: %s", message, id) + } + return fmt.Sprintf("%s\nDescription: %s", message, e.Message) +} diff --git a/api/cfnetworking/networkerror/unverified_server_error.go b/api/cfnetworking/networkerror/unverified_server_error.go new file mode 100644 index 00000000000..97b7992e614 --- /dev/null +++ b/api/cfnetworking/networkerror/unverified_server_error.go @@ -0,0 +1,11 @@ +package networkerror + +// UnverifiedServerError replaces x509.UnknownAuthorityError when the server +// has SSL but the client is unable to verify its certificate +type UnverifiedServerError struct { + URL string +} + +func (UnverifiedServerError) Error() string { + return "x509: certificate signed by unknown authority" +} diff --git a/api/cfnetworking/networking_connection.go b/api/cfnetworking/networking_connection.go new file mode 100644 index 00000000000..e2fae7eb705 --- /dev/null +++ b/api/cfnetworking/networking_connection.go @@ -0,0 +1,127 @@ +package cfnetworking + +import ( + "bytes" + "crypto/tls" + "crypto/x509" + "encoding/json" + "errors" + "io" + "net" + "net/http" + "net/url" + "time" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" +) + +// NetworkingConnection represents a connection to the Cloud Controller +// server. +type NetworkingConnection struct { + HTTPClient *http.Client + UserAgent string +} + +// Config is for configuring a NetworkingConnection. +type Config struct { + DialTimeout time.Duration + SkipSSLValidation bool +} + +// NewConnection returns a new NetworkingConnection with provided +// configuration. +func NewConnection(config Config) *NetworkingConnection { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: config.SkipSSLValidation, + }, + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + KeepAlive: 30 * time.Second, + Timeout: config.DialTimeout, + }).DialContext, + } + + return &NetworkingConnection{ + HTTPClient: &http.Client{Transport: tr}, + } +} + +// Make performs the request and parses the response. +func (connection *NetworkingConnection) Make(request *Request, passedResponse *Response) error { + // In case this function is called from a retry, passedResponse may already + // be populated with a previous response. We reset in case there's an HTTP + // error, and we don't repopulate it in populateResponse. + passedResponse.reset() + + response, err := connection.HTTPClient.Do(request.Request) + if err != nil { + return connection.processRequestErrors(request.Request, err) + } + + return connection.populateResponse(response, passedResponse) +} + +func (*NetworkingConnection) processRequestErrors(request *http.Request, err error) error { + switch err.(type) { + case *url.Error: + if errors.As(err, &x509.UnknownAuthorityError{}) { + return networkerror.UnverifiedServerError{ + URL: request.URL.String(), + } + } + hostnameError := x509.HostnameError{} + if errors.As(err, &hostnameError) { + return networkerror.SSLValidationHostnameError{ + Message: hostnameError.Error(), + } + } + return networkerror.RequestError{Err: err} + default: + return err + } +} + +func (connection *NetworkingConnection) populateResponse(response *http.Response, passedResponse *Response) error { + passedResponse.HTTPResponse = response + + if resourceLocationURL := response.Header.Get("Location"); resourceLocationURL != "" { + passedResponse.ResourceLocationURL = resourceLocationURL + } + + rawBytes, err := io.ReadAll(response.Body) + defer response.Body.Close() + if err != nil { + return err + } + + passedResponse.RawResponse = rawBytes + + err = connection.handleStatusCodes(response, passedResponse) + if err != nil { + return err + } + + if passedResponse.Result != nil { + decoder := json.NewDecoder(bytes.NewBuffer(passedResponse.RawResponse)) + decoder.UseNumber() + err = decoder.Decode(passedResponse.Result) + if err != nil { + return err + } + } + + return nil +} + +func (*NetworkingConnection) handleStatusCodes(response *http.Response, passedResponse *Response) error { + if response.StatusCode >= 400 { + return networkerror.RawHTTPStatusError{ + StatusCode: response.StatusCode, + RawResponse: passedResponse.RawResponse, + RequestIDs: response.Header["X-Vcap-Request-Id"], + } + } + + return nil +} diff --git a/api/cfnetworking/networking_connection_test.go b/api/cfnetworking/networking_connection_test.go new file mode 100644 index 00000000000..b2b0081409f --- /dev/null +++ b/api/cfnetworking/networking_connection_test.go @@ -0,0 +1,251 @@ +package cfnetworking_test + +import ( + "fmt" + "net/http" + "runtime" + "strings" + + . "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +type DummyResponse struct { + Val1 string `json:"val1"` + Val2 int `json:"val2"` + Val3 interface{} `json:"val3,omitempty"` +} + +var _ = Describe("CF Networking Connection", func() { + var connection *NetworkingConnection + + BeforeEach(func() { + connection = NewConnection(Config{SkipSSLValidation: true}) + }) + + Describe("Make", func() { + Describe("Data Unmarshalling", func() { + var request *Request + + BeforeEach(func() { + response := `{ + "val1":"2.59.0", + "val2":2, + "val3":1111111111111111111 + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v2/foo", ""), + RespondWith(http.StatusOK, response), + ), + ) + + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v2/foo", server.URL()), nil) + Expect(err).ToNot(HaveOccurred()) + request = &Request{Request: req} + }) + + When("passed a response with a result set", func() { + It("unmarshals the data into a struct", func() { + var body DummyResponse + response := Response{ + Result: &body, + } + + err := connection.Make(request, &response) + Expect(err).NotTo(HaveOccurred()) + + Expect(body.Val1).To(Equal("2.59.0")) + Expect(body.Val2).To(Equal(2)) + }) + + It("keeps numbers unmarshalled to interfaces as interfaces", func() { + var body DummyResponse + response := Response{ + Result: &body, + } + + err := connection.Make(request, &response) + Expect(err).NotTo(HaveOccurred()) + Expect(fmt.Sprint(body.Val3)).To(Equal("1111111111111111111")) + }) + }) + + When("passed an empty response", func() { + It("skips the unmarshalling step", func() { + var response Response + err := connection.Make(request, &response) + Expect(err).NotTo(HaveOccurred()) + Expect(response.Result).To(BeNil()) + }) + }) + }) + + Describe("HTTP Response", func() { + var request *Request + + BeforeEach(func() { + response := `{}` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v2/foo", ""), + RespondWith(http.StatusOK, response), + ), + ) + + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v2/foo", server.URL()), nil) + Expect(err).ToNot(HaveOccurred()) + request = &Request{Request: req} + }) + + It("returns the status", func() { + response := Response{} + + err := connection.Make(request, &response) + Expect(err).NotTo(HaveOccurred()) + + Expect(response.HTTPResponse.Status).To(Equal("200 OK")) + }) + }) + + Describe("Response Headers", func() { + Describe("Location", func() { + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v2/foo"), + RespondWith(http.StatusAccepted, "{}", http.Header{"Location": {"/v2/some-location"}}), + ), + ) + }) + + It("returns the location in the ResourceLocationURL", func() { + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v2/foo", server.URL()), nil) + Expect(err).ToNot(HaveOccurred()) + request := &Request{Request: req} + + var response Response + err = connection.Make(request, &response) + Expect(err).NotTo(HaveOccurred()) + + Expect(server.ReceivedRequests()).To(HaveLen(1)) + Expect(response.ResourceLocationURL).To(Equal("/v2/some-location")) + }) + }) + }) + + Describe("Errors", func() { + When("the server does not exist", func() { + BeforeEach(func() { + connection = NewConnection(Config{}) + }) + + It("returns a RequestError", func() { + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v2/foo", "http://garbledyguk.com"), nil) + Expect(err).ToNot(HaveOccurred()) + request := &Request{Request: req} + + var response Response + err = connection.Make(request, &response) + Expect(err).To(HaveOccurred()) + + requestErr, ok := err.(networkerror.RequestError) + Expect(ok).To(BeTrue()) + Expect(requestErr.Error()).To(MatchRegexp(".*http://garbledyguk.com/v2/foo.*[nN]o such host")) + }) + }) + + When("the server does not have a verified certificate", func() { + Context("skipSSLValidation is false", func() { + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v2/foo"), + ), + ) + + connection = NewConnection(Config{}) + }) + + It("returns a UnverifiedServerError", func() { + req, err := http.NewRequest(http.MethodGet, server.URL(), nil) + Expect(err).ToNot(HaveOccurred()) + request := &Request{Request: req} + + var response Response + err = connection.Make(request, &response) + Expect(err).To(MatchError(networkerror.UnverifiedServerError{URL: server.URL()})) + }) + }) + }) + + When("the server's certificate does not match the hostname", func() { + Context("skipSSLValidation is false", func() { + BeforeEach(func() { + if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + Skip("ssl validation has a different order on windows/darwin, will not be returned properly") + } + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/"), + ), + ) + + connection = NewConnection(Config{}) + }) + + // 127.0.0.1.nip.io is a custom DNS record setup to point to 127.0.0.1 + It("returns a SSLValidationHostnameError", func() { + altHostURL := strings.Replace(server.URL(), "127.0.0.1", "127.0.0.1.nip.io", -1) + req, err := http.NewRequest(http.MethodGet, altHostURL, nil) + Expect(err).ToNot(HaveOccurred()) + request := &Request{Request: req} + + var response Response + err = connection.Make(request, &response) + Expect(err).To(MatchError(networkerror.SSLValidationHostnameError{ + Message: "x509: certificate is valid for example.com, *.example.com, not 127.0.0.1.nip.io", + })) + }) + }) + }) + + Describe("RawHTTPStatusError", func() { + var networkResponse string + BeforeEach(func() { + networkResponse = `{ + "code": 90004, + "description": "The service binding could not be found: some-guid", + "error_code": "CF-ServiceBindingNotFound" + }` + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v2/foo"), + RespondWith(http.StatusNotFound, networkResponse, http.Header{"X-Vcap-Request-Id": {"6e0b4379-f5f7-4b2b-56b0-9ab7e96eed95", "6e0b4379-f5f7-4b2b-56b0-9ab7e96eed95::7445d9db-c31e-410d-8dc5-9f79ec3fc26f"}}), + ), + ) + }) + + It("returns a CCRawResponse", func() { + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v2/foo", server.URL()), nil) + Expect(err).ToNot(HaveOccurred()) + request := &Request{Request: req} + + var response Response + err = connection.Make(request, &response) + Expect(err).To(MatchError(networkerror.RawHTTPStatusError{ + StatusCode: http.StatusNotFound, + RawResponse: []byte(networkResponse), + RequestIDs: []string{"6e0b4379-f5f7-4b2b-56b0-9ab7e96eed95", "6e0b4379-f5f7-4b2b-56b0-9ab7e96eed95::7445d9db-c31e-410d-8dc5-9f79ec3fc26f"}, + })) + + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + }) + }) + }) +}) diff --git a/api/cfnetworking/request.go b/api/cfnetworking/request.go new file mode 100644 index 00000000000..8a81ca53897 --- /dev/null +++ b/api/cfnetworking/request.go @@ -0,0 +1,34 @@ +package cfnetworking + +import ( + "io" + "net/http" +) + +//counterfeiter:generate . ReadSeeker +type ReadSeeker interface { + io.ReadSeeker +} + +// Request represents the request of the cloud controller. +type Request struct { + *http.Request + + body io.ReadSeeker +} + +func (r *Request) ResetBody() error { + if r.body == nil { + return nil + } + + _, err := r.body.Seek(0, 0) + return err +} + +func NewRequest(request *http.Request, body io.ReadSeeker) *Request { + return &Request{ + Request: request, + body: body, + } +} diff --git a/api/cfnetworking/response.go b/api/cfnetworking/response.go new file mode 100644 index 00000000000..8d4de87ccac --- /dev/null +++ b/api/cfnetworking/response.go @@ -0,0 +1,29 @@ +package cfnetworking + +import "net/http" + +// Response represents a Cloud Controller response object. +type Response struct { + // Result represents the resource entity type that is expected in the + // response JSON. + Result interface{} + + // RawResponse represents the response body. + RawResponse []byte + + // Warnings represents warnings parsed from the custom warnings headers of a + // Cloud Controller response. + Warnings []string + + // HTTPResponse represents the HTTP response object. + HTTPResponse *http.Response + + // ResourceLocationURL represents the Location header value + ResourceLocationURL string +} + +func (r *Response) reset() { + r.RawResponse = []byte{} + r.Warnings = []string{} + r.HTTPResponse = nil +} diff --git a/api/cfnetworking/wrapper/request_logger.go b/api/cfnetworking/wrapper/request_logger.go new file mode 100644 index 00000000000..6918b8927f1 --- /dev/null +++ b/api/cfnetworking/wrapper/request_logger.go @@ -0,0 +1,156 @@ +package wrapper + +import ( + "fmt" + "io" + "net/http" + "sort" + "strings" + "time" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" +) + +// RequestLoggerOutput is the interface for displaying logs +// +//counterfeiter:generate . RequestLoggerOutput +type RequestLoggerOutput interface { + DisplayHeader(name string, value string) error + DisplayHost(name string) error + DisplayJSONBody(body []byte) error + DisplayMessage(msg string) error + DisplayRequestHeader(method string, uri string, httpProtocol string) error + DisplayResponseHeader(httpProtocol string, status string) error + DisplayType(name string, requestDate time.Time) error + HandleInternalError(err error) + Start() error + Stop() error +} + +// RequestLogger is the wrapper that logs requests to and responses from the +// Cloud Controller server +type RequestLogger struct { + connection cfnetworking.Connection + output RequestLoggerOutput +} + +// NewRequestLogger returns a pointer to a RequestLogger wrapper +func NewRequestLogger(output RequestLoggerOutput) *RequestLogger { + return &RequestLogger{ + output: output, + } +} + +// Wrap sets the connection on the RequestLogger and returns itself +func (logger *RequestLogger) Wrap(innerconnection cfnetworking.Connection) cfnetworking.Connection { + logger.connection = innerconnection + return logger +} + +// Make records the request and the response to UI +func (logger *RequestLogger) Make(request *cfnetworking.Request, passedResponse *cfnetworking.Response) error { + err := logger.displayRequest(request) + if err != nil { + logger.output.HandleInternalError(err) + } + + err = logger.connection.Make(request, passedResponse) + + if passedResponse.HTTPResponse != nil { + displayErr := logger.displayResponse(passedResponse) + if displayErr != nil { + logger.output.HandleInternalError(displayErr) + } + } + + return err +} + +func (logger *RequestLogger) displayRequest(request *cfnetworking.Request) error { + err := logger.output.Start() + if err != nil { + return err + } + defer logger.output.Stop() + + err = logger.output.DisplayType("REQUEST", time.Now()) + if err != nil { + return err + } + err = logger.output.DisplayRequestHeader(request.Method, request.URL.RequestURI(), request.Proto) + if err != nil { + return err + } + err = logger.output.DisplayHost(request.URL.Host) + if err != nil { + return err + } + err = logger.displaySortedHeaders(request.Header) + if err != nil { + return err + } + + contentType := request.Header.Get("Content-Type") + if request.Body != nil { + if strings.Contains(contentType, "json") { + rawRequestBody, err := io.ReadAll(request.Body) + if err != nil { + return err + } + + defer request.ResetBody() + + return logger.output.DisplayJSONBody(rawRequestBody) + } else if contentType != "" { + return logger.output.DisplayMessage(fmt.Sprintf("[%s Content Hidden]", strings.Split(contentType, ";")[0])) + } + } + return nil +} + +func (logger *RequestLogger) displayResponse(passedResponse *cfnetworking.Response) error { + err := logger.output.Start() + if err != nil { + return err + } + defer logger.output.Stop() + + err = logger.output.DisplayType("RESPONSE", time.Now()) + if err != nil { + return err + } + err = logger.output.DisplayResponseHeader(passedResponse.HTTPResponse.Proto, passedResponse.HTTPResponse.Status) + if err != nil { + return err + } + err = logger.displaySortedHeaders(passedResponse.HTTPResponse.Header) + if err != nil { + return err + } + return logger.output.DisplayJSONBody(passedResponse.RawResponse) +} + +func (logger *RequestLogger) displaySortedHeaders(headers http.Header) error { + keys := make([]string, 0) + for key := range headers { + keys = append(keys, key) + } + sort.Strings(keys) + + for _, key := range keys { + for _, value := range headers[key] { + err := logger.output.DisplayHeader(key, redactHeaders(key, value)) + if err != nil { + return err + } + } + } + return nil +} + +func redactHeaders(key string, value string) string { + if key == "Authorization" { + return "[PRIVATE DATA HIDDEN]" + } + return value +} diff --git a/api/cfnetworking/wrapper/request_logger_test.go b/api/cfnetworking/wrapper/request_logger_test.go new file mode 100644 index 00000000000..5a24135c0be --- /dev/null +++ b/api/cfnetworking/wrapper/request_logger_test.go @@ -0,0 +1,328 @@ +package wrapper_test + +import ( + "bytes" + "errors" + "io" + "net/http" + "net/url" + "time" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetworkingfakes" + . "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper/wrapperfakes" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Request Logger", func() { + var ( + fakeConnection *cfnetworkingfakes.FakeConnection + fakeOutput *wrapperfakes.FakeRequestLoggerOutput + + wrapper cfnetworking.Connection + + request *cfnetworking.Request + response *cfnetworking.Response + executeErr error + ) + + BeforeEach(func() { + fakeConnection = new(cfnetworkingfakes.FakeConnection) + fakeOutput = new(wrapperfakes.FakeRequestLoggerOutput) + + wrapper = NewRequestLogger(fakeOutput).Wrap(fakeConnection) + + body := bytes.NewReader([]byte("foo")) + + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", body) + Expect(err).NotTo(HaveOccurred()) + + req.URL.RawQuery = url.Values{ + "query1": {"a"}, + "query2": {"b"}, + }.Encode() + + headers := http.Header{} + headers.Add("Aghi", "bar") + headers.Add("Abc", "json") + headers.Add("Adef", "application/json") + req.Header = headers + + response = &cfnetworking.Response{ + RawResponse: []byte("some-response-body"), + HTTPResponse: &http.Response{}, + } + request = cfnetworking.NewRequest(req, body) + }) + + JustBeforeEach(func() { + executeErr = wrapper.Make(request, response) + }) + + Describe("Make", func() { + It("outputs the request", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(fakeOutput.DisplayTypeCallCount()).To(BeNumerically(">=", 1)) + name, date := fakeOutput.DisplayTypeArgsForCall(0) + Expect(name).To(Equal("REQUEST")) + Expect(date).To(BeTemporally("~", time.Now(), time.Second)) + + Expect(fakeOutput.DisplayRequestHeaderCallCount()).To(Equal(1)) + method, uri, protocol := fakeOutput.DisplayRequestHeaderArgsForCall(0) + Expect(method).To(Equal(http.MethodGet)) + Expect(uri).To(MatchRegexp("/banana\\?(?:query1=a&query2=b|query2=b&query1=a)")) + Expect(protocol).To(Equal("HTTP/1.1")) + + Expect(fakeOutput.DisplayHostCallCount()).To(Equal(1)) + host := fakeOutput.DisplayHostArgsForCall(0) + Expect(host).To(Equal("foo.bar.com")) + + Expect(fakeOutput.DisplayHeaderCallCount()).To(BeNumerically(">=", 3)) + name, value := fakeOutput.DisplayHeaderArgsForCall(0) + Expect(name).To(Equal("Abc")) + Expect(value).To(Equal("json")) + name, value = fakeOutput.DisplayHeaderArgsForCall(1) + Expect(name).To(Equal("Adef")) + Expect(value).To(Equal("application/json")) + name, value = fakeOutput.DisplayHeaderArgsForCall(2) + Expect(name).To(Equal("Aghi")) + Expect(value).To(Equal("bar")) + + Expect(fakeOutput.DisplayMessageCallCount()).To(Equal(0)) + }) + + Context("when an authorization header is in the request", func() { + BeforeEach(func() { + request.Header = http.Header{"Authorization": []string{"should not be shown"}} + }) + + It("redacts the contents of the authorization header", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(fakeOutput.DisplayHeaderCallCount()).To(Equal(1)) + key, value := fakeOutput.DisplayHeaderArgsForCall(0) + Expect(key).To(Equal("Authorization")) + Expect(value).To(Equal("[PRIVATE DATA HIDDEN]")) + }) + }) + + Context("when passed a body", func() { + Context("when the request's Content-Type is application/json", func() { + BeforeEach(func() { + request.Header.Set("Content-Type", "application/json") + }) + + It("outputs the body", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) + Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("foo"))) + + bytes, err := io.ReadAll(request.Body) + Expect(err).NotTo(HaveOccurred()) + Expect(bytes).To(Equal([]byte("foo"))) + }) + }) + + Context("when request's Content-Type is anything else", func() { + BeforeEach(func() { + request.Header.Set("Content-Type", "banana;rama") + }) + + It("does not display the body", func() { + Expect(fakeOutput.DisplayJSONBodyCallCount()).To(Equal(1)) // Once for response body only + Expect(fakeOutput.DisplayMessageCallCount()).To(Equal(1)) + Expect(fakeOutput.DisplayMessageArgsForCall(0)).To(Equal("[banana Content Hidden]")) + }) + }) + }) + + Context("when an error occures while trying to log the request", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("this should never block the request") + + calledOnce := false + fakeOutput.StartStub = func() error { + if !calledOnce { + calledOnce = true + return expectedErr + } + return nil + } + }) + + It("should display the error and continue on", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(fakeOutput.HandleInternalErrorCallCount()).To(Equal(1)) + Expect(fakeOutput.HandleInternalErrorArgsForCall(0)).To(MatchError(expectedErr)) + }) + }) + + Context("when the request is successful", func() { + BeforeEach(func() { + response = &cfnetworking.Response{ + RawResponse: []byte("some-response-body"), + HTTPResponse: &http.Response{ + Proto: "HTTP/1.1", + Status: "200 OK", + Header: http.Header{ + "BBBBB": {"second"}, + "AAAAA": {"first"}, + "CCCCC": {"third"}, + }, + }, + } + }) + + It("outputs the response", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(fakeOutput.DisplayTypeCallCount()).To(Equal(2)) + name, date := fakeOutput.DisplayTypeArgsForCall(1) + Expect(name).To(Equal("RESPONSE")) + Expect(date).To(BeTemporally("~", time.Now(), time.Second)) + + Expect(fakeOutput.DisplayResponseHeaderCallCount()).To(Equal(1)) + protocol, status := fakeOutput.DisplayResponseHeaderArgsForCall(0) + Expect(protocol).To(Equal("HTTP/1.1")) + Expect(status).To(Equal("200 OK")) + + Expect(fakeOutput.DisplayHeaderCallCount()).To(BeNumerically(">=", 6)) + name, value := fakeOutput.DisplayHeaderArgsForCall(3) + Expect(name).To(Equal("AAAAA")) + Expect(value).To(Equal("first")) + name, value = fakeOutput.DisplayHeaderArgsForCall(4) + Expect(name).To(Equal("BBBBB")) + Expect(value).To(Equal("second")) + name, value = fakeOutput.DisplayHeaderArgsForCall(5) + Expect(name).To(Equal("CCCCC")) + Expect(value).To(Equal("third")) + + Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) + Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("some-response-body"))) + }) + }) + + Context("when the request is unsuccessful", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("banana") + fakeConnection.MakeReturns(expectedErr) + }) + + Context("when the http response is not set", func() { + BeforeEach(func() { + response = &cfnetworking.Response{} + }) + + It("outputs nothing", func() { + Expect(executeErr).To(MatchError(expectedErr)) + Expect(fakeOutput.DisplayResponseHeaderCallCount()).To(Equal(0)) + }) + }) + + Context("when the http response is set", func() { + BeforeEach(func() { + response = &cfnetworking.Response{ + RawResponse: []byte("some-error-body"), + HTTPResponse: &http.Response{ + Proto: "HTTP/1.1", + Status: "200 OK", + Header: http.Header{ + "BBBBB": {"second"}, + "AAAAA": {"first"}, + "CCCCC": {"third"}, + }, + }, + } + }) + + It("outputs the response", func() { + Expect(executeErr).To(MatchError(expectedErr)) + + Expect(fakeOutput.DisplayTypeCallCount()).To(Equal(2)) + name, date := fakeOutput.DisplayTypeArgsForCall(1) + Expect(name).To(Equal("RESPONSE")) + Expect(date).To(BeTemporally("~", time.Now(), time.Second)) + + Expect(fakeOutput.DisplayResponseHeaderCallCount()).To(Equal(1)) + protocol, status := fakeOutput.DisplayResponseHeaderArgsForCall(0) + Expect(protocol).To(Equal("HTTP/1.1")) + Expect(status).To(Equal("200 OK")) + + Expect(fakeOutput.DisplayHeaderCallCount()).To(BeNumerically(">=", 6)) + name, value := fakeOutput.DisplayHeaderArgsForCall(3) + Expect(name).To(Equal("AAAAA")) + Expect(value).To(Equal("first")) + name, value = fakeOutput.DisplayHeaderArgsForCall(4) + Expect(name).To(Equal("BBBBB")) + Expect(value).To(Equal("second")) + name, value = fakeOutput.DisplayHeaderArgsForCall(5) + Expect(name).To(Equal("CCCCC")) + Expect(value).To(Equal("third")) + + Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) + Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("some-error-body"))) + }) + }) + }) + + Context("when an error occures while trying to log the response", func() { + var ( + originalErr error + expectedErr error + ) + + BeforeEach(func() { + originalErr = errors.New("this error should not be overwritten") + fakeConnection.MakeReturns(originalErr) + + expectedErr = errors.New("this should never block the request") + + calledOnce := false + fakeOutput.StartStub = func() error { + if !calledOnce { + calledOnce = true + return nil + } + return expectedErr + } + }) + + It("should display the error and continue on", func() { + Expect(executeErr).To(MatchError(originalErr)) + + Expect(fakeOutput.HandleInternalErrorCallCount()).To(Equal(1)) + Expect(fakeOutput.HandleInternalErrorArgsForCall(0)).To(MatchError(expectedErr)) + }) + }) + + It("starts and stops the output", func() { + Expect(fakeOutput.StartCallCount()).To(Equal(2)) + Expect(fakeOutput.StopCallCount()).To(Equal(2)) + }) + + Context("when displaying the logs have an error", func() { + var expectedErr error + BeforeEach(func() { + expectedErr = errors.New("Display error on request") + fakeOutput.StartReturns(expectedErr) + }) + + It("calls handle internal error", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(fakeOutput.HandleInternalErrorCallCount()).To(Equal(2)) + Expect(fakeOutput.HandleInternalErrorArgsForCall(0)).To(MatchError(expectedErr)) + Expect(fakeOutput.HandleInternalErrorArgsForCall(1)).To(MatchError(expectedErr)) + }) + }) + }) +}) diff --git a/api/cfnetworking/wrapper/retry_request.go b/api/cfnetworking/wrapper/retry_request.go new file mode 100644 index 00000000000..ff10e9a02bc --- /dev/null +++ b/api/cfnetworking/wrapper/retry_request.go @@ -0,0 +1,54 @@ +package wrapper + +import ( + "net/http" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" +) + +// RetryRequest is a wrapper that retries failed requests if they contain a 5XX +// status code. +type RetryRequest struct { + maxRetries int + connection cfnetworking.Connection +} + +// NewRetryRequest returns a pointer to a RetryRequest wrapper. +func NewRetryRequest(maxRetries int) *RetryRequest { + return &RetryRequest{ + maxRetries: maxRetries, + } +} + +// Wrap sets the connection in the RetryRequest and returns itself. +func (retry *RetryRequest) Wrap(innerconnection cfnetworking.Connection) cfnetworking.Connection { + retry.connection = innerconnection + return retry +} + +// Make retries the request if it comes back with certain status codes. +func (retry *RetryRequest) Make(request *cfnetworking.Request, passedResponse *cfnetworking.Response) error { + var err error + + for i := 0; i < retry.maxRetries+1; i += 1 { + err = retry.connection.Make(request, passedResponse) + if err == nil { + return nil + } + + if passedResponse.HTTPResponse != nil && + (passedResponse.HTTPResponse.StatusCode == http.StatusBadGateway || + passedResponse.HTTPResponse.StatusCode == http.StatusServiceUnavailable || + passedResponse.HTTPResponse.StatusCode == http.StatusGatewayTimeout || + (passedResponse.HTTPResponse.StatusCode >= 400 && passedResponse.HTTPResponse.StatusCode < 500)) { + break + } + + // Reset the request body prior to the next retry + resetErr := request.ResetBody() + if resetErr != nil { + return resetErr + } + } + return err +} diff --git a/api/cfnetworking/wrapper/retry_request_test.go b/api/cfnetworking/wrapper/retry_request_test.go new file mode 100644 index 00000000000..6c38d25b12d --- /dev/null +++ b/api/cfnetworking/wrapper/retry_request_test.go @@ -0,0 +1,110 @@ +package wrapper_test + +import ( + "errors" + "io" + "net/http" + "strings" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetworkingfakes" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + . "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Retry Request", func() { + DescribeTable("number of retries", + func(requestMethod string, responseStatusCode int, expectedNumberOfRetries int) { + rawRequestBody := "banana pants" + body := strings.NewReader(rawRequestBody) + + req, err := http.NewRequest(requestMethod, "https://foo.bar.com/banana", body) + Expect(err).NotTo(HaveOccurred()) + request := cfnetworking.NewRequest(req, body) + + response := &cfnetworking.Response{ + HTTPResponse: &http.Response{ + StatusCode: responseStatusCode, + }, + } + + fakeConnection := new(cfnetworkingfakes.FakeConnection) + expectedErr := networkerror.RawHTTPStatusError{ + StatusCode: responseStatusCode, + } + fakeConnection.MakeStub = func(req *cfnetworking.Request, passedResponse *cfnetworking.Response) error { + defer req.Body.Close() + body, readBodyErr := io.ReadAll(request.Body) + Expect(readBodyErr).ToNot(HaveOccurred()) + Expect(string(body)).To(Equal(rawRequestBody)) + return expectedErr + } + + wrapper := NewRetryRequest(2).Wrap(fakeConnection) + err = wrapper.Make(request, response) + Expect(err).To(MatchError(expectedErr)) + Expect(fakeConnection.MakeCallCount()).To(Equal(expectedNumberOfRetries)) + }, + + Entry("maxRetries for Non-Post (500) Internal Server Error", http.MethodGet, http.StatusInternalServerError, 3), + Entry("1 for Post (502) Bad Gateway", http.MethodGet, http.StatusBadGateway, 1), + Entry("1 for Post (503) Service Unavailable", http.MethodGet, http.StatusServiceUnavailable, 1), + Entry("1 for Post (504) Gateway Timeout", http.MethodGet, http.StatusGatewayTimeout, 1), + + Entry("1 for 4XX Errors", http.MethodGet, http.StatusNotFound, 1), + ) + + It("does not retry on success", func() { + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", nil) + Expect(err).NotTo(HaveOccurred()) + request := cfnetworking.NewRequest(req, nil) + response := &cfnetworking.Response{ + HTTPResponse: &http.Response{ + StatusCode: http.StatusOK, + }, + } + + fakeConnection := new(cfnetworkingfakes.FakeConnection) + wrapper := NewRetryRequest(2).Wrap(fakeConnection) + + err = wrapper.Make(request, response) + Expect(err).ToNot(HaveOccurred()) + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + }) + + Context("when seeking errors", func() { + var ( + request *cfnetworking.Request + response *cfnetworking.Response + + fakeConnection *cfnetworkingfakes.FakeConnection + wrapper cfnetworking.Connection + ) + + BeforeEach(func() { + fakeReadSeeker := new(cfnetworkingfakes.FakeReadSeeker) + fakeReadSeeker.SeekReturns(0, errors.New("oh noes")) + + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", fakeReadSeeker) + Expect(err).NotTo(HaveOccurred()) + request = cfnetworking.NewRequest(req, fakeReadSeeker) + + response = &cfnetworking.Response{ + HTTPResponse: &http.Response{ + StatusCode: http.StatusInternalServerError, + }, + } + fakeConnection = new(cfnetworkingfakes.FakeConnection) + fakeConnection.MakeReturns(errors.New("some error")) + wrapper = NewRetryRequest(3).Wrap(fakeConnection) + }) + + It("sets the err on SeekError", func() { + err := wrapper.Make(request, response) + Expect(err).To(MatchError("oh noes")) + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + }) + }) +}) diff --git a/api/cfnetworking/wrapper/uaa_authentication.go b/api/cfnetworking/wrapper/uaa_authentication.go new file mode 100644 index 00000000000..3c9b816fca7 --- /dev/null +++ b/api/cfnetworking/wrapper/uaa_authentication.go @@ -0,0 +1,81 @@ +package wrapper + +import ( + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + "code.cloudfoundry.org/cli/v8/api/uaa" +) + +// UAAClient is the interface for getting a valid access token +// +//counterfeiter:generate . UAAClient +type UAAClient interface { + RefreshAccessToken(refreshToken string) (uaa.RefreshedTokens, error) +} + +// TokenCache is where the UAA token information is stored. +// +//counterfeiter:generate . TokenCache +type TokenCache interface { + AccessToken() string + RefreshToken() string + SetAccessToken(token string) + SetRefreshToken(token string) +} + +// UAAAuthentication wraps connections and adds authentication headers to all +// requests +type UAAAuthentication struct { + connection cfnetworking.Connection + client UAAClient + cache TokenCache +} + +// NewUAAAuthentication returns a pointer to a UAAAuthentication wrapper with +// the client and a token cache. +func NewUAAAuthentication(client UAAClient, cache TokenCache) *UAAAuthentication { + return &UAAAuthentication{ + client: client, + cache: cache, + } +} + +// Wrap sets the connection on the UAAAuthentication and returns itself +func (t *UAAAuthentication) Wrap(innerconnection cfnetworking.Connection) cfnetworking.Connection { + t.connection = innerconnection + return t +} + +// SetClient sets the UAA client that the wrapper will use. +func (t *UAAAuthentication) SetClient(client UAAClient) { + t.client = client +} + +// Make adds authentication headers to the passed in request and then calls the +// wrapped connection's Make. If the client is not set on the wrapper, it will +// not add any header or handle any authentication errors. +func (t *UAAAuthentication) Make(request *cfnetworking.Request, passedResponse *cfnetworking.Response) error { + request.Header.Set("Authorization", t.cache.AccessToken()) + + requestErr := t.connection.Make(request, passedResponse) + if _, ok := requestErr.(networkerror.InvalidAuthTokenError); ok { + tokens, err := t.client.RefreshAccessToken(t.cache.RefreshToken()) + if err != nil { + return err + } + + t.cache.SetAccessToken(tokens.AuthorizationToken()) + t.cache.SetRefreshToken(tokens.RefreshToken) + + if request.Body != nil { + err = request.ResetBody() + if err != nil { + return err + } + } + request.Header.Set("Authorization", t.cache.AccessToken()) + requestErr = t.connection.Make(request, passedResponse) + } + + return requestErr +} diff --git a/api/cfnetworking/wrapper/uaa_authentication_test.go b/api/cfnetworking/wrapper/uaa_authentication_test.go new file mode 100644 index 00000000000..d2d088275ef --- /dev/null +++ b/api/cfnetworking/wrapper/uaa_authentication_test.go @@ -0,0 +1,174 @@ +package wrapper_test + +import ( + "errors" + "io" + "net/http" + "strings" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetworkingfakes" + . "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper/util" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/networkerror" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("UAA Authentication", func() { + var ( + fakeConnection *cfnetworkingfakes.FakeConnection + fakeClient *wrapperfakes.FakeUAAClient + inMemoryCache *util.InMemoryCache + + wrapper cfnetworking.Connection + request *cfnetworking.Request + inner *UAAAuthentication + ) + + BeforeEach(func() { + fakeConnection = new(cfnetworkingfakes.FakeConnection) + fakeClient = new(wrapperfakes.FakeUAAClient) + inMemoryCache = util.NewInMemoryTokenCache() + inMemoryCache.SetAccessToken("a-ok") + + inner = NewUAAAuthentication(fakeClient, inMemoryCache) + wrapper = inner.Wrap(fakeConnection) + + request = &cfnetworking.Request{ + Request: &http.Request{ + Header: http.Header{}, + }, + } + }) + + Describe("Make", func() { + It("adds authentication headers", func() { + err := wrapper.Make(request, nil) + Expect(err).ToNot(HaveOccurred()) + + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + authenticatedRequest, _ := fakeConnection.MakeArgsForCall(0) + headers := authenticatedRequest.Header + Expect(headers["Authorization"]).To(ConsistOf([]string{"a-ok"})) + }) + + Context("when the token is valid", func() { + Context("when the request already has headers", func() { + It("preserves existing headers", func() { + request.Header.Add("Existing", "header") + err := wrapper.Make(request, nil) + Expect(err).ToNot(HaveOccurred()) + + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + authenticatedRequest, _ := fakeConnection.MakeArgsForCall(0) + headers := authenticatedRequest.Header + Expect(headers["Existing"]).To(ConsistOf([]string{"header"})) + }) + }) + + Context("when the wrapped connection returns nil", func() { + It("returns nil", func() { + fakeConnection.MakeReturns(nil) + + err := wrapper.Make(request, nil) + Expect(err).ToNot(HaveOccurred()) + }) + }) + + Context("when the wrapped connection returns an error", func() { + It("returns the error", func() { + innerError := errors.New("inner error") + fakeConnection.MakeReturns(innerError) + + err := wrapper.Make(request, nil) + Expect(err).To(Equal(innerError)) + }) + }) + }) + + Context("when the token is invalid", func() { + var ( + expectedBody string + request *cfnetworking.Request + executeErr error + ) + + BeforeEach(func() { + expectedBody = "this body content should be preserved" + body := strings.NewReader(expectedBody) + request = cfnetworking.NewRequest(&http.Request{ + Header: http.Header{}, + Body: io.NopCloser(body), + }, body) + + makeCount := 0 + fakeConnection.MakeStub = func(request *cfnetworking.Request, response *cfnetworking.Response) error { + body, err := io.ReadAll(request.Body) + Expect(err).NotTo(HaveOccurred()) + Expect(string(body)).To(Equal(expectedBody)) + + if makeCount == 0 { + makeCount += 1 + return networkerror.InvalidAuthTokenError{} + } else { + return nil + } + } + + inMemoryCache.SetAccessToken("what") + + fakeClient.RefreshAccessTokenReturns( + uaa.RefreshedTokens{ + AccessToken: "foobar-2", + RefreshToken: "bananananananana", + Type: "bearer", + }, + nil, + ) + }) + + JustBeforeEach(func() { + executeErr = wrapper.Make(request, nil) + }) + + It("should refresh the token", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeClient.RefreshAccessTokenCallCount()).To(Equal(1)) + }) + + It("should resend the request", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeConnection.MakeCallCount()).To(Equal(2)) + + requestArg, _ := fakeConnection.MakeArgsForCall(1) + Expect(requestArg.Header.Get("Authorization")).To(Equal("bearer foobar-2")) + }) + + It("should save the refresh token", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(inMemoryCache.RefreshToken()).To(Equal("bananananananana")) + }) + + Context("when the reseting the request body fails", func() { + BeforeEach(func() { + fakeConnection.MakeReturnsOnCall(0, networkerror.InvalidAuthTokenError{}) + + fakeReadSeeker := new(cfnetworkingfakes.FakeReadSeeker) + fakeReadSeeker.SeekReturns(0, errors.New("oh noes")) + + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", fakeReadSeeker) + Expect(err).NotTo(HaveOccurred()) + request = cfnetworking.NewRequest(req, fakeReadSeeker) + }) + + It("returns error on seek", func() { + Expect(executeErr).To(MatchError("oh noes")) + }) + }) + }) + }) +}) diff --git a/api/cfnetworking/wrapper/util/in_memory_cache.go b/api/cfnetworking/wrapper/util/in_memory_cache.go new file mode 100644 index 00000000000..7e1f291fef5 --- /dev/null +++ b/api/cfnetworking/wrapper/util/in_memory_cache.go @@ -0,0 +1,26 @@ +package util + +type InMemoryCache struct { + accessToken string + refreshToken string +} + +func (c *InMemoryCache) AccessToken() string { + return c.accessToken +} + +func (c *InMemoryCache) RefreshToken() string { + return c.refreshToken +} + +func (c *InMemoryCache) SetAccessToken(token string) { + c.accessToken = token +} + +func (c *InMemoryCache) SetRefreshToken(token string) { + c.refreshToken = token +} + +func NewInMemoryTokenCache() *InMemoryCache { + return new(InMemoryCache) +} diff --git a/api/cfnetworking/wrapper/wrapper.go b/api/cfnetworking/wrapper/wrapper.go new file mode 100644 index 00000000000..c9964d98277 --- /dev/null +++ b/api/cfnetworking/wrapper/wrapper.go @@ -0,0 +1,3 @@ +package wrapper + +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/api/cfnetworking/wrapper/wrapper_suite_test.go b/api/cfnetworking/wrapper/wrapper_suite_test.go new file mode 100644 index 00000000000..36bb7436be4 --- /dev/null +++ b/api/cfnetworking/wrapper/wrapper_suite_test.go @@ -0,0 +1,35 @@ +package wrapper_test + +import ( + "bytes" + "log" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +func TestWrapper(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Wrapper Suite") +} + +var server *Server + +var _ = SynchronizedBeforeSuite(func() []byte { + return []byte{} +}, func(data []byte) { + server = NewTLSServer() + + // Suppresses ginkgo server logs + server.HTTPTestServer.Config.ErrorLog = log.New(&bytes.Buffer{}, "", 0) +}) + +var _ = SynchronizedAfterSuite(func() { + server.Close() +}, func() {}) + +var _ = BeforeEach(func() { + server.Reset() +}) diff --git a/api/cfnetworking/wrapper/wrapperfakes/fake_request_logger_output.go b/api/cfnetworking/wrapper/wrapperfakes/fake_request_logger_output.go new file mode 100644 index 00000000000..7d83cc31669 --- /dev/null +++ b/api/cfnetworking/wrapper/wrapperfakes/fake_request_logger_output.go @@ -0,0 +1,740 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package wrapperfakes + +import ( + "sync" + "time" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" +) + +type FakeRequestLoggerOutput struct { + DisplayHeaderStub func(string, string) error + displayHeaderMutex sync.RWMutex + displayHeaderArgsForCall []struct { + arg1 string + arg2 string + } + displayHeaderReturns struct { + result1 error + } + displayHeaderReturnsOnCall map[int]struct { + result1 error + } + DisplayHostStub func(string) error + displayHostMutex sync.RWMutex + displayHostArgsForCall []struct { + arg1 string + } + displayHostReturns struct { + result1 error + } + displayHostReturnsOnCall map[int]struct { + result1 error + } + DisplayJSONBodyStub func([]byte) error + displayJSONBodyMutex sync.RWMutex + displayJSONBodyArgsForCall []struct { + arg1 []byte + } + displayJSONBodyReturns struct { + result1 error + } + displayJSONBodyReturnsOnCall map[int]struct { + result1 error + } + DisplayMessageStub func(string) error + displayMessageMutex sync.RWMutex + displayMessageArgsForCall []struct { + arg1 string + } + displayMessageReturns struct { + result1 error + } + displayMessageReturnsOnCall map[int]struct { + result1 error + } + DisplayRequestHeaderStub func(string, string, string) error + displayRequestHeaderMutex sync.RWMutex + displayRequestHeaderArgsForCall []struct { + arg1 string + arg2 string + arg3 string + } + displayRequestHeaderReturns struct { + result1 error + } + displayRequestHeaderReturnsOnCall map[int]struct { + result1 error + } + DisplayResponseHeaderStub func(string, string) error + displayResponseHeaderMutex sync.RWMutex + displayResponseHeaderArgsForCall []struct { + arg1 string + arg2 string + } + displayResponseHeaderReturns struct { + result1 error + } + displayResponseHeaderReturnsOnCall map[int]struct { + result1 error + } + DisplayTypeStub func(string, time.Time) error + displayTypeMutex sync.RWMutex + displayTypeArgsForCall []struct { + arg1 string + arg2 time.Time + } + displayTypeReturns struct { + result1 error + } + displayTypeReturnsOnCall map[int]struct { + result1 error + } + HandleInternalErrorStub func(error) + handleInternalErrorMutex sync.RWMutex + handleInternalErrorArgsForCall []struct { + arg1 error + } + StartStub func() error + startMutex sync.RWMutex + startArgsForCall []struct { + } + startReturns struct { + result1 error + } + startReturnsOnCall map[int]struct { + result1 error + } + StopStub func() error + stopMutex sync.RWMutex + stopArgsForCall []struct { + } + stopReturns struct { + result1 error + } + stopReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeRequestLoggerOutput) DisplayHeader(arg1 string, arg2 string) error { + fake.displayHeaderMutex.Lock() + ret, specificReturn := fake.displayHeaderReturnsOnCall[len(fake.displayHeaderArgsForCall)] + fake.displayHeaderArgsForCall = append(fake.displayHeaderArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.DisplayHeaderStub + fakeReturns := fake.displayHeaderReturns + fake.recordInvocation("DisplayHeader", []interface{}{arg1, arg2}) + fake.displayHeaderMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayHeaderCallCount() int { + fake.displayHeaderMutex.RLock() + defer fake.displayHeaderMutex.RUnlock() + return len(fake.displayHeaderArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayHeaderCalls(stub func(string, string) error) { + fake.displayHeaderMutex.Lock() + defer fake.displayHeaderMutex.Unlock() + fake.DisplayHeaderStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayHeaderArgsForCall(i int) (string, string) { + fake.displayHeaderMutex.RLock() + defer fake.displayHeaderMutex.RUnlock() + argsForCall := fake.displayHeaderArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeRequestLoggerOutput) DisplayHeaderReturns(result1 error) { + fake.displayHeaderMutex.Lock() + defer fake.displayHeaderMutex.Unlock() + fake.DisplayHeaderStub = nil + fake.displayHeaderReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayHeaderReturnsOnCall(i int, result1 error) { + fake.displayHeaderMutex.Lock() + defer fake.displayHeaderMutex.Unlock() + fake.DisplayHeaderStub = nil + if fake.displayHeaderReturnsOnCall == nil { + fake.displayHeaderReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayHeaderReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayHost(arg1 string) error { + fake.displayHostMutex.Lock() + ret, specificReturn := fake.displayHostReturnsOnCall[len(fake.displayHostArgsForCall)] + fake.displayHostArgsForCall = append(fake.displayHostArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.DisplayHostStub + fakeReturns := fake.displayHostReturns + fake.recordInvocation("DisplayHost", []interface{}{arg1}) + fake.displayHostMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayHostCallCount() int { + fake.displayHostMutex.RLock() + defer fake.displayHostMutex.RUnlock() + return len(fake.displayHostArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayHostCalls(stub func(string) error) { + fake.displayHostMutex.Lock() + defer fake.displayHostMutex.Unlock() + fake.DisplayHostStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayHostArgsForCall(i int) string { + fake.displayHostMutex.RLock() + defer fake.displayHostMutex.RUnlock() + argsForCall := fake.displayHostArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeRequestLoggerOutput) DisplayHostReturns(result1 error) { + fake.displayHostMutex.Lock() + defer fake.displayHostMutex.Unlock() + fake.DisplayHostStub = nil + fake.displayHostReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayHostReturnsOnCall(i int, result1 error) { + fake.displayHostMutex.Lock() + defer fake.displayHostMutex.Unlock() + fake.DisplayHostStub = nil + if fake.displayHostReturnsOnCall == nil { + fake.displayHostReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayHostReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBody(arg1 []byte) error { + var arg1Copy []byte + if arg1 != nil { + arg1Copy = make([]byte, len(arg1)) + copy(arg1Copy, arg1) + } + fake.displayJSONBodyMutex.Lock() + ret, specificReturn := fake.displayJSONBodyReturnsOnCall[len(fake.displayJSONBodyArgsForCall)] + fake.displayJSONBodyArgsForCall = append(fake.displayJSONBodyArgsForCall, struct { + arg1 []byte + }{arg1Copy}) + stub := fake.DisplayJSONBodyStub + fakeReturns := fake.displayJSONBodyReturns + fake.recordInvocation("DisplayJSONBody", []interface{}{arg1Copy}) + fake.displayJSONBodyMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBodyCallCount() int { + fake.displayJSONBodyMutex.RLock() + defer fake.displayJSONBodyMutex.RUnlock() + return len(fake.displayJSONBodyArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBodyCalls(stub func([]byte) error) { + fake.displayJSONBodyMutex.Lock() + defer fake.displayJSONBodyMutex.Unlock() + fake.DisplayJSONBodyStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBodyArgsForCall(i int) []byte { + fake.displayJSONBodyMutex.RLock() + defer fake.displayJSONBodyMutex.RUnlock() + argsForCall := fake.displayJSONBodyArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBodyReturns(result1 error) { + fake.displayJSONBodyMutex.Lock() + defer fake.displayJSONBodyMutex.Unlock() + fake.DisplayJSONBodyStub = nil + fake.displayJSONBodyReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayJSONBodyReturnsOnCall(i int, result1 error) { + fake.displayJSONBodyMutex.Lock() + defer fake.displayJSONBodyMutex.Unlock() + fake.DisplayJSONBodyStub = nil + if fake.displayJSONBodyReturnsOnCall == nil { + fake.displayJSONBodyReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayJSONBodyReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayMessage(arg1 string) error { + fake.displayMessageMutex.Lock() + ret, specificReturn := fake.displayMessageReturnsOnCall[len(fake.displayMessageArgsForCall)] + fake.displayMessageArgsForCall = append(fake.displayMessageArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.DisplayMessageStub + fakeReturns := fake.displayMessageReturns + fake.recordInvocation("DisplayMessage", []interface{}{arg1}) + fake.displayMessageMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayMessageCallCount() int { + fake.displayMessageMutex.RLock() + defer fake.displayMessageMutex.RUnlock() + return len(fake.displayMessageArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayMessageCalls(stub func(string) error) { + fake.displayMessageMutex.Lock() + defer fake.displayMessageMutex.Unlock() + fake.DisplayMessageStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayMessageArgsForCall(i int) string { + fake.displayMessageMutex.RLock() + defer fake.displayMessageMutex.RUnlock() + argsForCall := fake.displayMessageArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeRequestLoggerOutput) DisplayMessageReturns(result1 error) { + fake.displayMessageMutex.Lock() + defer fake.displayMessageMutex.Unlock() + fake.DisplayMessageStub = nil + fake.displayMessageReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayMessageReturnsOnCall(i int, result1 error) { + fake.displayMessageMutex.Lock() + defer fake.displayMessageMutex.Unlock() + fake.DisplayMessageStub = nil + if fake.displayMessageReturnsOnCall == nil { + fake.displayMessageReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayMessageReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeader(arg1 string, arg2 string, arg3 string) error { + fake.displayRequestHeaderMutex.Lock() + ret, specificReturn := fake.displayRequestHeaderReturnsOnCall[len(fake.displayRequestHeaderArgsForCall)] + fake.displayRequestHeaderArgsForCall = append(fake.displayRequestHeaderArgsForCall, struct { + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + stub := fake.DisplayRequestHeaderStub + fakeReturns := fake.displayRequestHeaderReturns + fake.recordInvocation("DisplayRequestHeader", []interface{}{arg1, arg2, arg3}) + fake.displayRequestHeaderMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeaderCallCount() int { + fake.displayRequestHeaderMutex.RLock() + defer fake.displayRequestHeaderMutex.RUnlock() + return len(fake.displayRequestHeaderArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeaderCalls(stub func(string, string, string) error) { + fake.displayRequestHeaderMutex.Lock() + defer fake.displayRequestHeaderMutex.Unlock() + fake.DisplayRequestHeaderStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeaderArgsForCall(i int) (string, string, string) { + fake.displayRequestHeaderMutex.RLock() + defer fake.displayRequestHeaderMutex.RUnlock() + argsForCall := fake.displayRequestHeaderArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeaderReturns(result1 error) { + fake.displayRequestHeaderMutex.Lock() + defer fake.displayRequestHeaderMutex.Unlock() + fake.DisplayRequestHeaderStub = nil + fake.displayRequestHeaderReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayRequestHeaderReturnsOnCall(i int, result1 error) { + fake.displayRequestHeaderMutex.Lock() + defer fake.displayRequestHeaderMutex.Unlock() + fake.DisplayRequestHeaderStub = nil + if fake.displayRequestHeaderReturnsOnCall == nil { + fake.displayRequestHeaderReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayRequestHeaderReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeader(arg1 string, arg2 string) error { + fake.displayResponseHeaderMutex.Lock() + ret, specificReturn := fake.displayResponseHeaderReturnsOnCall[len(fake.displayResponseHeaderArgsForCall)] + fake.displayResponseHeaderArgsForCall = append(fake.displayResponseHeaderArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.DisplayResponseHeaderStub + fakeReturns := fake.displayResponseHeaderReturns + fake.recordInvocation("DisplayResponseHeader", []interface{}{arg1, arg2}) + fake.displayResponseHeaderMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeaderCallCount() int { + fake.displayResponseHeaderMutex.RLock() + defer fake.displayResponseHeaderMutex.RUnlock() + return len(fake.displayResponseHeaderArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeaderCalls(stub func(string, string) error) { + fake.displayResponseHeaderMutex.Lock() + defer fake.displayResponseHeaderMutex.Unlock() + fake.DisplayResponseHeaderStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeaderArgsForCall(i int) (string, string) { + fake.displayResponseHeaderMutex.RLock() + defer fake.displayResponseHeaderMutex.RUnlock() + argsForCall := fake.displayResponseHeaderArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeaderReturns(result1 error) { + fake.displayResponseHeaderMutex.Lock() + defer fake.displayResponseHeaderMutex.Unlock() + fake.DisplayResponseHeaderStub = nil + fake.displayResponseHeaderReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayResponseHeaderReturnsOnCall(i int, result1 error) { + fake.displayResponseHeaderMutex.Lock() + defer fake.displayResponseHeaderMutex.Unlock() + fake.DisplayResponseHeaderStub = nil + if fake.displayResponseHeaderReturnsOnCall == nil { + fake.displayResponseHeaderReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayResponseHeaderReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayType(arg1 string, arg2 time.Time) error { + fake.displayTypeMutex.Lock() + ret, specificReturn := fake.displayTypeReturnsOnCall[len(fake.displayTypeArgsForCall)] + fake.displayTypeArgsForCall = append(fake.displayTypeArgsForCall, struct { + arg1 string + arg2 time.Time + }{arg1, arg2}) + stub := fake.DisplayTypeStub + fakeReturns := fake.displayTypeReturns + fake.recordInvocation("DisplayType", []interface{}{arg1, arg2}) + fake.displayTypeMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) DisplayTypeCallCount() int { + fake.displayTypeMutex.RLock() + defer fake.displayTypeMutex.RUnlock() + return len(fake.displayTypeArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) DisplayTypeCalls(stub func(string, time.Time) error) { + fake.displayTypeMutex.Lock() + defer fake.displayTypeMutex.Unlock() + fake.DisplayTypeStub = stub +} + +func (fake *FakeRequestLoggerOutput) DisplayTypeArgsForCall(i int) (string, time.Time) { + fake.displayTypeMutex.RLock() + defer fake.displayTypeMutex.RUnlock() + argsForCall := fake.displayTypeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeRequestLoggerOutput) DisplayTypeReturns(result1 error) { + fake.displayTypeMutex.Lock() + defer fake.displayTypeMutex.Unlock() + fake.DisplayTypeStub = nil + fake.displayTypeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) DisplayTypeReturnsOnCall(i int, result1 error) { + fake.displayTypeMutex.Lock() + defer fake.displayTypeMutex.Unlock() + fake.DisplayTypeStub = nil + if fake.displayTypeReturnsOnCall == nil { + fake.displayTypeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.displayTypeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) HandleInternalError(arg1 error) { + fake.handleInternalErrorMutex.Lock() + fake.handleInternalErrorArgsForCall = append(fake.handleInternalErrorArgsForCall, struct { + arg1 error + }{arg1}) + stub := fake.HandleInternalErrorStub + fake.recordInvocation("HandleInternalError", []interface{}{arg1}) + fake.handleInternalErrorMutex.Unlock() + if stub != nil { + fake.HandleInternalErrorStub(arg1) + } +} + +func (fake *FakeRequestLoggerOutput) HandleInternalErrorCallCount() int { + fake.handleInternalErrorMutex.RLock() + defer fake.handleInternalErrorMutex.RUnlock() + return len(fake.handleInternalErrorArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) HandleInternalErrorCalls(stub func(error)) { + fake.handleInternalErrorMutex.Lock() + defer fake.handleInternalErrorMutex.Unlock() + fake.HandleInternalErrorStub = stub +} + +func (fake *FakeRequestLoggerOutput) HandleInternalErrorArgsForCall(i int) error { + fake.handleInternalErrorMutex.RLock() + defer fake.handleInternalErrorMutex.RUnlock() + argsForCall := fake.handleInternalErrorArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeRequestLoggerOutput) Start() error { + fake.startMutex.Lock() + ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] + fake.startArgsForCall = append(fake.startArgsForCall, struct { + }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns + fake.recordInvocation("Start", []interface{}{}) + fake.startMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) StartCallCount() int { + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + return len(fake.startArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) StartCalls(stub func() error) { + fake.startMutex.Lock() + defer fake.startMutex.Unlock() + fake.StartStub = stub +} + +func (fake *FakeRequestLoggerOutput) StartReturns(result1 error) { + fake.startMutex.Lock() + defer fake.startMutex.Unlock() + fake.StartStub = nil + fake.startReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) StartReturnsOnCall(i int, result1 error) { + fake.startMutex.Lock() + defer fake.startMutex.Unlock() + fake.StartStub = nil + if fake.startReturnsOnCall == nil { + fake.startReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.startReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) Stop() error { + fake.stopMutex.Lock() + ret, specificReturn := fake.stopReturnsOnCall[len(fake.stopArgsForCall)] + fake.stopArgsForCall = append(fake.stopArgsForCall, struct { + }{}) + stub := fake.StopStub + fakeReturns := fake.stopReturns + fake.recordInvocation("Stop", []interface{}{}) + fake.stopMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeRequestLoggerOutput) StopCallCount() int { + fake.stopMutex.RLock() + defer fake.stopMutex.RUnlock() + return len(fake.stopArgsForCall) +} + +func (fake *FakeRequestLoggerOutput) StopCalls(stub func() error) { + fake.stopMutex.Lock() + defer fake.stopMutex.Unlock() + fake.StopStub = stub +} + +func (fake *FakeRequestLoggerOutput) StopReturns(result1 error) { + fake.stopMutex.Lock() + defer fake.stopMutex.Unlock() + fake.StopStub = nil + fake.stopReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) StopReturnsOnCall(i int, result1 error) { + fake.stopMutex.Lock() + defer fake.stopMutex.Unlock() + fake.StopStub = nil + if fake.stopReturnsOnCall == nil { + fake.stopReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.stopReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRequestLoggerOutput) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.displayHeaderMutex.RLock() + defer fake.displayHeaderMutex.RUnlock() + fake.displayHostMutex.RLock() + defer fake.displayHostMutex.RUnlock() + fake.displayJSONBodyMutex.RLock() + defer fake.displayJSONBodyMutex.RUnlock() + fake.displayMessageMutex.RLock() + defer fake.displayMessageMutex.RUnlock() + fake.displayRequestHeaderMutex.RLock() + defer fake.displayRequestHeaderMutex.RUnlock() + fake.displayResponseHeaderMutex.RLock() + defer fake.displayResponseHeaderMutex.RUnlock() + fake.displayTypeMutex.RLock() + defer fake.displayTypeMutex.RUnlock() + fake.handleInternalErrorMutex.RLock() + defer fake.handleInternalErrorMutex.RUnlock() + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + fake.stopMutex.RLock() + defer fake.stopMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeRequestLoggerOutput) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ wrapper.RequestLoggerOutput = new(FakeRequestLoggerOutput) diff --git a/api/cfnetworking/wrapper/wrapperfakes/fake_token_cache.go b/api/cfnetworking/wrapper/wrapperfakes/fake_token_cache.go new file mode 100644 index 00000000000..7c5f78f9f84 --- /dev/null +++ b/api/cfnetworking/wrapper/wrapperfakes/fake_token_cache.go @@ -0,0 +1,245 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package wrapperfakes + +import ( + "sync" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" +) + +type FakeTokenCache struct { + AccessTokenStub func() string + accessTokenMutex sync.RWMutex + accessTokenArgsForCall []struct { + } + accessTokenReturns struct { + result1 string + } + accessTokenReturnsOnCall map[int]struct { + result1 string + } + RefreshTokenStub func() string + refreshTokenMutex sync.RWMutex + refreshTokenArgsForCall []struct { + } + refreshTokenReturns struct { + result1 string + } + refreshTokenReturnsOnCall map[int]struct { + result1 string + } + SetAccessTokenStub func(string) + setAccessTokenMutex sync.RWMutex + setAccessTokenArgsForCall []struct { + arg1 string + } + SetRefreshTokenStub func(string) + setRefreshTokenMutex sync.RWMutex + setRefreshTokenArgsForCall []struct { + arg1 string + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeTokenCache) AccessToken() string { + fake.accessTokenMutex.Lock() + ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] + fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { + }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns + fake.recordInvocation("AccessToken", []interface{}{}) + fake.accessTokenMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTokenCache) AccessTokenCallCount() int { + fake.accessTokenMutex.RLock() + defer fake.accessTokenMutex.RUnlock() + return len(fake.accessTokenArgsForCall) +} + +func (fake *FakeTokenCache) AccessTokenCalls(stub func() string) { + fake.accessTokenMutex.Lock() + defer fake.accessTokenMutex.Unlock() + fake.AccessTokenStub = stub +} + +func (fake *FakeTokenCache) AccessTokenReturns(result1 string) { + fake.accessTokenMutex.Lock() + defer fake.accessTokenMutex.Unlock() + fake.AccessTokenStub = nil + fake.accessTokenReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeTokenCache) AccessTokenReturnsOnCall(i int, result1 string) { + fake.accessTokenMutex.Lock() + defer fake.accessTokenMutex.Unlock() + fake.AccessTokenStub = nil + if fake.accessTokenReturnsOnCall == nil { + fake.accessTokenReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.accessTokenReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeTokenCache) RefreshToken() string { + fake.refreshTokenMutex.Lock() + ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] + fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { + }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns + fake.recordInvocation("RefreshToken", []interface{}{}) + fake.refreshTokenMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTokenCache) RefreshTokenCallCount() int { + fake.refreshTokenMutex.RLock() + defer fake.refreshTokenMutex.RUnlock() + return len(fake.refreshTokenArgsForCall) +} + +func (fake *FakeTokenCache) RefreshTokenCalls(stub func() string) { + fake.refreshTokenMutex.Lock() + defer fake.refreshTokenMutex.Unlock() + fake.RefreshTokenStub = stub +} + +func (fake *FakeTokenCache) RefreshTokenReturns(result1 string) { + fake.refreshTokenMutex.Lock() + defer fake.refreshTokenMutex.Unlock() + fake.RefreshTokenStub = nil + fake.refreshTokenReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeTokenCache) RefreshTokenReturnsOnCall(i int, result1 string) { + fake.refreshTokenMutex.Lock() + defer fake.refreshTokenMutex.Unlock() + fake.RefreshTokenStub = nil + if fake.refreshTokenReturnsOnCall == nil { + fake.refreshTokenReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.refreshTokenReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeTokenCache) SetAccessToken(arg1 string) { + fake.setAccessTokenMutex.Lock() + fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.SetAccessTokenStub + fake.recordInvocation("SetAccessToken", []interface{}{arg1}) + fake.setAccessTokenMutex.Unlock() + if stub != nil { + fake.SetAccessTokenStub(arg1) + } +} + +func (fake *FakeTokenCache) SetAccessTokenCallCount() int { + fake.setAccessTokenMutex.RLock() + defer fake.setAccessTokenMutex.RUnlock() + return len(fake.setAccessTokenArgsForCall) +} + +func (fake *FakeTokenCache) SetAccessTokenCalls(stub func(string)) { + fake.setAccessTokenMutex.Lock() + defer fake.setAccessTokenMutex.Unlock() + fake.SetAccessTokenStub = stub +} + +func (fake *FakeTokenCache) SetAccessTokenArgsForCall(i int) string { + fake.setAccessTokenMutex.RLock() + defer fake.setAccessTokenMutex.RUnlock() + argsForCall := fake.setAccessTokenArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeTokenCache) SetRefreshToken(arg1 string) { + fake.setRefreshTokenMutex.Lock() + fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.SetRefreshTokenStub + fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) + fake.setRefreshTokenMutex.Unlock() + if stub != nil { + fake.SetRefreshTokenStub(arg1) + } +} + +func (fake *FakeTokenCache) SetRefreshTokenCallCount() int { + fake.setRefreshTokenMutex.RLock() + defer fake.setRefreshTokenMutex.RUnlock() + return len(fake.setRefreshTokenArgsForCall) +} + +func (fake *FakeTokenCache) SetRefreshTokenCalls(stub func(string)) { + fake.setRefreshTokenMutex.Lock() + defer fake.setRefreshTokenMutex.Unlock() + fake.SetRefreshTokenStub = stub +} + +func (fake *FakeTokenCache) SetRefreshTokenArgsForCall(i int) string { + fake.setRefreshTokenMutex.RLock() + defer fake.setRefreshTokenMutex.RUnlock() + argsForCall := fake.setRefreshTokenArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeTokenCache) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.accessTokenMutex.RLock() + defer fake.accessTokenMutex.RUnlock() + fake.refreshTokenMutex.RLock() + defer fake.refreshTokenMutex.RUnlock() + fake.setAccessTokenMutex.RLock() + defer fake.setAccessTokenMutex.RUnlock() + fake.setRefreshTokenMutex.RLock() + defer fake.setRefreshTokenMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeTokenCache) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ wrapper.TokenCache = new(FakeTokenCache) diff --git a/api/cfnetworking/wrapper/wrapperfakes/fake_uaaclient.go b/api/cfnetworking/wrapper/wrapperfakes/fake_uaaclient.go new file mode 100644 index 00000000000..01522737530 --- /dev/null +++ b/api/cfnetworking/wrapper/wrapperfakes/fake_uaaclient.go @@ -0,0 +1,117 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package wrapperfakes + +import ( + "sync" + + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" +) + +type FakeUAAClient struct { + RefreshAccessTokenStub func(string) (uaa.RefreshedTokens, error) + refreshAccessTokenMutex sync.RWMutex + refreshAccessTokenArgsForCall []struct { + arg1 string + } + refreshAccessTokenReturns struct { + result1 uaa.RefreshedTokens + result2 error + } + refreshAccessTokenReturnsOnCall map[int]struct { + result1 uaa.RefreshedTokens + result2 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, error) { + fake.refreshAccessTokenMutex.Lock() + ret, specificReturn := fake.refreshAccessTokenReturnsOnCall[len(fake.refreshAccessTokenArgsForCall)] + fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns + fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) + fake.refreshAccessTokenMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeUAAClient) RefreshAccessTokenCallCount() int { + fake.refreshAccessTokenMutex.RLock() + defer fake.refreshAccessTokenMutex.RUnlock() + return len(fake.refreshAccessTokenArgsForCall) +} + +func (fake *FakeUAAClient) RefreshAccessTokenCalls(stub func(string) (uaa.RefreshedTokens, error)) { + fake.refreshAccessTokenMutex.Lock() + defer fake.refreshAccessTokenMutex.Unlock() + fake.RefreshAccessTokenStub = stub +} + +func (fake *FakeUAAClient) RefreshAccessTokenArgsForCall(i int) string { + fake.refreshAccessTokenMutex.RLock() + defer fake.refreshAccessTokenMutex.RUnlock() + argsForCall := fake.refreshAccessTokenArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeUAAClient) RefreshAccessTokenReturns(result1 uaa.RefreshedTokens, result2 error) { + fake.refreshAccessTokenMutex.Lock() + defer fake.refreshAccessTokenMutex.Unlock() + fake.RefreshAccessTokenStub = nil + fake.refreshAccessTokenReturns = struct { + result1 uaa.RefreshedTokens + result2 error + }{result1, result2} +} + +func (fake *FakeUAAClient) RefreshAccessTokenReturnsOnCall(i int, result1 uaa.RefreshedTokens, result2 error) { + fake.refreshAccessTokenMutex.Lock() + defer fake.refreshAccessTokenMutex.Unlock() + fake.RefreshAccessTokenStub = nil + if fake.refreshAccessTokenReturnsOnCall == nil { + fake.refreshAccessTokenReturnsOnCall = make(map[int]struct { + result1 uaa.RefreshedTokens + result2 error + }) + } + fake.refreshAccessTokenReturnsOnCall[i] = struct { + result1 uaa.RefreshedTokens + result2 error + }{result1, result2} +} + +func (fake *FakeUAAClient) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.refreshAccessTokenMutex.RLock() + defer fake.refreshAccessTokenMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeUAAClient) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ wrapper.UAAClient = new(FakeUAAClient) diff --git a/api/cloudcontroller/ccerror/ccerror_suite_test.go b/api/cloudcontroller/ccerror/ccerror_suite_test.go index 83106177c66..797f0f70c42 100644 --- a/api/cloudcontroller/ccerror/ccerror_suite_test.go +++ b/api/cloudcontroller/ccerror/ccerror_suite_test.go @@ -1,7 +1,7 @@ package ccerror_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/api/cloudcontroller/ccerror/multi_error_test.go b/api/cloudcontroller/ccerror/multi_error_test.go index 3f47bff273d..a1e40f3c18c 100644 --- a/api/cloudcontroller/ccerror/multi_error_test.go +++ b/api/cloudcontroller/ccerror/multi_error_test.go @@ -3,9 +3,9 @@ package ccerror_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccerror/service_instance_already_shared_error.go b/api/cloudcontroller/ccerror/service_instance_already_shared_error.go new file mode 100644 index 00000000000..9ff9c812b3c --- /dev/null +++ b/api/cloudcontroller/ccerror/service_instance_already_shared_error.go @@ -0,0 +1,11 @@ +package ccerror + +// ServiceInstanceAlreadySharedError is returned when a +// service instance is already shared. +type ServiceInstanceAlreadySharedError struct { + Message string +} + +func (e ServiceInstanceAlreadySharedError) Error() string { + return e.Message +} diff --git a/api/cloudcontroller/ccerror/service_offering_name_ambiguity_error_test.go b/api/cloudcontroller/ccerror/service_offering_name_ambiguity_error_test.go index bba9e873428..a654ca2f122 100644 --- a/api/cloudcontroller/ccerror/service_offering_name_ambiguity_error_test.go +++ b/api/cloudcontroller/ccerror/service_offering_name_ambiguity_error_test.go @@ -1,8 +1,8 @@ package ccerror_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccerror/service_offering_not_found_error_test.go b/api/cloudcontroller/ccerror/service_offering_not_found_error_test.go index d6364d723f8..0b122b11d5b 100644 --- a/api/cloudcontroller/ccerror/service_offering_not_found_error_test.go +++ b/api/cloudcontroller/ccerror/service_offering_not_found_error_test.go @@ -1,8 +1,8 @@ package ccerror_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccerror/user_not_found.go b/api/cloudcontroller/ccerror/user_not_found.go index 1ed3c3ee6c7..13e3a902077 100644 --- a/api/cloudcontroller/ccerror/user_not_found.go +++ b/api/cloudcontroller/ccerror/user_not_found.go @@ -3,7 +3,7 @@ package ccerror import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // UserNotFoundError is returned when a role does not exist. diff --git a/api/cloudcontroller/ccerror/v2_unexpected_response_error_test.go b/api/cloudcontroller/ccerror/v2_unexpected_response_error_test.go index afdaab8fef8..c40445248ad 100644 --- a/api/cloudcontroller/ccerror/v2_unexpected_response_error_test.go +++ b/api/cloudcontroller/ccerror/v2_unexpected_response_error_test.go @@ -1,9 +1,9 @@ package ccerror_test import ( - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccerror/v3_job_failed_error.go b/api/cloudcontroller/ccerror/v3_job_failed_error.go index aac4025f081..732cc898739 100644 --- a/api/cloudcontroller/ccerror/v3_job_failed_error.go +++ b/api/cloudcontroller/ccerror/v3_job_failed_error.go @@ -3,7 +3,7 @@ package ccerror import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // V3JobFailedError represents a failed Cloud Controller Job. It wraps the error diff --git a/api/cloudcontroller/ccerror/v3_unexpected_response_error_test.go b/api/cloudcontroller/ccerror/v3_unexpected_response_error_test.go index a5c8811693e..ece7202bfd7 100644 --- a/api/cloudcontroller/ccerror/v3_unexpected_response_error_test.go +++ b/api/cloudcontroller/ccerror/v3_unexpected_response_error_test.go @@ -3,9 +3,9 @@ package ccerror_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccv3/application.go b/api/cloudcontroller/ccv3/application.go index a060993253b..8de1d3b1b19 100644 --- a/api/cloudcontroller/ccv3/application.go +++ b/api/cloudcontroller/ccv3/application.go @@ -1,9 +1,9 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateApplication creates an application with the given settings. @@ -23,6 +23,8 @@ func (client *Client) GetApplicationByNameAndSpace(appName string, spaceGUID str apps, warnings, err := client.GetApplications( Query{Key: NameFilter, Values: []string{appName}}, Query{Key: SpaceGUIDFilter, Values: []string{spaceGUID}}, + Query{Key: PerPage, Values: []string{"1"}}, + Query{Key: Page, Values: []string{"1"}}, ) if err != nil { return resources.Application{}, warnings, err @@ -66,6 +68,19 @@ func (client *Client) UpdateApplication(app resources.Application) (resources.Ap return responseBody, warnings, err } +// UpdateApplicationName updates an application with the new name given +func (client *Client) UpdateApplicationName(newAppName string, appGUID string) (resources.Application, Warnings, error) { + var responseBody resources.Application + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.PatchApplicationRequest, + URIParams: internal.Params{"app_guid": appGUID}, + RequestBody: resources.ApplicationNameOnly{Name: newAppName}, + ResponseBody: &responseBody, + }) + + return responseBody, warnings, err +} + // UpdateApplicationRestart restarts the given application. func (client *Client) UpdateApplicationRestart(appGUID string) (resources.Application, Warnings, error) { var responseBody resources.Application diff --git a/api/cloudcontroller/ccv3/application_feature.go b/api/cloudcontroller/ccv3/application_feature.go index ee07cc6cf56..aa4f2ccc4b6 100644 --- a/api/cloudcontroller/ccv3/application_feature.go +++ b/api/cloudcontroller/ccv3/application_feature.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) type SSHEnabled struct { diff --git a/api/cloudcontroller/ccv3/application_feature_test.go b/api/cloudcontroller/ccv3/application_feature_test.go index e60d2192322..0c60b269537 100644 --- a/api/cloudcontroller/ccv3/application_feature_test.go +++ b/api/cloudcontroller/ccv3/application_feature_test.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/application_test.go b/api/cloudcontroller/ccv3/application_test.go index ff2bf9e4d4d..e7f5dce79b7 100644 --- a/api/cloudcontroller/ccv3/application_test.go +++ b/api/cloudcontroller/ccv3/application_test.go @@ -4,14 +4,14 @@ import ( "encoding/json" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -96,6 +96,17 @@ var _ = Describe("Application", func() { }) }) + When("lifecycle type cnb is provided", func() { + BeforeEach(func() { + app.LifecycleType = constant.AppLifecycleTypeCNB + app.LifecycleBuildpacks = []string{"docker://nodejs"} + }) + + It("sets the lifecycle buildpack to be empty in the JSON", func() { + Expect(string(appBytes)).To(MatchJSON(`{"lifecycle":{"data":{"buildpacks":["docker://nodejs"]},"type":"cnb"}}`)) + }) + }) + When("null buildpack is provided", func() { BeforeEach(func() { app.LifecycleBuildpacks = []string{"null"} @@ -206,7 +217,6 @@ var _ = Describe("Application", func() { }) When("lifecycle type buildpack is provided", func() { - When("other buildpacks are provided", func() { BeforeEach(func() { appBytes = []byte(`{"lifecycle":{"data":{"buildpacks":["some-buildpack"]},"type":"buildpack"}}`) @@ -358,6 +368,8 @@ var _ = Describe("Application", func() { Expect(actualParams.Query).To(Equal([]Query{ {Key: NameFilter, Values: []string{"some-app-name"}}, {Key: SpaceGUIDFilter, Values: []string{"some-space-guid"}}, + {Key: PerPage, Values: []string{"1"}}, + {Key: Page, Values: []string{"1"}}, })) _, ok := actualParams.ResponseBody.(resources.Application) Expect(ok).To(BeTrue()) @@ -614,6 +626,104 @@ var _ = Describe("Application", func() { }) }) + Describe("UpdateApplicationName", func() { + var ( + newAppName string + appGUID string + + updatedApp resources.Application + warnings Warnings + executeErr error + ) + + JustBeforeEach(func() { + newAppName = "some-new-app-name" + appGUID = "some-app-guid" + + updatedApp, warnings, executeErr = client.UpdateApplicationName(newAppName, appGUID) + }) + + When("the application successfully is updated", func() { + BeforeEach(func() { + requester.MakeRequestCalls(func(requestParams RequestParams) (JobURL, Warnings, error) { + requestParams.ResponseBody.(*resources.Application).GUID = appGUID + requestParams.ResponseBody.(*resources.Application).Name = requestParams.RequestBody.(resources.ApplicationNameOnly).Name + requestParams.ResponseBody.(*resources.Application).StackName = "some-stack-name" + requestParams.ResponseBody.(*resources.Application).LifecycleType = constant.AppLifecycleTypeBuildpack + requestParams.ResponseBody.(*resources.Application).LifecycleBuildpacks = []string{"some-buildpack"} + requestParams.ResponseBody.(*resources.Application).SpaceGUID = "some-space-guid" + return "", Warnings{"this is a warning"}, nil + }) + }) + + It("makes the correct request", func() { + Expect(requester.MakeRequestCallCount()).To(Equal(1)) + actualParams := requester.MakeRequestArgsForCall(0) + Expect(actualParams.RequestName).To(Equal(internal.PatchApplicationRequest)) + Expect(actualParams.URIParams).To(Equal(internal.Params{"app_guid": "some-app-guid"})) + Expect(actualParams.RequestBody).To(Equal(resources.ApplicationNameOnly{Name: newAppName})) + _, ok := actualParams.ResponseBody.(*resources.Application) + Expect(ok).To(BeTrue()) + }) + + It("returns the updated app and warnings", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("this is a warning")) + + Expect(updatedApp).To(Equal(resources.Application{ + GUID: "some-app-guid", + StackName: "some-stack-name", + LifecycleBuildpacks: []string{"some-buildpack"}, + LifecycleType: constant.AppLifecycleTypeBuildpack, + Name: "some-new-app-name", + SpaceGUID: "some-space-guid", + })) + }) + }) + + When("cc returns back an error or warnings", func() { + BeforeEach(func() { + errors := []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "App not found", + Title: "CF-ResourceNotFound", + }, + } + + requester.MakeRequestReturns( + "", + Warnings{"this is a warning"}, + ccerror.MultiError{ResponseCode: http.StatusTeapot, Errors: errors}, + ) + }) + + It("returns the error and all warnings", func() { + Expect(executeErr).To(MatchError(ccerror.MultiError{ + ResponseCode: http.StatusTeapot, + Errors: []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "App not found", + Title: "CF-ResourceNotFound", + }, + }, + })) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + }) + Describe("UpdateApplicationStop", func() { var ( responseApp resources.Application diff --git a/api/cloudcontroller/ccv3/build.go b/api/cloudcontroller/ccv3/build.go index 2c671892184..67e082ee9f9 100644 --- a/api/cloudcontroller/ccv3/build.go +++ b/api/cloudcontroller/ccv3/build.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateBuild creates the given build, requires Package GUID to be set on the diff --git a/api/cloudcontroller/ccv3/build_test.go b/api/cloudcontroller/ccv3/build_test.go index 2a2236c5ff3..33c799b8ba9 100644 --- a/api/cloudcontroller/ccv3/build_test.go +++ b/api/cloudcontroller/ccv3/build_test.go @@ -3,11 +3,11 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/buildpack.go b/api/cloudcontroller/ccv3/buildpack.go index 7846d58952e..f310cbf447f 100644 --- a/api/cloudcontroller/ccv3/buildpack.go +++ b/api/cloudcontroller/ccv3/buildpack.go @@ -3,9 +3,9 @@ package ccv3 import ( "io" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/api/cloudcontroller/uploads" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/uploads" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateBuildpack creates a buildpack with the given settings, Type and the diff --git a/api/cloudcontroller/ccv3/buildpack_test.go b/api/cloudcontroller/ccv3/buildpack_test.go index 5445d359413..265e34730d8 100644 --- a/api/cloudcontroller/ccv3/buildpack_test.go +++ b/api/cloudcontroller/ccv3/buildpack_test.go @@ -4,22 +4,20 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -69,7 +67,7 @@ var _ = Describe("Buildpacks", func() { "guid": "guid2", "name": "staticfile_buildpack", "state": "AWAITING_UPLOAD", - "stack": "cflinuxfs3", + "stack": "cflinuxfs4", "position": 2, "enabled": false, "locked": true, @@ -88,7 +86,7 @@ var _ = Describe("Buildpacks", func() { "guid": "guid3", "name": "go_buildpack", "state": "AWAITING_UPLOAD", - "stack": "cflinuxfs2", + "stack": "cflinuxfs4", "position": 3, "enabled": true, "locked": false, @@ -122,7 +120,7 @@ var _ = Describe("Buildpacks", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(buildpacks).To(ConsistOf( - Buildpack{ + resources.Buildpack{ Name: "ruby_buildpack", GUID: "guid1", Position: types.NullInt{Value: 1, IsSet: true}, @@ -130,27 +128,27 @@ var _ = Describe("Buildpacks", func() { Locked: types.NullBool{Value: false, IsSet: true}, Stack: "windows64", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, - Buildpack{ + resources.Buildpack{ Name: "staticfile_buildpack", GUID: "guid2", Position: types.NullInt{Value: 2, IsSet: true}, Enabled: types.NullBool{Value: false, IsSet: true}, Locked: types.NullBool{Value: true, IsSet: true}, - Stack: "cflinuxfs3", + Stack: "cflinuxfs4", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, - Buildpack{ + resources.Buildpack{ Name: "go_buildpack", GUID: "guid3", Position: types.NullInt{Value: 3, IsSet: true}, Enabled: types.NullBool{Value: true, IsSet: true}, Locked: types.NullBool{Value: false, IsSet: true}, - Stack: "cflinuxfs2", + Stack: "cflinuxfs4", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, )) Expect(warnings).To(ConsistOf("this is a warning", "this is another warning")) @@ -204,9 +202,9 @@ var _ = Describe("Buildpacks", func() { Describe("CreateBuildpack", func() { var ( - inputBuildpack Buildpack + inputBuildpack resources.Buildpack - bp Buildpack + bp resources.Buildpack warnings Warnings executeErr error ) @@ -217,7 +215,7 @@ var _ = Describe("Buildpacks", func() { When("the buildpack is successfully created", func() { BeforeEach(func() { - inputBuildpack = Buildpack{ + inputBuildpack = resources.Buildpack{ Name: "some-buildpack", Stack: "some-stack", } @@ -260,7 +258,7 @@ var _ = Describe("Buildpacks", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) - expectedBuildpack := Buildpack{ + expectedBuildpack := resources.Buildpack{ GUID: "some-bp-guid", Name: "some-buildpack", Stack: "some-stack", @@ -376,7 +374,7 @@ var _ = Describe("Buildpacks", func() { Expect(buildpackPart.FileName()).To(Equal("fake-buildpack.zip")) defer buildpackPart.Close() - partContents, err := ioutil.ReadAll(buildpackPart) + partContents, err := io.ReadAll(buildpackPart) Expect(err).ToNot(HaveOccurred()) Expect(string(partContents)).To(Equal(bpContent)) } @@ -461,7 +459,7 @@ var _ = Describe("Buildpacks", func() { defer GinkgoRecover() // Since this will be running in a thread if strings.HasSuffix(request.URL.String(), "/v3/buildpacks/some-buildpack-guid/upload") { - _, err := ioutil.ReadAll(request.Body) + _, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(request.Body.Close()).ToNot(HaveOccurred()) return request.ResetBody() @@ -490,7 +488,7 @@ var _ = Describe("Buildpacks", func() { if strings.HasSuffix(request.URL.String(), "/v3/buildpacks/some-buildpack-guid/upload") { defer request.Body.Close() - readBytes, err := ioutil.ReadAll(request.Body) + readBytes, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(len(readBytes)).To(BeNumerically(">", len(bpContent))) return expectedErr diff --git a/api/cloudcontroller/ccv3/ccv3_suite_test.go b/api/cloudcontroller/ccv3/ccv3_suite_test.go index c311fc4f311..a41a95fd5e7 100644 --- a/api/cloudcontroller/ccv3/ccv3_suite_test.go +++ b/api/cloudcontroller/ccv3/ccv3_suite_test.go @@ -5,9 +5,9 @@ import ( "log" "testing" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/ccv3fakes/fake_clock.go b/api/cloudcontroller/ccv3/ccv3fakes/fake_clock.go index 5c41fa00cda..efb16033463 100644 --- a/api/cloudcontroller/ccv3/ccv3fakes/fake_clock.go +++ b/api/cloudcontroller/ccv3/ccv3fakes/fake_clock.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" ) type FakeClock struct { @@ -28,15 +28,16 @@ func (fake *FakeClock) Now() time.Time { ret, specificReturn := fake.nowReturnsOnCall[len(fake.nowArgsForCall)] fake.nowArgsForCall = append(fake.nowArgsForCall, struct { }{}) + stub := fake.NowStub + fakeReturns := fake.nowReturns fake.recordInvocation("Now", []interface{}{}) fake.nowMutex.Unlock() - if fake.NowStub != nil { - return fake.NowStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.nowReturns return fakeReturns.result1 } diff --git a/api/cloudcontroller/ccv3/ccv3fakes/fake_connection_wrapper.go b/api/cloudcontroller/ccv3/ccv3fakes/fake_connection_wrapper.go index 46d95f6f2f3..d68345f3bb0 100644 --- a/api/cloudcontroller/ccv3/ccv3fakes/fake_connection_wrapper.go +++ b/api/cloudcontroller/ccv3/ccv3fakes/fake_connection_wrapper.go @@ -4,8 +4,8 @@ package ccv3fakes import ( "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" ) type FakeConnectionWrapper struct { @@ -43,15 +43,16 @@ func (fake *FakeConnectionWrapper) Make(arg1 *cloudcontroller.Request, arg2 *clo arg1 *cloudcontroller.Request arg2 *cloudcontroller.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } @@ -103,15 +104,16 @@ func (fake *FakeConnectionWrapper) Wrap(arg1 cloudcontroller.Connection) cloudco fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { arg1 cloudcontroller.Connection }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns fake.recordInvocation("Wrap", []interface{}{arg1}) fake.wrapMutex.Unlock() - if fake.WrapStub != nil { - return fake.WrapStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.wrapReturns return fakeReturns.result1 } diff --git a/api/cloudcontroller/ccv3/ccv3fakes/fake_reader.go b/api/cloudcontroller/ccv3/ccv3fakes/fake_reader.go index 09e6ccf14ce..395fb77fea9 100644 --- a/api/cloudcontroller/ccv3/ccv3fakes/fake_reader.go +++ b/api/cloudcontroller/ccv3/ccv3fakes/fake_reader.go @@ -35,15 +35,16 @@ func (fake *FakeReader) Read(arg1 []byte) (int, error) { fake.readArgsForCall = append(fake.readArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.ReadStub + fakeReturns := fake.readReturns fake.recordInvocation("Read", []interface{}{arg1Copy}) fake.readMutex.Unlock() - if fake.ReadStub != nil { - return fake.ReadStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/api/cloudcontroller/ccv3/ccv3fakes/fake_requester.go b/api/cloudcontroller/ccv3/ccv3fakes/fake_requester.go index 528b7ba15b2..44453af4880 100644 --- a/api/cloudcontroller/ccv3/ccv3fakes/fake_requester.go +++ b/api/cloudcontroller/ccv3/ccv3fakes/fake_requester.go @@ -6,8 +6,8 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) type FakeRequester struct { @@ -140,9 +140,10 @@ func (fake *FakeRequester) InitializeConnection(arg1 ccv3.TargetSettings) { fake.initializeConnectionArgsForCall = append(fake.initializeConnectionArgsForCall, struct { arg1 ccv3.TargetSettings }{arg1}) + stub := fake.InitializeConnectionStub fake.recordInvocation("InitializeConnection", []interface{}{arg1}) fake.initializeConnectionMutex.Unlock() - if fake.InitializeConnectionStub != nil { + if stub != nil { fake.InitializeConnectionStub(arg1) } } @@ -171,9 +172,10 @@ func (fake *FakeRequester) InitializeRouter(arg1 string) { fake.initializeRouterArgsForCall = append(fake.initializeRouterArgsForCall, struct { arg1 string }{arg1}) + stub := fake.InitializeRouterStub fake.recordInvocation("InitializeRouter", []interface{}{arg1}) fake.initializeRouterMutex.Unlock() - if fake.InitializeRouterStub != nil { + if stub != nil { fake.InitializeRouterStub(arg1) } } @@ -203,15 +205,16 @@ func (fake *FakeRequester) MakeListRequest(arg1 ccv3.RequestParams) (ccv3.Includ fake.makeListRequestArgsForCall = append(fake.makeListRequestArgsForCall, struct { arg1 ccv3.RequestParams }{arg1}) + stub := fake.MakeListRequestStub + fakeReturns := fake.makeListRequestReturns fake.recordInvocation("MakeListRequest", []interface{}{arg1}) fake.makeListRequestMutex.Unlock() - if fake.MakeListRequestStub != nil { - return fake.MakeListRequestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeListRequestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -269,15 +272,16 @@ func (fake *FakeRequester) MakeRequest(arg1 ccv3.RequestParams) (ccv3.JobURL, cc fake.makeRequestArgsForCall = append(fake.makeRequestArgsForCall, struct { arg1 ccv3.RequestParams }{arg1}) + stub := fake.MakeRequestStub + fakeReturns := fake.makeRequestReturns fake.recordInvocation("MakeRequest", []interface{}{arg1}) fake.makeRequestMutex.Unlock() - if fake.MakeRequestStub != nil { - return fake.MakeRequestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -337,15 +341,16 @@ func (fake *FakeRequester) MakeRequestReceiveRaw(arg1 string, arg2 internal.Para arg2 internal.Params arg3 string }{arg1, arg2, arg3}) + stub := fake.MakeRequestReceiveRawStub + fakeReturns := fake.makeRequestReceiveRawReturns fake.recordInvocation("MakeRequestReceiveRaw", []interface{}{arg1, arg2, arg3}) fake.makeRequestReceiveRawMutex.Unlock() - if fake.MakeRequestReceiveRawStub != nil { - return fake.MakeRequestReceiveRawStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestReceiveRawReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -412,15 +417,16 @@ func (fake *FakeRequester) MakeRequestSendRaw(arg1 string, arg2 internal.Params, arg4 string arg5 interface{} }{arg1, arg2, arg3Copy, arg4, arg5}) + stub := fake.MakeRequestSendRawStub + fakeReturns := fake.makeRequestSendRawReturns fake.recordInvocation("MakeRequestSendRaw", []interface{}{arg1, arg2, arg3Copy, arg4, arg5}) fake.makeRequestSendRawMutex.Unlock() - if fake.MakeRequestSendRawStub != nil { - return fake.MakeRequestSendRawStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestSendRawReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -486,15 +492,16 @@ func (fake *FakeRequester) MakeRequestSendReceiveRaw(arg1 string, arg2 string, a arg3 http.Header arg4 []byte }{arg1, arg2, arg3, arg4Copy}) + stub := fake.MakeRequestSendReceiveRawStub + fakeReturns := fake.makeRequestSendReceiveRawReturns fake.recordInvocation("MakeRequestSendReceiveRaw", []interface{}{arg1, arg2, arg3, arg4Copy}) fake.makeRequestSendReceiveRawMutex.Unlock() - if fake.MakeRequestSendReceiveRawStub != nil { - return fake.MakeRequestSendReceiveRawStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestSendReceiveRawReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -558,15 +565,16 @@ func (fake *FakeRequester) MakeRequestUploadAsync(arg1 string, arg2 internal.Par arg6 interface{} arg7 <-chan error }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) + stub := fake.MakeRequestUploadAsyncStub + fakeReturns := fake.makeRequestUploadAsyncReturns fake.recordInvocation("MakeRequestUploadAsync", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) fake.makeRequestUploadAsyncMutex.Unlock() - if fake.MakeRequestUploadAsyncStub != nil { - return fake.MakeRequestUploadAsyncStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeRequestUploadAsyncReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -623,9 +631,10 @@ func (fake *FakeRequester) WrapConnection(arg1 ccv3.ConnectionWrapper) { fake.wrapConnectionArgsForCall = append(fake.wrapConnectionArgsForCall, struct { arg1 ccv3.ConnectionWrapper }{arg1}) + stub := fake.WrapConnectionStub fake.recordInvocation("WrapConnection", []interface{}{arg1}) fake.wrapConnectionMutex.Unlock() - if fake.WrapConnectionStub != nil { + if stub != nil { fake.WrapConnectionStub(arg1) } } diff --git a/api/cloudcontroller/ccv3/client.go b/api/cloudcontroller/ccv3/client.go index 5a998f35154..060fd8779e4 100644 --- a/api/cloudcontroller/ccv3/client.go +++ b/api/cloudcontroller/ccv3/client.go @@ -7,9 +7,9 @@ // may include features and endpoints of later API versions. // // For more information on the Cloud Controller API see -// https://apidocs.cloudfoundry.org/ +// https://v2-apidocs.cloudfoundry.org/ // -// Method Naming Conventions +// # Method Naming Conventions // // The client takes a '' // approach to method names. If the and @@ -21,48 +21,50 @@ // word "Action" in the method name. // // For Example: -// Method Name: GetApplication -// Endpoint: /v3/applications/:guid -// Action Name: Get -// Top Level Endpoint: applications -// Return Value: Application -// -// Method Name: GetServiceInstances -// Endpoint: /v3/service_instances -// Action Name: Get -// Top Level Endpoint: service_instances -// Return Value: []ServiceInstance -// -// Method Name: GetSpaceServiceInstances -// Endpoint: /v3/spaces/:guid/service_instances -// Action Name: Get -// Top Level Endpoint: spaces -// Return Value: []ServiceInstance -// -// Method Name: CreateApplicationTask -// Endpoint: /v3/apps/:application_guid/task -// Action Name: Post -// Top Level Endpoint: apps -// Return Value: Task +// +// Method Name: GetApplication +// Endpoint: /v3/applications/:guid +// Action Name: Get +// Top Level Endpoint: applications +// Return Value: Application +// +// Method Name: GetServiceInstances +// Endpoint: /v3/service_instances +// Action Name: Get +// Top Level Endpoint: service_instances +// Return Value: []ServiceInstance +// +// Method Name: GetSpaceServiceInstances +// Endpoint: /v3/spaces/:guid/service_instances +// Action Name: Get +// Top Level Endpoint: spaces +// Return Value: []ServiceInstance +// +// Method Name: CreateApplicationTask +// Endpoint: /v3/apps/:application_guid/task +// Action Name: Post +// Top Level Endpoint: apps +// Return Value: Task // // Use the following table to determine which HTTP Command equates to which // Action Name: -// HTTP Command -> Action Name -// POST -> Create OR Update* -// GET -> Get -// PUT -> Update -// DELETE -> Delete -// PATCH -> Update +// +// HTTP Command -> Action Name +// POST -> Create OR Update* +// GET -> Get +// PUT -> Update +// DELETE -> Delete +// PATCH -> Update // // * - In some cases POSTs are updating resources, in these cases the method // should be called Update, not Create. // -// Method Locations +// # Method Locations // // Methods exist in the same file as their return type, regardless of which // endpoint they use. // -// Error Handling +// # Error Handling // // All error handling that requires parsing the error_code/code returned back // from the Cloud Controller should be placed in the errorWrapper. Everything @@ -75,7 +77,7 @@ package ccv3 import ( "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) // Warnings are a collection of warnings that the Cloud Controller can return @@ -84,7 +86,7 @@ type Warnings []string // Client can be used to talk to a Cloud Controller's V3 Endpoints. type Client struct { - Info + Root CloudControllerURL string Requester diff --git a/api/cloudcontroller/ccv3/client_test.go b/api/cloudcontroller/ccv3/client_test.go index 9cfaaa197dc..4e549a3f7aa 100644 --- a/api/cloudcontroller/ccv3/client_test.go +++ b/api/cloudcontroller/ccv3/client_test.go @@ -5,10 +5,10 @@ import ( "net/http" "runtime" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -63,7 +63,7 @@ var _ = Describe("Cloud Controller Client", func() { }) It("adds a user agent header", func() { - _, _, err := client.GetInfo() + _, _, err := client.GetRoot() Expect(err).ToNot(HaveOccurred()) Expect(server.ReceivedRequests()).To(HaveLen(1)) }) diff --git a/api/cloudcontroller/ccv3/connection_wrapper.go b/api/cloudcontroller/ccv3/connection_wrapper.go index 376891caddc..d3c2d27e43f 100644 --- a/api/cloudcontroller/ccv3/connection_wrapper.go +++ b/api/cloudcontroller/ccv3/connection_wrapper.go @@ -1,6 +1,6 @@ package ccv3 -import "code.cloudfoundry.org/cli/api/cloudcontroller" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ConnectionWrapper diff --git a/api/cloudcontroller/ccv3/constant/application.go b/api/cloudcontroller/ccv3/constant/application.go index b0acd644dc0..dca0b70af39 100644 --- a/api/cloudcontroller/ccv3/constant/application.go +++ b/api/cloudcontroller/ccv3/constant/application.go @@ -9,6 +9,9 @@ const ( // AppLifecycleTypeDocker will pull a docker image from a registry to run an // app. AppLifecycleTypeDocker AppLifecycleType = "docker" + // AppLifecycleTypeCNB will use a droplet (created with cloud native buildpacks) + // and a rootfs to run the app. + AppLifecycleTypeCNB AppLifecycleType = "cnb" ) // ApplicationAction represents the action being taken on an application diff --git a/api/cloudcontroller/ccv3/constant/deployment.go b/api/cloudcontroller/ccv3/constant/deployment.go index d324cb9aafb..2ae6159ebb7 100644 --- a/api/cloudcontroller/ccv3/constant/deployment.go +++ b/api/cloudcontroller/ccv3/constant/deployment.go @@ -5,51 +5,29 @@ package constant type DeploymentState string const ( - // DeploymentDeploying means the deployment is in state 'DEPLOYING' DeploymentDeploying DeploymentState = "DEPLOYING" - - // DeploymentCanceled means the deployment is in state 'CANCELED' - DeploymentCanceled DeploymentState = "CANCELED" - - // DeploymentDeployed means the deployment is in state 'DEPLOYED' - DeploymentDeployed DeploymentState = "DEPLOYED" - - // DeploymentCanceled means the deployment is in state 'CANCELING' + DeploymentCanceled DeploymentState = "CANCELED" + DeploymentDeployed DeploymentState = "DEPLOYED" DeploymentCanceling DeploymentState = "CANCELING" - - // DeploymentFailing means the deployment is in state 'FAILING' - DeploymentFailing DeploymentState = "FAILING" - - // DeploymentFailed means the deployment is in state 'FAILED' - DeploymentFailed DeploymentState = "FAILED" + DeploymentFailing DeploymentState = "FAILING" + DeploymentFailed DeploymentState = "FAILED" ) // DeploymentStatusReason describes the status reasons a deployment can have type DeploymentStatusReason string const ( - // DeploymentStatusReasonDeployed means the deployment's status.value is - // 'DEPLOYED' - DeploymentStatusReasonDeployed DeploymentStatusReason = "DEPLOYED" - - // DeploymentStatusReasonCanceled means the deployment's status.value is - // 'CANCELED' - DeploymentStatusReasonCanceled DeploymentStatusReason = "CANCELED" - - // DeploymentStatusReasonSuperseded means the deployment's status.value is - // 'SUPERSEDED' + DeploymentStatusReasonDeploying DeploymentStatusReason = "DEPLOYING" + DeploymentStatusReasonCanceling DeploymentStatusReason = "CANCELING" + DeploymentStatusReasonDeployed DeploymentStatusReason = "DEPLOYED" + DeploymentStatusReasonCanceled DeploymentStatusReason = "CANCELED" DeploymentStatusReasonSuperseded DeploymentStatusReason = "SUPERSEDED" + DeploymentStatusReasonPaused DeploymentStatusReason = "PAUSED" ) -// DeploymentStatusValue describes the status values a deployment can have type DeploymentStatusValue string const ( - // DeploymentStatusValueActive means the deployment's status.value is - // 'ACTIVE' - DeploymentStatusValueActive DeploymentStatusValue = "ACTIVE" - - // DeploymentStatusValueFinalized means the deployment's status.value is - // 'FINALIZED' + DeploymentStatusValueActive DeploymentStatusValue = "ACTIVE" DeploymentStatusValueFinalized DeploymentStatusValue = "FINALIZED" ) diff --git a/api/cloudcontroller/ccv3/constant/deployment_strategy.go b/api/cloudcontroller/ccv3/constant/deployment_strategy.go index 2e607f65541..de513bc614e 100644 --- a/api/cloudcontroller/ccv3/constant/deployment_strategy.go +++ b/api/cloudcontroller/ccv3/constant/deployment_strategy.go @@ -9,4 +9,7 @@ const ( // Rolling means a new web process will be created for the app and instances will roll from the old one to the new one. DeploymentStrategyRolling DeploymentStrategy = "rolling" + + // Canary means after a web process is created for the app the deployment will pause for evaluation until it is continued or canceled. + DeploymentStrategyCanary DeploymentStrategy = "canary" ) diff --git a/api/cloudcontroller/ccv3/constant/godoc.go b/api/cloudcontroller/ccv3/constant/godoc.go index f45e50016f7..089f7458ea2 100644 --- a/api/cloudcontroller/ccv3/constant/godoc.go +++ b/api/cloudcontroller/ccv3/constant/godoc.go @@ -6,13 +6,14 @@ // exception is 'state' types, where the word 'state' is omitted. // // For Example: -// Constant Type: PackageType -// Enum Name: Bits -// Enum Value: "bits" -// const PackageTypeBits PackageType = "bits" // -// Constant Type: PackageState -// Enum Name: Expired -// Enum Value: "EXPIRED" -// const PackageExpired PackageState = "EXPIRED" +// Constant Type: PackageType +// Enum Name: Bits +// Enum Value: "bits" +// const PackageTypeBits PackageType = "bits" +// +// Constant Type: PackageState +// Enum Name: Expired +// Enum Value: "EXPIRED" +// const PackageExpired PackageState = "EXPIRED" package constant diff --git a/api/cloudcontroller/ccv3/constant/relationships.go b/api/cloudcontroller/ccv3/constant/relationships.go index 6a8b3c12796..06e4eb3971e 100644 --- a/api/cloudcontroller/ccv3/constant/relationships.go +++ b/api/cloudcontroller/ccv3/constant/relationships.go @@ -21,4 +21,7 @@ const ( // RelationshipTypeQuota is a relationship with a Cloud Controller quota (org quota or space quota). RelationshipTypeQuota RelationshipType = "quota" + + // RelationshipTypeCurrentDroplet is a relationship with a Droplet. + RelationshipTypeCurrentDroplet RelationshipType = "current_droplet" ) diff --git a/api/cloudcontroller/ccv3/deployment.go b/api/cloudcontroller/ccv3/deployment.go index a4dc7da040f..9aa469bbb9c 100644 --- a/api/cloudcontroller/ccv3/deployment.go +++ b/api/cloudcontroller/ccv3/deployment.go @@ -1,42 +1,29 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) -func (client *Client) CancelDeployment(deploymentGUID string) (Warnings, error) { +func (client *Client) ContinueDeployment(deploymentGUID string) (Warnings, error) { _, warnings, err := client.MakeRequest(RequestParams{ - RequestName: internal.PostApplicationDeploymentActionCancelRequest, + RequestName: internal.PostApplicationDeploymentActionContinueRequest, URIParams: internal.Params{"deployment_guid": deploymentGUID}, }) return warnings, err } -func (client *Client) CreateApplicationDeployment(appGUID string, dropletGUID string) (string, Warnings, error) { - dep := resources.Deployment{ - DropletGUID: dropletGUID, - Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: appGUID}}, - } - - var responseBody resources.Deployment - +func (client *Client) CancelDeployment(deploymentGUID string) (Warnings, error) { _, warnings, err := client.MakeRequest(RequestParams{ - RequestName: internal.PostApplicationDeploymentRequest, - RequestBody: dep, - ResponseBody: &responseBody, + RequestName: internal.PostApplicationDeploymentActionCancelRequest, + URIParams: internal.Params{"deployment_guid": deploymentGUID}, }) - return responseBody.GUID, warnings, err + return warnings, err } -func (client *Client) CreateApplicationDeploymentByRevision(appGUID string, revisionGUID string) (string, Warnings, error) { - dep := resources.Deployment{ - RevisionGUID: revisionGUID, - Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: appGUID}}, - } +func (client *Client) CreateApplicationDeployment(dep resources.Deployment) (string, Warnings, error) { var responseBody resources.Deployment diff --git a/api/cloudcontroller/ccv3/deployment_test.go b/api/cloudcontroller/ccv3/deployment_test.go index 4c4e6c162d4..f96da5916d3 100644 --- a/api/cloudcontroller/ccv3/deployment_test.go +++ b/api/cloudcontroller/ccv3/deployment_test.go @@ -4,12 +4,13 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -165,7 +166,7 @@ var _ = Describe("Deployment", func() { }) }) - Describe("CreateApplicationDeployment", func() { + Describe("Create a deployment with app and droplet guids", func() { var ( deploymentGUID string warnings Warnings @@ -174,7 +175,11 @@ var _ = Describe("Deployment", func() { ) JustBeforeEach(func() { - deploymentGUID, warnings, executeErr = client.CreateApplicationDeployment("some-app-guid", dropletGUID) + var dep resources.Deployment + dep.Strategy = constant.DeploymentStrategyRolling + dep.DropletGUID = dropletGUID + dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}} + deploymentGUID, warnings, executeErr = client.CreateApplicationDeployment(dep) }) Context("when the application exists", func() { @@ -184,6 +189,7 @@ var _ = Describe("Deployment", func() { response = `{ "guid": "some-deployment-guid", "created_at": "2018-04-25T22:42:10Z", + "strategy": "rolling", "relationships": { "app": { "data": { @@ -199,7 +205,7 @@ var _ = Describe("Deployment", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodPost, "/v3/deployments"), - VerifyJSON(`{"droplet":{ "guid":"some-droplet-guid" }, "relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), + VerifyJSON(`{"droplet":{ "guid":"some-droplet-guid" }, "strategy": "rolling", "relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), RespondWith(http.StatusAccepted, response, http.Header{"X-Cf-Warnings": {"warning"}}), ), ) @@ -219,7 +225,7 @@ var _ = Describe("Deployment", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodPost, "/v3/deployments"), - VerifyJSON(`{"relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), + VerifyJSON(`{"strategy":"rolling", "relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), RespondWith(http.StatusAccepted, response, http.Header{"X-Cf-Warnings": {"warning"}}), ), ) @@ -233,7 +239,7 @@ var _ = Describe("Deployment", func() { }) }) - Describe("CreateApplicationDeploymentByRevision", func() { + Describe("Create a deployment with app and revision guids", func() { var ( deploymentGUID string warnings Warnings @@ -242,7 +248,16 @@ var _ = Describe("Deployment", func() { ) JustBeforeEach(func() { - deploymentGUID, warnings, executeErr = client.CreateApplicationDeploymentByRevision("some-app-guid", revisionGUID) + var dep resources.Deployment + dep.Strategy = constant.DeploymentStrategyCanary + dep.RevisionGUID = revisionGUID + dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}} + dep.Options.CanaryDeploymentOptions = &resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}}} + dep.Options.Instances = types.NullInt{IsSet: true, Value: 2} + dep.Options.MemoryInMB = types.NullUint64{IsSet: true, Value: 1024} + dep.Options.DiskInMB = types.NullUint64{IsSet: true, Value: 2048} + dep.Options.LogRateLimitInBPS = types.NullInt{IsSet: true, Value: 10} + deploymentGUID, warnings, executeErr = client.CreateApplicationDeployment(dep) }) Context("when the application exists", func() { @@ -252,6 +267,7 @@ var _ = Describe("Deployment", func() { response = `{ "guid": "some-deployment-guid", "created_at": "2018-04-25T22:42:10Z", + "strategy": "canary", "relationships": { "app": { "data": { @@ -267,7 +283,7 @@ var _ = Describe("Deployment", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodPost, "/v3/deployments"), - VerifyJSON(`{"revision":{ "guid":"some-revision-guid" }, "relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), + VerifyJSON(`{"revision":{ "guid":"some-revision-guid" }, "strategy": "canary", "relationships":{"app":{"data":{"guid":"some-app-guid"}}},"options":{"canary": {"steps": [{"instance_weight": 1}, {"instance_weight": 2}]},"web_instances": 2,"memory_in_mb": 1024,"disk_in_mb": 2048,"log_rate_limit_in_bytes_per_second": 10}}`), RespondWith(http.StatusAccepted, response, http.Header{"X-Cf-Warnings": {"warning"}}), ), ) @@ -280,6 +296,42 @@ var _ = Describe("Deployment", func() { }) }) }) + + When("the cloud controller version does not support canary deployment", func() { + BeforeEach(func() { + revisionGUID = "some-revision-guid" + response := `{ + "errors": [ + { + "code": 10008, + "detail": "Strategy 'canary' is not a supported deployment strategy", + "title": "CF-UnprocessableEntity" + } + ] +}` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPost, "/v3/deployments"), + VerifyJSON(`{"revision":{ "guid":"some-revision-guid" }, "strategy": "canary","options":{"canary": {"steps": [{"instance_weight": 1}, {"instance_weight": 2}]},"web_instances": 2,"memory_in_mb": 1024,"disk_in_mb": 2048,"log_rate_limit_in_bytes_per_second": 10}, "relationships":{"app":{"data":{"guid":"some-app-guid"}}}}`), + RespondWith(http.StatusTeapot, response, http.Header{}), + ), + ) + }) + + It("returns an error", func() { + Expect(executeErr).To(HaveOccurred()) + Expect(executeErr).To(MatchError(ccerror.V3UnexpectedResponseError{ + ResponseCode: http.StatusTeapot, + V3ErrorResponse: ccerror.V3ErrorResponse{ + Errors: []ccerror.V3Error{{ + Code: 10008, + Detail: "Strategy 'canary' is not a supported deployment strategy", + Title: "CF-UnprocessableEntity", + }}}, + }, + )) + }) + }) }) Describe("GetDeployment", func() { @@ -289,9 +341,16 @@ var _ = Describe("Deployment", func() { response = `{ "guid": "some-deployment-guid", "state": "DEPLOYED", + "strategy": "canary", "status": { "value": "FINALIZED", - "reason": "SUPERSEDED" + "reason": "SUPERSEDED", + "canary": { + "steps": { + "current": 4, + "total": 5 + } + } }, "droplet": { "guid": "some-droplet-guid" @@ -325,6 +384,9 @@ var _ = Describe("Deployment", func() { Expect(deployment.State).To(Equal(constant.DeploymentDeployed)) Expect(deployment.StatusValue).To(Equal(constant.DeploymentStatusValueFinalized)) Expect(deployment.StatusReason).To(Equal(constant.DeploymentStatusReasonSuperseded)) + Expect(deployment.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(deployment.CanaryStatus.Steps.CurrentStep).To(Equal(4)) + Expect(deployment.CanaryStatus.Steps.TotalSteps).To(Equal(5)) }) }) diff --git a/api/cloudcontroller/ccv3/domain.go b/api/cloudcontroller/ccv3/domain.go index 6b0aae2141c..c933d17e70e 100644 --- a/api/cloudcontroller/ccv3/domain.go +++ b/api/cloudcontroller/ccv3/domain.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) type SharedOrgs struct { diff --git a/api/cloudcontroller/ccv3/domain_test.go b/api/cloudcontroller/ccv3/domain_test.go index 29bf6e6397f..ecd529e62cc 100644 --- a/api/cloudcontroller/ccv3/domain_test.go +++ b/api/cloudcontroller/ccv3/domain_test.go @@ -4,12 +4,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/droplet.go b/api/cloudcontroller/ccv3/droplet.go index 7d9bfe5e703..e846864caf3 100644 --- a/api/cloudcontroller/ccv3/droplet.go +++ b/api/cloudcontroller/ccv3/droplet.go @@ -3,10 +3,10 @@ package ccv3 import ( "io" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/api/cloudcontroller/uploads" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/uploads" + "code.cloudfoundry.org/cli/v8/resources" ) type DropletCreateRequest struct { diff --git a/api/cloudcontroller/ccv3/droplet_test.go b/api/cloudcontroller/ccv3/droplet_test.go index 6c4ce7bd634..c482834f131 100644 --- a/api/cloudcontroller/ccv3/droplet_test.go +++ b/api/cloudcontroller/ccv3/droplet_test.go @@ -3,21 +3,20 @@ package ccv3_test import ( "errors" "io" - "io/ioutil" "mime/multipart" "net/http" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -263,7 +262,7 @@ var _ = Describe("Droplet", func() { Expect(dropletPart.FileName()).To(Equal("fake-droplet.tgz")) defer dropletPart.Close() - partContents, err := ioutil.ReadAll(dropletPart) + partContents, err := io.ReadAll(dropletPart) Expect(err).ToNot(HaveOccurred()) Expect(string(partContents)).To(Equal(dropletContent)) } @@ -375,7 +374,7 @@ var _ = Describe("Droplet", func() { defer GinkgoRecover() // Since this will be running in a thread if strings.HasSuffix(request.URL.String(), "/v3/droplets/some-droplet-guid/upload") { - _, err := ioutil.ReadAll(request.Body) + _, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(request.Body.Close()).ToNot(HaveOccurred()) return request.ResetBody() @@ -404,7 +403,7 @@ var _ = Describe("Droplet", func() { if strings.HasSuffix(request.URL.String(), "/v3/droplets/some-droplet-guid/upload") { defer request.Body.Close() - readBytes, err := ioutil.ReadAll(request.Body) + readBytes, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(len(readBytes)).To(BeNumerically(">", len(dropletContent))) return expectedErr @@ -434,7 +433,7 @@ var _ = Describe("Droplet", func() { }) BeforeEach(func() { - requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, ccv3.Warnings, error) { + requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, Warnings, error) { return []byte{'d', 'r', 'o', 'p'}, Warnings{"some-warning"}, errors.New("some-error") }) }) diff --git a/api/cloudcontroller/ccv3/environment.go b/api/cloudcontroller/ccv3/environment.go index 45af18d5bbe..28b3c1be2ed 100644 --- a/api/cloudcontroller/ccv3/environment.go +++ b/api/cloudcontroller/ccv3/environment.go @@ -1,7 +1,7 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) // Environment variables that will be provided to an app at runtime. It will @@ -13,11 +13,11 @@ type Environment struct { Application map[string]interface{} `json:"application_env_json"` // EnvironmentVariables are user provided environment variables. EnvironmentVariables map[string]interface{} `json:"environment_variables"` - //Running is the set of default environment variables available to running - //apps. + // Running is the set of default environment variables available to running + // apps. Running map[string]interface{} `json:"running_env_json"` - //Staging is the set of default environment variables available during - //staging. + // Staging is the set of default environment variables available during + // staging. Staging map[string]interface{} `json:"staging_env_json"` // System contains information about bound services for the application. AKA // VCAP_SERVICES. diff --git a/api/cloudcontroller/ccv3/environment_test.go b/api/cloudcontroller/ccv3/environment_test.go index d4bfcf9dfaf..1b95f7af8f3 100644 --- a/api/cloudcontroller/ccv3/environment_test.go +++ b/api/cloudcontroller/ccv3/environment_test.go @@ -3,9 +3,9 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/environment_variables.go b/api/cloudcontroller/ccv3/environment_variables.go index 22c50d8f97c..e8384790c72 100644 --- a/api/cloudcontroller/ccv3/environment_variables.go +++ b/api/cloudcontroller/ccv3/environment_variables.go @@ -1,9 +1,9 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // EnvironmentVariables represents the environment variables that can be set on diff --git a/api/cloudcontroller/ccv3/environment_variables_test.go b/api/cloudcontroller/ccv3/environment_variables_test.go index 4735e641eb0..2f4e227dc94 100644 --- a/api/cloudcontroller/ccv3/environment_variables_test.go +++ b/api/cloudcontroller/ccv3/environment_variables_test.go @@ -3,11 +3,11 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/errors.go b/api/cloudcontroller/ccv3/errors.go index 1a593a5fe1f..a153545dd26 100644 --- a/api/cloudcontroller/ccv3/errors.go +++ b/api/cloudcontroller/ccv3/errors.go @@ -6,8 +6,8 @@ import ( "regexp" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" ) const ( @@ -146,7 +146,7 @@ func handleNotFound(errorResponse ccerror.V3Error, request *cloudcontroller.Requ } func handleUnprocessableEntity(errorResponse ccerror.V3Error) error { - //idea to make route already exist error flexible for all relevant error cases + // idea to make route already exist error flexible for all relevant error cases errorString := errorResponse.Detail err := ccerror.UnprocessableEntityError{Message: errorResponse.Detail} appNameTakenRegexp := regexp.MustCompile(`App with the name '.*' already exists\.`) @@ -154,6 +154,7 @@ func handleUnprocessableEntity(errorResponse ccerror.V3Error) error { roleExistsRegexp := regexp.MustCompile(`User '.*' already has '.*' role.*`) quotaExistsRegexp := regexp.MustCompile(`.* Quota '.*' already exists\.`) securityGroupExistsRegexp := regexp.MustCompile(`Security group with name '.*' already exists\.`) + serviceInstanceSharedRegexp := regexp.MustCompile(`A service instance called .* has already been shared with .*\.`) // boolean switch case with partial/regex string matchers switch { @@ -171,6 +172,11 @@ func handleUnprocessableEntity(errorResponse ccerror.V3Error) error { case strings.Contains(errorString, "Assign a droplet before starting this app."): return ccerror.InvalidStartError{} + case strings.Contains(errorString, + "The service instance name is taken"): + return ccerror.ServiceInstanceNameTakenError{Message: err.Message} + case serviceInstanceSharedRegexp.MatchString(errorString): + return ccerror.ServiceInstanceAlreadySharedError{Message: err.Message} case orgNameTakenRegexp.MatchString(errorString): return ccerror.OrganizationNameTakenError{UnprocessableEntityError: err} case roleExistsRegexp.MatchString(errorString): diff --git a/api/cloudcontroller/ccv3/errors_test.go b/api/cloudcontroller/ccv3/errors_test.go index 8785a9a848c..7e633d05556 100644 --- a/api/cloudcontroller/ccv3/errors_test.go +++ b/api/cloudcontroller/ccv3/errors_test.go @@ -3,10 +3,10 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -486,6 +486,48 @@ var _ = Describe("Error Wrapper", func() { }) }) + When("the service instance name is taken", func() { + BeforeEach(func() { + serverResponse = ` +{ + "errors": [ + { + "code": 10008, + "detail": "The service instance name is taken", + "title": "CF-UnprocessableEntity" + } + ] +}` + }) + + It("returns an ServiceInstanceNameTakenError", func() { + Expect(makeError).To(MatchError(ccerror.ServiceInstanceNameTakenError{ + Message: "The service instance name is taken", + })) + }) + }) + + When("the service instance has already been shared", func() { + BeforeEach(func() { + serverResponse = ` +{ + "errors": [ + { + "code": 10008, + "detail": "A service instance called foo has already been shared with foo-space.", + "title": "CF-UnprocessableEntity" + } + ] +}` + }) + + It("returns an ServiceInstanceAlreadySharedError", func() { + Expect(makeError).To(MatchError(ccerror.ServiceInstanceAlreadySharedError{ + Message: "A service instance called foo has already been shared with foo-space.", + })) + }) + }) + When("the buildpack is invalid", func() { BeforeEach(func() { serverResponse = ` diff --git a/api/cloudcontroller/ccv3/event.go b/api/cloudcontroller/ccv3/event.go index bedc56faf8c..685736c742c 100644 --- a/api/cloudcontroller/ccv3/event.go +++ b/api/cloudcontroller/ccv3/event.go @@ -3,8 +3,8 @@ package ccv3 import ( "time" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) type Event struct { @@ -40,19 +40,18 @@ func (e *Event) UnmarshalJSON(data []byte) error { } // GetEvents uses the /v3/audit_events endpoint to retrieve a list of audit events. -// NOTE: This only returns the first page of results. We are intentionally not using the paginate helper to fetch all -// pages here because we only needed the first page for the `cf events` output. If we need to, we can refactor this -// later to fetch all pages and make `cf events` only filter down to the first page. func (client *Client) GetEvents(query ...Query) ([]Event, Warnings, error) { - var responseBody struct { - Resources []Event `json:"resources"` - } + var events []Event - _, warnings, err := client.MakeRequest(RequestParams{ + _, warnings, err := client.MakeListRequest(RequestParams{ RequestName: internal.GetEventsRequest, - ResponseBody: &responseBody, Query: query, + ResponseBody: Event{}, + AppendToList: func(item interface{}) error { + events = append(events, item.(Event)) + return nil + }, }) - return responseBody.Resources, warnings, err + return events, warnings, err } diff --git a/api/cloudcontroller/ccv3/event_test.go b/api/cloudcontroller/ccv3/event_test.go index 0f353910a86..643fd555a31 100644 --- a/api/cloudcontroller/ccv3/event_test.go +++ b/api/cloudcontroller/ccv3/event_test.go @@ -5,10 +5,10 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -31,7 +31,8 @@ var _ = Describe("Event", func() { events, warnings, executeErr = client.GetEvents( Query{Key: TargetGUIDFilter, Values: []string{"some-target-guid"}}, Query{Key: OrderBy, Values: []string{"-created_at"}}, - Query{Key: PerPage, Values: []string{"1"}}) + Query{Key: PerPage, Values: []string{"1"}}, + Query{Key: Page, Values: []string{"1"}}) }) var response string @@ -86,7 +87,7 @@ var _ = Describe("Event", func() { BeforeEach(func() { server.AppendHandlers( CombineHandlers( - VerifyRequest(http.MethodGet, "/v3/audit_events", "target_guids=some-target-guid&order_by=-created_at&per_page=1"), + VerifyRequest(http.MethodGet, "/v3/audit_events", "target_guids=some-target-guid&order_by=-created_at&per_page=1&page=1"), RespondWith(http.StatusAccepted, response, http.Header{"X-Cf-Warnings": {"warning"}}), ), ) @@ -132,7 +133,7 @@ var _ = Describe("Event", func() { server.AppendHandlers( CombineHandlers( - VerifyRequest(http.MethodGet, "/v3/audit_events", "target_guids=some-target-guid&order_by=-created_at&per_page=1"), + VerifyRequest(http.MethodGet, "/v3/audit_events", "target_guids=some-target-guid&order_by=-created_at&per_page=1&page=1"), RespondWith(http.StatusTeapot, response, http.Header{"X-Cf-Warnings": {"warning"}}), ), ) diff --git a/api/cloudcontroller/ccv3/feature_flag.go b/api/cloudcontroller/ccv3/feature_flag.go index 80f775acc8e..98da5cb50c5 100644 --- a/api/cloudcontroller/ccv3/feature_flag.go +++ b/api/cloudcontroller/ccv3/feature_flag.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) GetFeatureFlag(flagName string) (resources.FeatureFlag, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/feature_flag_test.go b/api/cloudcontroller/ccv3/feature_flag_test.go index a8c8aa1d113..121f62e1fab 100644 --- a/api/cloudcontroller/ccv3/feature_flag_test.go +++ b/api/cloudcontroller/ccv3/feature_flag_test.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/included_resources.go b/api/cloudcontroller/ccv3/included_resources.go index 0044707663a..aa25d3f82fd 100644 --- a/api/cloudcontroller/ccv3/included_resources.go +++ b/api/cloudcontroller/ccv3/included_resources.go @@ -1,6 +1,6 @@ package ccv3 -import "code.cloudfoundry.org/cli/resources" +import "code.cloudfoundry.org/cli/v8/resources" type IncludedResources struct { Users []resources.User `json:"users,omitempty"` @@ -12,3 +12,14 @@ type IncludedResources struct { ServicePlans []resources.ServicePlan `json:"service_plans,omitempty"` Apps []resources.Application `json:"apps,omitempty"` } + +func (i *IncludedResources) Merge(resources IncludedResources) { + i.Apps = append(i.Apps, resources.Apps...) + i.Users = append(i.Users, resources.Users...) + i.Organizations = append(i.Organizations, resources.Organizations...) + i.Spaces = append(i.Spaces, resources.Spaces...) + i.ServiceBrokers = append(i.ServiceBrokers, resources.ServiceBrokers...) + i.ServiceInstances = append(i.ServiceInstances, resources.ServiceInstances...) + i.ServiceOfferings = append(i.ServiceOfferings, resources.ServiceOfferings...) + i.ServicePlans = append(i.ServicePlans, resources.ServicePlans...) +} diff --git a/api/cloudcontroller/ccv3/info.go b/api/cloudcontroller/ccv3/info.go index 8a2e694a18c..18cc56d48ce 100644 --- a/api/cloudcontroller/ccv3/info.go +++ b/api/cloudcontroller/ccv3/info.go @@ -3,139 +3,22 @@ package ccv3 import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) -type InfoLinks struct { - // AppSSH is the link for application ssh info. - AppSSH resources.APILink `json:"app_ssh"` - - // CCV3 is the link to the Cloud Controller V3 API. - CCV3 resources.APILink `json:"cloud_controller_v3"` - - // Logging is the link to the Logging API. - Logging resources.APILink `json:"logging"` - - // Logging is the link to the Logging API. - LogCache resources.APILink `json:"log_cache"` - - // NetworkPolicyV1 is the link to the Container to Container Networking - // API. - NetworkPolicyV1 resources.APILink `json:"network_policy_v1"` - - // Routing is the link to the routing API - Routing resources.APILink `json:"routing"` - - // UAA is the link to the UAA API. - UAA resources.APILink `json:"uaa"` - - // Login is the link to the Login API. - Login resources.APILink `json:"login"` -} - -// Info represents a GET response from the '/' endpoint of the cloud -// controller API. type Info struct { - // Links is a list of top level Cloud Controller APIs. - Links InfoLinks `json:"links"` - CFOnK8s bool `json:"cf_on_k8s"` -} - -// AppSSHEndpoint returns the HREF for SSHing into an app container. -func (info Info) AppSSHEndpoint() string { - return info.Links.AppSSH.HREF + Name string `json:"name"` + Build string `json:"build"` + OSBAPIVersion string `json:"osbapi_version"` } -// AppSSHHostKeyFingerprint returns the SSH key fingerprint of the SSH proxy -// that brokers connections to application instances. -func (info Info) AppSSHHostKeyFingerprint() string { - return info.Links.AppSSH.Meta.HostKeyFingerprint -} - -// CloudControllerAPIVersion returns the version of the CloudController. -func (info Info) CloudControllerAPIVersion() string { - return info.Links.CCV3.Meta.Version -} - -// LogCache returns the HREF of the Loggregator Traffic Controller. -func (info Info) LogCache() string { - return info.Links.LogCache.HREF -} - -// Logging returns the HREF of the Loggregator Traffic Controller. -func (info Info) Logging() string { - return info.Links.Logging.HREF -} - -// NetworkPolicyV1 returns the HREF of the Container Networking v1 Policy API -func (info Info) NetworkPolicyV1() string { - return info.Links.NetworkPolicyV1.HREF -} - -// OAuthClient returns the oauth client ID of the SSH proxy that brokers -// connections to application instances. -func (info Info) OAuthClient() string { - return info.Links.AppSSH.Meta.OAuthClient -} - -// Routing returns the HREF of the routing API. -func (info Info) Routing() string { - return info.Links.Routing.HREF -} - -// UAA returns the HREF of the UAA server. -func (info Info) UAA() string { - return info.Links.UAA.HREF -} - -// Login returns the HREF of the login server. -func (info Info) Login() string { - return info.Links.Login.HREF -} - -// ccv3Link returns the HREF of the CloudController v3 API. -func (info Info) ccV3Link() string { - return info.Links.CCV3.HREF -} - -// ResourceLinks represents the information returned back from /v3. -type ResourceLinks map[string]resources.APILink - -// UnmarshalJSON helps unmarshal a Cloud Controller /v3 response. -func (links ResourceLinks) UnmarshalJSON(data []byte) error { - var ccResourceLinks struct { - Links map[string]resources.APILink `json:"links"` - } - err := cloudcontroller.DecodeJSON(data, &ccResourceLinks) - if err != nil { - return err - } - - for key, val := range ccResourceLinks.Links { - links[key] = val - } - - return nil -} - -// GetInfo returns endpoint and API information from /v3. +// GetRoot returns the /v3/info response func (client *Client) GetInfo() (Info, Warnings, error) { - rootResponse, warnings, err := client.RootResponse() - if err != nil { - return Info{}, warnings, err - } - - return rootResponse, warnings, err -} - -// rootResponse returns the CC API root document. -func (client *Client) RootResponse() (Info, Warnings, error) { var responseBody Info _, warnings, err := client.MakeRequest(RequestParams{ - URL: client.CloudControllerURL, + RequestName: internal.Info, ResponseBody: &responseBody, }) diff --git a/api/cloudcontroller/ccv3/info_test.go b/api/cloudcontroller/ccv3/info_test.go index 8f77db3ba96..2c895c4c992 100644 --- a/api/cloudcontroller/ccv3/info_test.go +++ b/api/cloudcontroller/ccv3/info_test.go @@ -1,30 +1,27 @@ package ccv3_test import ( - "fmt" "net/http" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) var _ = Describe("Info", func() { var ( - client *Client - rootRespondWith http.HandlerFunc - - info Info - warnings Warnings - executeErr error + client *Client + respondWith http.HandlerFunc + info Info + warnings Warnings + executeErr error ) - BeforeEach(func() { - rootRespondWith = nil + respondWith = nil }) JustBeforeEach(func() { @@ -32,8 +29,8 @@ var _ = Describe("Info", func() { server.AppendHandlers( CombineHandlers( - VerifyRequest(http.MethodGet, "/"), - rootRespondWith, + VerifyRequest(http.MethodGet, "/v3/info"), + respondWith, ), ) @@ -42,79 +39,35 @@ var _ = Describe("Info", func() { Describe("when all requests are successful", func() { BeforeEach(func() { - rootResponse := strings.Replace(`{ - "links": { - "self": { - "href": "SERVER_URL" - }, - "cloud_controller_v2": { - "href": "SERVER_URL/v2", - "meta": { - "version": "2.64.0" - } - }, - "cloud_controller_v3": { - "href": "SERVER_URL/v3", - "meta": { - "version": "3.0.0-alpha.5" - } - }, - "network_policy_v1": { - "href": "SERVER_URL/networking/v1/external" - }, - "uaa": { - "href": "https://uaa.bosh-lite.com" - }, - "logging": { - "href": "wss://doppler.bosh-lite.com:443" - }, - "app_ssh": { - "href": "ssh.bosh-lite.com:2222", - "meta": { - "host_key_fingerprint": "some-fingerprint", - "oath_client": "some-client" - } - } - } + response := strings.Replace(`{ + "name": "test-name", + "build": "test-build", + "osbapi_version": "1.0" }`, "SERVER_URL", server.URL(), -1) - rootRespondWith = RespondWith( + respondWith = RespondWith( http.StatusOK, - rootResponse, + response, http.Header{"X-Cf-Warnings": {"warning 1"}}) }) It("returns the CC Information", func() { Expect(executeErr).NotTo(HaveOccurred()) - Expect(info.UAA()).To(Equal("https://uaa.bosh-lite.com")) - Expect(info.Logging()).To(Equal("wss://doppler.bosh-lite.com:443")) - Expect(info.NetworkPolicyV1()).To(Equal(fmt.Sprintf("%s/networking/v1/external", server.URL()))) - Expect(info.AppSSHHostKeyFingerprint()).To(Equal("some-fingerprint")) - Expect(info.AppSSHEndpoint()).To(Equal("ssh.bosh-lite.com:2222")) - Expect(info.OAuthClient()).To(Equal("some-client")) - Expect(info.CFOnK8s).To(BeFalse()) + Expect(info.Name).To(Equal("test-name")) + Expect(info.Build).To(Equal("test-build")) + Expect(info.OSBAPIVersion).To(Equal("1.0")) }) It("returns all warnings", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("warning 1")) }) - - When("CF-on-K8s", func() { - BeforeEach(func() { - rootRespondWith = RespondWith(http.StatusOK, `{ "cf_on_k8s": true }`) - }) - - It("sets the CFOnK8s", func() { - Expect(info.CFOnK8s).To(BeTrue()) - }) - }) }) When("the cloud controller encounters an error", func() { - When("the root response is invalid", func() { + When("the info response is invalid", func() { BeforeEach(func() { - rootRespondWith = RespondWith( + respondWith = RespondWith( http.StatusNotFound, `i am google, bow down`, http.Header{"X-Cf-Warnings": {"warning 2"}}, @@ -127,9 +80,9 @@ var _ = Describe("Info", func() { }) }) - When("the error occurs making a request to '/'", func() { + When("the error occurs making a request to '/info'", func() { BeforeEach(func() { - rootRespondWith = RespondWith( + respondWith = RespondWith( http.StatusNotFound, `{"errors": [{}]}`, http.Header{"X-Cf-Warnings": {"this is a warning"}}) diff --git a/api/cloudcontroller/ccv3/internal/api_routes.go b/api/cloudcontroller/ccv3/internal/api_routes.go index f1d637933f3..5ba7deda0f0 100644 --- a/api/cloudcontroller/ccv3/internal/api_routes.go +++ b/api/cloudcontroller/ccv3/internal/api_routes.go @@ -103,6 +103,8 @@ const ( GetSpaceStagingSecurityGroupsRequest = "GetSpaceStagingSecurityGroups" GetSSHEnabled = "GetSSHEnabled" GetStacksRequest = "GetStacks" + GetTasksRequest = "GetTasks" + GetTaskRequest = "GetTask" GetUserRequest = "GetUser" GetUsersRequest = "GetUsers" MapRouteRequest = "MapRoute" @@ -112,6 +114,7 @@ const ( PatchApplicationFeaturesRequest = "PatchApplicationFeatures" PatchEnvironmentVariableGroupRequest = "PatchEnvironmentVariableGroup" PatchBuildpackRequest = "PatchBuildpack" + PatchDestinationRequest = "PatchDestination" PatchDomainRequest = "PatchDomain" PatchFeatureFlagRequest = "PatchFeatureFlag" PatchOrganizationRelationshipDefaultIsolationSegmentRequest = "PatchOrganizationRelationshipDefaultIsolationSegment" @@ -129,11 +132,13 @@ const ( PatchSpaceFeaturesRequest = "PatchSpaceFeatures" PatchSpaceQuotaRequest = "PatchSpaceQuota" PatchStackRequest = "PatchStack" + PatchMoveRouteRequest = "PatchMoveRouteRequest" PostApplicationActionApplyManifest = "PostApplicationActionApplyM" PostApplicationActionRestartRequest = "PostApplicationActionRestart" PostApplicationActionStartRequest = "PostApplicationActionStart" PostApplicationActionStopRequest = "PostApplicationActionStop" PostApplicationDeploymentActionCancelRequest = "PostApplicationDeploymentActionCancel" + PostApplicationDeploymentActionContinueRequest = "PostApplicationDeploymentActionContinue" PostApplicationDeploymentRequest = "PostApplicationDeployment" PostApplicationProcessActionScaleRequest = "PostApplicationProcessActionScale" PostApplicationRequest = "PostApplication" @@ -171,8 +176,12 @@ const ( PostUserRequest = "PostUser" PutTaskCancelRequest = "PutTaskCancel" SharePrivateDomainRequest = "SharePrivateDomainRequest" + ShareRouteRequest = "ShareRouteRequest" UnmapRouteRequest = "UnmapRoute" + UnshareRouteRequest = "UnshareRoute" + UpdateRouteRequest = "UpdateRoute" WhoAmI = "WhoAmI" + Info = "Info" ) // APIRoutes is a list of routes used by the router to construct request URLs. @@ -213,6 +222,7 @@ var APIRoutes = map[string]Route{ PostApplicationDeploymentRequest: {Path: "/v3/deployments", Method: http.MethodPost}, GetDeploymentRequest: {Path: "/v3/deployments/:deployment_guid", Method: http.MethodGet}, PostApplicationDeploymentActionCancelRequest: {Path: "/v3/deployments/:deployment_guid/actions/cancel", Method: http.MethodPost}, + PostApplicationDeploymentActionContinueRequest: {Path: "/v3/deployments/:deployment_guid/actions/continue", Method: http.MethodPost}, GetDomainsRequest: {Path: "/v3/domains", Method: http.MethodGet}, PostDomainRequest: {Path: "/v3/domains", Method: http.MethodPost}, DeleteDomainRequest: {Path: "/v3/domains/:domain_guid", Method: http.MethodDelete}, @@ -274,7 +284,12 @@ var APIRoutes = map[string]Route{ PatchRouteRequest: {Path: "/v3/routes/:route_guid", Method: http.MethodPatch}, GetRouteDestinationsRequest: {Path: "/v3/routes/:route_guid/destinations", Method: http.MethodGet}, MapRouteRequest: {Path: "/v3/routes/:route_guid/destinations", Method: http.MethodPost}, + UpdateRouteRequest: {Path: "/v3/routes/:route_guid", Method: http.MethodPatch}, UnmapRouteRequest: {Path: "/v3/routes/:route_guid/destinations/:destination_guid", Method: http.MethodDelete}, + PatchDestinationRequest: {Path: "/v3/routes/:route_guid/destinations/:destination_guid", Method: http.MethodPatch}, + ShareRouteRequest: {Path: "/v3/routes/:route_guid/relationships/shared_spaces", Method: http.MethodPost}, + UnshareRouteRequest: {Path: "/v3/routes/:route_guid/relationships/shared_spaces/:space_guid", Method: http.MethodDelete}, + PatchMoveRouteRequest: {Path: "/v3/routes/:route_guid/relationships/space", Method: http.MethodPatch}, GetSecurityGroupsRequest: {Path: "/v3/security_groups", Method: http.MethodGet}, PostSecurityGroupRequest: {Path: "/v3/security_groups", Method: http.MethodPost}, DeleteSecurityGroupRequest: {Path: "/v3/security_groups/:security_group_guid", Method: http.MethodDelete}, @@ -335,10 +350,13 @@ var APIRoutes = map[string]Route{ DeleteSpaceQuotaFromSpaceRequest: {Path: "/v3/space_quotas/:quota_guid/relationships/spaces/:space_guid", Method: http.MethodDelete}, GetStacksRequest: {Path: "/v3/stacks", Method: http.MethodGet}, PatchStackRequest: {Path: "/v3/stacks/:stack_guid", Method: http.MethodPatch}, + GetTaskRequest: {Path: "/v3/tasks/:task_guid", Method: http.MethodGet}, PutTaskCancelRequest: {Path: "/v3/tasks/:task_guid/cancel", Method: http.MethodPut}, + GetTasksRequest: {Path: "/v3/tasks", Method: http.MethodGet}, GetUsersRequest: {Path: "/v3/users", Method: http.MethodGet}, GetUserRequest: {Path: "/v3/users/:user_guid", Method: http.MethodGet}, PostUserRequest: {Path: "/v3/users", Method: http.MethodPost}, DeleteUserRequest: {Path: "/v3/users/:user_guid", Method: http.MethodDelete}, WhoAmI: {Path: "/whoami", Method: http.MethodGet}, + Info: {Path: "/v3/info", Method: http.MethodGet}, } diff --git a/api/cloudcontroller/ccv3/internal/internal_suite_test.go b/api/cloudcontroller/ccv3/internal/internal_suite_test.go index 7f6b68763e8..a43364c4c30 100644 --- a/api/cloudcontroller/ccv3/internal/internal_suite_test.go +++ b/api/cloudcontroller/ccv3/internal/internal_suite_test.go @@ -1,7 +1,7 @@ package internal_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/api/cloudcontroller/ccv3/internal/routing.go b/api/cloudcontroller/ccv3/internal/routing.go index 4b818cfca0c..d25e810c222 100644 --- a/api/cloudcontroller/ccv3/internal/routing.go +++ b/api/cloudcontroller/ccv3/internal/routing.go @@ -11,18 +11,22 @@ import ( // Params map path keys to values. For example, if your route has the path // pattern: -// /person/:person_id/pets/:pet_type -// Then a correct Params map would lool like: -// router.Params{ -// "person_id": "123", -// "pet_type": "cats", -// } +// +// /person/:person_id/pets/:pet_type +// +// Then a correct Params map would look like: +// +// router.Params{ +// "person_id": "123", +// "pet_type": "cats", +// } type Params map[string]string // Route defines the property of a Cloud Controller V3 endpoint. // // Method can be one of the following: -// GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE +// +// GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE // // Path conforms to Pat-style pattern matching. The following docs are taken // from http://godoc.org/github.com/bmizerany/pat#PatternServeMux @@ -35,26 +39,36 @@ type Params map[string]string // string. // // Example pattern with one capture: -// /hello/:name +// +// /hello/:name +// // Will match: -// /hello/blake -// /hello/keith +// +// /hello/blake +// /hello/keith +// // Will not match: -// /hello/blake/ -// /hello/blake/foo -// /foo -// /foo/bar +// +// /hello/blake/ +// /hello/blake/foo +// /foo +// /foo/bar // // Example 2: -// /hello/:name/ +// +// /hello/:name/ +// // Will match: -// /hello/blake/ -// /hello/keith/foo -// /hello/blake -// /hello/keith +// +// /hello/blake/ +// /hello/keith/foo +// /hello/blake +// /hello/keith +// // Will not match: -// /foo -// /foo/bar +// +// /foo +// /foo/bar type Route struct { // Method is any valid HTTP method Method string diff --git a/api/cloudcontroller/ccv3/internal/routing_test.go b/api/cloudcontroller/ccv3/internal/routing_test.go index 09e71f426d7..60666e5980d 100644 --- a/api/cloudcontroller/ccv3/internal/routing_test.go +++ b/api/cloudcontroller/ccv3/internal/routing_test.go @@ -3,9 +3,9 @@ package internal_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccv3/isolation_segment.go b/api/cloudcontroller/ccv3/isolation_segment.go index 16dbd4ec174..c712391d5a6 100644 --- a/api/cloudcontroller/ccv3/isolation_segment.go +++ b/api/cloudcontroller/ccv3/isolation_segment.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateIsolationSegment will create an Isolation Segment on the Cloud diff --git a/api/cloudcontroller/ccv3/isolation_segment_test.go b/api/cloudcontroller/ccv3/isolation_segment_test.go index 79026d78689..af8719d7c0c 100644 --- a/api/cloudcontroller/ccv3/isolation_segment_test.go +++ b/api/cloudcontroller/ccv3/isolation_segment_test.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/job.go b/api/cloudcontroller/ccv3/job.go index a0704a80841..63189a47f68 100644 --- a/api/cloudcontroller/ccv3/job.go +++ b/api/cloudcontroller/ccv3/job.go @@ -3,8 +3,8 @@ package ccv3 import ( "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Job represents a Cloud Controller Job. diff --git a/api/cloudcontroller/ccv3/job_test.go b/api/cloudcontroller/ccv3/job_test.go index f5d7b991626..e538a088397 100644 --- a/api/cloudcontroller/ccv3/job_test.go +++ b/api/cloudcontroller/ccv3/job_test.go @@ -5,12 +5,12 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/job_url.go b/api/cloudcontroller/ccv3/job_url.go index f49a965789f..49ae539030e 100644 --- a/api/cloudcontroller/ccv3/job_url.go +++ b/api/cloudcontroller/ccv3/job_url.go @@ -1,7 +1,7 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) // JobURL is the URL to a given Job. diff --git a/api/cloudcontroller/ccv3/job_url_test.go b/api/cloudcontroller/ccv3/job_url_test.go index e9fd42e3fd4..4d077daa6b2 100644 --- a/api/cloudcontroller/ccv3/job_url_test.go +++ b/api/cloudcontroller/ccv3/job_url_test.go @@ -3,9 +3,9 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/manifest.go b/api/cloudcontroller/ccv3/manifest.go index fba84e1c40a..6461efbe2fb 100644 --- a/api/cloudcontroller/ccv3/manifest.go +++ b/api/cloudcontroller/ccv3/manifest.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // GetApplicationManifest returns a (YAML) manifest for an application and its diff --git a/api/cloudcontroller/ccv3/manifest_test.go b/api/cloudcontroller/ccv3/manifest_test.go index 495b57a43e6..4b216c51788 100644 --- a/api/cloudcontroller/ccv3/manifest_test.go +++ b/api/cloudcontroller/ccv3/manifest_test.go @@ -4,20 +4,20 @@ import ( "errors" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Application Manifest", func() { var ( - client *Client + client *ccv3.Client requester *ccv3fakes.FakeRequester ) @@ -31,7 +31,7 @@ var _ = Describe("Application Manifest", func() { appGUID string rawManifest []byte - warnings Warnings + warnings ccv3.Warnings executeErr error expectedYAML []byte @@ -48,7 +48,7 @@ var _ = Describe("Application Manifest", func() { When("getting the manifest is successful", func() { BeforeEach(func() { expectedYAML = []byte("---\n- banana") - requester.MakeRequestReceiveRawReturns(expectedYAML, Warnings{"this is a warning"}, nil) + requester.MakeRequestReceiveRawReturns(expectedYAML, ccv3.Warnings{"this is a warning"}, nil) }) It("makes the correct request", func() { @@ -84,7 +84,7 @@ var _ = Describe("Application Manifest", func() { requester.MakeRequestReceiveRawReturns( nil, - Warnings{"this is a warning"}, + ccv3.Warnings{"this is a warning"}, ccerror.MultiError{ResponseCode: http.StatusTeapot, Errors: errors}, ) @@ -117,7 +117,7 @@ var _ = Describe("Application Manifest", func() { rawManifest []byte manifestDiff resources.ManifestDiff - warnings Warnings + warnings ccv3.Warnings executeErr error ) diff --git a/api/cloudcontroller/ccv3/metadata.go b/api/cloudcontroller/ccv3/metadata.go index a909e49f182..f8c277f64e4 100644 --- a/api/cloudcontroller/ccv3/metadata.go +++ b/api/cloudcontroller/ccv3/metadata.go @@ -3,8 +3,8 @@ package ccv3 import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) UpdateResourceMetadata(resource string, resourceGUID string, metadata resources.Metadata) (JobURL, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/metadata_test.go b/api/cloudcontroller/ccv3/metadata_test.go index b9302e0af59..24ca2f57ed0 100644 --- a/api/cloudcontroller/ccv3/metadata_test.go +++ b/api/cloudcontroller/ccv3/metadata_test.go @@ -4,12 +4,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/organization.go b/api/cloudcontroller/ccv3/organization.go index b75cad50e9a..5e21a0e7d80 100644 --- a/api/cloudcontroller/ccv3/organization.go +++ b/api/cloudcontroller/ccv3/organization.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) CreateOrganization(orgName string) (resources.Organization, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/organization_quota.go b/api/cloudcontroller/ccv3/organization_quota.go index 8812493a565..95a3a81e895 100644 --- a/api/cloudcontroller/ccv3/organization_quota.go +++ b/api/cloudcontroller/ccv3/organization_quota.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) ApplyOrganizationQuota(quotaGuid, orgGuid string) (resources.RelationshipList, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/organization_quota_test.go b/api/cloudcontroller/ccv3/organization_quota_test.go index 9d509d62a9f..b1aaaa41da1 100644 --- a/api/cloudcontroller/ccv3/organization_quota_test.go +++ b/api/cloudcontroller/ccv3/organization_quota_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -60,7 +60,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 5120, "per_process_memory_in_mb": 1024, "total_instances": 10, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -103,7 +104,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 10240, "per_process_memory_in_mb": 1024, "total_instances": 8, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 16 }, "services": { "paid_services_allowed": false, @@ -156,6 +158,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 5120, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 10, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true}, @@ -175,6 +178,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 10240, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 8, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 16, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true}, @@ -211,7 +215,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 10240, "per_process_memory_in_mb": 1024, "total_instances": 8, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": false, @@ -257,6 +262,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 10240, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 8, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true}, @@ -337,7 +343,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 5120, "per_process_memory_in_mb": 1024, "total_instances": 10, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -384,6 +391,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 5120, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 10, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true}, @@ -460,6 +468,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -488,7 +497,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 2048, "per_process_memory_in_mb": 1024, "total_instances": null, - "per_app_tasks": null + "per_app_tasks": null, + "log_rate_limit_in_bytes_per_second": null }, "services": { "paid_services_allowed": true, @@ -512,9 +522,10 @@ var _ = Describe("Organization Quotas", func() { expectedBody := map[string]interface{}{ "name": "elephant-trunk", "apps": map[string]interface{}{ - "total_memory_in_mb": 2048, - "per_process_memory_in_mb": 1024, - "total_instances": nil, + "total_memory_in_mb": 2048, + "per_process_memory_in_mb": 1024, + "total_instances": nil, + "log_rate_limit_in_bytes_per_second": nil, }, "services": map[string]interface{}{ "paid_services_allowed": true, @@ -711,6 +722,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -735,7 +747,8 @@ var _ = Describe("Organization Quotas", func() { "total_memory_in_mb": 2048, "per_process_memory_in_mb": 1024, "total_instances": null, - "per_app_tasks": null + "per_app_tasks": null, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -759,9 +772,10 @@ var _ = Describe("Organization Quotas", func() { expectedBody := map[string]interface{}{ "name": "elephant-trunk", "apps": map[string]interface{}{ - "total_memory_in_mb": 2048, - "per_process_memory_in_mb": 1024, - "total_instances": nil, + "total_memory_in_mb": 2048, + "per_process_memory_in_mb": 1024, + "total_instances": nil, + "log_rate_limit_in_bytes_per_second": 8, }, "services": map[string]interface{}{ "paid_services_allowed": true, @@ -791,6 +805,7 @@ var _ = Describe("Organization Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2048}, InstanceMemory: &types.NullInt{IsSet: true, Value: 1024}, TotalAppInstances: &types.NullInt{IsSet: false, Value: 0}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{IsSet: true, Value: 0}, diff --git a/api/cloudcontroller/ccv3/organization_test.go b/api/cloudcontroller/ccv3/organization_test.go index dcdab99d486..2adebad78cf 100644 --- a/api/cloudcontroller/ccv3/organization_test.go +++ b/api/cloudcontroller/ccv3/organization_test.go @@ -4,12 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -23,7 +22,7 @@ var _ = Describe("Organizations", func() { Describe("GetDefaultDomain", func() { var ( - defaultDomain resources.Domain + defaultDomain Domain warnings Warnings executeErr error orgGUID = "some-org-guid" @@ -61,7 +60,7 @@ var _ = Describe("Organizations", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(defaultDomain).To(Equal( - resources.Domain{Name: "domain-name-1", GUID: "domain-guid-1", Internal: types.NullBool{IsSet: true, Value: false}, + Domain{Name: "domain-name-1", GUID: "domain-guid-1", Internal: types.NullBool{IsSet: true, Value: false}, OrganizationGUID: "some-org-guid"}, )) Expect(warnings).To(ConsistOf("this is a warning")) @@ -449,7 +448,8 @@ var _ = Describe("Organizations", func() { }` expectedBody := map[string]interface{}{ - "name": "some-org-name", + "name": "some-org-name", + "suspended": false, } server.AppendHandlers( @@ -484,7 +484,8 @@ var _ = Describe("Organizations", func() { }` expectedBody := map[string]interface{}{ - "name": "some-org-name", + "name": "some-org-name", + "suspended": false, } server.AppendHandlers( @@ -524,7 +525,8 @@ var _ = Describe("Organizations", func() { }` expectedBody := map[string]interface{}{ - "name": "some-org-name", + "name": "some-org-name", + "suspended": false, } server.AppendHandlers( @@ -583,7 +585,8 @@ var _ = Describe("Organizations", func() { }` expectedBody := map[string]interface{}{ - "name": "some-org-name", + "name": "some-org-name", + "suspended": false, "metadata": map[string]interface{}{ "labels": map[string]string{ "k1": "v1", diff --git a/api/cloudcontroller/ccv3/package.go b/api/cloudcontroller/ccv3/package.go index 0dcdfcaaaf2..c220d630357 100644 --- a/api/cloudcontroller/ccv3/package.go +++ b/api/cloudcontroller/ccv3/package.go @@ -8,11 +8,11 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 io.Reader diff --git a/api/cloudcontroller/ccv3/package_test.go b/api/cloudcontroller/ccv3/package_test.go index ab1d7797765..54bcd15b38d 100644 --- a/api/cloudcontroller/ccv3/package_test.go +++ b/api/cloudcontroller/ccv3/package_test.go @@ -5,21 +5,20 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "mime/multipart" "net/http" "os" "strings" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/ghttp" @@ -498,7 +497,7 @@ var _ = Describe("Package", func() { defer resourcesPart.Close() expectedJSON, err := json.Marshal(inputResources) Expect(err).NotTo(HaveOccurred()) - Expect(ioutil.ReadAll(resourcesPart)).To(MatchJSON(expectedJSON)) + Expect(io.ReadAll(resourcesPart)).To(MatchJSON(expectedJSON)) // Verify that the application bits are sent properly resourcesPart, err = requestReader.NextPart() @@ -508,7 +507,7 @@ var _ = Describe("Package", func() { Expect(resourcesPart.FileName()).To(Equal("package.zip")) defer resourcesPart.Close() - Expect(ioutil.ReadAll(resourcesPart)).To(Equal(readerBody)) + Expect(io.ReadAll(resourcesPart)).To(Equal(readerBody)) } }) @@ -542,7 +541,7 @@ var _ = Describe("Package", func() { defer resourcesPart.Close() expectedJSON, err := json.Marshal(inputResources) Expect(err).NotTo(HaveOccurred()) - Expect(ioutil.ReadAll(resourcesPart)).To(MatchJSON(expectedJSON)) + Expect(io.ReadAll(resourcesPart)).To(MatchJSON(expectedJSON)) // Verify that the application bits are not sent _, err = requestReader.NextPart() @@ -626,7 +625,7 @@ var _ = Describe("Package", func() { defer GinkgoRecover() // Since this will be running in a thread if strings.HasSuffix(request.URL.String(), "/v3/packages/package-guid/upload") { - _, err := ioutil.ReadAll(request.Body) + _, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(request.Body.Close()).ToNot(HaveOccurred()) return request.ResetBody() @@ -657,7 +656,7 @@ var _ = Describe("Package", func() { if strings.HasSuffix(request.URL.String(), "/v3/packages/package-guid/upload") { defer request.Body.Close() - readBytes, err := ioutil.ReadAll(request.Body) + readBytes, err := io.ReadAll(request.Body) Expect(err).ToNot(HaveOccurred()) Expect(len(readBytes)).To(BeNumerically(">", UploadSize)) return expectedErr @@ -701,7 +700,7 @@ var _ = Describe("Package", func() { GUID: "package-guid", } - tempFile, err = ioutil.TempFile("", "package-upload") + tempFile, err = os.CreateTemp("", "package-upload") Expect(err).ToNot(HaveOccurred()) defer tempFile.Close() @@ -709,7 +708,7 @@ var _ = Describe("Package", func() { fileSize := 1024 contents := strings.Repeat("A", fileSize) - err = ioutil.WriteFile(tempFile.Name(), []byte(contents), 0666) + err = os.WriteFile(tempFile.Name(), []byte(contents), 0666) Expect(err).NotTo(HaveOccurred()) verifyHeaderAndBody := func(_ http.ResponseWriter, req *http.Request) { @@ -719,7 +718,7 @@ var _ = Describe("Package", func() { boundary := contentType[30:] defer req.Body.Close() - rawBody, err := ioutil.ReadAll(req.Body) + rawBody, err := io.ReadAll(req.Body) Expect(err).NotTo(HaveOccurred()) body := BufferWithBytes(rawBody) Expect(body).To(Say("--%s", boundary)) @@ -780,7 +779,7 @@ var _ = Describe("Package", func() { State: constant.PackageAwaitingUpload, } - tempFile, err = ioutil.TempFile("", "package-upload") + tempFile, err = os.CreateTemp("", "package-upload") Expect(err).ToNot(HaveOccurred()) defer tempFile.Close() @@ -788,7 +787,7 @@ var _ = Describe("Package", func() { fileSize := 1024 contents := strings.Repeat("A", fileSize) - err = ioutil.WriteFile(tempFile.Name(), []byte(contents), 0666) + err = os.WriteFile(tempFile.Name(), []byte(contents), 0666) Expect(err).NotTo(HaveOccurred()) response := ` { diff --git a/api/cloudcontroller/ccv3/paginate.go b/api/cloudcontroller/ccv3/paginate.go index 2fcf46a4d18..fa1359faad4 100644 --- a/api/cloudcontroller/ccv3/paginate.go +++ b/api/cloudcontroller/ccv3/paginate.go @@ -3,10 +3,10 @@ package ccv3 import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) -func (requester RealRequester) paginate(request *cloudcontroller.Request, obj interface{}, appendToExternalList func(interface{}) error) (IncludedResources, Warnings, error) { +func (requester RealRequester) paginate(request *cloudcontroller.Request, obj interface{}, appendToExternalList func(interface{}) error, specificPage bool) (IncludedResources, Warnings, error) { fullWarningsList := Warnings{} var includes IncludedResources @@ -17,16 +17,9 @@ func (requester RealRequester) paginate(request *cloudcontroller.Request, obj in return IncludedResources{}, fullWarningsList, err } - includes.Apps = append(includes.Apps, wrapper.IncludedResources.Apps...) - includes.Users = append(includes.Users, wrapper.IncludedResources.Users...) - includes.Organizations = append(includes.Organizations, wrapper.IncludedResources.Organizations...) - includes.Spaces = append(includes.Spaces, wrapper.IncludedResources.Spaces...) - includes.ServiceBrokers = append(includes.ServiceBrokers, wrapper.IncludedResources.ServiceBrokers...) - includes.ServiceInstances = append(includes.ServiceInstances, wrapper.IncludedResources.ServiceInstances...) - includes.ServiceOfferings = append(includes.ServiceOfferings, wrapper.IncludedResources.ServiceOfferings...) - includes.ServicePlans = append(includes.ServicePlans, wrapper.IncludedResources.ServicePlans...) + includes.Merge(wrapper.IncludedResources) - if wrapper.NextPage() == "" { + if specificPage || wrapper.NextPage() == "" { break } diff --git a/api/cloudcontroller/ccv3/paginated_resources_test.go b/api/cloudcontroller/ccv3/paginated_resources_test.go index 79088eb95d2..b41607387ba 100644 --- a/api/cloudcontroller/ccv3/paginated_resources_test.go +++ b/api/cloudcontroller/ccv3/paginated_resources_test.go @@ -3,11 +3,10 @@ package ccv3_test import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -199,7 +198,7 @@ var _ = Describe("Paginated Resources", func() { resources.User{GUID: "user-guid-1", Username: "user-name-1", Origin: "uaa"}, )) Expect(page.IncludedResources.Organizations).To(ConsistOf( - Organization{GUID: "org-guid-1", Name: "org-name-1"}, + resources.Organization{GUID: "org-guid-1", Name: "org-name-1"}, )) }) }) diff --git a/api/cloudcontroller/ccv3/process.go b/api/cloudcontroller/ccv3/process.go index d03f2885fb9..a386431491d 100644 --- a/api/cloudcontroller/ccv3/process.go +++ b/api/cloudcontroller/ccv3/process.go @@ -1,9 +1,9 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateApplicationProcessScale updates process instances count, memory or disk diff --git a/api/cloudcontroller/ccv3/process_instance.go b/api/cloudcontroller/ccv3/process_instance.go index 572ce04b8e3..8b4550c7ff0 100644 --- a/api/cloudcontroller/ccv3/process_instance.go +++ b/api/cloudcontroller/ccv3/process_instance.go @@ -5,9 +5,10 @@ import ( "strconv" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/types" ) // ProcessInstance represents a single process instance for a particular @@ -15,6 +16,8 @@ import ( type ProcessInstance struct { // CPU is the current CPU usage of the instance. CPU float64 + // CPU Entitlement is the current CPU entitlement usage of the instance. + CPUEntitlement types.NullFloat64 // Details is information about errors placing the instance. Details string // DiskQuota is the maximum disk the instance is allowed to use. @@ -29,10 +32,16 @@ type ProcessInstance struct { IsolationSegment string // MemoryQuota is the maximum memory the instance is allowed to use. MemoryQuota uint64 - // DiskUsage is the current memory usage of the instance. + // MemoryUsage is the current memory usage of the instance. MemoryUsage uint64 + // LogRateLimit is the maximum rate that the instance is allowed to log. + LogRateLimit int64 + // LogRate is the current rate that the instance is logging. + LogRate uint64 // State is the state of the instance. State constant.ProcessInstanceState + // Routeable is the readiness state of the instance, can be true, false or null. + Routable *bool // Type is the process type for the instance. Type string // Uptime is the duration that the instance has been running. @@ -47,13 +56,17 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { Index int64 `json:"index"` IsolationSegment string `json:"isolation_segment"` MemQuota uint64 `json:"mem_quota"` + LogRateLimit int64 `json:"log_rate_limit"` State string `json:"state"` + Routable *bool `json:"routable"` Type string `json:"type"` Uptime int64 `json:"uptime"` Usage struct { - CPU float64 `json:"cpu"` - Mem uint64 `json:"mem"` - Disk uint64 `json:"disk"` + CPU float64 `json:"cpu"` + CPUEntitlement types.NullFloat64 `json:"cpu_entitlement"` + Mem uint64 `json:"mem"` + Disk uint64 `json:"disk"` + LogRate uint64 `json:"log_rate"` } `json:"usage"` } @@ -63,6 +76,7 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { } instance.CPU = inputInstance.Usage.CPU + instance.CPUEntitlement = inputInstance.Usage.CPUEntitlement instance.Details = inputInstance.Details instance.DiskQuota = inputInstance.DiskQuota instance.DiskUsage = inputInstance.Usage.Disk @@ -70,7 +84,10 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { instance.IsolationSegment = inputInstance.IsolationSegment instance.MemoryQuota = inputInstance.MemQuota instance.MemoryUsage = inputInstance.Usage.Mem + instance.LogRateLimit = inputInstance.LogRateLimit + instance.LogRate = inputInstance.Usage.LogRate instance.State = constant.ProcessInstanceState(inputInstance.State) + instance.Routable = inputInstance.Routable instance.Type = inputInstance.Type instance.Uptime, err = time.ParseDuration(fmt.Sprintf("%ds", inputInstance.Uptime)) if err != nil { diff --git a/api/cloudcontroller/ccv3/process_instance_test.go b/api/cloudcontroller/ccv3/process_instance_test.go index a92935a8da3..1b292f838be 100644 --- a/api/cloudcontroller/ccv3/process_instance_test.go +++ b/api/cloudcontroller/ccv3/process_instance_test.go @@ -4,10 +4,11 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -92,11 +93,14 @@ var _ = Describe("ProcessInstance", func() { "state": "RUNNING", "usage": { "cpu": 0.01, + "cpu_entitlement": 0.02, "mem": 1000000, - "disk": 2000000 + "disk": 2000000, + "log_rate": 5000 }, "mem_quota": 2000000, "disk_quota": 4000000, + "log_rate_limit": 10000, "isolation_segment": "example_iso_segment", "index": 0, "uptime": 123, @@ -107,11 +111,14 @@ var _ = Describe("ProcessInstance", func() { "state": "RUNNING", "usage": { "cpu": 0.02, + "cpu_entitlement": 0.04, "mem": 8000000, - "disk": 16000000 + "disk": 16000000, + "log_rate": 32000 }, "mem_quota": 16000000, "disk_quota": 32000000, + "log_rate_limit": 64000, "isolation_segment": "example_iso_segment", "index": 1, "uptime": 456 @@ -132,6 +139,7 @@ var _ = Describe("ProcessInstance", func() { Expect(processes).To(ConsistOf( ProcessInstance{ CPU: 0.01, + CPUEntitlement: types.NullFloat64{IsSet: true, Value: 0.02}, Details: "some details", DiskQuota: 4000000, DiskUsage: 2000000, @@ -139,18 +147,23 @@ var _ = Describe("ProcessInstance", func() { IsolationSegment: "example_iso_segment", MemoryQuota: 2000000, MemoryUsage: 1000000, + LogRateLimit: 10000, + LogRate: 5000, State: constant.ProcessInstanceRunning, Type: "web", Uptime: 123 * time.Second, }, ProcessInstance{ CPU: 0.02, + CPUEntitlement: types.NullFloat64{IsSet: true, Value: 0.04}, DiskQuota: 32000000, DiskUsage: 16000000, Index: 1, IsolationSegment: "example_iso_segment", MemoryQuota: 16000000, MemoryUsage: 8000000, + LogRateLimit: 64000, + LogRate: 32000, State: constant.ProcessInstanceRunning, Type: "web", Uptime: 456 * time.Second, diff --git a/api/cloudcontroller/ccv3/process_test.go b/api/cloudcontroller/ccv3/process_test.go index 2502c8e57a1..ec2f2127287 100644 --- a/api/cloudcontroller/ccv3/process_test.go +++ b/api/cloudcontroller/ccv3/process_test.go @@ -4,12 +4,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" . "github.com/onsi/gomega/gstruct" @@ -41,6 +41,7 @@ var _ = Describe("Process", func() { "instances": 22, "memory_in_mb": 32, "disk_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 512, "relationships": { "app": { "data": { @@ -55,6 +56,14 @@ var _ = Describe("Process", func() { "endpoint": "/health", "invocation_timeout": 42 } + }, + "readiness_health_check": { + "type": "http", + "data": { + "interval": 9, + "endpoint": "/foo", + "invocation_timeout": 2 + } } }` server.AppendHandlers( @@ -69,17 +78,22 @@ var _ = Describe("Process", func() { Expect(err).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) Expect(process).To(MatchAllFields(Fields{ - "GUID": Equal("process-1-guid"), - "Type": Equal("some-type"), - "AppGUID": Equal("some-app-guid"), - "Command": Equal(types.FilteredString{IsSet: true, Value: "start-command-1"}), - "Instances": Equal(types.NullInt{Value: 22, IsSet: true}), - "MemoryInMB": Equal(types.NullUint64{Value: 32, IsSet: true}), - "DiskInMB": Equal(types.NullUint64{Value: 1024, IsSet: true}), - "HealthCheckType": Equal(constant.HTTP), - "HealthCheckEndpoint": Equal("/health"), - "HealthCheckInvocationTimeout": BeEquivalentTo(42), - "HealthCheckTimeout": BeEquivalentTo(90), + "GUID": Equal("process-1-guid"), + "Type": Equal("some-type"), + "AppGUID": Equal("some-app-guid"), + "Command": Equal(types.FilteredString{IsSet: true, Value: "start-command-1"}), + "Instances": Equal(types.NullInt{Value: 22, IsSet: true}), + "MemoryInMB": Equal(types.NullUint64{Value: 32, IsSet: true}), + "DiskInMB": Equal(types.NullUint64{Value: 1024, IsSet: true}), + "LogRateLimitInBPS": Equal(types.NullInt{Value: 512, IsSet: true}), + "HealthCheckType": Equal(constant.HTTP), + "HealthCheckEndpoint": Equal("/health"), + "HealthCheckInvocationTimeout": BeEquivalentTo(42), + "HealthCheckTimeout": BeEquivalentTo(90), + "ReadinessHealthCheckType": Equal(constant.HTTP), + "ReadinessHealthCheckEndpoint": Equal("/foo"), + "ReadinessHealthCheckInvocationTimeout": BeEquivalentTo(2), + "ReadinessHealthCheckInterval": BeEquivalentTo(9), })) }) }) @@ -135,15 +149,17 @@ var _ = Describe("Process", func() { When("providing all scale options", func() { BeforeEach(func() { passedProcess = resources.Process{ - Type: constant.ProcessTypeWeb, - Instances: types.NullInt{Value: 2, IsSet: true}, - MemoryInMB: types.NullUint64{Value: 100, IsSet: true}, - DiskInMB: types.NullUint64{Value: 200, IsSet: true}, + Type: constant.ProcessTypeWeb, + Instances: types.NullInt{Value: 2, IsSet: true}, + MemoryInMB: types.NullUint64{Value: 100, IsSet: true}, + DiskInMB: types.NullUint64{Value: 200, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 256, IsSet: true}, } expectedBody := `{ "instances": 2, "memory_in_mb": 100, - "disk_in_mb": 200 + "disk_in_mb": 200, + "log_rate_limit_in_bytes_per_second": 256 }` response := `{ "guid": "some-process-guid" @@ -168,15 +184,17 @@ var _ = Describe("Process", func() { When("providing all scale options with 0 values", func() { BeforeEach(func() { passedProcess = resources.Process{ - Type: constant.ProcessTypeWeb, - Instances: types.NullInt{Value: 0, IsSet: true}, - MemoryInMB: types.NullUint64{Value: 0, IsSet: true}, - DiskInMB: types.NullUint64{Value: 0, IsSet: true}, + Type: constant.ProcessTypeWeb, + Instances: types.NullInt{Value: 0, IsSet: true}, + MemoryInMB: types.NullUint64{Value: 0, IsSet: true}, + DiskInMB: types.NullUint64{Value: 0, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 0, IsSet: true}, } expectedBody := `{ "instances": 0, "memory_in_mb": 0, - "disk_in_mb": 0 + "disk_in_mb": 0, + "log_rate_limit_in_bytes_per_second": 0 }` response := `{ "guid": "some-process-guid" @@ -296,6 +314,7 @@ var _ = Describe("Process", func() { "instances": 22, "memory_in_mb": 32, "disk_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 64, "relationships": { "app": { "data": { @@ -310,6 +329,14 @@ var _ = Describe("Process", func() { "endpoint": "/health", "invocation_timeout": 42 } + }, + "readiness_health_check": { + "type": "http", + "data": { + "interval": 9, + "endpoint": "/foo", + "invocation_timeout": 2 + } } }` server.AppendHandlers( @@ -324,17 +351,22 @@ var _ = Describe("Process", func() { Expect(err).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) Expect(process).To(MatchAllFields(Fields{ - "GUID": Equal("process-1-guid"), - "Type": Equal("some-type"), - "AppGUID": Equal("some-app-guid"), - "Command": Equal(types.FilteredString{IsSet: true, Value: "start-command-1"}), - "Instances": Equal(types.NullInt{Value: 22, IsSet: true}), - "MemoryInMB": Equal(types.NullUint64{Value: 32, IsSet: true}), - "DiskInMB": Equal(types.NullUint64{Value: 1024, IsSet: true}), - "HealthCheckType": Equal(constant.HTTP), - "HealthCheckEndpoint": Equal("/health"), - "HealthCheckInvocationTimeout": BeEquivalentTo(42), - "HealthCheckTimeout": BeEquivalentTo(90), + "GUID": Equal("process-1-guid"), + "Type": Equal("some-type"), + "AppGUID": Equal("some-app-guid"), + "Command": Equal(types.FilteredString{IsSet: true, Value: "start-command-1"}), + "Instances": Equal(types.NullInt{Value: 22, IsSet: true}), + "MemoryInMB": Equal(types.NullUint64{Value: 32, IsSet: true}), + "DiskInMB": Equal(types.NullUint64{Value: 1024, IsSet: true}), + "LogRateLimitInBPS": Equal(types.NullInt{Value: 64, IsSet: true}), + "HealthCheckType": Equal(constant.HTTP), + "HealthCheckEndpoint": Equal("/health"), + "HealthCheckInvocationTimeout": BeEquivalentTo(42), + "HealthCheckTimeout": BeEquivalentTo(90), + "ReadinessHealthCheckType": Equal(constant.HTTP), + "ReadinessHealthCheckEndpoint": Equal("/foo"), + "ReadinessHealthCheckInvocationTimeout": BeEquivalentTo(2), + "ReadinessHealthCheckInterval": BeEquivalentTo(9), })) }) }) @@ -425,6 +457,7 @@ var _ = Describe("Process", func() { "type": "web", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 32, + "log_rate_limit_in_bytes_per_second": 64, "health_check": { "type": "port", "data": { @@ -438,6 +471,7 @@ var _ = Describe("Process", func() { "type": "worker", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 64, + "log_rate_limit_in_bytes_per_second": 128, "health_check": { "type": "http", "data": { @@ -459,6 +493,7 @@ var _ = Describe("Process", func() { "type": "console", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 128, + "log_rate_limit_in_bytes_per_second": 256, "health_check": { "type": "process", "data": { @@ -493,6 +528,7 @@ var _ = Describe("Process", func() { Type: constant.ProcessTypeWeb, Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 64, IsSet: true}, HealthCheckType: constant.Port, HealthCheckTimeout: 0, }, @@ -501,6 +537,7 @@ var _ = Describe("Process", func() { Type: "worker", Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 64, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 128, IsSet: true}, HealthCheckType: constant.HTTP, HealthCheckEndpoint: "/health", HealthCheckTimeout: 60, @@ -510,6 +547,7 @@ var _ = Describe("Process", func() { Type: "console", Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 128, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 256, IsSet: true}, HealthCheckType: constant.Process, HealthCheckTimeout: 90, }, @@ -560,6 +598,7 @@ var _ = Describe("Process", func() { "type": "web", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 32, + "log_rate_limit_in_bytes_per_second": 64, "health_check": { "type": "port", "data": { @@ -573,6 +612,7 @@ var _ = Describe("Process", func() { "type": "web", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 32, + "log_rate_limit_in_bytes_per_second": 64, "health_check": { "type": "port", "data": { @@ -586,6 +626,7 @@ var _ = Describe("Process", func() { "type": "worker", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 64, + "log_rate_limit_in_bytes_per_second": 128, "health_check": { "type": "http", "data": { @@ -608,6 +649,7 @@ var _ = Describe("Process", func() { "type": "console", "command": "[PRIVATE DATA HIDDEN IN LISTS]", "memory_in_mb": 128, + "log_rate_limit_in_bytes_per_second": 256, "health_check": { "type": "process", "data": { @@ -661,6 +703,7 @@ var _ = Describe("Process", func() { Type: constant.ProcessTypeWeb, Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 64, IsSet: true}, HealthCheckType: constant.Port, HealthCheckTimeout: 0, }, @@ -669,6 +712,7 @@ var _ = Describe("Process", func() { Type: "worker", Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 64, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 128, IsSet: true}, HealthCheckType: constant.HTTP, HealthCheckEndpoint: "/health", HealthCheckTimeout: 60, @@ -678,6 +722,7 @@ var _ = Describe("Process", func() { Type: "console", Command: types.FilteredString{IsSet: true, Value: "[PRIVATE DATA HIDDEN IN LISTS]"}, MemoryInMB: types.NullUint64{Value: 128, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 256, IsSet: true}, HealthCheckType: constant.Process, HealthCheckTimeout: 90, }, diff --git a/api/cloudcontroller/ccv3/query.go b/api/cloudcontroller/ccv3/query.go index 6761676067c..6c0cec48b37 100644 --- a/api/cloudcontroller/ccv3/query.go +++ b/api/cloudcontroller/ccv3/query.go @@ -17,6 +17,8 @@ const ( GUIDFilter QueryKey = "guids" // LabelSelectorFilter is a query parameter for listing objects by label LabelSelectorFilter QueryKey = "label_selector" + // LifecycleFilter is a query parameter for listing buildpacks by lifecycle + LifecycleFilter QueryKey = "lifecycle" // NameFilter is a query parameter for listing objects by name. NameFilter QueryKey = "names" // NoRouteFilter is a query parameter for skipping route creation and unmapping existing routes. @@ -94,6 +96,8 @@ const ( OrderBy QueryKey = "order_by" // PerPage is a query parameter for specifying the number of results per page. PerPage QueryKey = "per_page" + // Page is a query parameter for specifying the number of the requested page. + Page QueryKey = "page" // Include is a query parameter for specifying other resources associated with the // resource returned by the endpoint Include QueryKey = "include" diff --git a/api/cloudcontroller/ccv3/query_test.go b/api/cloudcontroller/ccv3/query_test.go index 35e1928bffa..205895c4ab8 100644 --- a/api/cloudcontroller/ccv3/query_test.go +++ b/api/cloudcontroller/ccv3/query_test.go @@ -3,8 +3,8 @@ package ccv3_test import ( "net/url" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccv3/relationship.go b/api/cloudcontroller/ccv3/relationship.go index e4ed3b81eff..86b035a3398 100644 --- a/api/cloudcontroller/ccv3/relationship.go +++ b/api/cloudcontroller/ccv3/relationship.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // DeleteIsolationSegmentOrganization will delete the relationship between diff --git a/api/cloudcontroller/ccv3/relationship_list.go b/api/cloudcontroller/ccv3/relationship_list.go index a60adef2505..e437cc3fc84 100644 --- a/api/cloudcontroller/ccv3/relationship_list.go +++ b/api/cloudcontroller/ccv3/relationship_list.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // EntitleIsolationSegmentToOrganizations will create a link between the diff --git a/api/cloudcontroller/ccv3/relationship_list_test.go b/api/cloudcontroller/ccv3/relationship_list_test.go index 4d3bfb0eec8..f9e4d0a8db9 100644 --- a/api/cloudcontroller/ccv3/relationship_list_test.go +++ b/api/cloudcontroller/ccv3/relationship_list_test.go @@ -3,10 +3,10 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/relationship_test.go b/api/cloudcontroller/ccv3/relationship_test.go index a5e00a8d9a7..22f1c440e73 100644 --- a/api/cloudcontroller/ccv3/relationship_test.go +++ b/api/cloudcontroller/ccv3/relationship_test.go @@ -4,10 +4,10 @@ import ( "encoding/json" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/request.go b/api/cloudcontroller/ccv3/request.go index dc799fc59ec..13cf361b973 100644 --- a/api/cloudcontroller/ccv3/request.go +++ b/api/cloudcontroller/ccv3/request.go @@ -3,9 +3,10 @@ package ccv3 import ( "io" "net/http" + "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) // requestOptions contains all the options to create an HTTP request. @@ -57,6 +58,7 @@ func (requester *RealRequester) newHTTPRequest(passedRequest requestOptions) (*c } request.Header = http.Header{} + if passedRequest.Header != nil { request.Header = passedRequest.Header } @@ -69,9 +71,15 @@ func (requester *RealRequester) newHTTPRequest(passedRequest requestOptions) (*c request.Header.Set("Accept", "application/json") } - if request.Header.Get("Content-Type") == "" { + if !isDownloadDroplet(passedRequest.URL, passedRequest.RequestName) && request.Header.Get("Content-Type") == "" { request.Header.Set("Content-Type", "application/json") + } else if isDownloadDroplet(passedRequest.URL, passedRequest.RequestName) && request.Header.Get("Content-Type") != "" { + request.Header.Del("Content-Type") } return cloudcontroller.NewRequest(request, passedRequest.Body), nil } + +func isDownloadDroplet(URL string, requestName string) bool { + return (strings.Contains(URL, "droplet") && strings.Contains(URL, "download")) || (requestName == internal.GetDropletBitsRequest) +} diff --git a/api/cloudcontroller/ccv3/requester.go b/api/cloudcontroller/ccv3/requester.go index f811a00e400..309f8e9b306 100644 --- a/api/cloudcontroller/ccv3/requester.go +++ b/api/cloudcontroller/ccv3/requester.go @@ -8,8 +8,8 @@ import ( "net/http" "runtime" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Requester @@ -95,7 +95,15 @@ func (requester *RealRequester) MakeListRequest(requestParams RequestParams) (In return IncludedResources{}, nil, err } - return requester.paginate(request, requestParams.ResponseBody, requestParams.AppendToList) + specificPage := false + for _, query := range requestParams.Query { + if query.Key == Page { + specificPage = true + break + } + } + + return requester.paginate(request, requestParams.ResponseBody, requestParams.AppendToList, specificPage) } func (requester *RealRequester) MakeRequest(requestParams RequestParams) (JobURL, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/requester_test.go b/api/cloudcontroller/ccv3/requester_test.go index 7eb0a946752..34ef10c9bba 100644 --- a/api/cloudcontroller/ccv3/requester_test.go +++ b/api/cloudcontroller/ccv3/requester_test.go @@ -8,14 +8,14 @@ import ( "net/http" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -320,11 +320,11 @@ var _ = Describe("shared request helpers", func() { Context("PATCH resource", func() { var ( - responseBody resources.Application + responseBody Application ) BeforeEach(func() { - requestBody := resources.Application{ + requestBody := Application{ GUID: "some-app-guid", Name: "some-app-name", StackName: "some-stack-name", @@ -358,6 +358,7 @@ var _ = Describe("shared request helpers", func() { expectedBody := map[string]interface{}{ "name": "some-app-name", + "guid": "some-app-guid", "lifecycle": map[string]interface{}{ "type": "buildpack", "data": map[string]interface{}{ @@ -386,7 +387,7 @@ var _ = Describe("shared request helpers", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) - Expect(responseBody).To(Equal(resources.Application{ + Expect(responseBody).To(Equal(Application{ GUID: "some-app-guid", StackName: "some-stack-name", LifecycleBuildpacks: []string{"some-buildpack"}, @@ -489,6 +490,7 @@ var _ = Describe("shared request helpers", func() { expectedBody := map[string]interface{}{ "name": "some-app-name", + "guid": "some-app-guid", "lifecycle": map[string]interface{}{ "type": "buildpack", "data": map[string]interface{}{ @@ -548,12 +550,12 @@ var _ = Describe("shared request helpers", func() { Context("with query params and included resources", func() { var ( - resourceList []resources.Role + resourceList []Role query []Query ) BeforeEach(func() { - resourceList = []resources.Role{} + resourceList = []Role{} query = []Query{ { Key: OrganizationGUIDFilter, @@ -567,9 +569,9 @@ var _ = Describe("shared request helpers", func() { requestParams = RequestParams{ RequestName: internal.GetRolesRequest, Query: query, - ResponseBody: resources.Role{}, + ResponseBody: Role{}, AppendToList: func(item interface{}) error { - resourceList = append(resourceList, item.(resources.Role)) + resourceList = append(resourceList, item.(Role)) return nil }, } @@ -619,7 +621,7 @@ var _ = Describe("shared request helpers", func() { It("returns the given resources and all warnings", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("warning-1", "warning-2")) - Expect(resourceList).To(Equal([]resources.Role{{ + Expect(resourceList).To(Equal([]Role{{ GUID: "role-guid-1", Type: constant.OrgUserRole, }, { @@ -781,7 +783,7 @@ var _ = Describe("shared request helpers", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("warning-1", "warning-2")) - Expect(resourceList).To(Equal([]resources.Role{{ + Expect(resourceList).To(Equal([]Role{{ GUID: "role-guid-1", Type: constant.OrgUserRole, UserGUID: "user-guid-1", @@ -792,10 +794,10 @@ var _ = Describe("shared request helpers", func() { }})) Expect(includedResources).To(Equal(IncludedResources{ - Apps: []resources.Application{ + Apps: []Application{ {Name: "app-name-1", GUID: "app-guid-1"}, }, - Users: []resources.User{ + Users: []User{ {GUID: "user-guid-1", Username: "user-name-1", Origin: "uaa"}, {GUID: "user-guid-2", Username: "user-name-2", Origin: "uaa"}, }, @@ -811,7 +813,7 @@ var _ = Describe("shared request helpers", func() { {Name: "broker-name-1", GUID: "broker-guid-1"}, {Name: "broker-name-2", GUID: "broker-guid-2"}, }, - ServiceInstances: []resources.ServiceInstance{ + ServiceInstances: []ServiceInstance{ {Name: "service-instance-name-1", GUID: "service-instance-guid-1"}, {Name: "service-instance-name-2", GUID: "service-instance-guid-2"}, }, @@ -938,6 +940,100 @@ var _ = Describe("shared request helpers", func() { }) }) }) + + Context("with 'per_page' and 'page' query params", func() { + var ( + resourceList []Stack + query []Query + ) + + BeforeEach(func() { + resourceList = []Stack{} + query = []Query{ + { + Key: PerPage, + Values: []string{"1"}, + }, + } + requestParams = RequestParams{ + RequestName: internal.GetStacksRequest, + Query: query, + ResponseBody: Stack{}, + AppendToList: func(item interface{}) error { + resourceList = append(resourceList, item.(Stack)) + return nil + }, + } + }) + + When("requesting page=1", func() { + BeforeEach(func() { + requestParams.Query = append(requestParams.Query, Query{ + Key: Page, Values: []string{"1"}, + }) + + response1 := fmt.Sprintf(`{ + "pagination": { + "next": { + "href": "%s/v3/stacks?per_page=1&page=2" + } + }, + "resources": [ + { + "guid": "stack-guid-1" + } + ] + }`, server.URL()) + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/stacks", "per_page=1&page=1"), + RespondWith(http.StatusOK, response1), + ), + ) + }) + + It("returns only the resources from the specified page", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(resourceList).To(Equal([]Stack{{ + GUID: "stack-guid-1", + }})) + }) + }) + + When("requesting page=2", func() { + BeforeEach(func() { + requestParams.Query = append(requestParams.Query, Query{ + Key: Page, Values: []string{"2"}, + }) + + response2 := `{ + "pagination": { + "next": null + }, + "resources": [ + { + "guid": "stack-guid-2" + } + ] + }` + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/stacks", "per_page=1&page=2"), + RespondWith(http.StatusOK, response2), + ), + ) + }) + + It("returns only the resources from the specified page", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(resourceList).To(Equal([]Stack{{ + GUID: "stack-guid-2", + }})) + }) + }) + }) }) Describe("MakeRequestReceiveRaw", func() { @@ -975,6 +1071,9 @@ var _ = Describe("shared request helpers", func() { CombineHandlers( VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/manifest"), VerifyHeaderKV("Accept", "application/x-yaml"), + func(w http.ResponseWriter, req *http.Request) { + Expect(req.Header).To(HaveKey("Content-Type"), "Header Content-Type is not present") + }, RespondWith( http.StatusOK, expectedResponseBody, @@ -1040,6 +1139,31 @@ var _ = Describe("shared request helpers", func() { }) }) }) + + Context("Download a droplet", func() { + BeforeEach(func() { + requestName = internal.GetDropletBitsRequest + uriParams = internal.Params{"droplet_guid": "some-droplet-guid"} + }) + + When("The server returns an unauthorized error", func() { + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/droplets/some-droplet-guid/download"), + func(w http.ResponseWriter, req *http.Request) { + Expect(req.Header).NotTo(HaveKey("Content-Type"), "Header Content-Type is present") + }, + RespondWith(http.StatusUnauthorized, "", http.Header{}), + ), + ) + }) + + It("fails", func() { + Expect(executeErr).To(HaveOccurred()) + }) + }) + }) }) Describe("MakeRequestSendRaw", func() { diff --git a/api/cloudcontroller/ccv3/resource.go b/api/cloudcontroller/ccv3/resource.go index cb8d778c37f..aaf944a3718 100644 --- a/api/cloudcontroller/ccv3/resource.go +++ b/api/cloudcontroller/ccv3/resource.go @@ -5,8 +5,8 @@ import ( "os" "strconv" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" ) type Checksum struct { diff --git a/api/cloudcontroller/ccv3/resource_test.go b/api/cloudcontroller/ccv3/resource_test.go index d1044017723..397a6b3e706 100644 --- a/api/cloudcontroller/ccv3/resource_test.go +++ b/api/cloudcontroller/ccv3/resource_test.go @@ -5,9 +5,9 @@ import ( "net/http" "os" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/revisions.go b/api/cloudcontroller/ccv3/revisions.go index 67b14a0fc53..b02ca2e1430 100644 --- a/api/cloudcontroller/ccv3/revisions.go +++ b/api/cloudcontroller/ccv3/revisions.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) GetApplicationRevisions(appGUID string, query ...Query) ([]resources.Revision, Warnings, error) { @@ -35,3 +35,14 @@ func (client *Client) GetApplicationRevisionsDeployed(appGUID string) ([]resourc }) return revisions, warnings, err } + +func (client *Client) GetEnvironmentVariablesByURL(url string) (resources.EnvironmentVariables, Warnings, error) { + environmentVariables := make(resources.EnvironmentVariables) + + _, warnings, err := client.MakeRequest(RequestParams{ + URL: url, + ResponseBody: &environmentVariables, + }) + + return environmentVariables, warnings, err +} diff --git a/api/cloudcontroller/ccv3/revisions_test.go b/api/cloudcontroller/ccv3/revisions_test.go index 34f6b01b53b..b702b4350e8 100644 --- a/api/cloudcontroller/ccv3/revisions_test.go +++ b/api/cloudcontroller/ccv3/revisions_test.go @@ -3,12 +3,13 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -133,4 +134,79 @@ var _ = Describe("Revisions", func() { }) }) }) + + Describe("GetEnvironmentVariablesByURL", func() { + var ( + warnings Warnings + executeErr error + environmentVariables resources.EnvironmentVariables + ) + + JustBeforeEach(func() { + environmentVariables, warnings, executeErr = client.GetEnvironmentVariablesByURL("url") + }) + + When("the cloud controller returns errors and warnings", func() { + BeforeEach(func() { + errors := []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "App not found", + Title: "CF-ResourceNotFound", + }, + } + + requester.MakeRequestReturns( + "url", + Warnings{"this is a warning"}, + ccerror.MultiError{ResponseCode: http.StatusTeapot, Errors: errors}, + ) + }) + + It("returns the error and all warnings", func() { + Expect(executeErr).To(MatchError(ccerror.MultiError{ + ResponseCode: http.StatusTeapot, + Errors: []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "App not found", + Title: "CF-ResourceNotFound", + }, + }, + })) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + + When("revision exist", func() { + BeforeEach(func() { + requester.MakeRequestCalls(func(requestParams RequestParams) (JobURL, Warnings, error) { + (*requestParams.ResponseBody.(*resources.EnvironmentVariables))["foo"] = *types.NewFilteredString("bar") + return "url", Warnings{"this is a warning"}, nil + }) + }) + + It("returns the environment variables and all warnings", func() { + Expect(requester.MakeRequestCallCount()).To(Equal(1)) + actualParams := requester.MakeRequestArgsForCall(0) + Expect(actualParams.URL).To(Equal("url")) + + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("this is a warning")) + + Expect(len(environmentVariables)).To(Equal(1)) + Expect(environmentVariables["foo"].Value).To(Equal("bar")) + }) + }) + }) }) diff --git a/api/cloudcontroller/ccv3/role.go b/api/cloudcontroller/ccv3/role.go index 7e12f96dc8b..5c7bb5f14a8 100644 --- a/api/cloudcontroller/ccv3/role.go +++ b/api/cloudcontroller/ccv3/role.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) CreateRole(roleSpec resources.Role) (resources.Role, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/role_test.go b/api/cloudcontroller/ccv3/role_test.go index befcb7fcf71..9b1c1d3dd49 100644 --- a/api/cloudcontroller/ccv3/role_test.go +++ b/api/cloudcontroller/ccv3/role_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/root.go b/api/cloudcontroller/ccv3/root.go new file mode 100644 index 00000000000..1f6027fd7c7 --- /dev/null +++ b/api/cloudcontroller/ccv3/root.go @@ -0,0 +1,143 @@ +package ccv3 + +import ( + "net/http" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/resources" +) + +type RootLinks struct { + // AppSSH is the link for application ssh info. + AppSSH resources.APILink `json:"app_ssh"` + + // CCV3 is the link to the Cloud Controller V3 API. + CCV3 resources.APILink `json:"cloud_controller_v3"` + + // Logging is the link to the Logging API. + Logging resources.APILink `json:"logging"` + + // Logging is the link to the Logging API. + LogCache resources.APILink `json:"log_cache"` + + // NetworkPolicyV1 is the link to the Container to Container Networking + // API. + NetworkPolicyV1 resources.APILink `json:"network_policy_v1"` + + // Routing is the link to the routing API + Routing resources.APILink `json:"routing"` + + // UAA is the link to the UAA API. + UAA resources.APILink `json:"uaa"` + + // Login is the link to the Login API. + Login resources.APILink `json:"login"` +} + +// Root represents a GET response from the '/' endpoint of the cloud +// controller API. +type Root struct { + // Links is a list of top level Cloud Controller APIs. + Links RootLinks `json:"links"` + CFOnK8s bool `json:"cf_on_k8s"` +} + +// AppSSHEndpoint returns the HREF for SSHing into an app container. +func (info Root) AppSSHEndpoint() string { + return info.Links.AppSSH.HREF +} + +// AppSSHHostKeyFingerprint returns the SSH key fingerprint of the SSH proxy +// that brokers connections to application instances. +func (info Root) AppSSHHostKeyFingerprint() string { + return info.Links.AppSSH.Meta.HostKeyFingerprint +} + +// CloudControllerAPIVersion returns the version of the CloudController. +func (info Root) CloudControllerAPIVersion() string { + return info.Links.CCV3.Meta.Version +} + +// LogCache returns the HREF of the Loggregator Traffic Controller. +func (info Root) LogCache() string { + return info.Links.LogCache.HREF +} + +// Logging returns the HREF of the Loggregator Traffic Controller. +func (info Root) Logging() string { + return info.Links.Logging.HREF +} + +// NetworkPolicyV1 returns the HREF of the Container Networking v1 Policy API +func (info Root) NetworkPolicyV1() string { + return info.Links.NetworkPolicyV1.HREF +} + +// OAuthClient returns the oauth client ID of the SSH proxy that brokers +// connections to application instances. +func (info Root) OAuthClient() string { + return info.Links.AppSSH.Meta.OAuthClient +} + +// Routing returns the HREF of the routing API. +func (info Root) Routing() string { + return info.Links.Routing.HREF +} + +// UAA returns the HREF of the UAA server. +func (info Root) UAA() string { + return info.Links.UAA.HREF +} + +// Login returns the HREF of the login server. +func (info Root) Login() string { + return info.Links.Login.HREF +} + +// ResourceLinks represents the information returned back from /v3. +type ResourceLinks map[string]resources.APILink + +// UnmarshalJSON helps unmarshal a Cloud Controller /v3 response. +func (links ResourceLinks) UnmarshalJSON(data []byte) error { + var ccResourceLinks struct { + Links map[string]resources.APILink `json:"links"` + } + err := cloudcontroller.DecodeJSON(data, &ccResourceLinks) + if err != nil { + return err + } + + for key, val := range ccResourceLinks.Links { + links[key] = val + } + + return nil +} + +// GetRoot returns endpoint and API information from /v3. +func (client *Client) GetRoot() (Root, Warnings, error) { + rootResponse, warnings, err := client.RootResponse() + if err != nil { + return Root{}, warnings, err + } + + return rootResponse, warnings, err +} + +// RootResponse returns the CC API root document. +func (client *Client) RootResponse() (Root, Warnings, error) { + var responseBody Root + + _, warnings, err := client.MakeRequest(RequestParams{ + URL: client.CloudControllerURL, + ResponseBody: &responseBody, + }) + + unknownSourceErr, ok := err.(ccerror.UnknownHTTPSourceError) + if ok && unknownSourceErr.StatusCode == http.StatusNotFound { + return Root{}, nil, ccerror.APINotFoundError{URL: client.CloudControllerURL} + } + + return responseBody, warnings, err +} diff --git a/api/cloudcontroller/ccv3/root_test.go b/api/cloudcontroller/ccv3/root_test.go new file mode 100644 index 00000000000..9785d46bcb6 --- /dev/null +++ b/api/cloudcontroller/ccv3/root_test.go @@ -0,0 +1,143 @@ +package ccv3_test + +import ( + "fmt" + "net/http" + "strings" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/ghttp" +) + +var _ = Describe("Root endpoints", func() { + var ( + client *Client + respondWith http.HandlerFunc + roof Root + warnings Warnings + executeErr error + ) + + BeforeEach(func() { + respondWith = nil + }) + + JustBeforeEach(func() { + client, _ = NewTestClient() + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/"), + respondWith, + ), + ) + + roof, warnings, executeErr = client.GetRoot() + }) + + Describe("when all requests are successful", func() { + BeforeEach(func() { + rootResponse := strings.Replace(`{ + "links": { + "self": { + "href": "SERVER_URL" + }, + "cloud_controller_v2": { + "href": "SERVER_URL/v2", + "meta": { + "version": "2.64.0" + } + }, + "cloud_controller_v3": { + "href": "SERVER_URL/v3", + "meta": { + "version": "3.0.0-alpha.5" + } + }, + "network_policy_v1": { + "href": "SERVER_URL/networking/v1/external" + }, + "uaa": { + "href": "https://uaa.bosh-lite.com" + }, + "logging": { + "href": "wss://doppler.bosh-lite.com:443" + }, + "app_ssh": { + "href": "ssh.bosh-lite.com:2222", + "meta": { + "host_key_fingerprint": "some-fingerprint", + "oauth_client": "some-client" + } + } + } + }`, "SERVER_URL", server.URL(), -1) + + respondWith = RespondWith( + http.StatusOK, + rootResponse, + http.Header{"X-Cf-Warnings": {"warning 1"}}) + }) + + It("returns the CC Information", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(roof.UAA()).To(Equal("https://uaa.bosh-lite.com")) + Expect(roof.Logging()).To(Equal("wss://doppler.bosh-lite.com:443")) + Expect(roof.NetworkPolicyV1()).To(Equal(fmt.Sprintf("%s/networking/v1/external", server.URL()))) + Expect(roof.AppSSHHostKeyFingerprint()).To(Equal("some-fingerprint")) + Expect(roof.AppSSHEndpoint()).To(Equal("ssh.bosh-lite.com:2222")) + Expect(roof.OAuthClient()).To(Equal("some-client")) + Expect(roof.CFOnK8s).To(BeFalse()) + }) + + It("returns all warnings", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("warning 1")) + }) + + When("CF-on-K8s", func() { + BeforeEach(func() { + respondWith = RespondWith(http.StatusOK, `{ "cf_on_k8s": true }`) + }) + + It("sets the CFOnK8s", func() { + Expect(roof.CFOnK8s).To(BeTrue()) + }) + }) + }) + + When("the cloud controller encounters an error", func() { + When("the root response is invalid", func() { + BeforeEach(func() { + respondWith = RespondWith( + http.StatusNotFound, + `i am google, bow down`, + http.Header{"X-Cf-Warnings": {"warning 2"}}, + ) + }) + + It("returns an APINotFoundError and no warnings", func() { + Expect(executeErr).To(MatchError(ccerror.APINotFoundError{URL: server.URL()})) + Expect(warnings).To(BeNil()) + }) + }) + + When("the error occurs making a request to '/'", func() { + BeforeEach(func() { + respondWith = RespondWith( + http.StatusNotFound, + `{"errors": [{}]}`, + http.Header{"X-Cf-Warnings": {"this is a warning"}}) + }) + + It("returns the same error and all warnings", func() { + Expect(executeErr).To(MatchError(ccerror.ResourceNotFoundError{})) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + }) +}) diff --git a/api/cloudcontroller/ccv3/route.go b/api/cloudcontroller/ccv3/route.go index 947461c1ee8..f42763956fa 100644 --- a/api/cloudcontroller/ccv3/route.go +++ b/api/cloudcontroller/ccv3/route.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client Client) CreateRoute(route resources.Route) (resources.Route, Warnings, error) { @@ -82,6 +82,24 @@ func (client Client) GetRoutes(query ...Query) ([]resources.Route, Warnings, err return routes, warnings, err } +func (client Client) UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, Warnings, error) { + var responseBody resources.Route + var route = resources.Route{} + var uriParams = internal.Params{"route_guid": routeGUID} + + route.Options = options + + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.UpdateRouteRequest, + URIParams: uriParams, + RequestBody: route, + ResponseBody: &responseBody, + }) + + return responseBody, warnings, err + +} + func (client Client) MapRoute(routeGUID string, appGUID string, destinationProtocol string) (Warnings, error) { type destinationProcess struct { ProcessType string `json:"process_type"` @@ -131,3 +149,81 @@ func (client Client) UnmapRoute(routeGUID string, destinationGUID string) (Warni return warnings, err } + +func (client Client) UnshareRoute(routeGUID string, spaceGUID string) (Warnings, error) { + var responseBody resources.Build + + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.UnshareRouteRequest, + URIParams: internal.Params{"route_guid": routeGUID, "space_guid": spaceGUID}, + ResponseBody: &responseBody, + }) + return warnings, err +} + +func (client Client) UpdateDestination(routeGUID string, destinationGUID string, protocol string) (Warnings, error) { + type body struct { + Protocol string `json:"protocol"` + } + requestBody := body{ + Protocol: protocol, + } + var responseBody resources.Build + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.PatchDestinationRequest, + URIParams: internal.Params{"route_guid": routeGUID, "destination_guid": destinationGUID}, + RequestBody: &requestBody, + ResponseBody: &responseBody, + }) + return warnings, err +} + +func (client Client) ShareRoute(routeGUID string, spaceGUID string) (Warnings, error) { + type space struct { + GUID string `json:"guid"` + } + + type body struct { + Data []space `json:"data"` + } + + requestBody := body{ + Data: []space{ + {GUID: spaceGUID}, + }, + } + + var responseBody resources.Build + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.ShareRouteRequest, + URIParams: internal.Params{"route_guid": routeGUID}, + RequestBody: &requestBody, + ResponseBody: &responseBody, + }) + return warnings, err +} + +func (client Client) MoveRoute(routeGUID string, spaceGUID string) (Warnings, error) { + type space struct { + GUID string `json:"guid"` + } + + type body struct { + Data space `json:"data"` + } + + requestBody := body{ + Data: space{ + GUID: spaceGUID, + }, + } + + var responseBody resources.Build + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.PatchMoveRouteRequest, + URIParams: internal.Params{"route_guid": routeGUID}, + RequestBody: &requestBody, + ResponseBody: &responseBody, + }) + return warnings, err +} diff --git a/api/cloudcontroller/ccv3/route_binding.go b/api/cloudcontroller/ccv3/route_binding.go index 643479d628d..b2701cfc8b0 100644 --- a/api/cloudcontroller/ccv3/route_binding.go +++ b/api/cloudcontroller/ccv3/route_binding.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) CreateRouteBinding(binding resources.RouteBinding) (JobURL, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/route_binding_test.go b/api/cloudcontroller/ccv3/route_binding_test.go index 453159d630b..43c3e495206 100644 --- a/api/cloudcontroller/ccv3/route_binding_test.go +++ b/api/cloudcontroller/ccv3/route_binding_test.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -193,7 +193,8 @@ var _ = Describe("RouteBinding", func() { ) It("makes the right request", func() { - client.DeleteRouteBinding(guid) + _, _, err := client.DeleteRouteBinding(guid) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) Expect(requester.MakeRequestArgsForCall(0)).To(Equal(RequestParams{ diff --git a/api/cloudcontroller/ccv3/route_test.go b/api/cloudcontroller/ccv3/route_test.go index 764b2787848..a0a6dd92d6b 100644 --- a/api/cloudcontroller/ccv3/route_test.go +++ b/api/cloudcontroller/ccv3/route_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -31,6 +31,7 @@ var _ = Describe("Route", func() { path string port int ccv3Route resources.Route + options map[string]*string ) BeforeEach(func() { @@ -42,7 +43,11 @@ var _ = Describe("Route", func() { JustBeforeEach(func() { spaceGUID = "space-guid" domainGUID = "domain-guid" - ccv3Route = resources.Route{SpaceGUID: spaceGUID, DomainGUID: domainGUID, Host: host, Path: path, Port: port} + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + options = map[string]*string{"loadbalancing": lbLeastConnections} + + ccv3Route = resources.Route{SpaceGUID: spaceGUID, DomainGUID: domainGUID, Host: host, Path: path, Port: port, Options: options} route, warnings, executeErr = client.CreateRoute(ccv3Route) }) @@ -60,18 +65,28 @@ var _ = Describe("Route", func() { "data": { "guid": "domain-guid" } } }, - "host": "" + "options": { + "loadbalancing": "least-connection" + }, + "host": "" }` expectedBody := `{ - "relationships": { - "space": { - "data": { "guid": "space-guid" } + "relationships": { + "space": { + "data": { + "guid": "space-guid" + } + }, + "domain": { + "data": { + "guid": "domain-guid" + } + } }, - "domain": { - "data": { "guid": "domain-guid" } + "options": { + "loadbalancing": "least-connection" } - } }` server.AppendHandlers( @@ -91,6 +106,7 @@ var _ = Describe("Route", func() { GUID: "some-route-guid", SpaceGUID: "space-guid", DomainGUID: "domain-guid", + Options: options, })) }) }) @@ -109,7 +125,10 @@ var _ = Describe("Route", func() { "data": { "guid": "domain-guid" } } }, - "host": "cheesecake" + "options": { + "loadbalancing": "least-connection" + }, + "host": "cheesecake" }` expectedBody := `{ @@ -121,7 +140,10 @@ var _ = Describe("Route", func() { "data": { "guid": "domain-guid" } } }, - "host": "cheesecake" + "options": { + "loadbalancing": "least-connection" + }, + "host": "cheesecake" }` server.AppendHandlers( @@ -142,6 +164,7 @@ var _ = Describe("Route", func() { SpaceGUID: "space-guid", DomainGUID: "domain-guid", Host: "cheesecake", + Options: options, })) }) }) @@ -164,7 +187,10 @@ var _ = Describe("Route", func() { } } }, - "path": "lion" + "path": "lion", + "options": { + "loadbalancing": "least-connection" + } }` expectedRequestBody := `{ "relationships": { @@ -179,7 +205,10 @@ var _ = Describe("Route", func() { } } }, - "path": "lion" + "path": "lion", + "options": { + "loadbalancing": "least-connection" + } }` server.AppendHandlers( @@ -200,6 +229,7 @@ var _ = Describe("Route", func() { SpaceGUID: "space-guid", DomainGUID: "domain-guid", Path: "lion", + Options: options, })) }) }) @@ -223,6 +253,9 @@ var _ = Describe("Route", func() { } } }, + "options": { + "loadbalancing": "least-connection" + }, "port": 1234 }` expectedRequestBody := `{ @@ -238,6 +271,9 @@ var _ = Describe("Route", func() { } } }, + "options": { + "loadbalancing": "least-connection" + }, "port": 1234 }` @@ -259,6 +295,7 @@ var _ = Describe("Route", func() { SpaceGUID: "space-guid", DomainGUID: "domain-guid", Port: 1234, + Options: options, })) }) }) @@ -798,6 +835,171 @@ var _ = Describe("Route", func() { }) }) + Describe("UnshareRoute", func() { + var ( + routeGUID string + spaceGUID string + warnings Warnings + executeErr error + ) + + JustBeforeEach(func() { + warnings, executeErr = client.UnshareRoute(routeGUID, spaceGUID) + }) + + When("aroute exists and is shared with the space", func() { + routeGUID = "route-guid" + spaceGUID = "space-guid" + + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodDelete, "/v3/routes/route-guid/relationships/shared_spaces/space-guid"), + RespondWith(http.StatusNoContent, nil, http.Header{ + "X-Cf-Warnings": {"this is a warning"}, + }), + ), + ) + }) + + It("returns warnings", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + + When("the cloud controller returns errors and warnings", func() { + BeforeEach(func() { + response := `{ + "errors": [ + { + "code": 10008, + "detail": "The request is semantically invalid: command presence", + "title": "CF-UnprocessableEntity" + }, + { + "code": 10010, + "detail": "Route not found", + "title": "CF-ResourceNotFound" + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodDelete, "/v3/routes/route-guid/relationships/shared_spaces/space-guid"), + RespondWith(http.StatusTeapot, response, http.Header{"X-Cf-Warnings": {"this is a warning"}}), + ), + ) + }) + + It("returns the error and all warnings", func() { + Expect(executeErr).To(MatchError(ccerror.MultiError{ + ResponseCode: http.StatusTeapot, + Errors: []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "Route not found", + Title: "CF-ResourceNotFound", + }, + }, + })) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + }) + + Describe("UpdateDestination", func() { + var ( + routeGUID string + destinationGUID string + protocol string + warnings Warnings + executeErr error + ) + + JustBeforeEach(func() { + warnings, executeErr = client.UpdateDestination(routeGUID, destinationGUID, protocol) + }) + + When("the request succeeds", func() { + routeGUID = "route-guid" + destinationGUID = "destination-guid" + protocol = "http2" + + expectedBody := fmt.Sprintf(`{ + "protocol": "%s" + }`, protocol) + + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPatch, "/v3/routes/route-guid/destinations/destination-guid"), + VerifyJSON(expectedBody), + RespondWith(http.StatusNoContent, nil, http.Header{ + "X-Cf-Warnings": {"this is a warning"}, + }), + ), + ) + }) + + It("returns all warnings", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + + When("the cloud controller returns errors and warnings", func() { + BeforeEach(func() { + response := `{ + "errors": [ + { + "code": 10008, + "detail": "The request is semantically invalid: command presence", + "title": "CF-UnprocessableEntity" + }, + { + "code": 10010, + "detail": "Isolation segment not found", + "title": "CF-ResourceNotFound" + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodPatch, "/v3/routes/route-guid/destinations/destination-guid"), + RespondWith(http.StatusTeapot, response, http.Header{ + "X-Cf-Warnings": {"this is a warning"}, + }), + ), + ) + }) + + It("returns the error and all warnings", func() { + Expect(executeErr).To(MatchError(ccerror.MultiError{ + ResponseCode: http.StatusTeapot, + Errors: []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "Isolation segment not found", + Title: "CF-ResourceNotFound", + }, + }, + })) + Expect(warnings).To(ConsistOf("this is a warning")) + }) + }) + }) + Describe("DeleteOrphanedRoutes", func() { var ( spaceGUID string diff --git a/api/cloudcontroller/ccv3/security_group.go b/api/cloudcontroller/ccv3/security_group.go index 1880769ceff..8a72533e457 100644 --- a/api/cloudcontroller/ccv3/security_group.go +++ b/api/cloudcontroller/ccv3/security_group.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) CreateSecurityGroup(securityGroup resources.SecurityGroup) (resources.SecurityGroup, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/security_group_test.go b/api/cloudcontroller/ccv3/security_group_test.go index 7a52af4047b..3683740bbcb 100644 --- a/api/cloudcontroller/ccv3/security_group_test.go +++ b/api/cloudcontroller/ccv3/security_group_test.go @@ -3,13 +3,13 @@ package ccv3_test import ( "errors" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccv3/service_broker.go b/api/cloudcontroller/ccv3/service_broker.go index c61b0d9fa23..07addf4081f 100644 --- a/api/cloudcontroller/ccv3/service_broker.go +++ b/api/cloudcontroller/ccv3/service_broker.go @@ -3,8 +3,8 @@ package ccv3 import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateServiceBroker registers a new service broker. diff --git a/api/cloudcontroller/ccv3/service_broker_test.go b/api/cloudcontroller/ccv3/service_broker_test.go index dcfd66ac329..8c46520fd20 100644 --- a/api/cloudcontroller/ccv3/service_broker_test.go +++ b/api/cloudcontroller/ccv3/service_broker_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/service_credential_binding.go b/api/cloudcontroller/ccv3/service_credential_binding.go index 8d3910273c8..5fb7e25d314 100644 --- a/api/cloudcontroller/ccv3/service_credential_binding.go +++ b/api/cloudcontroller/ccv3/service_credential_binding.go @@ -1,9 +1,9 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) func (client *Client) CreateServiceCredentialBinding(binding resources.ServiceCredentialBinding) (JobURL, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/service_credential_binding_test.go b/api/cloudcontroller/ccv3/service_credential_binding_test.go index 7ae420745bd..6de802b3826 100644 --- a/api/cloudcontroller/ccv3/service_credential_binding_test.go +++ b/api/cloudcontroller/ccv3/service_credential_binding_test.go @@ -6,13 +6,13 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -209,7 +209,8 @@ var _ = Describe("Service Credential Bindings", func() { ) It("makes the right request", func() { - client.DeleteServiceCredentialBinding(guid) + _, _, err := client.DeleteServiceCredentialBinding(guid) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) Expect(requester.MakeRequestArgsForCall(0)).To(Equal(RequestParams{ @@ -258,7 +259,7 @@ var _ = Describe("Service Credential Bindings", func() { BeforeEach(func() { requester.MakeRequestCalls(func(params RequestParams) (JobURL, Warnings, error) { - json.Unmarshal([]byte(`{"credentials":{"foo":"bar"}}`), params.ResponseBody) + Expect(json.Unmarshal([]byte(`{"credentials":{"foo":"bar"}}`), params.ResponseBody)).To(Succeed()) return "", Warnings{"warning-1", "warning-2"}, nil }) }) diff --git a/api/cloudcontroller/ccv3/service_instance.go b/api/cloudcontroller/ccv3/service_instance.go index 5a0b590f470..5f7a9257b5c 100644 --- a/api/cloudcontroller/ccv3/service_instance.go +++ b/api/cloudcontroller/ccv3/service_instance.go @@ -1,12 +1,12 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) type SpaceWithOrganization struct { @@ -34,14 +34,10 @@ func (client *Client) GetServiceInstances(query ...Query) ([]resources.ServiceIn func (client *Client) GetServiceInstanceByNameAndSpace(name, spaceGUID string, query ...Query) (resources.ServiceInstance, IncludedResources, Warnings, error) { query = append(query, - Query{ - Key: NameFilter, - Values: []string{name}, - }, - Query{ - Key: SpaceGUIDFilter, - Values: []string{spaceGUID}, - }, + Query{Key: NameFilter, Values: []string{name}}, + Query{Key: SpaceGUIDFilter, Values: []string{spaceGUID}}, + Query{Key: PerPage, Values: []string{"1"}}, + Query{Key: Page, Values: []string{"1"}}, ) instances, included, warnings, err := client.GetServiceInstances(query...) diff --git a/api/cloudcontroller/ccv3/service_instance_test.go b/api/cloudcontroller/ccv3/service_instance_test.go index a7d689e53a7..bd39e3a95c5 100644 --- a/api/cloudcontroller/ccv3/service_instance_test.go +++ b/api/cloudcontroller/ccv3/service_instance_test.go @@ -6,14 +6,14 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -156,18 +156,11 @@ var _ = Describe("Service Instance", func() { actualParams := requester.MakeListRequestArgsForCall(0) Expect(actualParams.RequestName).To(Equal(internal.GetServiceInstancesRequest)) Expect(actualParams.Query).To(ConsistOf( - Query{ - Key: NameFilter, - Values: []string{name}, - }, - Query{ - Key: SpaceGUIDFilter, - Values: []string{spaceGUID}, - }, - Query{ - Key: Include, - Values: []string{"unicorns"}, - }, + Query{Key: NameFilter, Values: []string{name}}, + Query{Key: SpaceGUIDFilter, Values: []string{spaceGUID}}, + Query{Key: PerPage, Values: []string{"1"}}, + Query{Key: Page, Values: []string{"1"}}, + Query{Key: Include, Values: []string{"unicorns"}}, )) Expect(actualParams.ResponseBody).To(BeAssignableToTypeOf(resources.ServiceInstance{})) }) @@ -292,13 +285,14 @@ var _ = Describe("Service Instance", func() { BeforeEach(func() { requester.MakeRequestCalls(func(params RequestParams) (JobURL, Warnings, error) { - json.Unmarshal([]byte(`{"foo":"bar"}`), params.ResponseBody) + Expect(json.Unmarshal([]byte(`{"foo":"bar"}`), params.ResponseBody)).To(Succeed()) return "", Warnings{"one", "two"}, nil }) }) It("makes the correct API request", func() { - client.GetServiceInstanceParameters(guid) + _, _, err := client.GetServiceInstanceParameters(guid) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) actualRequest := requester.MakeRequestArgsForCall(0) @@ -486,7 +480,8 @@ var _ = Describe("Service Instance", func() { ) It("makes the right request", func() { - client.DeleteServiceInstance(guid) + _, _, err := client.DeleteServiceInstance(guid) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) Expect(requester.MakeRequestArgsForCall(0)).To(Equal(RequestParams{ @@ -497,7 +492,8 @@ var _ = Describe("Service Instance", func() { When("there are query parameters", func() { It("passes them through", func() { - client.DeleteServiceInstance(guid, Query{Key: NameFilter, Values: []string{"foo"}}) + _, _, err := client.DeleteServiceInstance(guid, Query{Key: NameFilter, Values: []string{"foo"}}) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) Expect(requester.MakeRequestArgsForCall(0).Query).To(ConsistOf(Query{Key: NameFilter, Values: []string{"foo"}})) @@ -546,7 +542,8 @@ var _ = Describe("Service Instance", func() { }) It("makes the right request", func() { - client.ShareServiceInstanceToSpaces(serviceInstanceGUID, spaceGUIDs) + _, _, err := client.ShareServiceInstanceToSpaces(serviceInstanceGUID, spaceGUIDs) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) @@ -561,7 +558,7 @@ var _ = Describe("Service Instance", func() { When("the request succeeds", func() { BeforeEach(func() { requester.MakeRequestCalls(func(params RequestParams) (JobURL, Warnings, error) { - json.Unmarshal([]byte(`{"data":[{"guid":"some-space-guid"}, {"guid":"some-other-space-guid"}]}`), params.ResponseBody) + Expect(json.Unmarshal([]byte(`{"data":[{"guid":"some-space-guid"}, {"guid":"some-other-space-guid"}]}`), params.ResponseBody)).To(Succeed()) return "", Warnings{"fake-warning"}, nil }) }) @@ -601,7 +598,8 @@ var _ = Describe("Service Instance", func() { }) It("makes the right request", func() { - client.UnshareServiceInstanceFromSpace(serviceInstanceGUID, spaceGUID) + _, err := client.UnshareServiceInstanceFromSpace(serviceInstanceGUID, spaceGUID) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) Expect(requester.MakeRequestArgsForCall(0)).To(Equal(RequestParams{ @@ -649,7 +647,8 @@ var _ = Describe("Service Instance", func() { }) It("makes the right request", func() { - client.GetServiceInstanceSharedSpaces(serviceInstanceGUID) + _, _, err := client.GetServiceInstanceSharedSpaces(serviceInstanceGUID) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) @@ -671,7 +670,7 @@ var _ = Describe("Service Instance", func() { When("the request succeeds", func() { BeforeEach(func() { requester.MakeRequestCalls(func(params RequestParams) (JobURL, Warnings, error) { - jsonry.Unmarshal([]byte(`{ + Expect(jsonry.Unmarshal([]byte(`{ "data": [{"guid":"some-space-guid"},{"guid":"some-other-space-guid"}], "links": { "self": { @@ -710,7 +709,7 @@ var _ = Describe("Service Instance", func() { } ] } - }`), params.ResponseBody) + }`), params.ResponseBody)).To(Succeed()) return "", Warnings{"fake-warning"}, nil }) }) @@ -761,7 +760,8 @@ var _ = Describe("Service Instance", func() { }) It("makes the right request", func() { - client.GetServiceInstanceUsageSummary(serviceInstanceGUID) + _, _, err := client.GetServiceInstanceUsageSummary(serviceInstanceGUID) + Expect(err).NotTo(HaveOccurred()) Expect(requester.MakeRequestCallCount()).To(Equal(1)) @@ -773,7 +773,7 @@ var _ = Describe("Service Instance", func() { When("the request succeeds", func() { BeforeEach(func() { requester.MakeRequestCalls(func(params RequestParams) (JobURL, Warnings, error) { - jsonry.Unmarshal([]byte(`{ + Expect(jsonry.Unmarshal([]byte(`{ "usage_summary": [ { "space": { @@ -799,7 +799,7 @@ var _ = Describe("Service Instance", func() { "href": "https://api.example.org/v3/service_instances/some_instance_guid" } } - }`), params.ResponseBody) + }`), params.ResponseBody)).To(Succeed()) return "", Warnings{"fake-warning"}, nil }) }) diff --git a/api/cloudcontroller/ccv3/service_offering.go b/api/cloudcontroller/ccv3/service_offering.go index 86567c5d3f1..e48ec922c2e 100644 --- a/api/cloudcontroller/ccv3/service_offering.go +++ b/api/cloudcontroller/ccv3/service_offering.go @@ -1,10 +1,10 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) // GetServiceOffering lists service offering with optional filters. @@ -49,7 +49,11 @@ func (client *Client) GetServiceOfferingByGUID(guid string) (resources.ServiceOf } func (client *Client) GetServiceOfferingByNameAndBroker(serviceOfferingName, serviceBrokerName string) (resources.ServiceOffering, Warnings, error) { - query := []Query{{Key: NameFilter, Values: []string{serviceOfferingName}}} + query := []Query{ + {Key: NameFilter, Values: []string{serviceOfferingName}}, + {Key: PerPage, Values: []string{"2"}}, + {Key: Page, Values: []string{"1"}}, + } if serviceBrokerName != "" { query = append(query, Query{Key: ServiceBrokerNamesFilter, Values: []string{serviceBrokerName}}) } diff --git a/api/cloudcontroller/ccv3/service_offering_test.go b/api/cloudcontroller/ccv3/service_offering_test.go index 2519a8fd2bc..8968b554bf8 100644 --- a/api/cloudcontroller/ccv3/service_offering_test.go +++ b/api/cloudcontroller/ccv3/service_offering_test.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" . "github.com/onsi/gomega/gstruct" @@ -331,6 +331,8 @@ var _ = Describe("Service Offering", func() { "RequestName": Equal(internal.GetServiceOfferingsRequest), "Query": Equal([]Query{ {Key: NameFilter, Values: []string{serviceOfferingName}}, + {Key: PerPage, Values: []string{"2"}}, + {Key: Page, Values: []string{"1"}}, {Key: FieldsServiceBroker, Values: []string{"name", "guid"}}, }), "ResponseBody": Equal(resources.ServiceOffering{}), @@ -406,6 +408,8 @@ var _ = Describe("Service Offering", func() { Expect(requester.MakeListRequestArgsForCall(0).Query).To(ConsistOf( Query{Key: NameFilter, Values: []string{serviceOfferingName}}, Query{Key: ServiceBrokerNamesFilter, Values: []string{"myServiceBroker"}}, + Query{Key: PerPage, Values: []string{"2"}}, + Query{Key: Page, Values: []string{"1"}}, Query{Key: FieldsServiceBroker, Values: []string{"name", "guid"}}, )) }) diff --git a/api/cloudcontroller/ccv3/service_plan.go b/api/cloudcontroller/ccv3/service_plan.go index e61a462e6dd..e3a2c43086a 100644 --- a/api/cloudcontroller/ccv3/service_plan.go +++ b/api/cloudcontroller/ccv3/service_plan.go @@ -1,11 +1,11 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/lookuptable" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/lookuptable" ) func (client *Client) GetServicePlanByGUID(guid string) (resources.ServicePlan, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/service_plan_test.go b/api/cloudcontroller/ccv3/service_plan_test.go index 60f8610706b..3dc7701d31e 100644 --- a/api/cloudcontroller/ccv3/service_plan_test.go +++ b/api/cloudcontroller/ccv3/service_plan_test.go @@ -4,12 +4,12 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/service_plan_visibility.go b/api/cloudcontroller/ccv3/service_plan_visibility.go index 89fb79b21f7..7b647ea784c 100644 --- a/api/cloudcontroller/ccv3/service_plan_visibility.go +++ b/api/cloudcontroller/ccv3/service_plan_visibility.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) GetServicePlanVisibility(servicePlanGUID string) (resources.ServicePlanVisibility, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/service_plan_visibility_test.go b/api/cloudcontroller/ccv3/service_plan_visibility_test.go index 078ed20a2c5..70e135c04f5 100644 --- a/api/cloudcontroller/ccv3/service_plan_visibility_test.go +++ b/api/cloudcontroller/ccv3/service_plan_visibility_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/sidecar.go b/api/cloudcontroller/ccv3/sidecar.go index f9e59c92a25..d3b33c08058 100644 --- a/api/cloudcontroller/ccv3/sidecar.go +++ b/api/cloudcontroller/ccv3/sidecar.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) GetProcessSidecars(processGuid string) ([]resources.Sidecar, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/sidecar_test.go b/api/cloudcontroller/ccv3/sidecar_test.go index 6a963ed4cd7..933cf33ba55 100644 --- a/api/cloudcontroller/ccv3/sidecar_test.go +++ b/api/cloudcontroller/ccv3/sidecar_test.go @@ -3,11 +3,11 @@ package ccv3_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" . "github.com/onsi/gomega/gstruct" diff --git a/api/cloudcontroller/ccv3/space.go b/api/cloudcontroller/ccv3/space.go index cad31730bcb..7a68b9a9c16 100644 --- a/api/cloudcontroller/ccv3/space.go +++ b/api/cloudcontroller/ccv3/space.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) CreateSpace(space resources.Space) (resources.Space, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/space_feature.go b/api/cloudcontroller/ccv3/space_feature.go index 462295bc4e3..3600eb6857a 100644 --- a/api/cloudcontroller/ccv3/space_feature.go +++ b/api/cloudcontroller/ccv3/space_feature.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client *Client) GetSpaceFeature(spaceGUID string, featureName string) (bool, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/space_feature_test.go b/api/cloudcontroller/ccv3/space_feature_test.go index 45e97d398fd..8dddc891c3e 100644 --- a/api/cloudcontroller/ccv3/space_feature_test.go +++ b/api/cloudcontroller/ccv3/space_feature_test.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/space_quota.go b/api/cloudcontroller/ccv3/space_quota.go index b8fb01a176f..f555020b7ff 100644 --- a/api/cloudcontroller/ccv3/space_quota.go +++ b/api/cloudcontroller/ccv3/space_quota.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) func (client Client) ApplySpaceQuota(quotaGUID string, spaceGUID string) (resources.RelationshipList, Warnings, error) { diff --git a/api/cloudcontroller/ccv3/space_quota_test.go b/api/cloudcontroller/ccv3/space_quota_test.go index 26ba72d6126..6b41fb1d5d3 100644 --- a/api/cloudcontroller/ccv3/space_quota_test.go +++ b/api/cloudcontroller/ccv3/space_quota_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -130,7 +130,7 @@ var _ = Describe("Space Quotas", func() { }) - Describe("CreateSpaceQuotas", func() { + Describe("CreateSpaceQuota", func() { JustBeforeEach(func() { createdSpaceQuota, warnings, executeErr = client.CreateSpaceQuota(inputSpaceQuota) }) @@ -144,6 +144,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2}, InstanceMemory: &types.NullInt{IsSet: true, Value: 3}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 4}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 8}, }, Services: resources.ServiceLimit{ PaidServicePlans: &trueValue, @@ -166,7 +167,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 2, "per_process_memory_in_mb": 3, "total_instances": 4, - "per_app_tasks": 900 + "per_app_tasks": 900, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -200,9 +202,10 @@ var _ = Describe("Space Quotas", func() { expectedBody := map[string]interface{}{ "name": "my-space-quota", "apps": map[string]interface{}{ - "total_memory_in_mb": 2, - "per_process_memory_in_mb": 3, - "total_instances": 4, + "total_memory_in_mb": 2, + "per_process_memory_in_mb": 3, + "total_instances": 4, + "log_rate_limit_in_bytes_per_second": 8, }, "services": map[string]interface{}{ "paid_services_allowed": true, @@ -242,6 +245,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2}, InstanceMemory: &types.NullInt{IsSet: true, Value: 3}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 4}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 8}, }, Services: resources.ServiceLimit{ PaidServicePlans: &trueValue, @@ -266,6 +270,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2}, InstanceMemory: &types.NullInt{IsSet: true, Value: 3}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 4}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 8}, }, Services: resources.ServiceLimit{ PaidServicePlans: &trueValue, @@ -289,7 +294,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 2, "per_process_memory_in_mb": 3, "total_instances": 4, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -324,9 +330,10 @@ var _ = Describe("Space Quotas", func() { expectedBody := map[string]interface{}{ "name": "my-space-quota", "apps": map[string]interface{}{ - "total_memory_in_mb": 2, - "per_process_memory_in_mb": 3, - "total_instances": 4, + "total_memory_in_mb": 2, + "per_process_memory_in_mb": 3, + "total_instances": 4, + "log_rate_limit_in_bytes_per_second": 8, }, "services": map[string]interface{}{ "paid_services_allowed": true, @@ -372,6 +379,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2}, InstanceMemory: &types.NullInt{IsSet: true, Value: 3}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 4}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 8}, }, Services: resources.ServiceLimit{ PaidServicePlans: &trueValue, @@ -522,7 +530,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 10240, "per_process_memory_in_mb": 1024, "total_instances": 8, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": false, @@ -566,6 +575,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{Value: 10240, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 8, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true}, @@ -663,7 +673,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 5120, "per_process_memory_in_mb": 1024, "total_instances": 10, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": true, @@ -703,7 +714,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 10240, "per_process_memory_in_mb": 1024, "total_instances": 8, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 16 }, "services": { "paid_services_allowed": false, @@ -756,6 +768,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{Value: 5120, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 10, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 10, IsSet: true}, @@ -776,6 +789,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{Value: 10240, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 8, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 16, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true}, @@ -812,7 +826,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 10240, "per_process_memory_in_mb": 1024, "total_instances": 8, - "per_app_tasks": 5 + "per_app_tasks": 5, + "log_rate_limit_in_bytes_per_second": 8 }, "services": { "paid_services_allowed": false, @@ -858,6 +873,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{Value: 10240, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 8, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 8, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 8, IsSet: true}, @@ -1011,6 +1027,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{Value: 2048, IsSet: true}, InstanceMemory: &types.NullInt{Value: 1024, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: true}, @@ -1035,7 +1052,8 @@ var _ = Describe("Space Quotas", func() { "total_memory_in_mb": 2048, "per_process_memory_in_mb": 1024, "total_instances": null, - "per_app_tasks": null + "per_app_tasks": null, + "log_rate_limit_in_bytes_per_second": null }, "services": { "paid_services_allowed": true, @@ -1056,9 +1074,10 @@ var _ = Describe("Space Quotas", func() { expectedBody := map[string]interface{}{ "name": "elephant-trunk", "apps": map[string]interface{}{ - "total_memory_in_mb": 2048, - "per_process_memory_in_mb": 1024, - "total_instances": nil, + "total_memory_in_mb": 2048, + "per_process_memory_in_mb": 1024, + "total_instances": nil, + "log_rate_limit_in_bytes_per_second": nil, }, "services": map[string]interface{}{ "paid_services_allowed": true, @@ -1088,6 +1107,7 @@ var _ = Describe("Space Quotas", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2048}, InstanceMemory: &types.NullInt{IsSet: true, Value: 1024}, TotalAppInstances: &types.NullInt{IsSet: false, Value: 0}, + TotalLogVolume: &types.NullInt{IsSet: false, Value: 0}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{IsSet: true, Value: 0}, diff --git a/api/cloudcontroller/ccv3/space_test.go b/api/cloudcontroller/ccv3/space_test.go index c8e5ca29f66..01235b98627 100644 --- a/api/cloudcontroller/ccv3/space_test.go +++ b/api/cloudcontroller/ccv3/space_test.go @@ -4,13 +4,13 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -31,7 +31,7 @@ var _ = Describe("Spaces", func() { ) JustBeforeEach(func() { - spaceToCreate = Space{Name: "some-space", Relationships: resources.Relationships{constant.RelationshipTypeOrganization: resources.Relationship{GUID: "some-org-guid"}}} + spaceToCreate = Space{Name: "some-space", Relationships: Relationships{constant.RelationshipTypeOrganization: Relationship{GUID: "some-org-guid"}}} space, warnings, executeErr = client.CreateSpace(spaceToCreate) }) @@ -199,14 +199,14 @@ var _ = Describe("Spaces", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(spaces).To(ConsistOf( - Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-1"}, + Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-1"}, }}, - Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-2"}, + Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-2"}, }}, - Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-3"}, + Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-3"}, }}, )) Expect(warnings).To(ConsistOf("this is a warning", "this is another warning")) @@ -305,14 +305,14 @@ var _ = Describe("Spaces", func() { Expect(warnings).To(ConsistOf("warning-1", "warning-2")) Expect(spaces).To(ConsistOf( - Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-1"}, + Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-1"}, }}, - Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-2"}, + Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-2"}, }}, - Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-3"}, + Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-3"}, }}, )) diff --git a/api/cloudcontroller/ccv3/stack.go b/api/cloudcontroller/ccv3/stack.go index e1704a3c39a..ece8e6e491f 100644 --- a/api/cloudcontroller/ccv3/stack.go +++ b/api/cloudcontroller/ccv3/stack.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // GetStacks lists stacks with optional filters. diff --git a/api/cloudcontroller/ccv3/stack_test.go b/api/cloudcontroller/ccv3/stack_test.go index 7dc60174cb2..f6a3fa2e05c 100644 --- a/api/cloudcontroller/ccv3/stack_test.go +++ b/api/cloudcontroller/ccv3/stack_test.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/target_test.go b/api/cloudcontroller/ccv3/target_test.go index 35c1d8dd9a4..a0549c18f15 100644 --- a/api/cloudcontroller/ccv3/target_test.go +++ b/api/cloudcontroller/ccv3/target_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -73,7 +73,7 @@ var _ = Describe("Target", func() { fakeWrapper2.WrapReturns(fakeWrapper2) fakeWrapper2.MakeStub = func(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error { - apiInfo, ok := passedResponse.DecodeJSONResponseInto.(*Info) + apiInfo, ok := passedResponse.DecodeJSONResponseInto.(*Root) if ok { // Only caring about the first time Make is called, ignore all others apiInfo.Links.CCV3.HREF = server.URL() + "/v3" } diff --git a/api/cloudcontroller/ccv3/task.go b/api/cloudcontroller/ccv3/task.go index 2b67040596d..f1bd65b1ff8 100644 --- a/api/cloudcontroller/ccv3/task.go +++ b/api/cloudcontroller/ccv3/task.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateApplication resources.Task runs a command in the Application environment @@ -25,6 +25,16 @@ func (client *Client) CreateApplicationTask(appGUID string, task resources.Task) func (client *Client) GetApplicationTasks(appGUID string, query ...Query) ([]resources.Task, Warnings, error) { var tasks []resources.Task + foundPerPageQuery := false + for _, keyVal := range query { + if keyVal.Key == PerPage { + foundPerPageQuery = true + } + } + if !foundPerPageQuery { + query = append(query, Query{Key: PerPage, Values: []string{MaxPerPage}}) + } + _, warnings, err := client.MakeListRequest(RequestParams{ RequestName: internal.GetApplicationTasksRequest, URIParams: internal.Params{"app_guid": appGUID}, @@ -53,3 +63,17 @@ func (client *Client) UpdateTaskCancel(taskGUID string) (resources.Task, Warning return responseBody, warnings, err } + +func (client *Client) GetTask(guid string) (resources.Task, Warnings, error) { + var responseBody resources.Task + + _, warnings, err := client.MakeRequest(RequestParams{ + RequestName: internal.GetTaskRequest, + URIParams: internal.Params{ + "task_guid": guid, + }, + ResponseBody: &responseBody, + }) + + return responseBody, warnings, err +} diff --git a/api/cloudcontroller/ccv3/task_test.go b/api/cloudcontroller/ccv3/task_test.go index 24d810d2193..d47735376fa 100644 --- a/api/cloudcontroller/ccv3/task_test.go +++ b/api/cloudcontroller/ccv3/task_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -190,9 +190,18 @@ var _ = Describe("Task", func() { warnings Warnings executeErr error ) + BeforeEach(func() { + // This is required because ginkgo does not instantiate variable per test context so the tests pollute the + // variables for the next tests. + submitQuery = Query{} + }) JustBeforeEach(func() { - tasks, warnings, executeErr = client.GetApplicationTasks("some-app-guid", submitQuery) + if submitQuery.Key == "" { + tasks, warnings, executeErr = client.GetApplicationTasks("some-app-guid") + } else { + tasks, warnings, executeErr = client.GetApplicationTasks("some-app-guid", submitQuery) + } }) When("the application exists", func() { @@ -201,7 +210,8 @@ var _ = Describe("Task", func() { "pagination": { "next": { "href": "%s/v3/apps/some-app-guid/tasks?per_page=2&page=2" - } + }, + "total_results": 3 }, "resources": [ { @@ -245,7 +255,7 @@ var _ = Describe("Task", func() { ) server.AppendHandlers( CombineHandlers( - VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks", "per_page=2&page=2"), + VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks", "page=2&per_page=2"), RespondWith(http.StatusOK, response2, http.Header{"X-Cf-Warnings": {"warning-2"}}), ), ) @@ -353,6 +363,154 @@ var _ = Describe("Task", func() { Expect(warnings).To(ConsistOf("warning")) }) }) + + When("the application has 10000 tasks", func() { + BeforeEach(func() { + response2 := fmt.Sprintf(`{ + "pagination": { + "next": { + "href": "%s/v3/apps/some-app-guid/tasks?per_page=5000&page=2" + }, + "total_results": 10000 + }, + "resources": [ + { + "guid": "task-1-guid", + "sequence_id": 1, + "name": "task-1", + "command": "some-command", + "state": "SUCCEEDED", + "created_at": "2016-11-07T05:59:01Z" + }, + { + "guid": "task-2-guid", + "sequence_id": 2, + "name": "task-2", + "command": "some-command", + "state": "FAILED", + "created_at": "2016-11-07T06:59:01Z" + } + ] + }`, server.URL()) + response3 := fmt.Sprintf(`{ + "pagination": { + "total_results": 10000 + }, + "resources": [ + { + "guid": "task-1-guid", + "sequence_id": 1, + "name": "task-1", + "command": "some-command", + "state": "SUCCEEDED", + "created_at": "2016-11-07T05:59:01Z" + }, + { + "guid": "task-2-guid", + "sequence_id": 2, + "name": "task-2", + "command": "some-command", + "state": "FAILED", + "created_at": "2016-11-07T06:59:01Z" + } + ] + }`) + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks", "per_page=5000"), + RespondWith(http.StatusOK, response2, http.Header{"X-Cf-Warnings": {"warning-2"}}), + ), + ) + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks", "page=2&per_page=5000"), + RespondWith(http.StatusOK, response3, http.Header{"X-Cf-Warnings": {"warning-2"}}), + ), + ) + }) + + It("calls CAPI 2 times", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) + + When("the application has 4999 tasks", func() { + BeforeEach(func() { + response2 := fmt.Sprintf(`{ + "pagination": { + "total_results": 4999 + }, + "resources": [ + { + "guid": "task-1-guid", + "sequence_id": 1, + "name": "task-1", + "command": "some-command", + "state": "SUCCEEDED", + "created_at": "2016-11-07T05:59:01Z" + }, + { + "guid": "task-2-guid", + "sequence_id": 2, + "name": "task-2", + "command": "some-command", + "state": "FAILED", + "created_at": "2016-11-07T06:59:01Z" + } + ] + }`) + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks", "per_page=5000"), + RespondWith(http.StatusOK, response2, http.Header{"X-Cf-Warnings": {"warning-2"}}), + ), + ) + }) + + It("calls CAPI 2 times", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) + + When("the application has 2 tasks", func() { + BeforeEach(func() { + response1 := fmt.Sprintf(`{ + "pagination": { + "total_results": 2 + }, + "resources": [ + { + "guid": "task-1-guid", + "sequence_id": 1, + "name": "task-1", + "command": "some-command", + "state": "SUCCEEDED", + "created_at": "2016-11-07T05:59:01Z" + }, + { + "guid": "task-2-guid", + "sequence_id": 2, + "name": "task-2", + "command": "some-command", + "state": "FAILED", + "created_at": "2016-11-07T06:59:01Z" + } + ] + }`) + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/tasks"), + RespondWith(http.StatusAccepted, response1, http.Header{"X-Cf-Warnings": {"warning"}}), + ), + ) + }) + + It("calls CAPI 1 time", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) }) Describe("UpdateTaskCancel", func() { @@ -443,4 +601,89 @@ var _ = Describe("Task", func() { }) }) }) + + Describe("GetTask", func() { + When("the task exists", func() { + BeforeEach(func() { + response := `{ + "guid": "the-task-guid", + "sequence_id": 1, + "name": "task-1", + "command": "some-command", + "state": "SUCCEEDED", + "created_at": "2016-11-07T05:59:01Z" + }` + + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/tasks/the-task-guid"), + RespondWith(http.StatusOK, response, http.Header{"X-Cf-Warnings": {"warning"}}), + ), + ) + }) + + It("returns the task and all warnings", func() { + task, warnings, err := client.GetTask("the-task-guid") + Expect(err).ToNot(HaveOccurred()) + + expectedTask := resources.Task{ + GUID: "the-task-guid", + SequenceID: 1, + Name: "task-1", + State: constant.TaskSucceeded, + CreatedAt: "2016-11-07T05:59:01Z", + Command: "some-command", + } + + Expect(task).To(Equal(expectedTask)) + Expect(warnings).To(ConsistOf("warning")) + }) + }) + + When("the cloud controller returns errors and warnings", func() { + BeforeEach(func() { + response := `{ + "errors": [ + { + "code": 10008, + "detail": "The request is semantically invalid: command presence", + "title": "CF-UnprocessableEntity" + }, + { + "code": 10010, + "detail": "Task not found", + "title": "CF-ResourceNotFound" + } + ] + }` + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/tasks/the-task-guid"), + RespondWith(http.StatusTeapot, response, http.Header{"X-Cf-Warnings": {"warning"}}), + ), + ) + }) + + It("returns the errors and all warnings", func() { + _, warnings, err := client.GetTask("the-task-guid") + + Expect(err).To(MatchError(ccerror.MultiError{ + ResponseCode: http.StatusTeapot, + Errors: []ccerror.V3Error{ + { + Code: 10008, + Detail: "The request is semantically invalid: command presence", + Title: "CF-UnprocessableEntity", + }, + { + Code: 10010, + Detail: "Task not found", + Title: "CF-ResourceNotFound", + }, + }, + })) + Expect(warnings).To(ConsistOf("warning")) + }) + }) + }) }) diff --git a/api/cloudcontroller/ccv3/user.go b/api/cloudcontroller/ccv3/user.go index 7b2aa8edb20..247d3a77d68 100644 --- a/api/cloudcontroller/ccv3/user.go +++ b/api/cloudcontroller/ccv3/user.go @@ -1,8 +1,8 @@ package ccv3 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/internal" + "code.cloudfoundry.org/cli/v8/resources" ) // CreateUser creates a new Cloud Controller User from the provided UAA user diff --git a/api/cloudcontroller/ccv3/user_test.go b/api/cloudcontroller/ccv3/user_test.go index 19637ae5b8e..75ef1c8fec5 100644 --- a/api/cloudcontroller/ccv3/user_test.go +++ b/api/cloudcontroller/ccv3/user_test.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/ccv3/v2_formatted_resource.go b/api/cloudcontroller/ccv3/v2_formatted_resource.go index 2107a905a9d..ca981f2ed01 100644 --- a/api/cloudcontroller/ccv3/v2_formatted_resource.go +++ b/api/cloudcontroller/ccv3/v2_formatted_resource.go @@ -5,7 +5,7 @@ import ( "os" "strconv" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) // V2FormattedResource represents a Cloud Controller Resource that still has the same shape as the V2 Resource. diff --git a/api/cloudcontroller/ccv3/v2_formatted_resource_test.go b/api/cloudcontroller/ccv3/v2_formatted_resource_test.go index 8a5b605c697..d8937bdd1cb 100644 --- a/api/cloudcontroller/ccv3/v2_formatted_resource_test.go +++ b/api/cloudcontroller/ccv3/v2_formatted_resource_test.go @@ -3,8 +3,8 @@ package ccv3_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/cloudcontroller/ccversion/minimum_version.go b/api/cloudcontroller/ccversion/minimum_version.go index 524f740604f..4a26f5ace56 100644 --- a/api/cloudcontroller/ccversion/minimum_version.go +++ b/api/cloudcontroller/ccversion/minimum_version.go @@ -13,4 +13,15 @@ const ( MinVersionHTTP2RoutingV3 = "3.104.0" MinVersionSpaceSupporterV3 = "3.104.0" + + MinVersionLogRateLimitingV3 = "3.124.0" // TODO: update this when we have a CAPI release + + MinVersionCNB = "3.168.0" + MinVersionBuildpackLifecycleQuery = "3.194.0" + + MinVersionPerRouteOpts = "3.183.0" + + MinVersionCanarySteps = "3.189.0" + + MinVersionServiceBindingStrategy = "3.205.0" ) diff --git a/api/cloudcontroller/cloud_controller_connection.go b/api/cloudcontroller/cloud_controller_connection.go index da375475186..74141674f0e 100644 --- a/api/cloudcontroller/cloud_controller_connection.go +++ b/api/cloudcontroller/cloud_controller_connection.go @@ -2,15 +2,16 @@ package cloudcontroller import ( "crypto/x509" - "io/ioutil" + "errors" + "io" "net" "net/http" "net/url" "strings" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/util" ) // Config is for configuring a CloudControllerConnection. @@ -54,6 +55,7 @@ func (connection *CloudControllerConnection) Make(request *Request, passedRespon if err != nil { return connection.processRequestErrors(request.Request, err) } + defer response.Body.Close() return connection.populateResponse(response, passedResponse) } @@ -62,8 +64,7 @@ func (*CloudControllerConnection) handleStatusCodes(response *http.Response, pas if response.StatusCode == http.StatusNoContent { passedResponse.RawResponse = []byte("{}") } else { - rawBytes, err := ioutil.ReadAll(response.Body) - defer response.Body.Close() + rawBytes, err := io.ReadAll(response.Body) if err != nil { return err } @@ -133,18 +134,21 @@ func (connection *CloudControllerConnection) populateResponse(response *http.Res func (*CloudControllerConnection) processRequestErrors(request *http.Request, err error) error { switch e := err.(type) { case *url.Error: - switch urlErr := e.Err.(type) { - case x509.UnknownAuthorityError: + if errors.As(err, &x509.UnknownAuthorityError{}) { return ccerror.UnverifiedServerError{ URL: request.URL.String(), } - case x509.HostnameError: + } + + hostnameError := x509.HostnameError{} + if errors.As(err, &hostnameError) { return ccerror.SSLValidationHostnameError{ - Message: urlErr.Error(), + Message: hostnameError.Error(), } - default: - return ccerror.RequestError{Err: e} } + + return ccerror.RequestError{Err: e} + default: return err } diff --git a/api/cloudcontroller/cloud_controller_connection_test.go b/api/cloudcontroller/cloud_controller_connection_test.go index c0dbbd5c3d7..4b78bce2ae3 100644 --- a/api/cloudcontroller/cloud_controller_connection_test.go +++ b/api/cloudcontroller/cloud_controller_connection_test.go @@ -6,9 +6,9 @@ import ( "runtime" "strings" - . "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -253,6 +253,9 @@ var _ = Describe("Cloud Controller Connection", func() { When("the server does not have a verified certificate", func() { Context("skipSSLValidation is false", func() { BeforeEach(func() { + if runtime.GOOS == "darwin" { + Skip("ssl verification is different on darwin") + } server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodGet, "/v2/foo"), @@ -277,8 +280,8 @@ var _ = Describe("Cloud Controller Connection", func() { When("the server's certificate does not match the hostname", func() { Context("skipSSLValidation is false", func() { BeforeEach(func() { - if runtime.GOOS == "windows" { - Skip("ssl validation has a different order on windows, will not be returned properly") + if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + Skip("ssl validation has a different order on windows/darwin, will not be returned properly") } server.AppendHandlers( CombineHandlers( @@ -289,18 +292,23 @@ var _ = Describe("Cloud Controller Connection", func() { connection = NewConnection(Config{}) }) - // loopback.cli.fun is a custom DNS record setup to point to 127.0.0.1 + // 127.0.0.1.nip.io is a custom DNS record setup to point to 127.0.0.1 It("returns a SSLValidationHostnameError", func() { - altHostURL := strings.Replace(server.URL(), "127.0.0.1", "loopback.cli.fun", -1) + altHostURL := strings.Replace(server.URL(), "127.0.0.1", "127.0.0.1.nip.io", -1) req, err := http.NewRequest(http.MethodGet, altHostURL, nil) Expect(err).ToNot(HaveOccurred()) request := &Request{Request: req} var response Response err = connection.Make(request, &response) - Expect(err).To(MatchError(ccerror.SSLValidationHostnameError{ - Message: "x509: certificate is valid for example.com, not loopback.cli.fun", - })) + Expect(err).To( + SatisfyAny( + MatchError(ccerror.SSLValidationHostnameError{ + Message: "x509: certificate is valid for example.com, *.example.com, not 127.0.0.1.nip.io", + }), + MatchError(ccerror.SSLValidationHostnameError{ + Message: "x509: certificate is valid for example.com, not 127.0.0.1.nip.io", + }))) }) }) }) diff --git a/api/cloudcontroller/cloudcontroller_suite_test.go b/api/cloudcontroller/cloudcontroller_suite_test.go index e3e4b4577c6..d8ad80d299b 100644 --- a/api/cloudcontroller/cloudcontroller_suite_test.go +++ b/api/cloudcontroller/cloudcontroller_suite_test.go @@ -3,12 +3,11 @@ package cloudcontroller_test import ( "bytes" "log" + "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" - - "testing" ) func TestCloudcontroller(t *testing.T) { diff --git a/api/cloudcontroller/cloudcontrollerfakes/fake_connection.go b/api/cloudcontroller/cloudcontrollerfakes/fake_connection.go index 068ea8e1a50..6a653c9b315 100644 --- a/api/cloudcontroller/cloudcontrollerfakes/fake_connection.go +++ b/api/cloudcontroller/cloudcontrollerfakes/fake_connection.go @@ -4,7 +4,7 @@ package cloudcontrollerfakes import ( "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) type FakeConnection struct { @@ -31,15 +31,16 @@ func (fake *FakeConnection) Make(arg1 *cloudcontroller.Request, arg2 *cloudcontr arg1 *cloudcontroller.Request arg2 *cloudcontroller.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } diff --git a/api/cloudcontroller/connection.go b/api/cloudcontroller/connection.go index 65ab2169fdd..8d0ee03b1ae 100644 --- a/api/cloudcontroller/connection.go +++ b/api/cloudcontroller/connection.go @@ -1,4 +1,4 @@ -// Package cloudcontroller contains shared utilies between the V2 and V3 +// Package cloudcontroller contains shared utilities between the V2 and V3 // clients. // // These sets of packages are still under development/pre-pre-pre...alpha. Use diff --git a/api/cloudcontroller/pipebomb.go b/api/cloudcontroller/pipebomb.go index 29ac6b0fe17..c3ba3c69b47 100644 --- a/api/cloudcontroller/pipebomb.go +++ b/api/cloudcontroller/pipebomb.go @@ -3,7 +3,7 @@ package cloudcontroller import ( "io" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" ) // Pipebomb is a wrapper around an io.Pipe's io.ReadCloser that turns it into a diff --git a/api/cloudcontroller/uploads/upload.go b/api/cloudcontroller/uploads/upload.go index fa69b97a9ad..9e812962571 100644 --- a/api/cloudcontroller/uploads/upload.go +++ b/api/cloudcontroller/uploads/upload.go @@ -6,7 +6,7 @@ import ( "mime/multipart" "path/filepath" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) func CalculateRequestSize(fileSize int64, path string, fieldName string) (int64, error) { diff --git a/api/cloudcontroller/wrapper/custom_wrapper.go b/api/cloudcontroller/wrapper/custom_wrapper.go index dc6b38af746..09cc493f1d6 100644 --- a/api/cloudcontroller/wrapper/custom_wrapper.go +++ b/api/cloudcontroller/wrapper/custom_wrapper.go @@ -1,6 +1,6 @@ package wrapper -import "code.cloudfoundry.org/cli/api/cloudcontroller" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller" // CustomWrapper is a wrapper that can execute arbitrary code via the // CustomMake function on every request that passes through Make. diff --git a/api/cloudcontroller/wrapper/kubernetes_authentication.go b/api/cloudcontroller/wrapper/kubernetes_authentication.go index b683278077e..cc2fe0561a8 100644 --- a/api/cloudcontroller/wrapper/kubernetes_authentication.go +++ b/api/cloudcontroller/wrapper/kubernetes_authentication.go @@ -1,25 +1,12 @@ package wrapper import ( - "bytes" - "crypto/x509" - "encoding/base64" - "encoding/pem" - "errors" - "fmt" "net/http" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/command" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/tools/clientcmd/api" - "k8s.io/client-go/transport" - - _ "k8s.io/client-go/plugin/pkg/client/auth/azure" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/shared" + "code.cloudfoundry.org/cli/v8/command" ) type KubernetesAuthentication struct { @@ -40,87 +27,16 @@ func NewKubernetesAuthentication( } func (a *KubernetesAuthentication) Make(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error { - username, err := a.config.CurrentUserName() + roundTripper, err := shared.WrapForCFOnK8sAuth(a.config, a.k8sConfigGetter, connectionRoundTripper{ + connection: a.connection, + ccRequest: request, + ccResponse: passedResponse, + }) if err != nil { return err } - if username == "" { - return errors.New("current user not set") - } - - k8sConfig, err := a.k8sConfigGetter.Get() - if err != nil { - return err - } - - restConfig, err := clientcmd.NewDefaultClientConfig( - *k8sConfig, - &clientcmd.ConfigOverrides{ - Context: api.Context{AuthInfo: username}, - }).ClientConfig() - if err != nil { - return err - } - - tlsConfig, err := rest.TLSConfigFor(restConfig) - if err != nil { - return fmt.Errorf("failed to get tls config: %w", err) - } - - if tlsConfig != nil && tlsConfig.GetClientCertificate != nil { - cert, err := tlsConfig.GetClientCertificate(nil) - if err != nil { - return fmt.Errorf("failed to get client certificate: %w", err) - } - - if len(cert.Certificate) > 0 && cert.PrivateKey != nil { - var buf bytes.Buffer - - if err := pem.Encode(&buf, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Certificate[0]}); err != nil { - return fmt.Errorf("could not convert certificate to PEM format: %w", err) - } - - key, err := x509.MarshalPKCS8PrivateKey(cert.PrivateKey) - if err != nil { - return fmt.Errorf("could not marshal private key: %w", err) - } - - if err := pem.Encode(&buf, &pem.Block{Type: "PRIVATE KEY", Bytes: key}); err != nil { - return fmt.Errorf("could not convert key to PEM format: %w", err) - } - - auth := "ClientCert " + base64.StdEncoding.EncodeToString(buf.Bytes()) - request.Header.Set("Authorization", auth) - - return a.connection.Make(request, passedResponse) - } - } - - transportConfig, err := restConfig.TransportConfig() - if err != nil { - return fmt.Errorf("failed to get transport config: %w", err) - } - - var roundtripper http.RoundTripper - if transportConfig.WrapTransport == nil { - // i.e. not auth-provider or exec plugin - roundtripper, err = transport.HTTPWrappersForConfig(transportConfig, connectionRoundTripper{ - connection: a.connection, - ccRequest: request, - ccResponse: passedResponse, - }) - if err != nil { - return fmt.Errorf("failed to create new transport: %w", err) - } - } else { - roundtripper = transportConfig.WrapTransport(connectionRoundTripper{ - connection: a.connection, - ccRequest: request, - ccResponse: passedResponse, - }) - } - _, err = roundtripper.RoundTrip(request.Request) + _, err = roundTripper.RoundTrip(request.Request) return err } diff --git a/api/cloudcontroller/wrapper/kubernetes_authentication_test.go b/api/cloudcontroller/wrapper/kubernetes_authentication_test.go index e46a282438e..222420d873c 100644 --- a/api/cloudcontroller/wrapper/kubernetes_authentication_test.go +++ b/api/cloudcontroller/wrapper/kubernetes_authentication_test.go @@ -5,21 +5,21 @@ import ( "encoding/json" "encoding/pem" "errors" - "io/ioutil" + "io" "net/http" "os" "strings" "time" - "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/command/commandfakes" - + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/ccv3fakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/integration/helpers" "github.com/SermoDigital/jose/crypto" "github.com/SermoDigital/jose/jws" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" @@ -119,7 +119,7 @@ var _ = Describe("KubernetesAuthentication", func() { }) }) - When("the chosen kubeernetes auth info is not present in kubeconfig", func() { + When("the chosen kubernetes auth info is not present in kubeconfig", func() { BeforeEach(func() { config.CurrentUserNameReturns("not-present", nil) }) @@ -136,7 +136,7 @@ var _ = Describe("KubernetesAuthentication", func() { actualReq, actualResp := wrappedConnection.MakeArgsForCall(0) Expect(actualResp.HTTPResponse).To(HaveHTTPStatus(http.StatusTeapot)) - body, err := ioutil.ReadAll(actualReq.Body) + body, err := io.ReadAll(actualReq.Body) Expect(err).NotTo(HaveOccurred()) Expect(string(body)).To(Equal("hello")) @@ -339,6 +339,8 @@ var _ = Describe("KubernetesAuthentication", func() { }) It("uses the exec command to generate the Bearer token", func() { + helpers.SkipIfWindows() + Expect(makeErr).NotTo(HaveOccurred()) Expect(wrappedConnection.MakeCallCount()).To(Equal(1)) @@ -391,7 +393,7 @@ var _ = Describe("KubernetesAuthentication", func() { var tokenFilePath string BeforeEach(func() { - tokenFile, err := ioutil.TempFile("", "") + tokenFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) defer tokenFile.Close() _, err = tokenFile.Write(token) @@ -441,9 +443,10 @@ func base64Decode(encoded string) string { } func writeToFile(base64Data string) string { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") + Expect(err).NotTo(HaveOccurred()) + _, err = file.WriteString(base64Decode(base64Data)) Expect(err).NotTo(HaveOccurred()) - file.WriteString(base64Decode(base64Data)) Expect(file.Close()).To(Succeed()) return file.Name() } diff --git a/api/cloudcontroller/wrapper/request_logger.go b/api/cloudcontroller/wrapper/request_logger.go index e354cad2080..a3db0437f6a 100644 --- a/api/cloudcontroller/wrapper/request_logger.go +++ b/api/cloudcontroller/wrapper/request_logger.go @@ -2,13 +2,13 @@ package wrapper import ( "fmt" - "io/ioutil" + "io" "net/http" "sort" "strings" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RequestLoggerOutput @@ -93,7 +93,7 @@ func (logger *RequestLogger) displayRequest(request *cloudcontroller.Request) er contentType := request.Header.Get("Content-Type") if request.Body != nil { if strings.Contains(contentType, "json") { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) if err != nil { return err } @@ -102,7 +102,7 @@ func (logger *RequestLogger) displayRequest(request *cloudcontroller.Request) er return logger.output.DisplayJSONBody(rawRequestBody) } else if strings.Contains(contentType, "x-www-form-urlencoded") { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) if err != nil { return err } diff --git a/api/cloudcontroller/wrapper/request_logger_test.go b/api/cloudcontroller/wrapper/request_logger_test.go index 81e3deb124e..66fef9f37b0 100644 --- a/api/cloudcontroller/wrapper/request_logger_test.go +++ b/api/cloudcontroller/wrapper/request_logger_test.go @@ -3,17 +3,17 @@ package wrapper_test import ( "bytes" "errors" - "io/ioutil" + "io" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/cloudcontrollerfakes" - . "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/cloudcontrollerfakes" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper/wrapperfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -135,7 +135,7 @@ var _ = Describe("Request Logger", func() { Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("foo"))) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) }) @@ -149,7 +149,7 @@ var _ = Describe("Request Logger", func() { It("outputs the body", func() { Expect(makeErr).NotTo(HaveOccurred()) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) Expect(fakeOutput.DisplayMessageCallCount()).To(Equal(1)) @@ -171,7 +171,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the request", func() { + When("an error occurs while trying to log the request", func() { var expectedErr error BeforeEach(func() { @@ -348,7 +348,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the response", func() { + When("an error occurs while trying to log the response", func() { var ( originalErr error expectedErr error diff --git a/api/cloudcontroller/wrapper/retry_request.go b/api/cloudcontroller/wrapper/retry_request.go index cf9e7f6cd6b..dbca1b9f9ea 100644 --- a/api/cloudcontroller/wrapper/retry_request.go +++ b/api/cloudcontroller/wrapper/retry_request.go @@ -3,8 +3,8 @@ package wrapper import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" ) // RetryRequest is a wrapper that retries failed requests if they contain a 5XX diff --git a/api/cloudcontroller/wrapper/retry_request_test.go b/api/cloudcontroller/wrapper/retry_request_test.go index 0fe277d490b..747a3cf6e88 100644 --- a/api/cloudcontroller/wrapper/retry_request_test.go +++ b/api/cloudcontroller/wrapper/retry_request_test.go @@ -2,16 +2,16 @@ package wrapper_test import ( "errors" - "io/ioutil" + "io" "net/http" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/cloudcontrollerfakes" - . "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/cloudcontrollerfakes" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -37,7 +37,7 @@ var _ = Describe("Retry Request", func() { } fakeConnection.MakeStub = func(req *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error { defer req.Body.Close() - body, readErr := ioutil.ReadAll(request.Body) + body, readErr := io.ReadAll(request.Body) Expect(readErr).ToNot(HaveOccurred()) Expect(string(body)).To(Equal(rawRequestBody)) return expectedErr diff --git a/api/cloudcontroller/wrapper/trace_request.go b/api/cloudcontroller/wrapper/trace_request.go new file mode 100644 index 00000000000..eb10f791424 --- /dev/null +++ b/api/cloudcontroller/wrapper/trace_request.go @@ -0,0 +1,31 @@ +package wrapper + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/shared" +) + +// CCTraceHeaderRequest is a wrapper that adds b3 trace headers to requests. +type CCTraceHeaderRequest struct { + headers *shared.TraceHeaders + connection cloudcontroller.Connection +} + +// NewCCTraceHeaderRequest returns a pointer to a CCTraceHeaderRequest wrapper. +func NewCCTraceHeaderRequest(trace string) *CCTraceHeaderRequest { + return &CCTraceHeaderRequest{ + headers: shared.NewTraceHeaders(trace), + } +} + +// Add tracing headers +func (t *CCTraceHeaderRequest) Make(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error { + t.headers.SetHeaders(request.Request) + return t.connection.Make(request, passedResponse) +} + +// Wrap sets the connection in the CCTraceHeaderRequest and returns itself. +func (t *CCTraceHeaderRequest) Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection { + t.connection = innerconnection + return t +} diff --git a/api/cloudcontroller/wrapper/trace_request_test.go b/api/cloudcontroller/wrapper/trace_request_test.go new file mode 100644 index 00000000000..2a68d96be08 --- /dev/null +++ b/api/cloudcontroller/wrapper/trace_request_test.go @@ -0,0 +1,65 @@ +package wrapper_test + +import ( + "bytes" + "net/http" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/cloudcontrollerfakes" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("CCTraceHeaderRequest", func() { + var ( + fakeConnection *cloudcontrollerfakes.FakeConnection + + wrapper cloudcontroller.Connection + + request *cloudcontroller.Request + response *cloudcontroller.Response + makeErr error + + traceHeader string + ) + + BeforeEach(func() { + fakeConnection = new(cloudcontrollerfakes.FakeConnection) + + traceHeader = "trace-id" + + wrapper = NewCCTraceHeaderRequest(traceHeader).Wrap(fakeConnection) + + body := bytes.NewReader([]byte("foo")) + + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", body) + Expect(err).NotTo(HaveOccurred()) + + response = &cloudcontroller.Response{ + RawResponse: []byte("some-response-body"), + HTTPResponse: &http.Response{}, + } + request = cloudcontroller.NewRequest(req, body) + }) + + JustBeforeEach(func() { + makeErr = wrapper.Make(request, response) + }) + + Describe("Make", func() { + It("Adds the request headers", func() { + Expect(makeErr).NotTo(HaveOccurred()) + Expect(request.Header.Get("X-B3-TraceId")).To(Equal(traceHeader)) + Expect(request.Header.Get("X-B3-SpanId")).ToNot(BeEmpty()) + }) + + It("Calls the inner connection", func() { + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + req, resp := fakeConnection.MakeArgsForCall(0) + Expect(req).To(Equal(request)) + Expect(resp).To(Equal(response)) + }) + }) +}) diff --git a/api/cloudcontroller/wrapper/uaa_authentication.go b/api/cloudcontroller/wrapper/uaa_authentication.go index d11ae162857..375bf3fd24c 100644 --- a/api/cloudcontroller/wrapper/uaa_authentication.go +++ b/api/cloudcontroller/wrapper/uaa_authentication.go @@ -6,8 +6,8 @@ import ( "github.com/SermoDigital/jose/jws" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/uaa" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UAAClient diff --git a/api/cloudcontroller/wrapper/uaa_authentication_test.go b/api/cloudcontroller/wrapper/uaa_authentication_test.go index e6429356230..adcca89b224 100644 --- a/api/cloudcontroller/wrapper/uaa_authentication_test.go +++ b/api/cloudcontroller/wrapper/uaa_authentication_test.go @@ -2,25 +2,25 @@ package wrapper_test import ( "errors" - "io/ioutil" + "io" "net/http" "strings" "time" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" "github.com/SermoDigital/jose/crypto" "github.com/SermoDigital/jose/jws" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/cloudcontrollerfakes" - . "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper/wrapperfakes" - "code.cloudfoundry.org/cli/api/uaa/wrapper/util" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/cloudcontrollerfakes" + . "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper/util" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -181,7 +181,7 @@ var _ = Describe("UAA Authentication", func() { body := strings.NewReader(expectedBody) request = cloudcontroller.NewRequest(&http.Request{ Header: http.Header{}, - Body: ioutil.NopCloser(body), + Body: io.NopCloser(body), }, body) inMemoryCache.SetAccessToken(invalidAccessToken) diff --git a/api/cloudcontroller/wrapper/wrapper_suite_test.go b/api/cloudcontroller/wrapper/wrapper_suite_test.go index ba828571f05..bb74362971a 100644 --- a/api/cloudcontroller/wrapper/wrapper_suite_test.go +++ b/api/cloudcontroller/wrapper/wrapper_suite_test.go @@ -7,7 +7,7 @@ import ( "log" "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/cloudcontroller/wrapper/wrapperfakes/fake_request_logger_output.go b/api/cloudcontroller/wrapper/wrapperfakes/fake_request_logger_output.go index 1ef43d68900..7d682916651 100644 --- a/api/cloudcontroller/wrapper/wrapperfakes/fake_request_logger_output.go +++ b/api/cloudcontroller/wrapper/wrapperfakes/fake_request_logger_output.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" ) type FakeRequestLoggerOutput struct { @@ -127,15 +127,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHeader(arg1 string, arg2 string) err arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayHeaderStub + fakeReturns := fake.displayHeaderReturns fake.recordInvocation("DisplayHeader", []interface{}{arg1, arg2}) fake.displayHeaderMutex.Unlock() - if fake.DisplayHeaderStub != nil { - return fake.DisplayHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHeaderReturns return fakeReturns.result1 } @@ -187,15 +188,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHost(arg1 string) error { fake.displayHostArgsForCall = append(fake.displayHostArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayHostStub + fakeReturns := fake.displayHostReturns fake.recordInvocation("DisplayHost", []interface{}{arg1}) fake.displayHostMutex.Unlock() - if fake.DisplayHostStub != nil { - return fake.DisplayHostStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHostReturns return fakeReturns.result1 } @@ -252,15 +254,16 @@ func (fake *FakeRequestLoggerOutput) DisplayJSONBody(arg1 []byte) error { fake.displayJSONBodyArgsForCall = append(fake.displayJSONBodyArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.DisplayJSONBodyStub + fakeReturns := fake.displayJSONBodyReturns fake.recordInvocation("DisplayJSONBody", []interface{}{arg1Copy}) fake.displayJSONBodyMutex.Unlock() - if fake.DisplayJSONBodyStub != nil { - return fake.DisplayJSONBodyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayJSONBodyReturns return fakeReturns.result1 } @@ -312,15 +315,16 @@ func (fake *FakeRequestLoggerOutput) DisplayMessage(arg1 string) error { fake.displayMessageArgsForCall = append(fake.displayMessageArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayMessageStub + fakeReturns := fake.displayMessageReturns fake.recordInvocation("DisplayMessage", []interface{}{arg1}) fake.displayMessageMutex.Unlock() - if fake.DisplayMessageStub != nil { - return fake.DisplayMessageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayMessageReturns return fakeReturns.result1 } @@ -374,15 +378,16 @@ func (fake *FakeRequestLoggerOutput) DisplayRequestHeader(arg1 string, arg2 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DisplayRequestHeaderStub + fakeReturns := fake.displayRequestHeaderReturns fake.recordInvocation("DisplayRequestHeader", []interface{}{arg1, arg2, arg3}) fake.displayRequestHeaderMutex.Unlock() - if fake.DisplayRequestHeaderStub != nil { - return fake.DisplayRequestHeaderStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayRequestHeaderReturns return fakeReturns.result1 } @@ -435,15 +440,16 @@ func (fake *FakeRequestLoggerOutput) DisplayResponseHeader(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayResponseHeaderStub + fakeReturns := fake.displayResponseHeaderReturns fake.recordInvocation("DisplayResponseHeader", []interface{}{arg1, arg2}) fake.displayResponseHeaderMutex.Unlock() - if fake.DisplayResponseHeaderStub != nil { - return fake.DisplayResponseHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayResponseHeaderReturns return fakeReturns.result1 } @@ -496,15 +502,16 @@ func (fake *FakeRequestLoggerOutput) DisplayType(arg1 string, arg2 time.Time) er arg1 string arg2 time.Time }{arg1, arg2}) + stub := fake.DisplayTypeStub + fakeReturns := fake.displayTypeReturns fake.recordInvocation("DisplayType", []interface{}{arg1, arg2}) fake.displayTypeMutex.Unlock() - if fake.DisplayTypeStub != nil { - return fake.DisplayTypeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayTypeReturns return fakeReturns.result1 } @@ -555,9 +562,10 @@ func (fake *FakeRequestLoggerOutput) HandleInternalError(arg1 error) { fake.handleInternalErrorArgsForCall = append(fake.handleInternalErrorArgsForCall, struct { arg1 error }{arg1}) + stub := fake.HandleInternalErrorStub fake.recordInvocation("HandleInternalError", []interface{}{arg1}) fake.handleInternalErrorMutex.Unlock() - if fake.HandleInternalErrorStub != nil { + if stub != nil { fake.HandleInternalErrorStub(arg1) } } @@ -586,15 +594,16 @@ func (fake *FakeRequestLoggerOutput) Start() error { ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -638,15 +647,16 @@ func (fake *FakeRequestLoggerOutput) Stop() error { ret, specificReturn := fake.stopReturnsOnCall[len(fake.stopArgsForCall)] fake.stopArgsForCall = append(fake.stopArgsForCall, struct { }{}) + stub := fake.StopStub + fakeReturns := fake.stopReturns fake.recordInvocation("Stop", []interface{}{}) fake.stopMutex.Unlock() - if fake.StopStub != nil { - return fake.StopStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stopReturns return fakeReturns.result1 } diff --git a/api/cloudcontroller/wrapper/wrapperfakes/fake_token_cache.go b/api/cloudcontroller/wrapper/wrapperfakes/fake_token_cache.go index fc1158cfa33..68a758271c3 100644 --- a/api/cloudcontroller/wrapper/wrapperfakes/fake_token_cache.go +++ b/api/cloudcontroller/wrapper/wrapperfakes/fake_token_cache.go @@ -4,7 +4,7 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" ) type FakeTokenCache struct { @@ -47,15 +47,16 @@ func (fake *FakeTokenCache) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -99,15 +100,16 @@ func (fake *FakeTokenCache) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -151,9 +153,10 @@ func (fake *FakeTokenCache) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -182,9 +185,10 @@ func (fake *FakeTokenCache) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } diff --git a/api/cloudcontroller/wrapper/wrapperfakes/fake_uaaclient.go b/api/cloudcontroller/wrapper/wrapperfakes/fake_uaaclient.go index b328b1d7c81..e62a035dcb1 100644 --- a/api/cloudcontroller/wrapper/wrapperfakes/fake_uaaclient.go +++ b/api/cloudcontroller/wrapper/wrapperfakes/fake_uaaclient.go @@ -4,8 +4,8 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" ) type FakeUAAClient struct { @@ -32,15 +32,16 @@ func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/log_cache_client.go b/api/logcache/log_cache_client.go similarity index 58% rename from command/log_cache_client.go rename to api/logcache/log_cache_client.go index f6884818225..93fe0b83e90 100644 --- a/command/log_cache_client.go +++ b/api/logcache/log_cache_client.go @@ -1,4 +1,4 @@ -package command +package logcache import ( "fmt" @@ -8,8 +8,12 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/util" - logcache "code.cloudfoundry.org/go-log-cache" + logcache "code.cloudfoundry.org/go-log-cache/v2" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/shared" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/util" ) type RequestLoggerOutput interface { @@ -30,31 +34,31 @@ type DebugPrinter struct { func (p DebugPrinter) PrintError(err error) { for _, output := range p.outputs { - _ = output.Start() //nolint - _ = output.DisplayType("ERROR", time.Now()) //nolint - _ = output.DisplayDump(err.Error()) //nolint - _ = output.Stop() //nolint + _ = output.Start() // nolint + _ = output.DisplayType("ERROR", time.Now()) // nolint + _ = output.DisplayDump(err.Error()) // nolint + _ = output.Stop() // nolint } } func (p DebugPrinter) PrintRequest(req *http.Request) { for _, output := range p.outputs { - _ = output.Start() //nolint - _ = output.DisplayType("REQUEST", time.Now()) //nolint - _ = output.DisplayRequestHeader(req.Method, req.URL.RequestURI(), req.Proto) //nolint - _ = output.DisplayHost(req.URL.Host) //nolint - _ = output.DisplayDump(headersString(req.Header)) //nolint - _ = output.Stop() //nolint + _ = output.Start() // nolint + _ = output.DisplayType("REQUEST", time.Now()) // nolint + _ = output.DisplayRequestHeader(req.Method, req.URL.RequestURI(), req.Proto) // nolint + _ = output.DisplayHost(req.URL.Host) // nolint + _ = output.DisplayDump(headersString(req.Header)) // nolint + _ = output.Stop() // nolint } } func (p DebugPrinter) PrintResponse(resp *http.Response) { for _, output := range p.outputs { - _ = output.Start() //nolint - _ = output.DisplayType("RESPONSE", time.Now()) //nolint - _ = output.DisplayResponseHeader(resp.Proto, resp.Status) //nolint - _ = output.DisplayDump(headersString(resp.Header)) //nolint - _ = output.Stop() //nolint + _ = output.Start() // nolint + _ = output.DisplayType("RESPONSE", time.Now()) // nolint + _ = output.DisplayResponseHeader(resp.Proto, resp.Status) // nolint + _ = output.DisplayDump(headersString(resp.Header)) // nolint + _ = output.Stop() // nolint } } @@ -62,15 +66,23 @@ func (p *DebugPrinter) addOutput(output RequestLoggerOutput) { p.outputs = append(p.outputs, output) } +type userAgentHTTPClient struct { + c logcache.HTTPClient + userAgent string +} + +func (c *userAgentHTTPClient) Do(req *http.Request) (*http.Response, error) { + req.Header.Set("User-Agent", c.userAgent) + return c.c.Do(req) +} + type tokenHTTPClient struct { c logcache.HTTPClient accessToken func() string - userAgent string } func (c *tokenHTTPClient) Do(req *http.Request) (*http.Response, error) { req.Header.Set("Authorization", c.accessToken()) - req.Header.Set("User-Agent", c.userAgent) return c.c.Do(req) } @@ -93,9 +105,9 @@ func (c *httpDebugClient) Do(req *http.Request) (*http.Response, error) { return resp, err } -// NewLogCacheClient returns back a configured Log Cache Client. -func NewLogCacheClient(logCacheEndpoint string, config Config, ui UI) *logcache.Client { - tr := &http.Transport{ +// NewClient returns back a configured Log Cache Client. +func NewClient(logCacheEndpoint string, config command.Config, ui command.UI, k8sConfigGetter v7action.KubernetesConfigGetter) (*logcache.Client, error) { + var tr http.RoundTripper = &http.Transport{ Proxy: http.ProxyFromEnvironment, TLSClientConfig: util.NewTLSConfig(nil, config.SkipSSLValidation()), DialContext: (&net.Dialer{ @@ -104,8 +116,19 @@ func NewLogCacheClient(logCacheEndpoint string, config Config, ui UI) *logcache. }).DialContext, } - var client logcache.HTTPClient //nolint - client = &http.Client{Transport: tr} + if config.IsCFOnK8s() { + var err error + tr, err = shared.WrapForCFOnK8sAuth(config, k8sConfigGetter, tr) + if err != nil { + return nil, err + } + } + + var client logcache.HTTPClient // nolint + client = &userAgentHTTPClient{ + c: &http.Client{Transport: tr}, + userAgent: fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS), + } verbose, location := config.Verbose() if verbose && ui != nil { @@ -118,16 +141,19 @@ func NewLogCacheClient(logCacheEndpoint string, config Config, ui UI) *logcache. client = &httpDebugClient{printer: printer, c: client} } - userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS) - return logcache.NewClient( - logCacheEndpoint, - logcache.WithHTTPClient(&tokenHTTPClient{ + if !config.IsCFOnK8s() { + client = &tokenHTTPClient{ c: client, accessToken: config.AccessToken, - userAgent: userAgent, - }), - ) + } + } + + return logcache.NewClient( + logCacheEndpoint, + logcache.WithHTTPClient(client), + ), nil } + func headersString(header http.Header) string { var result string for name, values := range header { diff --git a/api/plugin/client_test.go b/api/plugin/client_test.go index 8d7a37b1ab0..d4b87714aab 100644 --- a/api/plugin/client_test.go +++ b/api/plugin/client_test.go @@ -5,9 +5,9 @@ import ( "net/http" "runtime" - . "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/plugin/download_plugin.go b/api/plugin/download_plugin.go index c08e3ea344d..e6cf51da50c 100644 --- a/api/plugin/download_plugin.go +++ b/api/plugin/download_plugin.go @@ -1,6 +1,6 @@ package plugin -import "io/ioutil" +import "os" func (client *Client) DownloadPlugin(pluginURL string, path string, proxyReader ProxyReader) error { request, err := client.newGETRequest(pluginURL) @@ -14,7 +14,7 @@ func (client *Client) DownloadPlugin(pluginURL string, path string, proxyReader return err } - err = ioutil.WriteFile(path, response.RawResponse, 0700) + err = os.WriteFile(path, response.RawResponse, 0700) if err != nil { return err } diff --git a/api/plugin/download_plugin_test.go b/api/plugin/download_plugin_test.go index 9f53aea4bfe..0c2f6a90d01 100644 --- a/api/plugin/download_plugin_test.go +++ b/api/plugin/download_plugin_test.go @@ -2,15 +2,14 @@ package plugin_test import ( "io" - "io/ioutil" "net/http" "net/url" "os" - . "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -24,7 +23,7 @@ var _ = Describe("DownloadPlugin", func() { BeforeEach(func() { client = NewTestClient() - tempFile, err := ioutil.TempFile("", "") + tempFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) tempPath = tempFile.Name() @@ -56,12 +55,12 @@ var _ = Describe("DownloadPlugin", func() { fakeProxyReader := new(pluginfakes.FakeProxyReader) fakeProxyReader.WrapStub = func(reader io.Reader) io.ReadCloser { - return ioutil.NopCloser(reader) + return io.NopCloser(reader) } err := client.DownloadPlugin(server.URL(), tempPath, fakeProxyReader) Expect(err).ToNot(HaveOccurred()) - fileData, err := ioutil.ReadFile(tempPath) + fileData, err := os.ReadFile(tempPath) Expect(err).ToNot(HaveOccurred()) Expect(fileData).To(Equal(data)) diff --git a/api/plugin/plugin_connection.go b/api/plugin/plugin_connection.go index a93d6c78478..7fcd3fdabe5 100644 --- a/api/plugin/plugin_connection.go +++ b/api/plugin/plugin_connection.go @@ -4,15 +4,15 @@ import ( "bytes" "crypto/x509" "encoding/json" + "errors" "io" - "io/ioutil" "net" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/util" ) // PluginConnection represents a connection to a plugin repo. @@ -73,7 +73,7 @@ func (*PluginConnection) handleStatusCodes(response *http.Response, passedRespon func (connection *PluginConnection) populateResponse(response *http.Response, passedResponse *Response, body io.ReadCloser) error { passedResponse.HTTPResponse = response - rawBytes, err := ioutil.ReadAll(body) + rawBytes, err := io.ReadAll(body) defer body.Close() if err != nil { return err @@ -101,18 +101,21 @@ func (connection *PluginConnection) populateResponse(response *http.Response, pa func (connection *PluginConnection) processRequestErrors(request *http.Request, err error) error { switch e := err.(type) { case *url.Error: - switch urlErr := e.Err.(type) { - case x509.UnknownAuthorityError: + if errors.As(err, &x509.UnknownAuthorityError{}) { return pluginerror.UnverifiedServerError{ URL: request.URL.String(), } - case x509.HostnameError: + } + + hostnameError := x509.HostnameError{} + if errors.As(err, &hostnameError) { return pluginerror.SSLValidationHostnameError{ - Message: urlErr.Error(), + Message: hostnameError.Error(), } - default: - return pluginerror.RequestError{Err: e} } + + return pluginerror.RequestError{Err: e} + default: return err } diff --git a/api/plugin/plugin_connection_test.go b/api/plugin/plugin_connection_test.go index 6415fdc7b9c..eab0add21c9 100644 --- a/api/plugin/plugin_connection_test.go +++ b/api/plugin/plugin_connection_test.go @@ -3,15 +3,14 @@ package plugin_test import ( "fmt" "io" - "io/ioutil" "net/http" "runtime" "strings" - . "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -33,7 +32,7 @@ var _ = Describe("Plugin Connection", func() { fakeProxyReader = new(pluginfakes.FakeProxyReader) fakeProxyReader.WrapStub = func(reader io.Reader) io.ReadCloser { - return ioutil.NopCloser(reader) + return io.NopCloser(reader) } }) @@ -155,6 +154,9 @@ var _ = Describe("Plugin Connection", func() { When("the server does not have a verified certificate", func() { Context("skipSSLValidation is false", func() { BeforeEach(func() { + if runtime.GOOS == "darwin" { + Skip("ssl verification is different on darwin") + } server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodGet, "/list"), @@ -178,8 +180,8 @@ var _ = Describe("Plugin Connection", func() { When("the server's certificate does not match the hostname", func() { Context("skipSSLValidation is false", func() { BeforeEach(func() { - if runtime.GOOS == "windows" { - Skip("ssl validation has a different order on windows, will not be returned properly") + if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + Skip("ssl validation has a different order on windows/darwin, will not be returned properly") } server.AppendHandlers( CombineHandlers( @@ -190,17 +192,22 @@ var _ = Describe("Plugin Connection", func() { connection = NewConnection(false, 0) }) - // loopback.cli.fun is a custom DNS record setup to point to 127.0.0.1 + // 127.0.0.1.nip.io is a DNS record setup to point to 127.0.0.1 It("returns a SSLValidationHostnameError", func() { - altHostURL := strings.Replace(server.URL(), "127.0.0.1", "loopback.cli.fun", -1) + altHostURL := strings.Replace(server.URL(), "127.0.0.1", "127.0.0.1.nip.io", -1) request, err := http.NewRequest(http.MethodGet, altHostURL, nil) Expect(err).ToNot(HaveOccurred()) var response Response err = connection.Make(request, &response, nil) - Expect(err).To(MatchError(pluginerror.SSLValidationHostnameError{ - Message: "x509: certificate is valid for example.com, not loopback.cli.fun", - })) + Expect(err).To( + SatisfyAny( + MatchError(pluginerror.SSLValidationHostnameError{ + Message: "x509: certificate is valid for example.com, *.example.com, not 127.0.0.1.nip.io", + }), + MatchError(pluginerror.SSLValidationHostnameError{ + Message: "x509: certificate is valid for example.com, not 127.0.0.1.nip.io", + }))) }) }) }) diff --git a/api/plugin/plugin_repository_test.go b/api/plugin/plugin_repository_test.go index f0e187f14ca..7fd9b572627 100644 --- a/api/plugin/plugin_repository_test.go +++ b/api/plugin/plugin_repository_test.go @@ -5,9 +5,9 @@ import ( "net/http" "net/url" - . "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/plugin/plugin_suite_test.go b/api/plugin/plugin_suite_test.go index b514244a53a..6b8e479c5ee 100644 --- a/api/plugin/plugin_suite_test.go +++ b/api/plugin/plugin_suite_test.go @@ -3,13 +3,12 @@ package plugin_test import ( "bytes" "log" + "testing" - . "code.cloudfoundry.org/cli/api/plugin" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/plugin" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" - - "testing" ) func TestPlugin(t *testing.T) { diff --git a/api/plugin/pluginfakes/fake_connection.go b/api/plugin/pluginfakes/fake_connection.go index 7c0c8374cf4..36c4fcf9f03 100644 --- a/api/plugin/pluginfakes/fake_connection.go +++ b/api/plugin/pluginfakes/fake_connection.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin" ) type FakeConnection struct { @@ -34,15 +34,16 @@ func (fake *FakeConnection) Make(arg1 *http.Request, arg2 *plugin.Response, arg3 arg2 *plugin.Response arg3 plugin.ProxyReader }{arg1, arg2, arg3}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2, arg3}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } diff --git a/api/plugin/pluginfakes/fake_connection_wrapper.go b/api/plugin/pluginfakes/fake_connection_wrapper.go index 02121dbbc4d..a981905093a 100644 --- a/api/plugin/pluginfakes/fake_connection_wrapper.go +++ b/api/plugin/pluginfakes/fake_connection_wrapper.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin" ) type FakeConnectionWrapper struct { @@ -45,15 +45,16 @@ func (fake *FakeConnectionWrapper) Make(arg1 *http.Request, arg2 *plugin.Respons arg2 *plugin.Response arg3 plugin.ProxyReader }{arg1, arg2, arg3}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2, arg3}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } @@ -105,15 +106,16 @@ func (fake *FakeConnectionWrapper) Wrap(arg1 plugin.Connection) plugin.Connectio fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { arg1 plugin.Connection }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns fake.recordInvocation("Wrap", []interface{}{arg1}) fake.wrapMutex.Unlock() - if fake.WrapStub != nil { - return fake.WrapStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.wrapReturns return fakeReturns.result1 } diff --git a/api/plugin/pluginfakes/fake_proxy_reader.go b/api/plugin/pluginfakes/fake_proxy_reader.go index bb9729e831c..225c33d8be2 100644 --- a/api/plugin/pluginfakes/fake_proxy_reader.go +++ b/api/plugin/pluginfakes/fake_proxy_reader.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin" ) type FakeProxyReader struct { @@ -37,9 +37,10 @@ func (fake *FakeProxyReader) Finish() { fake.finishMutex.Lock() fake.finishArgsForCall = append(fake.finishArgsForCall, struct { }{}) + stub := fake.FinishStub fake.recordInvocation("Finish", []interface{}{}) fake.finishMutex.Unlock() - if fake.FinishStub != nil { + if stub != nil { fake.FinishStub() } } @@ -61,9 +62,10 @@ func (fake *FakeProxyReader) Start(arg1 int64) { fake.startArgsForCall = append(fake.startArgsForCall, struct { arg1 int64 }{arg1}) + stub := fake.StartStub fake.recordInvocation("Start", []interface{}{arg1}) fake.startMutex.Unlock() - if fake.StartStub != nil { + if stub != nil { fake.StartStub(arg1) } } @@ -93,15 +95,16 @@ func (fake *FakeProxyReader) Wrap(arg1 io.Reader) io.ReadCloser { fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { arg1 io.Reader }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns fake.recordInvocation("Wrap", []interface{}{arg1}) fake.wrapMutex.Unlock() - if fake.WrapStub != nil { - return fake.WrapStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.wrapReturns return fakeReturns.result1 } diff --git a/api/plugin/wrapper/request_logger.go b/api/plugin/wrapper/request_logger.go index c878d36e4b9..6b193410e7f 100644 --- a/api/plugin/wrapper/request_logger.go +++ b/api/plugin/wrapper/request_logger.go @@ -2,12 +2,12 @@ package wrapper import ( "bytes" - "io/ioutil" + "io" "net/http" "sort" "time" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RequestLoggerOutput @@ -90,13 +90,13 @@ func (logger *RequestLogger) displayRequest(request *http.Request) error { } if request.Body != nil && request.Header.Get("Content-Type") == "application/json" { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) defer request.Body.Close() if err != nil { return err } - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) err = logger.output.DisplayJSONBody(rawRequestBody) if err != nil { return err diff --git a/api/plugin/wrapper/request_logger_test.go b/api/plugin/wrapper/request_logger_test.go index ad447373f64..ec06eda9f3e 100644 --- a/api/plugin/wrapper/request_logger_test.go +++ b/api/plugin/wrapper/request_logger_test.go @@ -4,17 +4,16 @@ import ( "bytes" "errors" "io" - "io/ioutil" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - . "code.cloudfoundry.org/cli/api/plugin/wrapper" - "code.cloudfoundry.org/cli/api/plugin/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + . "code.cloudfoundry.org/cli/v8/api/plugin/wrapper" + "code.cloudfoundry.org/cli/v8/api/plugin/wrapper/wrapperfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -132,7 +131,7 @@ var _ = Describe("Request Logger", func() { BeforeEach(func() { request.Header.Set("Content-Type", "application/json") - originalBody = ioutil.NopCloser(bytes.NewReader([]byte("foo"))) + originalBody = io.NopCloser(bytes.NewReader([]byte("foo"))) request.Body = originalBody }) @@ -142,7 +141,7 @@ var _ = Describe("Request Logger", func() { Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("foo"))) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) }) @@ -160,7 +159,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the request", func() { + When("an error occurs while trying to log the request", func() { var expectedErr error BeforeEach(func() { @@ -198,7 +197,7 @@ var _ = Describe("Request Logger", func() { "AAAAA": {"first"}, "CCCCC": {"third"}, }, - Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"some-key":"some-value"}`))), + Body: io.NopCloser(bytes.NewReader([]byte(`{"some-key":"some-value"}`))), }, } }) @@ -249,7 +248,7 @@ var _ = Describe("Request Logger", func() { "AAAAA": {"first"}, "CCCCC": {"third"}, }, - Body: ioutil.NopCloser(bytes.NewReader([]byte(`not JSON`))), + Body: io.NopCloser(bytes.NewReader([]byte(`not JSON`))), }, } }) @@ -335,7 +334,7 @@ var _ = Describe("Request Logger", func() { "AAAAA": {"first"}, "CCCCC": {"third"}, }, - Body: ioutil.NopCloser(bytes.NewReader([]byte(`some-error-body`))), + Body: io.NopCloser(bytes.NewReader([]byte(`some-error-body`))), }, } }) @@ -373,7 +372,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the response", func() { + When("an error occurs while trying to log the response", func() { var ( originalErr error expectedErr error diff --git a/api/plugin/wrapper/retry_request.go b/api/plugin/wrapper/retry_request.go index 83436bd5296..b0535b2f111 100644 --- a/api/plugin/wrapper/retry_request.go +++ b/api/plugin/wrapper/retry_request.go @@ -2,10 +2,10 @@ package wrapper import ( "bytes" - "io/ioutil" + "io" "net/http" - "code.cloudfoundry.org/cli/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin" ) // RetryRequest is a wrapper that retries failed requests if they contain a 5XX @@ -28,7 +28,7 @@ func (retry *RetryRequest) Make(request *http.Request, passedResponse *plugin.Re var rawRequestBody []byte if request.Body != nil { - rawRequestBody, err = ioutil.ReadAll(request.Body) + rawRequestBody, err = io.ReadAll(request.Body) defer request.Body.Close() if err != nil { return err @@ -37,7 +37,7 @@ func (retry *RetryRequest) Make(request *http.Request, passedResponse *plugin.Re for i := 0; i < retry.maxRetries+1; i++ { if rawRequestBody != nil { - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) } err = retry.connection.Make(request, passedResponse, proxyReader) if err == nil { diff --git a/api/plugin/wrapper/retry_request_test.go b/api/plugin/wrapper/retry_request_test.go index dcd97918f58..c3ecfe12946 100644 --- a/api/plugin/wrapper/retry_request_test.go +++ b/api/plugin/wrapper/retry_request_test.go @@ -2,16 +2,16 @@ package wrapper_test import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - . "code.cloudfoundry.org/cli/api/plugin/wrapper" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + . "code.cloudfoundry.org/cli/v8/api/plugin/wrapper" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -22,7 +22,7 @@ var _ = Describe("Retry Request", func() { Expect(err).NotTo(HaveOccurred()) rawRequestBody := "banana pants" - request.Body = ioutil.NopCloser(strings.NewReader(rawRequestBody)) + request.Body = io.NopCloser(strings.NewReader(rawRequestBody)) response := &plugin.Response{ HTTPResponse: &http.Response{ @@ -36,7 +36,7 @@ var _ = Describe("Retry Request", func() { } fakeConnection.MakeStub = func(req *http.Request, passedResponse *plugin.Response, proxyReader plugin.ProxyReader) error { defer req.Body.Close() - body, readErr := ioutil.ReadAll(request.Body) + body, readErr := io.ReadAll(request.Body) Expect(readErr).ToNot(HaveOccurred()) Expect(string(body)).To(Equal(rawRequestBody)) return expectedErr diff --git a/api/plugin/wrapper/wrapper_suite_test.go b/api/plugin/wrapper/wrapper_suite_test.go index 9ff807b77f8..c63da4999de 100644 --- a/api/plugin/wrapper/wrapper_suite_test.go +++ b/api/plugin/wrapper/wrapper_suite_test.go @@ -3,12 +3,11 @@ package wrapper_test import ( "bytes" "log" + "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" - - "testing" ) func TestPlugin(t *testing.T) { diff --git a/api/plugin/wrapper/wrapperfakes/fake_request_logger_output.go b/api/plugin/wrapper/wrapperfakes/fake_request_logger_output.go index 5f0b28bfaaa..d3413626b21 100644 --- a/api/plugin/wrapper/wrapperfakes/fake_request_logger_output.go +++ b/api/plugin/wrapper/wrapperfakes/fake_request_logger_output.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/plugin/wrapper" + "code.cloudfoundry.org/cli/v8/api/plugin/wrapper" ) type FakeRequestLoggerOutput struct { @@ -126,15 +126,16 @@ func (fake *FakeRequestLoggerOutput) DisplayDump(arg1 string) error { fake.displayDumpArgsForCall = append(fake.displayDumpArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayDumpStub + fakeReturns := fake.displayDumpReturns fake.recordInvocation("DisplayDump", []interface{}{arg1}) fake.displayDumpMutex.Unlock() - if fake.DisplayDumpStub != nil { - return fake.DisplayDumpStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayDumpReturns return fakeReturns.result1 } @@ -187,15 +188,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHeader(arg1 string, arg2 string) err arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayHeaderStub + fakeReturns := fake.displayHeaderReturns fake.recordInvocation("DisplayHeader", []interface{}{arg1, arg2}) fake.displayHeaderMutex.Unlock() - if fake.DisplayHeaderStub != nil { - return fake.DisplayHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHeaderReturns return fakeReturns.result1 } @@ -247,15 +249,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHost(arg1 string) error { fake.displayHostArgsForCall = append(fake.displayHostArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayHostStub + fakeReturns := fake.displayHostReturns fake.recordInvocation("DisplayHost", []interface{}{arg1}) fake.displayHostMutex.Unlock() - if fake.DisplayHostStub != nil { - return fake.DisplayHostStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHostReturns return fakeReturns.result1 } @@ -312,15 +315,16 @@ func (fake *FakeRequestLoggerOutput) DisplayJSONBody(arg1 []byte) error { fake.displayJSONBodyArgsForCall = append(fake.displayJSONBodyArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.DisplayJSONBodyStub + fakeReturns := fake.displayJSONBodyReturns fake.recordInvocation("DisplayJSONBody", []interface{}{arg1Copy}) fake.displayJSONBodyMutex.Unlock() - if fake.DisplayJSONBodyStub != nil { - return fake.DisplayJSONBodyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayJSONBodyReturns return fakeReturns.result1 } @@ -374,15 +378,16 @@ func (fake *FakeRequestLoggerOutput) DisplayRequestHeader(arg1 string, arg2 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DisplayRequestHeaderStub + fakeReturns := fake.displayRequestHeaderReturns fake.recordInvocation("DisplayRequestHeader", []interface{}{arg1, arg2, arg3}) fake.displayRequestHeaderMutex.Unlock() - if fake.DisplayRequestHeaderStub != nil { - return fake.DisplayRequestHeaderStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayRequestHeaderReturns return fakeReturns.result1 } @@ -435,15 +440,16 @@ func (fake *FakeRequestLoggerOutput) DisplayResponseHeader(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayResponseHeaderStub + fakeReturns := fake.displayResponseHeaderReturns fake.recordInvocation("DisplayResponseHeader", []interface{}{arg1, arg2}) fake.displayResponseHeaderMutex.Unlock() - if fake.DisplayResponseHeaderStub != nil { - return fake.DisplayResponseHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayResponseHeaderReturns return fakeReturns.result1 } @@ -496,15 +502,16 @@ func (fake *FakeRequestLoggerOutput) DisplayType(arg1 string, arg2 time.Time) er arg1 string arg2 time.Time }{arg1, arg2}) + stub := fake.DisplayTypeStub + fakeReturns := fake.displayTypeReturns fake.recordInvocation("DisplayType", []interface{}{arg1, arg2}) fake.displayTypeMutex.Unlock() - if fake.DisplayTypeStub != nil { - return fake.DisplayTypeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayTypeReturns return fakeReturns.result1 } @@ -555,9 +562,10 @@ func (fake *FakeRequestLoggerOutput) HandleInternalError(arg1 error) { fake.handleInternalErrorArgsForCall = append(fake.handleInternalErrorArgsForCall, struct { arg1 error }{arg1}) + stub := fake.HandleInternalErrorStub fake.recordInvocation("HandleInternalError", []interface{}{arg1}) fake.handleInternalErrorMutex.Unlock() - if fake.HandleInternalErrorStub != nil { + if stub != nil { fake.HandleInternalErrorStub(arg1) } } @@ -586,15 +594,16 @@ func (fake *FakeRequestLoggerOutput) Start() error { ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -638,15 +647,16 @@ func (fake *FakeRequestLoggerOutput) Stop() error { ret, specificReturn := fake.stopReturnsOnCall[len(fake.stopArgsForCall)] fake.stopArgsForCall = append(fake.stopArgsForCall, struct { }{}) + stub := fake.StopStub + fakeReturns := fake.stopReturns fake.recordInvocation("Stop", []interface{}{}) fake.stopMutex.Unlock() - if fake.StopStub != nil { - return fake.StopStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stopReturns return fakeReturns.result1 } diff --git a/api/router/client.go b/api/router/client.go index b6ceeefe46f..531a8539ef5 100644 --- a/api/router/client.go +++ b/api/router/client.go @@ -5,7 +5,7 @@ import ( "fmt" "runtime" - "code.cloudfoundry.org/cli/api/router/internal" + "code.cloudfoundry.org/cli/v8/api/router/internal" "github.com/tedsuo/rata" ) diff --git a/api/router/router_connection.go b/api/router/router_connection.go index 999ec889946..43562a340b6 100644 --- a/api/router/router_connection.go +++ b/api/router/router_connection.go @@ -4,15 +4,15 @@ import ( "bytes" "crypto/x509" "encoding/json" - "io/ioutil" + "io" "net" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/router/routererror" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + "code.cloudfoundry.org/cli/v8/util" ) // ConnectionConfig is for configuring the RouterConnection @@ -71,7 +71,7 @@ func (*RouterConnection) handleStatusCodes(httpResponse *http.Response, response func (connection *RouterConnection) populateResponse(httpResponse *http.Response, responseToPopulate *Response) error { responseToPopulate.HTTPResponse = httpResponse - rawBytes, err := ioutil.ReadAll(httpResponse.Body) + rawBytes, err := io.ReadAll(httpResponse.Body) defer httpResponse.Body.Close() if err != nil { return err diff --git a/api/router/router_group.go b/api/router/router_group.go index de67d5cf6f2..fae6675b2b1 100644 --- a/api/router/router_group.go +++ b/api/router/router_group.go @@ -3,8 +3,8 @@ package router import ( "net/url" - "code.cloudfoundry.org/cli/api/router/internal" - "code.cloudfoundry.org/cli/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/router/internal" + "code.cloudfoundry.org/cli/v8/api/router/routererror" ) // RouterGroup represents a router group. diff --git a/api/router/router_group_test.go b/api/router/router_group_test.go index 78d60b4b910..26f9cfcc38f 100644 --- a/api/router/router_group_test.go +++ b/api/router/router_group_test.go @@ -3,10 +3,10 @@ package router_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" - "code.cloudfoundry.org/cli/api/router/wrapper" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/router/wrapper" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/router/router_suite_test.go b/api/router/router_suite_test.go index d059eb5813d..56fb9c41afe 100644 --- a/api/router/router_suite_test.go +++ b/api/router/router_suite_test.go @@ -4,13 +4,12 @@ import ( "bytes" "log" "net/url" + "testing" - "code.cloudfoundry.org/cli/api/router" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/router" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" - - "testing" ) func TestRouter(t *testing.T) { diff --git a/api/router/routerfakes/fake_connection.go b/api/router/routerfakes/fake_connection.go index 5185d53c75f..c7919361f4d 100644 --- a/api/router/routerfakes/fake_connection.go +++ b/api/router/routerfakes/fake_connection.go @@ -4,7 +4,7 @@ package routerfakes import ( "sync" - "code.cloudfoundry.org/cli/api/router" + "code.cloudfoundry.org/cli/v8/api/router" ) type FakeConnection struct { @@ -31,15 +31,16 @@ func (fake *FakeConnection) Make(arg1 *router.Request, arg2 *router.Response) er arg1 *router.Request arg2 *router.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } diff --git a/api/router/routerfakes/fake_connection_wrapper.go b/api/router/routerfakes/fake_connection_wrapper.go index d890a183eb8..7bb514be222 100644 --- a/api/router/routerfakes/fake_connection_wrapper.go +++ b/api/router/routerfakes/fake_connection_wrapper.go @@ -4,7 +4,7 @@ package routerfakes import ( "sync" - "code.cloudfoundry.org/cli/api/router" + "code.cloudfoundry.org/cli/v8/api/router" ) type FakeConnectionWrapper struct { @@ -42,15 +42,16 @@ func (fake *FakeConnectionWrapper) Make(arg1 *router.Request, arg2 *router.Respo arg1 *router.Request arg2 *router.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } @@ -102,15 +103,16 @@ func (fake *FakeConnectionWrapper) Wrap(arg1 router.Connection) router.Connectio fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { arg1 router.Connection }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns fake.recordInvocation("Wrap", []interface{}{arg1}) fake.wrapMutex.Unlock() - if fake.WrapStub != nil { - return fake.WrapStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.wrapReturns return fakeReturns.result1 } diff --git a/api/router/wrapper/error_wrapper.go b/api/router/wrapper/error_wrapper.go index 07579b90951..8a33fdee6d3 100644 --- a/api/router/wrapper/error_wrapper.go +++ b/api/router/wrapper/error_wrapper.go @@ -4,8 +4,8 @@ import ( "encoding/json" "net/http" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" ) const expiredTokenMessage = "Token is expired" diff --git a/api/router/wrapper/error_wrapper_test.go b/api/router/wrapper/error_wrapper_test.go index de75d125ff0..b4b99d6c532 100644 --- a/api/router/wrapper/error_wrapper_test.go +++ b/api/router/wrapper/error_wrapper_test.go @@ -3,11 +3,11 @@ package wrapper_test import ( "net/http" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" - "code.cloudfoundry.org/cli/api/router/routerfakes" - . "code.cloudfoundry.org/cli/api/router/wrapper" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/router/routerfakes" + . "code.cloudfoundry.org/cli/v8/api/router/wrapper" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/router/wrapper/request_logger.go b/api/router/wrapper/request_logger.go index e843d158aab..be8bdd57a94 100644 --- a/api/router/wrapper/request_logger.go +++ b/api/router/wrapper/request_logger.go @@ -2,13 +2,13 @@ package wrapper import ( "fmt" - "io/ioutil" + "io" "net/http" "sort" "strings" "time" - "code.cloudfoundry.org/cli/api/router" + "code.cloudfoundry.org/cli/v8/api/router" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RequestLoggerOutput @@ -93,7 +93,7 @@ func (logger *RequestLogger) displayRequest(request *router.Request) error { contentType := request.Header.Get("Content-Type") if request.Body != nil { if strings.Contains(contentType, "json") { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) if err != nil { return err } @@ -102,7 +102,7 @@ func (logger *RequestLogger) displayRequest(request *router.Request) error { return logger.output.DisplayJSONBody(rawRequestBody) } else if strings.Contains(contentType, "x-www-form-urlencoded") { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) if err != nil { return err } diff --git a/api/router/wrapper/request_logger_test.go b/api/router/wrapper/request_logger_test.go index ba361891961..36397b58fb1 100644 --- a/api/router/wrapper/request_logger_test.go +++ b/api/router/wrapper/request_logger_test.go @@ -3,17 +3,17 @@ package wrapper_test import ( "bytes" "errors" - "io/ioutil" + "io" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routerfakes" - . "code.cloudfoundry.org/cli/api/router/wrapper" - "code.cloudfoundry.org/cli/api/router/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routerfakes" + . "code.cloudfoundry.org/cli/v8/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/router/wrapper/wrapperfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -135,7 +135,7 @@ var _ = Describe("Request Logger", func() { Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte("foo"))) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) }) @@ -149,7 +149,7 @@ var _ = Describe("Request Logger", func() { It("outputs the body", func() { Expect(makeErr).NotTo(HaveOccurred()) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) Expect(fakeOutput.DisplayMessageCallCount()).To(Equal(1)) @@ -171,7 +171,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the request", func() { + When("an error occurs while trying to log the request", func() { var expectedErr error BeforeEach(func() { @@ -305,7 +305,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the response", func() { + When("an error occurs while trying to log the response", func() { var ( originalErr error expectedErr error diff --git a/api/router/wrapper/trace_request.go b/api/router/wrapper/trace_request.go new file mode 100644 index 00000000000..fe290a2bc83 --- /dev/null +++ b/api/router/wrapper/trace_request.go @@ -0,0 +1,31 @@ +package wrapper + +import ( + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/shared" +) + +// RoutingTraceHeaderRequest is a wrapper that adds b3 trace headers to requests. +type RoutingTraceHeaderRequest struct { + headers *shared.TraceHeaders + connection router.Connection +} + +// NewRoutingTraceHeaderRequest returns a pointer to a RoutingTraceHeaderRequest wrapper. +func NewRoutingTraceHeaderRequest(trace string) *RoutingTraceHeaderRequest { + return &RoutingTraceHeaderRequest{ + headers: shared.NewTraceHeaders(trace), + } +} + +// Add tracing headers +func (t *RoutingTraceHeaderRequest) Make(request *router.Request, passedResponse *router.Response) error { + t.headers.SetHeaders(request.Request) + return t.connection.Make(request, passedResponse) +} + +// Wrap sets the connection in the RoutingTraceHeaderRequest and returns itself. +func (t *RoutingTraceHeaderRequest) Wrap(innerconnection router.Connection) router.Connection { + t.connection = innerconnection + return t +} diff --git a/api/router/wrapper/trace_request_test.go b/api/router/wrapper/trace_request_test.go new file mode 100644 index 00000000000..b4f5f86bd72 --- /dev/null +++ b/api/router/wrapper/trace_request_test.go @@ -0,0 +1,64 @@ +package wrapper_test + +import ( + "bytes" + "net/http" + + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routerfakes" + . "code.cloudfoundry.org/cli/v8/api/router/wrapper" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("CCTraceHeaderRequest", func() { + var ( + fakeConnection *routerfakes.FakeConnection + + wrapper router.Connection + + request *router.Request + response *router.Response + makeErr error + + traceHeader string + ) + + BeforeEach(func() { + fakeConnection = new(routerfakes.FakeConnection) + + traceHeader = "trace-id" + wrapper = NewRoutingTraceHeaderRequest(traceHeader).Wrap(fakeConnection) + + body := bytes.NewReader([]byte("foo")) + + req, err := http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", body) + Expect(err).NotTo(HaveOccurred()) + + response = &router.Response{ + RawResponse: []byte("some-response-body"), + HTTPResponse: &http.Response{}, + } + request = router.NewRequest(req, body) + }) + + JustBeforeEach(func() { + makeErr = wrapper.Make(request, response) + }) + + Describe("Make", func() { + It("Adds the request headers", func() { + Expect(makeErr).NotTo(HaveOccurred()) + Expect(request.Header.Get("X-B3-TraceId")).To(Equal(traceHeader)) + Expect(request.Header.Get("X-B3-SpanId")).ToNot(BeEmpty()) + }) + + It("Calls the inner connection", func() { + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + req, resp := fakeConnection.MakeArgsForCall(0) + Expect(req).To(Equal(request)) + Expect(resp).To(Equal(response)) + }) + }) +}) diff --git a/api/router/wrapper/uaa_authentication.go b/api/router/wrapper/uaa_authentication.go index 6fca8a07d8b..cf2766c3efc 100644 --- a/api/router/wrapper/uaa_authentication.go +++ b/api/router/wrapper/uaa_authentication.go @@ -1,9 +1,9 @@ package wrapper import ( - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/uaa" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UAAClient diff --git a/api/router/wrapper/uaa_authentication_test.go b/api/router/wrapper/uaa_authentication_test.go index 86788c337df..5f288ade4a3 100644 --- a/api/router/wrapper/uaa_authentication_test.go +++ b/api/router/wrapper/uaa_authentication_test.go @@ -2,19 +2,19 @@ package wrapper_test import ( "errors" - "io/ioutil" + "io" "net/http" "strings" - "code.cloudfoundry.org/cli/api/router" - "code.cloudfoundry.org/cli/api/router/routererror" - "code.cloudfoundry.org/cli/api/router/routerfakes" - . "code.cloudfoundry.org/cli/api/router/wrapper" - "code.cloudfoundry.org/cli/api/router/wrapper/wrapperfakes" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/wrapper/util" + "code.cloudfoundry.org/cli/v8/api/router" + "code.cloudfoundry.org/cli/v8/api/router/routererror" + "code.cloudfoundry.org/cli/v8/api/router/routerfakes" + . "code.cloudfoundry.org/cli/v8/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/router/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper/util" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -118,12 +118,12 @@ var _ = Describe("UAA Authentication", func() { body := strings.NewReader(expectedBody) request = router.NewRequest(&http.Request{ Header: http.Header{}, - Body: ioutil.NopCloser(body), + Body: io.NopCloser(body), }, body) makeCount := 0 fakeConnection.MakeStub = func(request *router.Request, response *router.Response) error { - body, err := ioutil.ReadAll(request.Body) + body, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(string(body)).To(Equal(expectedBody)) diff --git a/api/router/wrapper/wrapper_suite_test.go b/api/router/wrapper/wrapper_suite_test.go index a0aaff50b6b..ce086767016 100644 --- a/api/router/wrapper/wrapper_suite_test.go +++ b/api/router/wrapper/wrapper_suite_test.go @@ -3,7 +3,7 @@ package wrapper import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/router/wrapper/wrapperfakes/fake_request_logger_output.go b/api/router/wrapper/wrapperfakes/fake_request_logger_output.go index 665f9441df8..f909d7d0121 100644 --- a/api/router/wrapper/wrapperfakes/fake_request_logger_output.go +++ b/api/router/wrapper/wrapperfakes/fake_request_logger_output.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/router/wrapper" ) type FakeRequestLoggerOutput struct { @@ -127,15 +127,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHeader(arg1 string, arg2 string) err arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayHeaderStub + fakeReturns := fake.displayHeaderReturns fake.recordInvocation("DisplayHeader", []interface{}{arg1, arg2}) fake.displayHeaderMutex.Unlock() - if fake.DisplayHeaderStub != nil { - return fake.DisplayHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHeaderReturns return fakeReturns.result1 } @@ -187,15 +188,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHost(arg1 string) error { fake.displayHostArgsForCall = append(fake.displayHostArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayHostStub + fakeReturns := fake.displayHostReturns fake.recordInvocation("DisplayHost", []interface{}{arg1}) fake.displayHostMutex.Unlock() - if fake.DisplayHostStub != nil { - return fake.DisplayHostStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHostReturns return fakeReturns.result1 } @@ -252,15 +254,16 @@ func (fake *FakeRequestLoggerOutput) DisplayJSONBody(arg1 []byte) error { fake.displayJSONBodyArgsForCall = append(fake.displayJSONBodyArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.DisplayJSONBodyStub + fakeReturns := fake.displayJSONBodyReturns fake.recordInvocation("DisplayJSONBody", []interface{}{arg1Copy}) fake.displayJSONBodyMutex.Unlock() - if fake.DisplayJSONBodyStub != nil { - return fake.DisplayJSONBodyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayJSONBodyReturns return fakeReturns.result1 } @@ -312,15 +315,16 @@ func (fake *FakeRequestLoggerOutput) DisplayMessage(arg1 string) error { fake.displayMessageArgsForCall = append(fake.displayMessageArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayMessageStub + fakeReturns := fake.displayMessageReturns fake.recordInvocation("DisplayMessage", []interface{}{arg1}) fake.displayMessageMutex.Unlock() - if fake.DisplayMessageStub != nil { - return fake.DisplayMessageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayMessageReturns return fakeReturns.result1 } @@ -374,15 +378,16 @@ func (fake *FakeRequestLoggerOutput) DisplayRequestHeader(arg1 string, arg2 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DisplayRequestHeaderStub + fakeReturns := fake.displayRequestHeaderReturns fake.recordInvocation("DisplayRequestHeader", []interface{}{arg1, arg2, arg3}) fake.displayRequestHeaderMutex.Unlock() - if fake.DisplayRequestHeaderStub != nil { - return fake.DisplayRequestHeaderStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayRequestHeaderReturns return fakeReturns.result1 } @@ -435,15 +440,16 @@ func (fake *FakeRequestLoggerOutput) DisplayResponseHeader(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayResponseHeaderStub + fakeReturns := fake.displayResponseHeaderReturns fake.recordInvocation("DisplayResponseHeader", []interface{}{arg1, arg2}) fake.displayResponseHeaderMutex.Unlock() - if fake.DisplayResponseHeaderStub != nil { - return fake.DisplayResponseHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayResponseHeaderReturns return fakeReturns.result1 } @@ -496,15 +502,16 @@ func (fake *FakeRequestLoggerOutput) DisplayType(arg1 string, arg2 time.Time) er arg1 string arg2 time.Time }{arg1, arg2}) + stub := fake.DisplayTypeStub + fakeReturns := fake.displayTypeReturns fake.recordInvocation("DisplayType", []interface{}{arg1, arg2}) fake.displayTypeMutex.Unlock() - if fake.DisplayTypeStub != nil { - return fake.DisplayTypeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayTypeReturns return fakeReturns.result1 } @@ -555,9 +562,10 @@ func (fake *FakeRequestLoggerOutput) HandleInternalError(arg1 error) { fake.handleInternalErrorArgsForCall = append(fake.handleInternalErrorArgsForCall, struct { arg1 error }{arg1}) + stub := fake.HandleInternalErrorStub fake.recordInvocation("HandleInternalError", []interface{}{arg1}) fake.handleInternalErrorMutex.Unlock() - if fake.HandleInternalErrorStub != nil { + if stub != nil { fake.HandleInternalErrorStub(arg1) } } @@ -586,15 +594,16 @@ func (fake *FakeRequestLoggerOutput) Start() error { ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -638,15 +647,16 @@ func (fake *FakeRequestLoggerOutput) Stop() error { ret, specificReturn := fake.stopReturnsOnCall[len(fake.stopArgsForCall)] fake.stopArgsForCall = append(fake.stopArgsForCall, struct { }{}) + stub := fake.StopStub + fakeReturns := fake.stopReturns fake.recordInvocation("Stop", []interface{}{}) fake.stopMutex.Unlock() - if fake.StopStub != nil { - return fake.StopStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stopReturns return fakeReturns.result1 } diff --git a/api/router/wrapper/wrapperfakes/fake_token_cache.go b/api/router/wrapper/wrapperfakes/fake_token_cache.go index 780d388a0bd..f982080fb29 100644 --- a/api/router/wrapper/wrapperfakes/fake_token_cache.go +++ b/api/router/wrapper/wrapperfakes/fake_token_cache.go @@ -4,7 +4,7 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/router/wrapper" ) type FakeTokenCache struct { @@ -47,15 +47,16 @@ func (fake *FakeTokenCache) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -99,15 +100,16 @@ func (fake *FakeTokenCache) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -151,9 +153,10 @@ func (fake *FakeTokenCache) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -182,9 +185,10 @@ func (fake *FakeTokenCache) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } diff --git a/api/router/wrapper/wrapperfakes/fake_uaaclient.go b/api/router/wrapper/wrapperfakes/fake_uaaclient.go index e534f49ba47..052b836552c 100644 --- a/api/router/wrapper/wrapperfakes/fake_uaaclient.go +++ b/api/router/wrapper/wrapperfakes/fake_uaaclient.go @@ -4,8 +4,8 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/router/wrapper" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" ) type FakeUAAClient struct { @@ -32,15 +32,16 @@ func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/api/shared/shared_suite_test.go b/api/shared/shared_suite_test.go new file mode 100644 index 00000000000..2ae985574c0 --- /dev/null +++ b/api/shared/shared_suite_test.go @@ -0,0 +1,25 @@ +package shared_test + +import ( + "crypto/rand" + "crypto/rsa" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestShared(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Shared Wrapper Suite") +} + +var ( + keyPair *rsa.PrivateKey +) + +var _ = BeforeEach(func() { + var err error + keyPair, err = rsa.GenerateKey(rand.Reader, 2048) + Expect(err).NotTo(HaveOccurred()) +}) diff --git a/api/shared/sharedfakes/fake_round_tripper.go b/api/shared/sharedfakes/fake_round_tripper.go new file mode 100644 index 00000000000..e8c0e9dd4f4 --- /dev/null +++ b/api/shared/sharedfakes/fake_round_tripper.go @@ -0,0 +1,115 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package sharedfakes + +import ( + "net/http" + "sync" +) + +type FakeRoundTripper struct { + RoundTripStub func(*http.Request) (*http.Response, error) + roundTripMutex sync.RWMutex + roundTripArgsForCall []struct { + arg1 *http.Request + } + roundTripReturns struct { + result1 *http.Response + result2 error + } + roundTripReturnsOnCall map[int]struct { + result1 *http.Response + result2 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeRoundTripper) RoundTrip(arg1 *http.Request) (*http.Response, error) { + fake.roundTripMutex.Lock() + ret, specificReturn := fake.roundTripReturnsOnCall[len(fake.roundTripArgsForCall)] + fake.roundTripArgsForCall = append(fake.roundTripArgsForCall, struct { + arg1 *http.Request + }{arg1}) + stub := fake.RoundTripStub + fakeReturns := fake.roundTripReturns + fake.recordInvocation("RoundTrip", []interface{}{arg1}) + fake.roundTripMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeRoundTripper) RoundTripCallCount() int { + fake.roundTripMutex.RLock() + defer fake.roundTripMutex.RUnlock() + return len(fake.roundTripArgsForCall) +} + +func (fake *FakeRoundTripper) RoundTripCalls(stub func(*http.Request) (*http.Response, error)) { + fake.roundTripMutex.Lock() + defer fake.roundTripMutex.Unlock() + fake.RoundTripStub = stub +} + +func (fake *FakeRoundTripper) RoundTripArgsForCall(i int) *http.Request { + fake.roundTripMutex.RLock() + defer fake.roundTripMutex.RUnlock() + argsForCall := fake.roundTripArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeRoundTripper) RoundTripReturns(result1 *http.Response, result2 error) { + fake.roundTripMutex.Lock() + defer fake.roundTripMutex.Unlock() + fake.RoundTripStub = nil + fake.roundTripReturns = struct { + result1 *http.Response + result2 error + }{result1, result2} +} + +func (fake *FakeRoundTripper) RoundTripReturnsOnCall(i int, result1 *http.Response, result2 error) { + fake.roundTripMutex.Lock() + defer fake.roundTripMutex.Unlock() + fake.RoundTripStub = nil + if fake.roundTripReturnsOnCall == nil { + fake.roundTripReturnsOnCall = make(map[int]struct { + result1 *http.Response + result2 error + }) + } + fake.roundTripReturnsOnCall[i] = struct { + result1 *http.Response + result2 error + }{result1, result2} +} + +func (fake *FakeRoundTripper) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.roundTripMutex.RLock() + defer fake.roundTripMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeRoundTripper) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ http.RoundTripper = new(FakeRoundTripper) diff --git a/api/shared/trace_headers.go b/api/shared/trace_headers.go new file mode 100644 index 00000000000..1623bd2e413 --- /dev/null +++ b/api/shared/trace_headers.go @@ -0,0 +1,37 @@ +package shared + +import ( + "net/http" + + "code.cloudfoundry.org/cli/v8/util/trace" +) + +const ( + B3TraceIDHeader = "X-B3-TraceId" + B3SpanIDHeader = "X-B3-SpanId" +) + +// TraceHeaders sets b3 trace headers to requests. +type TraceHeaders struct { + b3trace string +} + +// NewTraceHeaders returns a pointer to a TraceHeaderRequest. +func NewTraceHeaders(trace string) *TraceHeaders { + return &TraceHeaders{ + b3trace: trace, + } +} + +// Add tracing headers if they are not already set. +func (t *TraceHeaders) SetHeaders(request *http.Request) { + // only override the trace headers if they are not already set (e.g. already explicitly set by cf curl) + if request.Header.Get(B3TraceIDHeader) == "" { + request.Header.Add(B3TraceIDHeader, t.b3trace) + } + if request.Header.Get(B3SpanIDHeader) == "" { + request.Header.Add(B3SpanIDHeader, trace.GenerateRandomTraceID(16)) + } + + // request.Header.Add(("B3", request.Header.Get(B3TraceIDHeader)+request.Header.Get(B3SpanIDHeader))) +} diff --git a/api/shared/trace_headers_test.go b/api/shared/trace_headers_test.go new file mode 100644 index 00000000000..c53dac9e351 --- /dev/null +++ b/api/shared/trace_headers_test.go @@ -0,0 +1,42 @@ +package shared_test + +import ( + "net/http" + + . "code.cloudfoundry.org/cli/v8/api/shared" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("B3 Trace Headers", func() { + Describe("SetHeaders", func() { + Context("when there are already headers set", func() { + It("does not add the headers", func() { + traceHeaders := NewTraceHeaders("new_trace_id") + request := &http.Request{ + Header: http.Header{}, + } + request.Header.Set("X-B3-TraceId", "old_trace_id") + request.Header.Set("X-B3-SpanId", "old_span_id") + traceHeaders.SetHeaders(request) + + Expect(request.Header.Get("X-B3-TraceId")).To(Equal("old_trace_id")) + Expect(request.Header.Get("X-B3-SpanId")).To(Equal("old_span_id")) + }) + }) + + Context("when there are no headers set", func() { + It("adds the headers", func() { + traceHeaders := NewTraceHeaders("new_trace_id") + request := &http.Request{ + Header: http.Header{}, + } + traceHeaders.SetHeaders(request) + + Expect(request.Header.Get("X-B3-TraceId")).To(Equal("new_trace_id")) + Expect(request.Header.Get("X-B3-SpanId")).ToNot(BeEmpty()) + }) + }) + }) +}) diff --git a/api/shared/wrap_for_cf_on_k8s.go b/api/shared/wrap_for_cf_on_k8s.go new file mode 100644 index 00000000000..383452510be --- /dev/null +++ b/api/shared/wrap_for_cf_on_k8s.go @@ -0,0 +1,124 @@ +package shared + +import ( + "bytes" + "crypto/tls" + "crypto/x509" + "encoding/base64" + "encoding/pem" + "errors" + "fmt" + "net/http" + + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" + "k8s.io/client-go/tools/clientcmd/api" + "k8s.io/client-go/transport" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + + // imported for the side effects + _ "k8s.io/client-go/plugin/pkg/client/auth/azure" + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" +) + +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 net/http.RoundTripper + +func WrapForCFOnK8sAuth(config command.Config, k8sConfigGetter v7action.KubernetesConfigGetter, roundTripper http.RoundTripper) (http.RoundTripper, error) { + username, err := config.CurrentUserName() + if err != nil { + return nil, err + } + if username == "" { + return nil, errors.New("current user not set") + } + + k8sConfig, err := k8sConfigGetter.Get() + if err != nil { + return nil, err + } + + restConfig, err := clientcmd.NewDefaultClientConfig( + *k8sConfig, + &clientcmd.ConfigOverrides{ + Context: api.Context{AuthInfo: username}, + }, + ).ClientConfig() + if err != nil { + return nil, err + } + + // Special case for certs, since we don't want mtls + cert, err := getCert(restConfig) + if err != nil { + return nil, err + } + + transportConfig, err := restConfig.TransportConfig() + if err != nil { + return nil, fmt.Errorf("failed to get transport config: %w", err) + } + + if cert != nil { + return certRoundTripper{ + cert: cert, + roundTripper: roundTripper, + }, nil + } + + if transportConfig.WrapTransport == nil { + // i.e. not auth-provider or exec plugin + return transport.HTTPWrappersForConfig(transportConfig, roundTripper) + } + + // using auth provider to generate token + return transportConfig.WrapTransport(roundTripper), nil +} + +func getCert(restConfig *rest.Config) (*tls.Certificate, error) { + tlsConfig, err := rest.TLSConfigFor(restConfig) + if err != nil { + return nil, fmt.Errorf("failed to get tls config: %w", err) + } + + if tlsConfig != nil && tlsConfig.GetClientCertificate != nil { + cert, err := tlsConfig.GetClientCertificate(nil) + if err != nil { + return nil, fmt.Errorf("failed to get client certificate: %w", err) + } + + if len(cert.Certificate) > 0 && cert.PrivateKey != nil { + return cert, nil + } + } + return nil, nil +} + +type certRoundTripper struct { + cert *tls.Certificate + roundTripper http.RoundTripper +} + +func (rt certRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + var buf bytes.Buffer + + if err := pem.Encode(&buf, &pem.Block{Type: "CERTIFICATE", Bytes: rt.cert.Certificate[0]}); err != nil { + return nil, fmt.Errorf("could not convert certificate to PEM format: %w", err) + } + + key, err := x509.MarshalPKCS8PrivateKey(rt.cert.PrivateKey) + if err != nil { + return nil, fmt.Errorf("could not marshal private key: %w", err) + } + + if err := pem.Encode(&buf, &pem.Block{Type: "PRIVATE KEY", Bytes: key}); err != nil { + return nil, fmt.Errorf("could not convert key to PEM format: %w", err) + } + + auth := "ClientCert " + base64.StdEncoding.EncodeToString(buf.Bytes()) + req.Header.Set("Authorization", auth) + + return rt.roundTripper.RoundTrip(req) +} diff --git a/api/shared/wrap_for_cf_on_k8s_test.go b/api/shared/wrap_for_cf_on_k8s_test.go new file mode 100644 index 00000000000..05a52fdad13 --- /dev/null +++ b/api/shared/wrap_for_cf_on_k8s_test.go @@ -0,0 +1,466 @@ +package shared_test + +import ( + "encoding/base64" + "encoding/json" + "encoding/pem" + "errors" + "io" + "net/http" + "os" + "strings" + "time" + + "code.cloudfoundry.org/cli/v8/actor/v7action/v7actionfakes" + "code.cloudfoundry.org/cli/v8/api/shared" + "code.cloudfoundry.org/cli/v8/api/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + "github.com/SermoDigital/jose/crypto" + "github.com/SermoDigital/jose/jws" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" + "k8s.io/client-go/tools/clientcmd/api" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +const ( + clientCertData = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJVk9iMUFIckxNUjh3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRFd01EVXhOVEExTURsYUZ3MHlNakV3TURVeE5UQTFNVEZhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXJrdWxLbS9qTTJhZWZsdjkKK00zQk9Jc2QvVXZrRTBONGhWb3hSeWRBbE0xQXhWd3REYUdzL3dmUzRzb0xuNHJENTF3UE1SRlNJaitwSzdGYQprRGdaR0x4UFhrai96UkZOTzcvU3J2RHYwVGxjYjJENzNCS21qaXArQ2hBWkpQdWhMQlY2VnlTN0pXSWhOM1lOCktyamR5TnB5MHN3SjI1TW9CbW1saUpFc3V2dCtDaEhseERqWE9KenF1U2owa1hPQVVsWUFTN1dKK09JMU9HbzQKUjcvdHdHZlFTNW9oYXpRVVlDR2lZSllYcjVRNkVKTmJOVVI0RjdpRSthY1I5Rm9GNnNKSmkrQStET1VDUFFSKwptbjQ5Zm1pcFVHSGtMc3BicTNFZ0FEME40VW5jcmIyeUJEMFNVTmdLQmJjclY1S2hybFA2SzkwNkY5NEpubzNHCm1Id1JwUUlEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RBWURWUjBUQVFIL0JBSXdBREFmQmdOVkhTTUVHREFXZ0JUV2VNZ1ZBRkRhbWcraDRqS3hoRUh2Q1l5egp5akFOQmdrcWhraUc5dzBCQVFzRkFBT0NBUUVBUUxMWWFXQTRva1M2b3ZEWjQ1Z28ybkVZdUR4MklmRXZwYnh3CkNmYkFTNDY4M3lLT3FiYVBHOEpTVGhSbkh3TWlMcVBrbGFsdkJvV2R3aFB5Vkk0d2tVNHI4Y2c0UEpxNEZwWnQKVkNUQzFPZWVwRGpTMFpVQjRwSDVIZVlNQUxqSDBqcFV3RU96djFpaEtid05IMHFoZ2pGeUNTdld5TG9oZHdzbApJWXIvV1NEZm50NlBETC84TjFpcEJJbEN5Z1JHVGdoSFhPemhHUklPWG4rYWVOR29yWm9YWm0xbHErc1hyUnc5CktNdVZhRmdhaWVjSm0vbytyemFFSG9VZjRYOERKeVNubmVTa3ViaEx6ZERNc2o5eEs1cEJpdFgvaDlQMUQrMkcKeW5rcWdJVTJSWTM0SjBRcnU4Z0syNlJVT2pOcHIvRWJHQ0dUQUxiMXJnSDM0K2NFdlE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==" + clientKeyData = "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2Z0lCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktnd2dnU2tBZ0VBQW9JQkFRQ3VTNlVxYitNelpwNSsKVy8zNHpjRTRpeDM5UytRVFEzaUZXakZISjBDVXpVREZYQzBOb2F6L0I5TGl5Z3VmaXNQblhBOHhFVklpUDZrcgpzVnFRT0JrWXZFOWVTUC9ORVUwN3Y5S3U4Ty9ST1Z4dllQdmNFcWFPS240S0VCa2srNkVzRlhwWEpMc2xZaUUzCmRnMHF1TjNJMm5MU3pBbmJreWdHYWFXSWtTeTYrMzRLRWVYRU9OYzRuT3E1S1BTUmM0QlNWZ0JMdFluNDRqVTQKYWpoSHYrM0FaOUJMbWlGck5CUmdJYUpnbGhldmxEb1FrMXMxUkhnWHVJVDVweEgwV2dYcXdrbUw0RDRNNVFJOQpCSDZhZmoxK2FLbFFZZVF1eWx1cmNTQUFQUTNoU2R5dHZiSUVQUkpRMkFvRnR5dFhrcUd1VS9vcjNUb1gzZ21lCmpjYVlmQkdsQWdNQkFBRUNnZ0VBZG80WndLM3VteTM0TFBjaDM3VUU4eE1keVFkd0VmSlk3a3dWTE5MMFNNTDgKaGNKWEd1aVlKYmtLcHh6TG55L2laV0xuS25jZnFSQW9ZQUg1R2hRdWJmYlkvY2NseURVMmxhZTdCU2Y1MkJUdQpYUXhaQks3aS85ekRjdERVYWFXSFVkY2lLbGhmdStQdHVDM2ljdWJnWlJqQjljUzRCOVVtNm9XK0JSREtuandICkduQ0lEZlNNQWt4VXdTaUwwa2NXelNpZ1BYMVN3UHcxOEZvZWgzTmJEd1VXTHhxUWZLVThydVlSTUsxYUg5M3cKcjFtbjlDWUwvd0hiVWRqcmtZMlIxTjVUR21ab2Vldm5qUXgyQVc2NkYzdEg1cGg4RTF6TEFQVTl4TFdRTW9KcwpXM0gzSTdUaEYvRnJuNERQa3hQbThUUVVhQUdvQ09SSWFUQkN5VlgxQVFLQmdRREkxbkRmNWYySHdHaldrTStpCk9YbGE1R1VnRUtXaGZpeGhidE5OclNpMDU5VnZQUEJwNXdtbGQzMHJKUDhWem8vbnFnUW5ISmpmaEQ2Y3NSMTQKL2VlMHZ1Um0zYzZwZzMrODdwOHhWY3lLNHhDd0JmdFFuMGRZWWFLMkRMOEtYb0liYThpN09EQmFoNW5OZWQwcgpKa1RPcE5NRGRkL0p0bEpPZ25jRXBlUk9oUUtCZ1FEZUt1L0R1MXU1QVR3Y3p5STRXOWV1L1YwTXRwMHdqM3RpClF2MmpObW83QU1zS3BwK0ZKVDFqWFhUKzZCTm02OWpxUVJwdlAyd2RhVUdqV1dLa1lHVEVpbUZCc2ZuKzJDOFAKOEc3Uk50YWpRdEV2QlR1ZDZPN0tZUkFoTU56dm9RcDkrZmJKY1ZsRG13Nlk0bUYzUTJXS3NmZU51TGtpY3VqNQpYVFV1ekVMd29RS0JnUUREU0IvQTFYVEx4cjhwd3V6aHBGam5sQ1R3Skwrb1kzTHIya01EeUZkSWNCUU1jWWlpCnNNK2tZS2NJaUpTdnM0WWhrQ014bEpEZzVVbXNPbHVhQmVpQ3l3cHpLMEdEZWlWK285ZU90UXFLRVhkc2NLU0oKSkJiUFRVQlZHOWUyVVdiWkd0aTNrazhSOThBSkYzR0NQMWV3Um53WFpVb1FiSU5qYTJBbTJOZEJzUUtCZ0Q4eApOVXVXTWl1NE56SDJsTVExRTI4NXI4cmE4bkVLanN6UFF6ZTJWWmI4emNQMHl2RGpPOGZVb0YrVkFWZklBOFgxCnlLQVdDUm1BZytRRG03UW5tdUh3Zm1OaVRUcDRvVUpHWUM3d0N6TWE0VWNmbE9xQWc5TmFzbXpPYWpsYXRCSkwKRkRBT0pwYTlOdlN6aDRlVnl2OGRTYzJzMmpQN1BWc1ljUFVqc25LaEFvR0JBSy9kQjlnVEFpME5nczVmaVNtWQovWkp3Yk52MjcyTHdKbWV4Vit2eWtjN3J5LzRraTRQb2xRd1BHNzQ5eFZ0T2NNc2FhRlVNMVVkclN2NlIwbjlkCmpTbXhCeTl2YWdzc1FmVDNSc3BvUUJKM0w5YWxiNHM2V2ZtUEpzNkFrQkhIZHNpVXFaaElYT2J2WE1lQ0k2aVMKOTQ2R0toekFxMlVGbjhFUGxXaFVNeEFiCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K" +) + +var _ = Describe("WrapForCFOnK8sAuth", func() { + var ( + config *commandfakes.FakeConfig + k8sConfigGetter *v7actionfakes.FakeKubernetesConfigGetter + req *http.Request + res *http.Response + actualRes *http.Response + kubeConfig *api.Config + wrapErr error + wrappedRoundTripper *sharedfakes.FakeRoundTripper + ) + + BeforeEach(func() { + kubeConfig = &api.Config{ + Kind: "Config", + APIVersion: "v1", + Clusters: map[string]*api.Cluster{ + "my-cluster": { + Server: "https://example.org", + }, + }, + Contexts: map[string]*api.Context{ + "my-context": { + Cluster: "my-cluster", + AuthInfo: "my-auth-info", + Namespace: "my-namespace", + }, + }, + CurrentContext: "my-context", + AuthInfos: map[string]*api.AuthInfo{}, + } + + k8sConfigGetter = new(v7actionfakes.FakeKubernetesConfigGetter) + k8sConfigGetter.GetReturns(kubeConfig, nil) + + config = new(commandfakes.FakeConfig) + config.CurrentUserNameReturns("auth-test", nil) + + var err error + req, err = http.NewRequest(http.MethodPost, "", strings.NewReader("hello")) + Expect(err).NotTo(HaveOccurred()) + + wrappedRoundTripper = new(sharedfakes.FakeRoundTripper) + res = &http.Response{StatusCode: http.StatusTeapot} + + wrappedRoundTripper.RoundTripReturns(res, nil) + actualRes = nil + }) + + JustBeforeEach(func() { + var roundTripper http.RoundTripper + roundTripper, wrapErr = shared.WrapForCFOnK8sAuth(config, k8sConfigGetter, wrappedRoundTripper) + + if wrapErr == nil { + actualRes, wrapErr = roundTripper.RoundTrip(req) + } + }) + + When("getting the k8s config fails", func() { + BeforeEach(func() { + k8sConfigGetter.GetReturns(nil, errors.New("boom!")) + }) + + It("returns the error", func() { + Expect(wrapErr).To(MatchError("boom!")) + }) + }) + + When("no user is set in the config", func() { + BeforeEach(func() { + config.CurrentUserNameReturns("", nil) + }) + + It("errors", func() { + Expect(wrapErr).To(MatchError(ContainSubstring("current user not set"))) + }) + }) + + When("there is an error getting the current user from the config", func() { + BeforeEach(func() { + config.CurrentUserNameReturns("", errors.New("boom")) + }) + + It("errors", func() { + Expect(wrapErr).To(MatchError(ContainSubstring("boom"))) + }) + }) + + When("the chosen kubernetes auth info is not present in kubeconfig", func() { + BeforeEach(func() { + config.CurrentUserNameReturns("not-present", nil) + }) + + It("errors", func() { + Expect(wrapErr).To(MatchError(ContainSubstring(`auth info "not-present" does not exist`))) + }) + }) + + checkCalls := func() *http.Request { + Expect(wrapErr).NotTo(HaveOccurred()) + Expect(wrappedRoundTripper.RoundTripCallCount()).To(Equal(1)) + + actualReq := wrappedRoundTripper.RoundTripArgsForCall(0) + + body, err := io.ReadAll(actualReq.Body) + Expect(err).NotTo(HaveOccurred()) + Expect(string(body)).To(Equal("hello")) + + Expect(actualRes).To(Equal(res)) + + return actualReq + } + + checkBearerTokenInAuthHeader := func() { + actualReq := checkCalls() + + token, err := jws.ParseJWTFromRequest(actualReq) + Expect(err).NotTo(HaveOccurred()) + Expect(token.Validate(keyPair.Public(), crypto.SigningMethodRS256)).To(Succeed()) + + claims := token.Claims() + Expect(claims).To(HaveKeyWithValue("another", "thing")) + } + + checkClientCertInAuthHeader := func() { + actualReq := checkCalls() + + Expect(actualReq.Header).To(HaveKeyWithValue("Authorization", ConsistOf(HavePrefix("ClientCert ")))) + + certAndKeyPEMBase64 := actualReq.Header.Get("Authorization")[11:] + certAndKeyPEM, err := base64.StdEncoding.DecodeString(certAndKeyPEMBase64) + Expect(err).NotTo(HaveOccurred()) + + cert, rest := pem.Decode(certAndKeyPEM) + Expect(cert.Type).To(Equal(pemDecodeKubeConfigCertData(clientCertData).Type)) + Expect(cert.Bytes).To(Equal(pemDecodeKubeConfigCertData(clientCertData).Bytes)) + + var key *pem.Block + key, rest = pem.Decode(rest) + Expect(key.Bytes).To(Equal(pemDecodeKubeConfigCertData(clientKeyData).Bytes)) + + Expect(rest).To(BeEmpty()) + } + + Describe("auth-provider", func() { + var token []byte + + BeforeEach(func() { + jwt := jws.NewJWT(jws.Claims{ + "exp": time.Now().Add(time.Hour).Unix(), + "another": "thing", + }, crypto.SigningMethodRS256) + var err error + token, err = jwt.Serialize(keyPair) + Expect(err).NotTo(HaveOccurred()) + + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + AuthProvider: &api.AuthProviderConfig{ + Name: "oidc", + Config: map[string]string{ + "id-token": string(token), + "idp-issuer-url": "-", + "client-id": "-", + }, + }, + } + }) + + It("uses the auth-provider to generate the Bearer token", func() { + checkBearerTokenInAuthHeader() + }) + }) + + Describe("client certs", func() { + var ( + certFilePath string + keyFilePath string + ) + + BeforeEach(func() { + certFilePath = writeToFile(clientCertData) + keyFilePath = writeToFile(clientKeyData) + }) + + AfterEach(func() { + Expect(os.RemoveAll(certFilePath)).To(Succeed()) + Expect(os.RemoveAll(keyFilePath)).To(Succeed()) + }) + + When("inline cert and key are provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificateData: []byte(base64Decode(clientCertData)), + ClientKeyData: []byte(base64Decode(clientKeyData)), + } + }) + + It("puts concatenated client ceritificate and key data into the Authorization header", func() { + checkClientCertInAuthHeader() + }) + }) + + When("cert and key are provided in files", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificate: certFilePath, + ClientKey: keyFilePath, + } + }) + + It("puts concatenated client ceritificate and key data into the Authorization header", func() { + checkClientCertInAuthHeader() + }) + + When("cert file cannot be read", func() { + BeforeEach(func() { + Expect(os.Remove(certFilePath)).To(Succeed()) + }) + + It("returns an error", func() { + Expect(wrapErr).To(MatchError(ContainSubstring(certFilePath))) + }) + }) + + When("key file cannot be read", func() { + BeforeEach(func() { + Expect(os.Remove(keyFilePath)).To(Succeed()) + }) + + It("returns an error", func() { + Expect(wrapErr).To(MatchError(ContainSubstring(keyFilePath))) + }) + }) + }) + + When("file and inline cert is provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificate: certFilePath, + ClientCertificateData: []byte(base64Decode(clientCertData)), + ClientKeyData: []byte(base64Decode(clientKeyData)), + } + }) + + It("complains about invalid configuration", func() { + Expect(wrapErr).To(MatchError(ContainSubstring("client-cert-data and client-cert are both specified"))) + }) + }) + + When("file and inline key is provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificateData: []byte(base64Decode(clientCertData)), + ClientKeyData: []byte(base64Decode(clientKeyData)), + ClientKey: keyFilePath, + } + }) + + It("complains about invalid configuration", func() { + Expect(wrapErr).To(MatchError(ContainSubstring("client-key-data and client-key are both specified"))) + }) + }) + + When("inline cert and key file are provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificateData: []byte(base64Decode(clientCertData)), + ClientKey: keyFilePath, + } + }) + + It("uses the inline key", func() { + checkClientCertInAuthHeader() + }) + }) + + When("cert file and inline key are provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + ClientCertificate: certFilePath, + ClientKeyData: []byte(base64Decode(clientKeyData)), + } + }) + + It("uses the inline key", func() { + checkClientCertInAuthHeader() + }) + }) + }) + + Describe("exec", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + Exec: &api.ExecConfig{ + APIVersion: "client.authentication.k8s.io/v1beta1", + InteractiveMode: "Never", + Command: "echo", + }, + } + }) + + When("the command returns a token", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"].Exec.Args = []string{execCredential(&clientauthenticationv1beta1.ExecCredentialStatus{ + Token: "a-token", + })} + }) + + It("uses the exec command to generate the Bearer token", func() { + helpers.SkipIfWindows() // We're getting "plugin returned version client.authentication.k8s.io/__internal" on Windows. This issue is unresolved in upstream library. + + Expect(wrapErr).NotTo(HaveOccurred()) + Expect(wrappedRoundTripper.RoundTripCallCount()).To(Equal(1)) + + actualReq := wrappedRoundTripper.RoundTripArgsForCall(0) + Expect(actualReq.Header.Get("Authorization")).To(Equal("Bearer a-token")) + + Expect(actualRes).To(Equal(res)) + }) + }) + + When("the command returns a client cert and key", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"].Exec.Args = []string{execCredential(&clientauthenticationv1beta1.ExecCredentialStatus{ + ClientCertificateData: base64Decode(clientCertData), + ClientKeyData: base64Decode(clientKeyData), + })} + }) + + It("uses the exec command to generate client certs", func() { + checkClientCertInAuthHeader() + }) + }) + }) + + Describe("tokens provided in config", func() { + var token []byte + + BeforeEach(func() { + jwt := jws.NewJWT(jws.Claims{ + "exp": time.Now().Add(time.Hour).Unix(), + "another": "thing", + }, crypto.SigningMethodRS256) + var err error + token, err = jwt.Serialize(keyPair) + Expect(err).NotTo(HaveOccurred()) + }) + + Context("inline tokens", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + Token: string(token), + } + }) + + It("inserts the token in the authorization header", func() { + checkBearerTokenInAuthHeader() + }) + }) + + Context("token file paths", func() { + var tokenFilePath string + + BeforeEach(func() { + tokenFile, err := os.CreateTemp("", "") + Expect(err).NotTo(HaveOccurred()) + defer tokenFile.Close() + _, err = tokenFile.Write(token) + Expect(err).NotTo(HaveOccurred()) + tokenFilePath = tokenFile.Name() + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + TokenFile: tokenFilePath, + } + }) + + AfterEach(func() { + Expect(os.RemoveAll(tokenFilePath)).To(Succeed()) + }) + + It("inserts the token in the authorization header", func() { + checkBearerTokenInAuthHeader() + }) + }) + + When("both file and inline token are provided", func() { + BeforeEach(func() { + kubeConfig.AuthInfos["auth-test"] = &api.AuthInfo{ + Token: string(token), + TokenFile: "some-path", + } + }) + + It("the inline token takes precedence", func() { + checkBearerTokenInAuthHeader() + }) + }) + }) +}) + +func pemDecodeKubeConfigCertData(data string) *pem.Block { + decodedData, err := base64.StdEncoding.DecodeString(data) + Expect(err).NotTo(HaveOccurred()) + pemDecodedBlock, rest := pem.Decode(decodedData) + Expect(rest).To(BeEmpty()) + return pemDecodedBlock +} + +func base64Decode(encoded string) string { + decoded, err := base64.StdEncoding.DecodeString(encoded) + Expect(err).NotTo(HaveOccurred()) + return string(decoded) +} + +func writeToFile(base64Data string) string { + file, err := os.CreateTemp("", "") + Expect(err).NotTo(HaveOccurred()) + _, err = file.WriteString(base64Decode(base64Data)) + Expect(err).NotTo(HaveOccurred()) + Expect(file.Close()).To(Succeed()) + return file.Name() +} + +func execCredential(status *clientauthenticationv1beta1.ExecCredentialStatus) string { + execCred, err := json.Marshal(clientauthenticationv1beta1.ExecCredential{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "client.authentication.k8s.io/v1beta1", + }, + Status: status, + }) + Expect(err).NotTo(HaveOccurred()) + return string(execCred) +} diff --git a/api/uaa/auth.go b/api/uaa/auth.go index fa208611e75..c3401f3f403 100644 --- a/api/uaa/auth.go +++ b/api/uaa/auth.go @@ -8,8 +8,8 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // AuthResponse contains the access token and refresh token which are granted @@ -62,6 +62,17 @@ func (client Client) Authenticate(creds map[string]string, origin string, grantT if grantType == constant.GrantTypePassword { request.SetBasicAuth(client.config.UAAOAuthClient(), client.config.UAAOAuthClientSecret()) + } else if grantType == constant.GrantTypeJwtBearer { + // overwrite client authentication in case of provided parameters in cf auth clientid clientsecret or use defaults as done in password grant + clientId := client.config.UAAOAuthClient() + clientSecret := client.config.UAAOAuthClientSecret() + if creds["client_id"] != "" { + clientId = creds["client_id"] + } + if creds["client_secret"] != "" { + clientSecret = creds["client_secret"] + } + request.SetBasicAuth(clientId, clientSecret) } responseBody := AuthResponse{} @@ -109,7 +120,11 @@ func (client Client) getJtiFromToken(token string) (string, error) { } payload := make(map[string]interface{}) - json.Unmarshal(jsonPayload, &payload) + err = json.Unmarshal(jsonPayload, &payload) + if err != nil { + return "", err + } + jti, ok := payload["jti"].(string) if !ok { diff --git a/api/uaa/auth_test.go b/api/uaa/auth_test.go index 4f47fd97b1e..22fc04d0876 100644 --- a/api/uaa/auth_test.go +++ b/api/uaa/auth_test.go @@ -6,10 +6,10 @@ import ( "net/http" "net/url" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -161,6 +161,37 @@ var _ = Describe("Auth", func() { Expect(refreshToken).To(BeEmpty()) }) }) + + When("the grant type is jwt bearer assertion", func() { + BeforeEach(func() { + response := `{ + "access_token":"some-access-token" + }` + + credentials = map[string]string{ + "client_id": "some-client-id", + "client_secret": "some-client-secret", + } + origin = "" + grantType = constant.GrantTypeJwtBearer + server.AppendHandlers( + CombineHandlers( + verifyRequestHost(TestAuthorizationResource), + VerifyRequest(http.MethodPost, "/oauth/token"), + VerifyHeaderKV("Content-Type", "application/x-www-form-urlencoded"), + VerifyHeaderKV("Authorization", "Basic c29tZS1jbGllbnQtaWQ6c29tZS1jbGllbnQtc2VjcmV0"), + VerifyBody([]byte(fmt.Sprintf("client_id=%s&client_secret=%s&grant_type=%s", credentials["client_id"], credentials["client_secret"], url.QueryEscape(string(grantType))))), + RespondWith(http.StatusOK, response), + )) + }) + + It("authenticates with the assertion provided", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(accessToken).To(Equal("some-access-token")) + Expect(refreshToken).To(BeEmpty()) + }) + }) }) When("an error occurs", func() { diff --git a/api/uaa/client.go b/api/uaa/client.go index a8ccd54e4f9..4953c991b76 100644 --- a/api/uaa/client.go +++ b/api/uaa/client.go @@ -9,7 +9,7 @@ import ( "fmt" "runtime" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // Client is the UAA client diff --git a/api/uaa/client_test.go b/api/uaa/client_test.go index 57afc6ee855..b6cabeb70e9 100644 --- a/api/uaa/client_test.go +++ b/api/uaa/client_test.go @@ -5,10 +5,10 @@ import ( "net/http" "runtime" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -51,7 +51,7 @@ var _ = Describe("UAA Client", func() { }) }) - Describe("Conection", func() { + Describe("Connection", func() { BeforeEach(func() { server.AppendHandlers( CombineHandlers( diff --git a/api/uaa/constant/grant_type.go b/api/uaa/constant/grant_type.go index e302d2f6562..7cc92cc1193 100644 --- a/api/uaa/constant/grant_type.go +++ b/api/uaa/constant/grant_type.go @@ -10,4 +10,6 @@ const ( // GrantTypePassword is used for user's username/password authentication. GrantTypePassword GrantType = "password" GrantTypeRefreshToken GrantType = "refresh_token" + // GrantTypeJwtBearer is used for token based user authentication + GrantTypeJwtBearer GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer" ) diff --git a/api/uaa/constant/package.go b/api/uaa/constant/package.go index fd0648153c5..acf4aecfb8d 100644 --- a/api/uaa/constant/package.go +++ b/api/uaa/constant/package.go @@ -6,13 +6,14 @@ // exception is 'state' types, where the word 'state' is omitted. // // For Example: -// Constant Type: PackageType -// Enum Name: Bits -// Enum Value: "bits" -// const PackageTypeBits PackageType = "bits" // -// Constant Type: PackageState -// Enum Name: Expired -// Enum Value: "EXPIRED" -// const PackageExpired PackageState = "EXPIRED" +// Constant Type: PackageType +// Enum Name: Bits +// Enum Value: "bits" +// const PackageTypeBits PackageType = "bits" +// +// Constant Type: PackageState +// Enum Name: Expired +// Enum Value: "EXPIRED" +// const PackageExpired PackageState = "EXPIRED" package constant diff --git a/api/uaa/error_converter.go b/api/uaa/error_converter.go index ebbe950caee..c5ecb299214 100644 --- a/api/uaa/error_converter.go +++ b/api/uaa/error_converter.go @@ -53,7 +53,7 @@ func convert(rawHTTPStatusErr RawHTTPStatusError) error { if uaaErrorResponse.Type == "invalid_token" { return InvalidAuthTokenError{Message: uaaErrorResponse.Description} } - if uaaErrorResponse.Type == "unauthorized" { + if uaaErrorResponse.Type == "unauthorized" || uaaErrorResponse.Type == "invalid_client" { if uaaErrorResponse.Description == "Your account has been locked because of too many failed attempts to login." { return AccountLockedError{Message: "Your account has been locked because of too many failed attempts to login."} } diff --git a/api/uaa/error_converter_test.go b/api/uaa/error_converter_test.go index 16ccaca085f..a23509fa4ba 100644 --- a/api/uaa/error_converter_test.go +++ b/api/uaa/error_converter_test.go @@ -3,9 +3,9 @@ package uaa_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -135,6 +135,22 @@ var _ = Describe("Error Wrapper", func() { }) }) + Context("invalid_client with bad credentials", func() { + BeforeEach(func() { + fakeConnectionErr.RawResponse = []byte(`{ + "error": "invalid_client", + "error_description": "Bad credentials" +}`) + fakeConnection.MakeReturns(fakeConnectionErr) + }) + + It("returns a BadCredentialsError", func() { + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + + Expect(makeErr).To(MatchError(UnauthorizedError{Message: "Bad credentials"})) + }) + }) + Context("unauthorized - too many failed login attempts", func() { BeforeEach(func() { fakeConnectionErr.RawResponse = []byte(`{ diff --git a/api/uaa/errors.go b/api/uaa/errors.go index 0fdd4287415..c4e9d2815f3 100644 --- a/api/uaa/errors.go +++ b/api/uaa/errors.go @@ -52,7 +52,7 @@ func (e RequestError) Error() string { return e.Err.Error() } -// UnauthorizedError is returned when the authentication informatin is invalid. +// UnauthorizedError is returned when the authentication information is invalid. type UnauthorizedError struct { Message string } @@ -80,7 +80,7 @@ func (e InsufficientScopeError) Error() string { return e.Message } -// InvalidSCIMResourceError is returned usually when the client tries to create an inproperly formatted username +// InvalidSCIMResourceError is returned usually when the client tries to create an improperly formatted username type InvalidSCIMResourceError struct { Message string } diff --git a/api/uaa/info_test.go b/api/uaa/info_test.go index 4993b24a74c..3f58a6f0cf5 100644 --- a/api/uaa/info_test.go +++ b/api/uaa/info_test.go @@ -1,9 +1,9 @@ package uaa_test import ( - . "code.cloudfoundry.org/cli/api/uaa" + . "code.cloudfoundry.org/cli/v8/api/uaa" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/uaa/internal/internal_suite_test.go b/api/uaa/internal/internal_suite_test.go index f87ad622192..4c5515d385e 100644 --- a/api/uaa/internal/internal_suite_test.go +++ b/api/uaa/internal/internal_suite_test.go @@ -1,7 +1,7 @@ package internal_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/api/uaa/internal/routing.go b/api/uaa/internal/routing.go index 7c1fcad0856..2cbd948ce0c 100644 --- a/api/uaa/internal/routing.go +++ b/api/uaa/internal/routing.go @@ -11,18 +11,22 @@ import ( // Params map path keys to values. For example, if your route has the path // pattern: -// /person/:person_id/pets/:pet_type -// Then a correct Params map would lool like: -// router.Params{ -// "person_id": "123", -// "pet_type": "cats", -// } +// +// /person/:person_id/pets/:pet_type +// +// Then a correct Params map would look like: +// +// router.Params{ +// "person_id": "123", +// "pet_type": "cats", +// } type Params map[string]string // Route defines the property of a Cloud Controller V3 endpoint. // // Method can be one of the following: -// GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE +// +// GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE // // Path conforms to Pat-style pattern matching. The following docs are taken // from http://godoc.org/github.com/bmizerany/pat#PatternServeMux @@ -35,26 +39,36 @@ type Params map[string]string // string. // // Example pattern with one capture: -// /hello/:name +// +// /hello/:name +// // Will match: -// /hello/blake -// /hello/keith +// +// /hello/blake +// /hello/keith +// // Will not match: -// /hello/blake/ -// /hello/blake/foo -// /foo -// /foo/bar +// +// /hello/blake/ +// /hello/blake/foo +// /foo +// /foo/bar // // Example 2: -// /hello/:name/ +// +// /hello/:name/ +// // Will match: -// /hello/blake/ -// /hello/keith/foo -// /hello/blake -// /hello/keith +// +// /hello/blake/ +// /hello/keith/foo +// /hello/blake +// /hello/keith +// // Will not match: -// /foo -// /foo/bar +// +// /foo +// /foo/bar type Route struct { // Name is a key specifying which HTTP route the router should associate with // the endpoint at runtime. diff --git a/api/uaa/internal/routing_test.go b/api/uaa/internal/routing_test.go index ddad27b7d15..0a804607b5f 100644 --- a/api/uaa/internal/routing_test.go +++ b/api/uaa/internal/routing_test.go @@ -3,9 +3,9 @@ package internal_test import ( "net/http" - . "code.cloudfoundry.org/cli/api/uaa/internal" + . "code.cloudfoundry.org/cli/v8/api/uaa/internal" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/uaa/noaabridge/noaabridge_suite_test.go b/api/uaa/noaabridge/noaabridge_suite_test.go index f94004666a4..6fd6362d87c 100644 --- a/api/uaa/noaabridge/noaabridge_suite_test.go +++ b/api/uaa/noaabridge/noaabridge_suite_test.go @@ -1,7 +1,7 @@ package noaabridge_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/api/uaa/noaabridge/noaabridgefakes/fake_token_cache.go b/api/uaa/noaabridge/noaabridgefakes/fake_token_cache.go index d905db448bd..267b6889254 100644 --- a/api/uaa/noaabridge/noaabridgefakes/fake_token_cache.go +++ b/api/uaa/noaabridge/noaabridgefakes/fake_token_cache.go @@ -4,7 +4,7 @@ package noaabridgefakes import ( "sync" - "code.cloudfoundry.org/cli/api/uaa/noaabridge" + "code.cloudfoundry.org/cli/v8/api/uaa/noaabridge" ) type FakeTokenCache struct { @@ -37,15 +37,16 @@ func (fake *FakeTokenCache) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -89,9 +90,10 @@ func (fake *FakeTokenCache) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -120,9 +122,10 @@ func (fake *FakeTokenCache) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } diff --git a/api/uaa/noaabridge/noaabridgefakes/fake_uaaclient.go b/api/uaa/noaabridge/noaabridgefakes/fake_uaaclient.go index 21ec9048164..7d37b56fb18 100644 --- a/api/uaa/noaabridge/noaabridgefakes/fake_uaaclient.go +++ b/api/uaa/noaabridge/noaabridgefakes/fake_uaaclient.go @@ -4,8 +4,8 @@ package noaabridgefakes import ( "sync" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/noaabridge" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/noaabridge" ) type FakeUAAClient struct { @@ -32,15 +32,16 @@ func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/api/uaa/noaabridge/token_refresher.go b/api/uaa/noaabridge/token_refresher.go index 1c5278618ba..3e588b6cb47 100644 --- a/api/uaa/noaabridge/token_refresher.go +++ b/api/uaa/noaabridge/token_refresher.go @@ -2,7 +2,7 @@ // TokenRefresher interface for noaa/consumer. package noaabridge -import "code.cloudfoundry.org/cli/api/uaa" +import "code.cloudfoundry.org/cli/v8/api/uaa" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UAAClient diff --git a/api/uaa/noaabridge/token_refresher_test.go b/api/uaa/noaabridge/token_refresher_test.go index cdcb00eb6a2..59294d0f860 100644 --- a/api/uaa/noaabridge/token_refresher_test.go +++ b/api/uaa/noaabridge/token_refresher_test.go @@ -3,10 +3,10 @@ package noaabridge_test import ( "errors" - "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/api/uaa/noaabridge" - "code.cloudfoundry.org/cli/api/uaa/noaabridge/noaabridgefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/uaa" + . "code.cloudfoundry.org/cli/v8/api/uaa/noaabridge" + "code.cloudfoundry.org/cli/v8/api/uaa/noaabridge/noaabridgefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/uaa/prompts_test.go b/api/uaa/prompts_test.go index a44478486b6..8181fd1bdf6 100644 --- a/api/uaa/prompts_test.go +++ b/api/uaa/prompts_test.go @@ -3,24 +3,23 @@ package uaa_test import ( "net/http" - "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) var _ = Describe("Prompts", func() { var ( - client *Client + client *uaa.Client fakeConfig *uaafakes.FakeConfig ) BeforeEach(func() { fakeConfig = NewTestConfig() - client = NewClient(fakeConfig) + client = uaa.NewClient(fakeConfig) client.Info.Links.Login = "https://" + TestAuthorizationResource }) diff --git a/api/uaa/refresh_token.go b/api/uaa/refresh_token.go index fba19e211ea..7d7daa2468a 100644 --- a/api/uaa/refresh_token.go +++ b/api/uaa/refresh_token.go @@ -6,8 +6,8 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // RefreshedTokens represents the UAA refresh token response. @@ -29,7 +29,7 @@ func (client *Client) RefreshAccessToken(refreshToken string) (RefreshedTokens, switch client.config.UAAGrantType() { case string(constant.GrantTypeClientCredentials): values = client.clientCredentialRefreshBody() - case "", string(constant.GrantTypePassword): // CLI used to write empty string for grant type in the case of password; preserve compatibility with old config.json files + case "", string(constant.GrantTypePassword), string(constant.GrantTypeJwtBearer): // CLI used to write empty string for grant type in the case of password; preserve compatibility with old config.json files values = client.refreshTokenBody(refreshToken) } diff --git a/api/uaa/refresh_token_test.go b/api/uaa/refresh_token_test.go index b648b22fa05..03a2bec62b2 100644 --- a/api/uaa/refresh_token_test.go +++ b/api/uaa/refresh_token_test.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/uaa/request.go b/api/uaa/request.go index a49df595b4d..db3d93af98b 100644 --- a/api/uaa/request.go +++ b/api/uaa/request.go @@ -5,7 +5,7 @@ import ( "net/http" "net/url" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // RequestOptions contains all the options to create an HTTP Request. diff --git a/api/uaa/resources.go b/api/uaa/resources.go index 5a674db8c6c..1184e5ef772 100644 --- a/api/uaa/resources.go +++ b/api/uaa/resources.go @@ -1,7 +1,7 @@ package uaa import ( - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // SetupResources configures the client to use the specified settings and diescopers the UAA and Authentication resources diff --git a/api/uaa/resources_test.go b/api/uaa/resources_test.go index c1e6330e3a0..355f4263ca4 100644 --- a/api/uaa/resources_test.go +++ b/api/uaa/resources_test.go @@ -1,9 +1,9 @@ package uaa_test import ( - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/api/uaa/ssh.go b/api/uaa/ssh.go index 01cff5eeaa9..d8091cd74d8 100644 --- a/api/uaa/ssh.go +++ b/api/uaa/ssh.go @@ -3,7 +3,7 @@ package uaa import ( "net/url" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) func (client *Client) GetSSHPasscode(accessToken string, sshOAuthClient string) (string, error) { diff --git a/api/uaa/ssh_test.go b/api/uaa/ssh_test.go index 2e81e9c2c3f..a8628090c75 100644 --- a/api/uaa/ssh_test.go +++ b/api/uaa/ssh_test.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/uaa/uaa_connection.go b/api/uaa/uaa_connection.go index 6e6cd80fc18..fd90a004efb 100644 --- a/api/uaa/uaa_connection.go +++ b/api/uaa/uaa_connection.go @@ -4,13 +4,14 @@ import ( "bytes" "crypto/x509" "encoding/json" - "io/ioutil" + "errors" + "io" "net" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/util" ) // UAAConnection represents the connection to UAA @@ -73,7 +74,7 @@ func (*UAAConnection) handleStatusCodes(response *http.Response, passedResponse func (connection *UAAConnection) populateResponse(response *http.Response, passedResponse *Response) error { passedResponse.HTTPResponse = response - rawBytes, err := ioutil.ReadAll(response.Body) + rawBytes, err := io.ReadAll(response.Body) defer response.Body.Close() if err != nil { return err @@ -100,7 +101,7 @@ func (connection *UAAConnection) populateResponse(response *http.Response, passe func (connection *UAAConnection) processRequestErrors(request *http.Request, err error) error { switch e := err.(type) { case *url.Error: - if _, ok := e.Err.(x509.UnknownAuthorityError); ok { + if errors.As(err, &x509.UnknownAuthorityError{}) { return UnverifiedServerError{ URL: request.URL.String(), } diff --git a/api/uaa/uaa_connection_test.go b/api/uaa/uaa_connection_test.go index ed49ccdac82..8f05b8eee4a 100644 --- a/api/uaa/uaa_connection_test.go +++ b/api/uaa/uaa_connection_test.go @@ -3,9 +3,10 @@ package uaa_test import ( "fmt" "net/http" + "runtime" - . "code.cloudfoundry.org/cli/api/uaa" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) @@ -120,6 +121,9 @@ var _ = Describe("UAA Connection", func() { When("the server does not have a verified certificate", func() { Context("skipSSLValidation is false", func() { BeforeEach(func() { + if runtime.GOOS == "darwin" { + Skip("ssl verification is different on darwin") + } server.AppendHandlers( CombineHandlers( VerifyRequest(http.MethodGet, "/v2/foo"), diff --git a/api/uaa/uaa_suite_test.go b/api/uaa/uaa_suite_test.go index b49b0b2e8bb..66269e34a39 100644 --- a/api/uaa/uaa_suite_test.go +++ b/api/uaa/uaa_suite_test.go @@ -7,9 +7,9 @@ import ( "net/url" "testing" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/uaa/uaafakes/fake_config.go b/api/uaa/uaafakes/fake_config.go index 02dc7f5e992..52676b5022d 100644 --- a/api/uaa/uaafakes/fake_config.go +++ b/api/uaa/uaafakes/fake_config.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) type FakeConfig struct { @@ -103,15 +103,16 @@ func (fake *FakeConfig) BinaryName() string { ret, specificReturn := fake.binaryNameReturnsOnCall[len(fake.binaryNameArgsForCall)] fake.binaryNameArgsForCall = append(fake.binaryNameArgsForCall, struct { }{}) + stub := fake.BinaryNameStub + fakeReturns := fake.binaryNameReturns fake.recordInvocation("BinaryName", []interface{}{}) fake.binaryNameMutex.Unlock() - if fake.BinaryNameStub != nil { - return fake.BinaryNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryNameReturns return fakeReturns.result1 } @@ -155,15 +156,16 @@ func (fake *FakeConfig) BinaryVersion() string { ret, specificReturn := fake.binaryVersionReturnsOnCall[len(fake.binaryVersionArgsForCall)] fake.binaryVersionArgsForCall = append(fake.binaryVersionArgsForCall, struct { }{}) + stub := fake.BinaryVersionStub + fakeReturns := fake.binaryVersionReturns fake.recordInvocation("BinaryVersion", []interface{}{}) fake.binaryVersionMutex.Unlock() - if fake.BinaryVersionStub != nil { - return fake.BinaryVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryVersionReturns return fakeReturns.result1 } @@ -207,15 +209,16 @@ func (fake *FakeConfig) DialTimeout() time.Duration { ret, specificReturn := fake.dialTimeoutReturnsOnCall[len(fake.dialTimeoutArgsForCall)] fake.dialTimeoutArgsForCall = append(fake.dialTimeoutArgsForCall, struct { }{}) + stub := fake.DialTimeoutStub + fakeReturns := fake.dialTimeoutReturns fake.recordInvocation("DialTimeout", []interface{}{}) fake.dialTimeoutMutex.Unlock() - if fake.DialTimeoutStub != nil { - return fake.DialTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dialTimeoutReturns return fakeReturns.result1 } @@ -259,9 +262,10 @@ func (fake *FakeConfig) SetUAAEndpoint(arg1 string) { fake.setUAAEndpointArgsForCall = append(fake.setUAAEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAEndpointStub fake.recordInvocation("SetUAAEndpoint", []interface{}{arg1}) fake.setUAAEndpointMutex.Unlock() - if fake.SetUAAEndpointStub != nil { + if stub != nil { fake.SetUAAEndpointStub(arg1) } } @@ -290,15 +294,16 @@ func (fake *FakeConfig) SkipSSLValidation() bool { ret, specificReturn := fake.skipSSLValidationReturnsOnCall[len(fake.skipSSLValidationArgsForCall)] fake.skipSSLValidationArgsForCall = append(fake.skipSSLValidationArgsForCall, struct { }{}) + stub := fake.SkipSSLValidationStub + fakeReturns := fake.skipSSLValidationReturns fake.recordInvocation("SkipSSLValidation", []interface{}{}) fake.skipSSLValidationMutex.Unlock() - if fake.SkipSSLValidationStub != nil { - return fake.SkipSSLValidationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.skipSSLValidationReturns return fakeReturns.result1 } @@ -342,15 +347,16 @@ func (fake *FakeConfig) UAADisableKeepAlives() bool { ret, specificReturn := fake.uAADisableKeepAlivesReturnsOnCall[len(fake.uAADisableKeepAlivesArgsForCall)] fake.uAADisableKeepAlivesArgsForCall = append(fake.uAADisableKeepAlivesArgsForCall, struct { }{}) + stub := fake.UAADisableKeepAlivesStub + fakeReturns := fake.uAADisableKeepAlivesReturns fake.recordInvocation("UAADisableKeepAlives", []interface{}{}) fake.uAADisableKeepAlivesMutex.Unlock() - if fake.UAADisableKeepAlivesStub != nil { - return fake.UAADisableKeepAlivesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAADisableKeepAlivesReturns return fakeReturns.result1 } @@ -394,15 +400,16 @@ func (fake *FakeConfig) UAAGrantType() string { ret, specificReturn := fake.uAAGrantTypeReturnsOnCall[len(fake.uAAGrantTypeArgsForCall)] fake.uAAGrantTypeArgsForCall = append(fake.uAAGrantTypeArgsForCall, struct { }{}) + stub := fake.UAAGrantTypeStub + fakeReturns := fake.uAAGrantTypeReturns fake.recordInvocation("UAAGrantType", []interface{}{}) fake.uAAGrantTypeMutex.Unlock() - if fake.UAAGrantTypeStub != nil { - return fake.UAAGrantTypeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAGrantTypeReturns return fakeReturns.result1 } @@ -446,15 +453,16 @@ func (fake *FakeConfig) UAAOAuthClient() string { ret, specificReturn := fake.uAAOAuthClientReturnsOnCall[len(fake.uAAOAuthClientArgsForCall)] fake.uAAOAuthClientArgsForCall = append(fake.uAAOAuthClientArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientStub + fakeReturns := fake.uAAOAuthClientReturns fake.recordInvocation("UAAOAuthClient", []interface{}{}) fake.uAAOAuthClientMutex.Unlock() - if fake.UAAOAuthClientStub != nil { - return fake.UAAOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientReturns return fakeReturns.result1 } @@ -498,15 +506,16 @@ func (fake *FakeConfig) UAAOAuthClientSecret() string { ret, specificReturn := fake.uAAOAuthClientSecretReturnsOnCall[len(fake.uAAOAuthClientSecretArgsForCall)] fake.uAAOAuthClientSecretArgsForCall = append(fake.uAAOAuthClientSecretArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientSecretStub + fakeReturns := fake.uAAOAuthClientSecretReturns fake.recordInvocation("UAAOAuthClientSecret", []interface{}{}) fake.uAAOAuthClientSecretMutex.Unlock() - if fake.UAAOAuthClientSecretStub != nil { - return fake.UAAOAuthClientSecretStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientSecretReturns return fakeReturns.result1 } diff --git a/api/uaa/uaafakes/fake_connection.go b/api/uaa/uaafakes/fake_connection.go index b9013ee19d7..cc9b816d275 100644 --- a/api/uaa/uaafakes/fake_connection.go +++ b/api/uaa/uaafakes/fake_connection.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) type FakeConnection struct { @@ -32,15 +32,16 @@ func (fake *FakeConnection) Make(arg1 *http.Request, arg2 *uaa.Response) error { arg1 *http.Request arg2 *uaa.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } diff --git a/api/uaa/uaafakes/fake_connection_wrapper.go b/api/uaa/uaafakes/fake_connection_wrapper.go index 98ef73893ff..56c236a793d 100644 --- a/api/uaa/uaafakes/fake_connection_wrapper.go +++ b/api/uaa/uaafakes/fake_connection_wrapper.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) type FakeConnectionWrapper struct { @@ -43,15 +43,16 @@ func (fake *FakeConnectionWrapper) Make(arg1 *http.Request, arg2 *uaa.Response) arg1 *http.Request arg2 *uaa.Response }{arg1, arg2}) + stub := fake.MakeStub + fakeReturns := fake.makeReturns fake.recordInvocation("Make", []interface{}{arg1, arg2}) fake.makeMutex.Unlock() - if fake.MakeStub != nil { - return fake.MakeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.makeReturns return fakeReturns.result1 } @@ -103,15 +104,16 @@ func (fake *FakeConnectionWrapper) Wrap(arg1 uaa.Connection) uaa.Connection { fake.wrapArgsForCall = append(fake.wrapArgsForCall, struct { arg1 uaa.Connection }{arg1}) + stub := fake.WrapStub + fakeReturns := fake.wrapReturns fake.recordInvocation("Wrap", []interface{}{arg1}) fake.wrapMutex.Unlock() - if fake.WrapStub != nil { - return fake.WrapStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.wrapReturns return fakeReturns.result1 } diff --git a/api/uaa/user.go b/api/uaa/user.go index 0ca5fa9d39e..50df8e4276b 100644 --- a/api/uaa/user.go +++ b/api/uaa/user.go @@ -7,8 +7,8 @@ import ( "net/http" "net/url" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/uaa/internal" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/uaa/internal" ) // User represents an UAA user account. diff --git a/api/uaa/user_test.go b/api/uaa/user_test.go index 96ac8e4a6ab..a92a4713ce2 100644 --- a/api/uaa/user_test.go +++ b/api/uaa/user_test.go @@ -3,10 +3,10 @@ package uaa_test import ( "net/http" - "code.cloudfoundry.org/cli/actor/actionerror" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + . "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) diff --git a/api/uaa/version_test.go b/api/uaa/version_test.go index 246d19304c9..be62689f811 100644 --- a/api/uaa/version_test.go +++ b/api/uaa/version_test.go @@ -3,24 +3,23 @@ package uaa_test import ( "net/http" - "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" ) var _ = Describe("Version", func() { var ( - client *Client + client *uaa.Client fakeConfig *uaafakes.FakeConfig ) BeforeEach(func() { fakeConfig = NewTestConfig() - client = NewClient(fakeConfig) + client = uaa.NewClient(fakeConfig) client.Info.Links.Login = "https://" + TestAuthorizationResource }) diff --git a/api/uaa/wrapper/request_logger.go b/api/uaa/wrapper/request_logger.go index e68a8ad3f8d..1f08e23257d 100644 --- a/api/uaa/wrapper/request_logger.go +++ b/api/uaa/wrapper/request_logger.go @@ -2,13 +2,13 @@ package wrapper import ( "bytes" - "io/ioutil" + "io" "net/http" "regexp" "sort" "time" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RequestLoggerOutput @@ -91,13 +91,13 @@ func (logger *RequestLogger) displayRequest(request *http.Request) error { } if request.Body != nil { - rawRequestBody, err := ioutil.ReadAll(request.Body) + rawRequestBody, err := io.ReadAll(request.Body) defer request.Body.Close() if err != nil { return err } - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) if request.Header.Get("Content-Type") == "application/json" { err = logger.output.DisplayJSONBody(rawRequestBody) } else { diff --git a/api/uaa/wrapper/request_logger_test.go b/api/uaa/wrapper/request_logger_test.go index bd19d6455a6..2919d42eb05 100644 --- a/api/uaa/wrapper/request_logger_test.go +++ b/api/uaa/wrapper/request_logger_test.go @@ -4,17 +4,16 @@ import ( "bytes" "errors" "io" - "io/ioutil" "net/http" "net/url" "time" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "code.cloudfoundry.org/cli/api/uaa/wrapper" - "code.cloudfoundry.org/cli/api/uaa/wrapper/wrapperfakes" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper/wrapperfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -156,7 +155,7 @@ var _ = Describe("Request Logger", func() { When("the body is not JSON", func() { BeforeEach(func() { - originalBody = ioutil.NopCloser(bytes.NewReader([]byte("foo"))) + originalBody = io.NopCloser(bytes.NewReader([]byte("foo"))) request.Body = originalBody }) @@ -166,7 +165,7 @@ var _ = Describe("Request Logger", func() { Expect(fakeOutput.DisplayBodyCallCount()).To(BeNumerically(">=", 1)) Expect(fakeOutput.DisplayBodyArgsForCall(0)).To(Equal([]byte("foo"))) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte("foo"))) }) @@ -177,7 +176,7 @@ var _ = Describe("Request Logger", func() { BeforeEach(func() { jsonBody = `{"some-key": "some-value"}` - originalBody = ioutil.NopCloser(bytes.NewReader([]byte(jsonBody))) + originalBody = io.NopCloser(bytes.NewReader([]byte(jsonBody))) request.Body = originalBody request.Header.Add("Content-Type", "application/json") }) @@ -188,14 +187,14 @@ var _ = Describe("Request Logger", func() { Expect(fakeOutput.DisplayJSONBodyCallCount()).To(BeNumerically(">=", 1)) Expect(fakeOutput.DisplayJSONBodyArgsForCall(0)).To(Equal([]byte(jsonBody))) - bytes, err := ioutil.ReadAll(request.Body) + bytes, err := io.ReadAll(request.Body) Expect(err).NotTo(HaveOccurred()) Expect(bytes).To(Equal([]byte(jsonBody))) }) }) }) - When("an error occures while trying to log the request", func() { + When("an error occurs while trying to log the request", func() { var expectedErr error BeforeEach(func() { @@ -329,7 +328,7 @@ var _ = Describe("Request Logger", func() { }) }) - When("an error occures while trying to log the response", func() { + When("an error occurs while trying to log the response", func() { var ( originalErr error expectedErr error diff --git a/api/uaa/wrapper/retry_request.go b/api/uaa/wrapper/retry_request.go index 538752f77d3..c02278d5bfb 100644 --- a/api/uaa/wrapper/retry_request.go +++ b/api/uaa/wrapper/retry_request.go @@ -2,10 +2,10 @@ package wrapper import ( "bytes" - "io/ioutil" + "io" "net/http" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) // RetryRequest is a wrapper that retries failed requests if they contain a 5XX @@ -28,7 +28,7 @@ func (retry *RetryRequest) Make(request *http.Request, passedResponse *uaa.Respo var rawRequestBody []byte if request.Body != nil { - rawRequestBody, err = ioutil.ReadAll(request.Body) + rawRequestBody, err = io.ReadAll(request.Body) defer request.Body.Close() if err != nil { return err @@ -37,7 +37,7 @@ func (retry *RetryRequest) Make(request *http.Request, passedResponse *uaa.Respo for i := 0; i < retry.maxRetries+1; i++ { if rawRequestBody != nil { - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) } err = retry.connection.Make(request, passedResponse) if err == nil { diff --git a/api/uaa/wrapper/retry_request_test.go b/api/uaa/wrapper/retry_request_test.go index 142dca860a9..9ee42eca791 100644 --- a/api/uaa/wrapper/retry_request_test.go +++ b/api/uaa/wrapper/retry_request_test.go @@ -1,15 +1,15 @@ package wrapper_test import ( - "io/ioutil" + "io" "net/http" "strings" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "code.cloudfoundry.org/cli/api/uaa/wrapper" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,7 +20,7 @@ var _ = Describe("Retry Request", func() { Expect(err).NotTo(HaveOccurred()) rawRequestBody := "banana pants" - request.Body = ioutil.NopCloser(strings.NewReader(rawRequestBody)) + request.Body = io.NopCloser(strings.NewReader(rawRequestBody)) response := &uaa.Response{ HTTPResponse: &http.Response{ @@ -34,7 +34,7 @@ var _ = Describe("Retry Request", func() { } fakeConnection.MakeStub = func(req *http.Request, passedResponse *uaa.Response) error { defer req.Body.Close() - body, readErr := ioutil.ReadAll(request.Body) + body, readErr := io.ReadAll(request.Body) Expect(readErr).ToNot(HaveOccurred()) Expect(string(body)).To(Equal(rawRequestBody)) return expectedErr diff --git a/api/uaa/wrapper/trace_request.go b/api/uaa/wrapper/trace_request.go new file mode 100644 index 00000000000..b3d716c65ec --- /dev/null +++ b/api/uaa/wrapper/trace_request.go @@ -0,0 +1,33 @@ +package wrapper + +import ( + "net/http" + + "code.cloudfoundry.org/cli/v8/api/shared" + "code.cloudfoundry.org/cli/v8/api/uaa" +) + +// UAATraceHeaderRequest is a wrapper that adds b3 trace headers to requests. +type UAATraceHeaderRequest struct { + headers *shared.TraceHeaders + connection uaa.Connection +} + +// NewUAATraceHeaderRequest returns a pointer to a UAATraceHeaderRequest wrapper. +func NewUAATraceHeaderRequest(trace string) *UAATraceHeaderRequest { + return &UAATraceHeaderRequest{ + headers: shared.NewTraceHeaders(trace), + } +} + +// Add tracing headers +func (t *UAATraceHeaderRequest) Make(request *http.Request, passedResponse *uaa.Response) error { + t.headers.SetHeaders(request) + return t.connection.Make(request, passedResponse) +} + +// Wrap sets the connection in the UAATraceHeaderRequest and returns itself. +func (t *UAATraceHeaderRequest) Wrap(innerconnection uaa.Connection) uaa.Connection { + t.connection = innerconnection + return t +} diff --git a/api/uaa/wrapper/trace_request_test.go b/api/uaa/wrapper/trace_request_test.go new file mode 100644 index 00000000000..01905ed9ad0 --- /dev/null +++ b/api/uaa/wrapper/trace_request_test.go @@ -0,0 +1,65 @@ +package wrapper_test + +import ( + "bytes" + "net/http" + + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("CCTraceHeaderRequest", func() { + var ( + fakeConnection *uaafakes.FakeConnection + + wrapper uaa.Connection + + request *http.Request + response *uaa.Response + makeErr error + + traceHeader string + ) + + BeforeEach(func() { + fakeConnection = new(uaafakes.FakeConnection) + + traceHeader = "trace-id" + + wrapper = NewUAATraceHeaderRequest(traceHeader).Wrap(fakeConnection) + + body := bytes.NewReader([]byte("foo")) + + var err error + request, err = http.NewRequest(http.MethodGet, "https://foo.bar.com/banana", body) + Expect(err).NotTo(HaveOccurred()) + + response = &uaa.Response{ + RawResponse: []byte("some-response-body"), + HTTPResponse: &http.Response{}, + } + }) + + JustBeforeEach(func() { + makeErr = wrapper.Make(request, response) + }) + + Describe("Make", func() { + It("Adds the request headers", func() { + Expect(makeErr).NotTo(HaveOccurred()) + Expect(request.Header.Get("X-B3-TraceId")).To(Equal(traceHeader)) + Expect(request.Header.Get("X-B3-SpanId")).ToNot(BeEmpty()) + }) + + It("Calls the inner connection", func() { + Expect(fakeConnection.MakeCallCount()).To(Equal(1)) + req, resp := fakeConnection.MakeArgsForCall(0) + Expect(req).To(Equal(request)) + Expect(resp).To(Equal(response)) + }) + }) +}) diff --git a/api/uaa/wrapper/uaa_authentication.go b/api/uaa/wrapper/uaa_authentication.go index 10b1268e704..96cc3d36b22 100644 --- a/api/uaa/wrapper/uaa_authentication.go +++ b/api/uaa/wrapper/uaa_authentication.go @@ -2,11 +2,11 @@ package wrapper import ( "bytes" - "io/ioutil" + "io" "net/http" "strings" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UAAClient @@ -54,13 +54,13 @@ func (t *UAAAuthentication) Make(request *http.Request, passedResponse *uaa.Resp var rawRequestBody []byte if request.Body != nil { - rawRequestBody, err = ioutil.ReadAll(request.Body) + rawRequestBody, err = io.ReadAll(request.Body) defer request.Body.Close() if err != nil { return err } - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) if skipAuthenticationHeader(request, rawRequestBody) { return t.connection.Make(request, passedResponse) @@ -80,7 +80,7 @@ func (t *UAAAuthentication) Make(request *http.Request, passedResponse *uaa.Resp t.cache.SetRefreshToken(tokens.RefreshToken) if rawRequestBody != nil { - request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody)) + request.Body = io.NopCloser(bytes.NewBuffer(rawRequestBody)) } request.Header.Set("Authorization", t.cache.AccessToken()) return t.connection.Make(request, passedResponse) @@ -109,5 +109,6 @@ func skipAuthenticationHeader(request *http.Request, body []byte) bool { request.Method == http.MethodPost && (strings.Contains(stringBody, "grant_type=refresh_token") || strings.Contains(stringBody, "grant_type=password") || + strings.Contains(stringBody, "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer") || strings.Contains(stringBody, "grant_type=client_credentials")) } diff --git a/api/uaa/wrapper/uaa_authentication_test.go b/api/uaa/wrapper/uaa_authentication_test.go index 63048f4d01e..516f7a21e90 100644 --- a/api/uaa/wrapper/uaa_authentication_test.go +++ b/api/uaa/wrapper/uaa_authentication_test.go @@ -3,17 +3,17 @@ package wrapper_test import ( "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/uaafakes" - . "code.cloudfoundry.org/cli/api/uaa/wrapper" - "code.cloudfoundry.org/cli/api/uaa/wrapper/util" - "code.cloudfoundry.org/cli/api/uaa/wrapper/wrapperfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/uaafakes" + . "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper/util" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper/wrapperfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -113,13 +113,13 @@ var _ = Describe("UAA Authentication", func() { request, err := http.NewRequest( http.MethodGet, server.URL(), - ioutil.NopCloser(strings.NewReader(expectedBody)), + io.NopCloser(strings.NewReader(expectedBody)), ) Expect(err).NotTo(HaveOccurred()) makeCount := 0 fakeConnection.MakeStub = func(request *http.Request, response *uaa.Response) error { - body, readErr := ioutil.ReadAll(request.Body) + body, readErr := io.ReadAll(request.Body) Expect(readErr).NotTo(HaveOccurred()) Expect(string(body)).To(Equal(expectedBody)) diff --git a/api/uaa/wrapper/wrapper_suite_test.go b/api/uaa/wrapper/wrapper_suite_test.go index 808ebf747a0..7e400a74abc 100644 --- a/api/uaa/wrapper/wrapper_suite_test.go +++ b/api/uaa/wrapper/wrapper_suite_test.go @@ -3,12 +3,11 @@ package wrapper_test import ( "bytes" "log" + "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" - - "testing" ) func TestUAA(t *testing.T) { diff --git a/api/uaa/wrapper/wrapperfakes/fake_request_logger_output.go b/api/uaa/wrapper/wrapperfakes/fake_request_logger_output.go index 4d6ba759ad9..f331009bd05 100644 --- a/api/uaa/wrapper/wrapperfakes/fake_request_logger_output.go +++ b/api/uaa/wrapper/wrapperfakes/fake_request_logger_output.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" ) type FakeRequestLoggerOutput struct { @@ -131,15 +131,16 @@ func (fake *FakeRequestLoggerOutput) DisplayBody(arg1 []byte) error { fake.displayBodyArgsForCall = append(fake.displayBodyArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.DisplayBodyStub + fakeReturns := fake.displayBodyReturns fake.recordInvocation("DisplayBody", []interface{}{arg1Copy}) fake.displayBodyMutex.Unlock() - if fake.DisplayBodyStub != nil { - return fake.DisplayBodyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayBodyReturns return fakeReturns.result1 } @@ -192,15 +193,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHeader(arg1 string, arg2 string) err arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayHeaderStub + fakeReturns := fake.displayHeaderReturns fake.recordInvocation("DisplayHeader", []interface{}{arg1, arg2}) fake.displayHeaderMutex.Unlock() - if fake.DisplayHeaderStub != nil { - return fake.DisplayHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHeaderReturns return fakeReturns.result1 } @@ -252,15 +254,16 @@ func (fake *FakeRequestLoggerOutput) DisplayHost(arg1 string) error { fake.displayHostArgsForCall = append(fake.displayHostArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisplayHostStub + fakeReturns := fake.displayHostReturns fake.recordInvocation("DisplayHost", []interface{}{arg1}) fake.displayHostMutex.Unlock() - if fake.DisplayHostStub != nil { - return fake.DisplayHostStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayHostReturns return fakeReturns.result1 } @@ -317,15 +320,16 @@ func (fake *FakeRequestLoggerOutput) DisplayJSONBody(arg1 []byte) error { fake.displayJSONBodyArgsForCall = append(fake.displayJSONBodyArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.DisplayJSONBodyStub + fakeReturns := fake.displayJSONBodyReturns fake.recordInvocation("DisplayJSONBody", []interface{}{arg1Copy}) fake.displayJSONBodyMutex.Unlock() - if fake.DisplayJSONBodyStub != nil { - return fake.DisplayJSONBodyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayJSONBodyReturns return fakeReturns.result1 } @@ -379,15 +383,16 @@ func (fake *FakeRequestLoggerOutput) DisplayRequestHeader(arg1 string, arg2 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DisplayRequestHeaderStub + fakeReturns := fake.displayRequestHeaderReturns fake.recordInvocation("DisplayRequestHeader", []interface{}{arg1, arg2, arg3}) fake.displayRequestHeaderMutex.Unlock() - if fake.DisplayRequestHeaderStub != nil { - return fake.DisplayRequestHeaderStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayRequestHeaderReturns return fakeReturns.result1 } @@ -440,15 +445,16 @@ func (fake *FakeRequestLoggerOutput) DisplayResponseHeader(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.DisplayResponseHeaderStub + fakeReturns := fake.displayResponseHeaderReturns fake.recordInvocation("DisplayResponseHeader", []interface{}{arg1, arg2}) fake.displayResponseHeaderMutex.Unlock() - if fake.DisplayResponseHeaderStub != nil { - return fake.DisplayResponseHeaderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayResponseHeaderReturns return fakeReturns.result1 } @@ -501,15 +507,16 @@ func (fake *FakeRequestLoggerOutput) DisplayType(arg1 string, arg2 time.Time) er arg1 string arg2 time.Time }{arg1, arg2}) + stub := fake.DisplayTypeStub + fakeReturns := fake.displayTypeReturns fake.recordInvocation("DisplayType", []interface{}{arg1, arg2}) fake.displayTypeMutex.Unlock() - if fake.DisplayTypeStub != nil { - return fake.DisplayTypeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayTypeReturns return fakeReturns.result1 } @@ -560,9 +567,10 @@ func (fake *FakeRequestLoggerOutput) HandleInternalError(arg1 error) { fake.handleInternalErrorArgsForCall = append(fake.handleInternalErrorArgsForCall, struct { arg1 error }{arg1}) + stub := fake.HandleInternalErrorStub fake.recordInvocation("HandleInternalError", []interface{}{arg1}) fake.handleInternalErrorMutex.Unlock() - if fake.HandleInternalErrorStub != nil { + if stub != nil { fake.HandleInternalErrorStub(arg1) } } @@ -591,15 +599,16 @@ func (fake *FakeRequestLoggerOutput) Start() error { ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -643,15 +652,16 @@ func (fake *FakeRequestLoggerOutput) Stop() error { ret, specificReturn := fake.stopReturnsOnCall[len(fake.stopArgsForCall)] fake.stopArgsForCall = append(fake.stopArgsForCall, struct { }{}) + stub := fake.StopStub + fakeReturns := fake.stopReturns fake.recordInvocation("Stop", []interface{}{}) fake.stopMutex.Unlock() - if fake.StopStub != nil { - return fake.StopStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stopReturns return fakeReturns.result1 } diff --git a/api/uaa/wrapper/wrapperfakes/fake_token_cache.go b/api/uaa/wrapper/wrapperfakes/fake_token_cache.go index b1516a14ad4..583fd56ed77 100644 --- a/api/uaa/wrapper/wrapperfakes/fake_token_cache.go +++ b/api/uaa/wrapper/wrapperfakes/fake_token_cache.go @@ -4,7 +4,7 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" ) type FakeTokenCache struct { @@ -47,15 +47,16 @@ func (fake *FakeTokenCache) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -99,15 +100,16 @@ func (fake *FakeTokenCache) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -151,9 +153,10 @@ func (fake *FakeTokenCache) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -182,9 +185,10 @@ func (fake *FakeTokenCache) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } diff --git a/api/uaa/wrapper/wrapperfakes/fake_uaaclient.go b/api/uaa/wrapper/wrapperfakes/fake_uaaclient.go index 57836aafcd7..8d9dd05a87c 100644 --- a/api/uaa/wrapper/wrapperfakes/fake_uaaclient.go +++ b/api/uaa/wrapper/wrapperfakes/fake_uaaclient.go @@ -4,8 +4,8 @@ package wrapperfakes import ( "sync" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" ) type FakeUAAClient struct { @@ -32,15 +32,16 @@ func (fake *FakeUAAClient) RefreshAccessToken(arg1 string) (uaa.RefreshedTokens, fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{arg1}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/bin/bump-version b/bin/bump-version deleted file mode 100755 index 7bb7882877a..00000000000 --- a/bin/bump-version +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -component=$1 - -old_version=$(cat BUILD_VERSION) -major=$(echo $old_version | cut -d'.' -f 1) -minor=$(echo $old_version | cut -d'.' -f 2) -patch=$(echo $old_version | cut -d'.' -f 3) - -case "$component" in - major ) - major=$(expr $major + 1) - minor=0 - patch=0 - ;; - minor ) - minor=$(expr $minor + 1) - patch=0 - ;; - patch ) - patch=$(expr $patch + 1) - ;; - * ) - echo "Error - argument must be 'major', 'minor' or 'patch'" - echo "Usage: bump-version [major | minor | patch]" - exit 1 - ;; -esac - -version=$major.$minor.$patch - -echo "Updating BUILD_VERSION file to $version" -echo $version > BUILD_VERSION - -echo "Committing change" -git reset . -git add BUILD_VERSION - -git commit -m "Bump version to $version" diff --git a/bin/cleanup-integration b/bin/cleanup-integration index bb5592b173d..51a3bcfebd0 100755 --- a/bin/cleanup-integration +++ b/bin/cleanup-integration @@ -56,17 +56,17 @@ cf orgs | grep -i -e ^integration-org -e CATS- | xargs_func cf delete-org -f cf delete-org -f temp-org cf buildpacks | awk '/INTEGRATION-BUILDPACK/ { if(NF >= 6) { printf("cf delete-buildpack -f %s -s %s\n", $2, $3); } else { printf("cf delete-buildpack -f %s\n", $2); }}' | bash +cf buildpacks | awk '/INTEGRATION-BUILDPACK/ { printf("cf delete-buildpack -f %s\n", $2); }' | bash for stack in $(cf stacks | awk '/INTEGRATION-STACK/ { print $1 }'); do echo Deleting $stack cf curl -X DELETE "/v3/stacks/$(cf stack --guid $stack)" done -CF_USERS=$(cf curl /v3/users | grep total_results | grep -o '[0-9]\+') -USER_PAGES=$(( $CF_USERS / 50 + 1)) +USER_PAGES=$(cf curl /v3/users | jq -r .pagination.total_pages) for ((i=1; i<=${USER_PAGES}; i++)) ; do - cf curl "/v3/users?per_page=50&page=${i}" | \ + cf curl "/v3/users?&page=${i}" | \ jq -r .resources[].username | \ grep -i -e ^integration-user -e CATS- | \ xargs_func cf delete-user -f || echo diff --git a/bin/generate-release-notes b/bin/generate-release-notes deleted file mode 100755 index f1aad7ebcc5..00000000000 --- a/bin/generate-release-notes +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -VERSION=$(cat BUILD_VERSION) - -cat <<-NOTES -Package Manager Installation ----------- -- [apt-get, yum, homebrew](https://github.com/cloudfoundry/cli#installing-using-a-package-manager) - -Installers ----------- -- Debian [64 bit](https://packages.cloudfoundry.org/stable?release=debian64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=debian32&version=$VERSION&source=github-rel) (deb) -- Redhat [64 bit](https://packages.cloudfoundry.org/stable?release=redhat64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=redhat32&version=$VERSION&source=github-rel) (rpm) -- Mac OS X [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64&version=$VERSION&source=github-rel) (pkg) -- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32&version=$VERSION&source=github-rel) (zip) - -Binaries --------- -- Linux [64 bit](https://packages.cloudfoundry.org/stable?release=linux64-binary&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=linux32-binary&version=$VERSION&source=github-rel) (tgz) -- Mac OS X [64 bit](https://packages.cloudfoundry.org/stable?release=macosx64-binary&version=$VERSION&source=github-rel) (tgz) -- Windows [64 bit](https://packages.cloudfoundry.org/stable?release=windows64-exe&version=$VERSION&source=github-rel) / [32 bit](https://packages.cloudfoundry.org/stable?release=windows32-exe&version=$VERSION&source=github-rel) (zip) - - -Docker --------- -\`\`\`shell -docker pull cloudfoundry/cli:$VERSION -\`\`\` - -Change Log ----------- -NOTES diff --git a/bin/style/main.go b/bin/style/main.go deleted file mode 100644 index 366b4e05a65..00000000000 --- a/bin/style/main.go +++ /dev/null @@ -1,333 +0,0 @@ -package main - -import ( - "fmt" - "go/ast" - "go/parser" - "go/token" - "io" - "os" - "path/filepath" - "sort" - "strings" - - "github.com/fatih/color" -) - -type warning struct { - format string - vars []interface{} - token.Position -} - -type warningPrinter struct { - warnings []warning -} - -func (w warningPrinter) print(writer io.Writer) { - w.sortWarnings() - - for _, warning := range w.warnings { - coloredVars := make([]interface{}, len(warning.vars)) - for i, v := range warning.vars { - coloredVars[i] = color.CyanString(v.(string)) - } - - message := fmt.Sprintf(warning.format, coloredVars...) - - fmt.Printf( - "%s %s %s\n", - color.MagentaString(warning.Position.Filename), - color.MagentaString(fmt.Sprintf("+%d", warning.Position.Line)), - message) - } -} - -func (w warningPrinter) sortWarnings() { - sort.Slice(w.warnings, func(i int, j int) bool { - if w.warnings[i].Position.Filename < w.warnings[j].Position.Filename { - return true - } - if w.warnings[i].Position.Filename > w.warnings[j].Position.Filename { - return false - } - - if w.warnings[i].Position.Line < w.warnings[j].Position.Line { - return true - } - if w.warnings[i].Position.Line > w.warnings[j].Position.Line { - return false - } - - iMessage := fmt.Sprintf(w.warnings[i].format, w.warnings[i].vars...) - jMessage := fmt.Sprintf(w.warnings[j].format, w.warnings[j].vars...) - - return iMessage < jMessage - }) -} - -type visitor struct { - fileSet *token.FileSet - - lastConstSpec string - lastFuncDecl string - lastReceiverFunc string - lastReceiver string - lastVarSpec string - typeSpecs []string - - warnings []warning - - previousPass *visitor -} - -func (v *visitor) Visit(node ast.Node) ast.Visitor { - switch typedNode := node.(type) { - case *ast.File: - return v - case *ast.GenDecl: - if typedNode.Tok == token.CONST { - v.checkConst(typedNode) - } else if typedNode.Tok == token.VAR { - v.checkVar(typedNode) - } - return v - case *ast.FuncDecl: - v.checkFunc(typedNode) - case *ast.TypeSpec: - v.checkType(typedNode) - } - - return nil -} - -func (v *visitor) addWarning(pos token.Pos, format string, vars ...interface{}) { - v.warnings = append(v.warnings, warning{ - format: format, - vars: vars, - Position: v.fileSet.Position(pos), - }) -} - -func (v *visitor) checkConst(node *ast.GenDecl) { - currentConstantNode := node.Specs[0].(*ast.ValueSpec) - constName := currentConstantNode.Names[0].Name - constType := fmt.Sprint(currentConstantNode.Type) - - if v.lastFuncDecl != "" { - v.addWarning(node.Pos(), "File Positioning: constant %s defined after a function declarations", constName) - } - if len(v.typeSpecs) != 0 && !isIn(constType, v.typeSpecs) { - v.addWarning(node.Pos(), "File Positioning: constant %s defined after a type declarations", constName) - } - if v.lastVarSpec != "" { - v.addWarning(node.Pos(), "File Positioning: constant %s defined after a variable declarations", constName) - } - - if strings.Compare(constName, v.lastConstSpec) == -1 { - v.addWarning(node.Pos(), "Alphabetical Ordering: constant %s defined after constant %s", constName, v.lastConstSpec) - } - - v.lastConstSpec = constName -} - -func (v *visitor) checkFunc(node *ast.FuncDecl) { - if node.Recv != nil { - v.checkFuncWithReceiver(node) - } else { - funcName := node.Name.Name - if funcName == "Execute" || - strings.HasPrefix(funcName, "New") || - strings.HasPrefix(funcName, "new") || - strings.HasPrefix(funcName, "Default") || - strings.HasPrefix(funcName, "default") { - return - } - - v.lastFuncDecl = funcName - } -} - -func (v *visitor) checkFuncWithReceiver(node *ast.FuncDecl) { - funcName := node.Name.Name - - var receiver string - switch typedType := node.Recv.List[0].Type.(type) { - case *ast.Ident: - receiver = typedType.Name - case *ast.StarExpr: - receiver = typedType.X.(*ast.Ident).Name - } - if v.lastFuncDecl != "" { - v.addWarning(node.Pos(), "method %s.%s defined after function %s", receiver, funcName, v.lastFuncDecl) - } - if len(v.typeSpecs) > 0 { - lastTypeSpec := v.typeSpecs[len(v.typeSpecs)-1] - if v.typeDefinedInFile(receiver) && receiver != lastTypeSpec { - v.addWarning(node.Pos(), "method %s.%s should be defined immediately after type %s", receiver, funcName, receiver) - } - } - - v.lastReceiver = receiver - v.lastReceiverFunc = funcName -} - -func (v *visitor) checkType(node *ast.TypeSpec) { - typeName := node.Name.Name - if v.lastFuncDecl != "" { - v.addWarning(node.Pos(), "type declaration %s defined after a function declaration", typeName) - } - v.typeSpecs = append(v.typeSpecs, typeName) -} - -func (v *visitor) checkVar(node *ast.GenDecl) { - varName := node.Specs[0].(*ast.ValueSpec).Names[0].Name - - if v.lastFuncDecl != "" { - v.addWarning(node.Pos(), "variable %s defined after a function declaration", varName) - } - if len(v.typeSpecs) != 0 { - v.addWarning(node.Pos(), "variable %s defined after a type declaration", varName) - } - - if strings.Compare(varName, v.lastVarSpec) == -1 { - v.addWarning(node.Pos(), "variable %s defined after variable %s", varName, v.lastVarSpec) - } - - v.lastVarSpec = varName -} - -func (v *visitor) typeDefinedInFile(typeName string) bool { - if v.previousPass == nil { - return true - } - - for _, definedTypeName := range v.previousPass.typeSpecs { - if definedTypeName == typeName { - return true - } - } - - return false -} - -func check(fileSet *token.FileSet, path string) ([]warning, error) { - stat, err := os.Stat(path) - if err != nil { - return nil, err - } - - if stat.IsDir() { - return checkDir(fileSet, path) - } else { - return checkFile(fileSet, path) - } -} - -func checkDir(fileSet *token.FileSet, path string) ([]warning, error) { - var warnings []warning - - err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if !info.IsDir() { - return nil - } - - if shouldSkipDir(path) { - return filepath.SkipDir - } - - packages, err := parser.ParseDir(fileSet, path, shouldParseFile, 0) - if err != nil { - return err - } - - for _, packag := range packages { - for _, file := range packag.Files { - warnings = append(warnings, walkFile(fileSet, file)...) - } - } - - return nil - }) - - return warnings, err -} - -func checkFile(fileSet *token.FileSet, path string) ([]warning, error) { - file, err := parser.ParseFile(fileSet, path, nil, 0) - if err != nil { - return nil, err - } - - return walkFile(fileSet, file), nil -} - -func main() { - if len(os.Args) < 2 { - fmt.Fprintf(os.Stderr, "Usage: %s [--] [FILE or DIRECTORY]...\n", os.Args[0]) - os.Exit(1) - } - - var allWarnings []warning - - args := os.Args[1:] - if args[0] == "--" { - args = args[1:] - } - - fileSet := token.NewFileSet() - - for _, arg := range args { - warnings, err := check(fileSet, arg) - if err != nil { - panic(err) - } - allWarnings = append(allWarnings, warnings...) - } - - warningPrinter := warningPrinter{ - warnings: allWarnings, - } - warningPrinter.print(os.Stdout) - - if len(allWarnings) > 0 { - os.Exit(1) - } -} - -func isIn(s string, ary []string) bool { - for _, item := range ary { - if s == item { - return true - } - } - return false -} - -func shouldParseFile(info os.FileInfo) bool { - return !strings.HasSuffix(info.Name(), "_test.go") -} - -func shouldSkipDir(path string) bool { - base := filepath.Base(path) - return base == "vendor" || base == ".git" || strings.HasSuffix(base, "fakes") -} - -func walkFile(fileSet *token.FileSet, file *ast.File) []warning { - firstPass := visitor{ - fileSet: fileSet, - } - ast.Walk(&firstPass, file) - - v := visitor{ - fileSet: fileSet, - previousPass: &firstPass, - } - ast.Walk(&v, file) - - return v.warnings -} diff --git a/bin/test-integration b/bin/test-integration deleted file mode 100755 index e9737413059..00000000000 --- a/bin/test-integration +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -x -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -export CF_DIAL_TIMEOUT=15 - -$DIR/cleanup-integration - -ginkgo -r -randomizeAllSpecs -slowSpecThreshold=60 $@ integration/isolated integration/plugin integration/experimental - -if [[ -z $SKIP_OTHER ]]; then - # The following test suite **cannot** be run in parallel!!! - ginkgo -r -randomizeAllSpecs -slowSpecThreshold=60 integration/global -fi - -$DIR/cleanup-integration diff --git a/cf/actors/actors_suite_test.go b/cf/actors/actors_suite_test.go index ddedc64c6af..5480df72c51 100644 --- a/cf/actors/actors_suite_test.go +++ b/cf/actors/actors_suite_test.go @@ -1,9 +1,9 @@ package actors_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/actors/actorsfakes/fake_push_actor.go b/cf/actors/actorsfakes/fake_push_actor.go index caa013a6867..798fdce194e 100644 --- a/cf/actors/actorsfakes/fake_push_actor.go +++ b/cf/actors/actorsfakes/fake_push_actor.go @@ -5,9 +5,9 @@ import ( "os" "sync" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakePushActor struct { @@ -96,15 +96,16 @@ func (fake *FakePushActor) GatherFiles(arg1 []models.AppFileFields, arg2 string, arg3 string arg4 bool }{arg1Copy, arg2, arg3, arg4}) + stub := fake.GatherFilesStub + fakeReturns := fake.gatherFilesReturns fake.recordInvocation("GatherFiles", []interface{}{arg1Copy, arg2, arg3, arg4}) fake.gatherFilesMutex.Unlock() - if fake.GatherFilesStub != nil { - return fake.GatherFilesStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.gatherFilesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -164,15 +165,16 @@ func (fake *FakePushActor) MapManifestRoute(arg1 string, arg2 models.Application arg2 models.Application arg3 models.AppParams }{arg1, arg2, arg3}) + stub := fake.MapManifestRouteStub + fakeReturns := fake.mapManifestRouteReturns fake.recordInvocation("MapManifestRoute", []interface{}{arg1, arg2, arg3}) fake.mapManifestRouteMutex.Unlock() - if fake.MapManifestRouteStub != nil { - return fake.MapManifestRouteStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.mapManifestRouteReturns return fakeReturns.result1 } @@ -225,15 +227,16 @@ func (fake *FakePushActor) ProcessPath(arg1 string, arg2 func(string) error) err arg1 string arg2 func(string) error }{arg1, arg2}) + stub := fake.ProcessPathStub + fakeReturns := fake.processPathReturns fake.recordInvocation("ProcessPath", []interface{}{arg1, arg2}) fake.processPathMutex.Unlock() - if fake.ProcessPathStub != nil { - return fake.ProcessPathStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.processPathReturns return fakeReturns.result1 } @@ -292,15 +295,16 @@ func (fake *FakePushActor) UploadApp(arg1 string, arg2 *os.File, arg3 []resource arg2 *os.File arg3 []resources.AppFileResource }{arg1, arg2, arg3Copy}) + stub := fake.UploadAppStub + fakeReturns := fake.uploadAppReturns fake.recordInvocation("UploadApp", []interface{}{arg1, arg2, arg3Copy}) fake.uploadAppMutex.Unlock() - if fake.UploadAppStub != nil { - return fake.UploadAppStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.uploadAppReturns return fakeReturns.result1 } @@ -357,15 +361,16 @@ func (fake *FakePushActor) ValidateAppParams(arg1 []models.AppParams) []error { fake.validateAppParamsArgsForCall = append(fake.validateAppParamsArgsForCall, struct { arg1 []models.AppParams }{arg1Copy}) + stub := fake.ValidateAppParamsStub + fakeReturns := fake.validateAppParamsReturns fake.recordInvocation("ValidateAppParams", []interface{}{arg1Copy}) fake.validateAppParamsMutex.Unlock() - if fake.ValidateAppParamsStub != nil { - return fake.ValidateAppParamsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.validateAppParamsReturns return fakeReturns.result1 } diff --git a/cf/actors/actorsfakes/fake_route_actor.go b/cf/actors/actorsfakes/fake_route_actor.go index 795612f4250..18a4b673341 100644 --- a/cf/actors/actorsfakes/fake_route_actor.go +++ b/cf/actors/actorsfakes/fake_route_actor.go @@ -4,8 +4,8 @@ package actorsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRouteActor struct { @@ -129,15 +129,16 @@ func (fake *FakeRouteActor) BindRoute(arg1 models.Application, arg2 models.Route arg1 models.Application arg2 models.Route }{arg1, arg2}) + stub := fake.BindRouteStub + fakeReturns := fake.bindRouteReturns fake.recordInvocation("BindRoute", []interface{}{arg1, arg2}) fake.bindRouteMutex.Unlock() - if fake.BindRouteStub != nil { - return fake.BindRouteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindRouteReturns return fakeReturns.result1 } @@ -189,15 +190,16 @@ func (fake *FakeRouteActor) CreateRandomTCPRoute(arg1 models.DomainFields) (mode fake.createRandomTCPRouteArgsForCall = append(fake.createRandomTCPRouteArgsForCall, struct { arg1 models.DomainFields }{arg1}) + stub := fake.CreateRandomTCPRouteStub + fakeReturns := fake.createRandomTCPRouteReturns fake.recordInvocation("CreateRandomTCPRoute", []interface{}{arg1}) fake.createRandomTCPRouteMutex.Unlock() - if fake.CreateRandomTCPRouteStub != nil { - return fake.CreateRandomTCPRouteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createRandomTCPRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -254,15 +256,16 @@ func (fake *FakeRouteActor) FindAndBindRoute(arg1 string, arg2 models.Applicatio arg2 models.Application arg3 models.AppParams }{arg1, arg2, arg3}) + stub := fake.FindAndBindRouteStub + fakeReturns := fake.findAndBindRouteReturns fake.recordInvocation("FindAndBindRoute", []interface{}{arg1, arg2, arg3}) fake.findAndBindRouteMutex.Unlock() - if fake.FindAndBindRouteStub != nil { - return fake.FindAndBindRouteStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.findAndBindRouteReturns return fakeReturns.result1 } @@ -314,15 +317,16 @@ func (fake *FakeRouteActor) FindDomain(arg1 string) (string, models.DomainFields fake.findDomainArgsForCall = append(fake.findDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindDomainStub + fakeReturns := fake.findDomainReturns fake.recordInvocation("FindDomain", []interface{}{arg1}) fake.findDomainMutex.Unlock() - if fake.FindDomainStub != nil { - return fake.FindDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.findDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -384,15 +388,16 @@ func (fake *FakeRouteActor) FindOrCreateRoute(arg1 string, arg2 models.DomainFie arg4 int arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.FindOrCreateRouteStub + fakeReturns := fake.findOrCreateRouteReturns fake.recordInvocation("FindOrCreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.findOrCreateRouteMutex.Unlock() - if fake.FindOrCreateRouteStub != nil { - return fake.FindOrCreateRouteStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findOrCreateRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -447,15 +452,16 @@ func (fake *FakeRouteActor) FindPath(arg1 string) (string, string) { fake.findPathArgsForCall = append(fake.findPathArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindPathStub + fakeReturns := fake.findPathReturns fake.recordInvocation("FindPath", []interface{}{arg1}) fake.findPathMutex.Unlock() - if fake.FindPathStub != nil { - return fake.FindPathStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findPathReturns return fakeReturns.result1, fakeReturns.result2 } @@ -510,15 +516,16 @@ func (fake *FakeRouteActor) FindPort(arg1 string) (string, int, error) { fake.findPortArgsForCall = append(fake.findPortArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindPortStub + fakeReturns := fake.findPortReturns fake.recordInvocation("FindPort", []interface{}{arg1}) fake.findPortMutex.Unlock() - if fake.FindPortStub != nil { - return fake.FindPortStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.findPortReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -576,15 +583,16 @@ func (fake *FakeRouteActor) UnbindAll(arg1 models.Application) error { fake.unbindAllArgsForCall = append(fake.unbindAllArgsForCall, struct { arg1 models.Application }{arg1}) + stub := fake.UnbindAllStub + fakeReturns := fake.unbindAllReturns fake.recordInvocation("UnbindAll", []interface{}{arg1}) fake.unbindAllMutex.Unlock() - if fake.UnbindAllStub != nil { - return fake.UnbindAllStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindAllReturns return fakeReturns.result1 } diff --git a/cf/actors/actorsfakes/fake_service_actor.go b/cf/actors/actorsfakes/fake_service_actor.go index 292c15a4dae..9505474660e 100644 --- a/cf/actors/actorsfakes/fake_service_actor.go +++ b/cf/actors/actorsfakes/fake_service_actor.go @@ -4,8 +4,8 @@ package actorsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceActor struct { @@ -36,15 +36,16 @@ func (fake *FakeServiceActor) FilterBrokers(arg1 string, arg2 string, arg3 strin arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.FilterBrokersStub + fakeReturns := fake.filterBrokersReturns fake.recordInvocation("FilterBrokers", []interface{}{arg1, arg2, arg3}) fake.filterBrokersMutex.Unlock() - if fake.FilterBrokersStub != nil { - return fake.FilterBrokersStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.filterBrokersReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/actors/actorsfakes/fake_service_plan_actor.go b/cf/actors/actorsfakes/fake_service_plan_actor.go index 35cd597e588..d3a7fc0fd25 100644 --- a/cf/actors/actorsfakes/fake_service_plan_actor.go +++ b/cf/actors/actorsfakes/fake_service_plan_actor.go @@ -4,7 +4,7 @@ package actorsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/actors" ) type FakeServicePlanActor struct { @@ -85,15 +85,16 @@ func (fake *FakeServicePlanActor) FindServiceAccess(arg1 string, arg2 string) (a arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindServiceAccessStub + fakeReturns := fake.findServiceAccessReturns fake.recordInvocation("FindServiceAccess", []interface{}{arg1, arg2}) fake.findServiceAccessMutex.Unlock() - if fake.FindServiceAccessStub != nil { - return fake.FindServiceAccessStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findServiceAccessReturns return fakeReturns.result1, fakeReturns.result2 } @@ -149,15 +150,16 @@ func (fake *FakeServicePlanActor) UpdateAllPlansForService(arg1 string, arg2 boo arg1 string arg2 bool }{arg1, arg2}) + stub := fake.UpdateAllPlansForServiceStub + fakeReturns := fake.updateAllPlansForServiceReturns fake.recordInvocation("UpdateAllPlansForService", []interface{}{arg1, arg2}) fake.updateAllPlansForServiceMutex.Unlock() - if fake.UpdateAllPlansForServiceStub != nil { - return fake.UpdateAllPlansForServiceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateAllPlansForServiceReturns return fakeReturns.result1 } @@ -211,15 +213,16 @@ func (fake *FakeServicePlanActor) UpdateOrgForService(arg1 string, arg2 string, arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.UpdateOrgForServiceStub + fakeReturns := fake.updateOrgForServiceReturns fake.recordInvocation("UpdateOrgForService", []interface{}{arg1, arg2, arg3}) fake.updateOrgForServiceMutex.Unlock() - if fake.UpdateOrgForServiceStub != nil { - return fake.UpdateOrgForServiceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateOrgForServiceReturns return fakeReturns.result1 } @@ -274,15 +277,16 @@ func (fake *FakeServicePlanActor) UpdatePlanAndOrgForService(arg1 string, arg2 s arg3 string arg4 bool }{arg1, arg2, arg3, arg4}) + stub := fake.UpdatePlanAndOrgForServiceStub + fakeReturns := fake.updatePlanAndOrgForServiceReturns fake.recordInvocation("UpdatePlanAndOrgForService", []interface{}{arg1, arg2, arg3, arg4}) fake.updatePlanAndOrgForServiceMutex.Unlock() - if fake.UpdatePlanAndOrgForServiceStub != nil { - return fake.UpdatePlanAndOrgForServiceStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.updatePlanAndOrgForServiceReturns return fakeReturns.result1 } @@ -336,15 +340,16 @@ func (fake *FakeServicePlanActor) UpdateSinglePlanForService(arg1 string, arg2 s arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.UpdateSinglePlanForServiceStub + fakeReturns := fake.updateSinglePlanForServiceReturns fake.recordInvocation("UpdateSinglePlanForService", []interface{}{arg1, arg2, arg3}) fake.updateSinglePlanForServiceMutex.Unlock() - if fake.UpdateSinglePlanForServiceStub != nil { - return fake.UpdateSinglePlanForServiceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateSinglePlanForServiceReturns return fakeReturns.result1 } diff --git a/cf/actors/brokerbuilder/broker_builder.go b/cf/actors/brokerbuilder/broker_builder.go index e46d9501f5c..97c0e0076b6 100644 --- a/cf/actors/brokerbuilder/broker_builder.go +++ b/cf/actors/brokerbuilder/broker_builder.go @@ -1,9 +1,9 @@ package brokerbuilder import ( - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . BrokerBuilder diff --git a/cf/actors/brokerbuilder/broker_builder_suite_test.go b/cf/actors/brokerbuilder/broker_builder_suite_test.go index c0bfffd9847..59afbdfa575 100644 --- a/cf/actors/brokerbuilder/broker_builder_suite_test.go +++ b/cf/actors/brokerbuilder/broker_builder_suite_test.go @@ -1,7 +1,7 @@ package brokerbuilder_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/actors/brokerbuilder/broker_builder_test.go b/cf/actors/brokerbuilder/broker_builder_test.go index 174b7e11c9c..ec3a17b6e75 100644 --- a/cf/actors/brokerbuilder/broker_builder_test.go +++ b/cf/actors/brokerbuilder/broker_builder_test.go @@ -3,13 +3,13 @@ package brokerbuilder_test import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/brokerbuilder" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/brokerbuilder" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder/servicebuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder/servicebuilderfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -225,7 +225,7 @@ var _ = Describe("Broker Builder", func() { }) Describe(".GetBrokerWithSpecifiedService", func() { - It("returns an error if a broker containeing the specific service cannot be found", func() { + It("returns an error if a broker containing the specific service cannot be found", func() { serviceBuilder.GetServiceByNameWithPlansWithOrgNamesReturns(models.ServiceOffering{}, errors.New("Asplosions")) _, err := brokerBuilder.GetBrokerWithSpecifiedService("totally-not-a-service") diff --git a/cf/actors/brokerbuilder/brokerbuilderfakes/fake_broker_builder.go b/cf/actors/brokerbuilder/brokerbuilderfakes/fake_broker_builder.go index 8afcd08a52a..1253dbb140d 100644 --- a/cf/actors/brokerbuilder/brokerbuilderfakes/fake_broker_builder.go +++ b/cf/actors/brokerbuilder/brokerbuilderfakes/fake_broker_builder.go @@ -4,8 +4,8 @@ package brokerbuilderfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors/brokerbuilder" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/brokerbuilder" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeBrokerBuilder struct { @@ -89,15 +89,16 @@ func (fake *FakeBrokerBuilder) AttachBrokersToServices(arg1 []models.ServiceOffe fake.attachBrokersToServicesArgsForCall = append(fake.attachBrokersToServicesArgsForCall, struct { arg1 []models.ServiceOffering }{arg1Copy}) + stub := fake.AttachBrokersToServicesStub + fakeReturns := fake.attachBrokersToServicesReturns fake.recordInvocation("AttachBrokersToServices", []interface{}{arg1Copy}) fake.attachBrokersToServicesMutex.Unlock() - if fake.AttachBrokersToServicesStub != nil { - return fake.AttachBrokersToServicesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.attachBrokersToServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -158,15 +159,16 @@ func (fake *FakeBrokerBuilder) AttachSpecificBrokerToServices(arg1 string, arg2 arg1 string arg2 []models.ServiceOffering }{arg1, arg2Copy}) + stub := fake.AttachSpecificBrokerToServicesStub + fakeReturns := fake.attachSpecificBrokerToServicesReturns fake.recordInvocation("AttachSpecificBrokerToServices", []interface{}{arg1, arg2Copy}) fake.attachSpecificBrokerToServicesMutex.Unlock() - if fake.AttachSpecificBrokerToServicesStub != nil { - return fake.AttachSpecificBrokerToServicesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.attachSpecificBrokerToServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -220,15 +222,16 @@ func (fake *FakeBrokerBuilder) GetAllServiceBrokers() ([]models.ServiceBroker, e ret, specificReturn := fake.getAllServiceBrokersReturnsOnCall[len(fake.getAllServiceBrokersArgsForCall)] fake.getAllServiceBrokersArgsForCall = append(fake.getAllServiceBrokersArgsForCall, struct { }{}) + stub := fake.GetAllServiceBrokersStub + fakeReturns := fake.getAllServiceBrokersReturns fake.recordInvocation("GetAllServiceBrokers", []interface{}{}) fake.getAllServiceBrokersMutex.Unlock() - if fake.GetAllServiceBrokersStub != nil { - return fake.GetAllServiceBrokersStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAllServiceBrokersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -276,15 +279,16 @@ func (fake *FakeBrokerBuilder) GetBrokerWithAllServices(arg1 string) (models.Ser fake.getBrokerWithAllServicesArgsForCall = append(fake.getBrokerWithAllServicesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetBrokerWithAllServicesStub + fakeReturns := fake.getBrokerWithAllServicesReturns fake.recordInvocation("GetBrokerWithAllServices", []interface{}{arg1}) fake.getBrokerWithAllServicesMutex.Unlock() - if fake.GetBrokerWithAllServicesStub != nil { - return fake.GetBrokerWithAllServicesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getBrokerWithAllServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -339,15 +343,16 @@ func (fake *FakeBrokerBuilder) GetBrokerWithSpecifiedService(arg1 string) (model fake.getBrokerWithSpecifiedServiceArgsForCall = append(fake.getBrokerWithSpecifiedServiceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetBrokerWithSpecifiedServiceStub + fakeReturns := fake.getBrokerWithSpecifiedServiceReturns fake.recordInvocation("GetBrokerWithSpecifiedService", []interface{}{arg1}) fake.getBrokerWithSpecifiedServiceMutex.Unlock() - if fake.GetBrokerWithSpecifiedServiceStub != nil { - return fake.GetBrokerWithSpecifiedServiceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getBrokerWithSpecifiedServiceReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/actors/planbuilder/plan_builder.go b/cf/actors/planbuilder/plan_builder.go index 871f450a4ed..4d735ba5773 100644 --- a/cf/actors/planbuilder/plan_builder.go +++ b/cf/actors/planbuilder/plan_builder.go @@ -1,9 +1,9 @@ package planbuilder import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PlanBuilder diff --git a/cf/actors/planbuilder/plan_builder_suite_test.go b/cf/actors/planbuilder/plan_builder_suite_test.go index f1f592be337..df13f1fd1f7 100644 --- a/cf/actors/planbuilder/plan_builder_suite_test.go +++ b/cf/actors/planbuilder/plan_builder_suite_test.go @@ -1,7 +1,7 @@ package planbuilder_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/actors/planbuilder/plan_builder_test.go b/cf/actors/planbuilder/plan_builder_test.go index bcb23d1e4cc..8f842bb11ce 100644 --- a/cf/actors/planbuilder/plan_builder_test.go +++ b/cf/actors/planbuilder/plan_builder_test.go @@ -3,11 +3,11 @@ package planbuilder_test import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/planbuilder/planbuilderfakes/fake_plan_builder.go b/cf/actors/planbuilder/planbuilderfakes/fake_plan_builder.go index 73e44142c00..d73c05bf77b 100644 --- a/cf/actors/planbuilder/planbuilderfakes/fake_plan_builder.go +++ b/cf/actors/planbuilder/planbuilderfakes/fake_plan_builder.go @@ -4,8 +4,8 @@ package planbuilderfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakePlanBuilder struct { @@ -118,15 +118,16 @@ func (fake *FakePlanBuilder) AttachOrgToPlans(arg1 []models.ServicePlanFields, a arg1 []models.ServicePlanFields arg2 string }{arg1Copy, arg2}) + stub := fake.AttachOrgToPlansStub + fakeReturns := fake.attachOrgToPlansReturns fake.recordInvocation("AttachOrgToPlans", []interface{}{arg1Copy, arg2}) fake.attachOrgToPlansMutex.Unlock() - if fake.AttachOrgToPlansStub != nil { - return fake.AttachOrgToPlansStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.attachOrgToPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -186,15 +187,16 @@ func (fake *FakePlanBuilder) AttachOrgsToPlans(arg1 []models.ServicePlanFields) fake.attachOrgsToPlansArgsForCall = append(fake.attachOrgsToPlansArgsForCall, struct { arg1 []models.ServicePlanFields }{arg1Copy}) + stub := fake.AttachOrgsToPlansStub + fakeReturns := fake.attachOrgsToPlansReturns fake.recordInvocation("AttachOrgsToPlans", []interface{}{arg1Copy}) fake.attachOrgsToPlansMutex.Unlock() - if fake.AttachOrgsToPlansStub != nil { - return fake.AttachOrgsToPlansStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.attachOrgsToPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -254,15 +256,16 @@ func (fake *FakePlanBuilder) GetPlansForManyServicesWithOrgs(arg1 []string) ([]m fake.getPlansForManyServicesWithOrgsArgsForCall = append(fake.getPlansForManyServicesWithOrgsArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.GetPlansForManyServicesWithOrgsStub + fakeReturns := fake.getPlansForManyServicesWithOrgsReturns fake.recordInvocation("GetPlansForManyServicesWithOrgs", []interface{}{arg1Copy}) fake.getPlansForManyServicesWithOrgsMutex.Unlock() - if fake.GetPlansForManyServicesWithOrgsStub != nil { - return fake.GetPlansForManyServicesWithOrgsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPlansForManyServicesWithOrgsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -317,15 +320,16 @@ func (fake *FakePlanBuilder) GetPlansForService(arg1 string) ([]models.ServicePl fake.getPlansForServiceArgsForCall = append(fake.getPlansForServiceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPlansForServiceStub + fakeReturns := fake.getPlansForServiceReturns fake.recordInvocation("GetPlansForService", []interface{}{arg1}) fake.getPlansForServiceMutex.Unlock() - if fake.GetPlansForServiceStub != nil { - return fake.GetPlansForServiceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPlansForServiceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -381,15 +385,16 @@ func (fake *FakePlanBuilder) GetPlansForServiceForOrg(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetPlansForServiceForOrgStub + fakeReturns := fake.getPlansForServiceForOrgReturns fake.recordInvocation("GetPlansForServiceForOrg", []interface{}{arg1, arg2}) fake.getPlansForServiceForOrgMutex.Unlock() - if fake.GetPlansForServiceForOrgStub != nil { - return fake.GetPlansForServiceForOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPlansForServiceForOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -444,15 +449,16 @@ func (fake *FakePlanBuilder) GetPlansForServiceWithOrgs(arg1 string) ([]models.S fake.getPlansForServiceWithOrgsArgsForCall = append(fake.getPlansForServiceWithOrgsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPlansForServiceWithOrgsStub + fakeReturns := fake.getPlansForServiceWithOrgsReturns fake.recordInvocation("GetPlansForServiceWithOrgs", []interface{}{arg1}) fake.getPlansForServiceWithOrgsMutex.Unlock() - if fake.GetPlansForServiceWithOrgsStub != nil { - return fake.GetPlansForServiceWithOrgsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPlansForServiceWithOrgsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -507,15 +513,16 @@ func (fake *FakePlanBuilder) GetPlansVisibleToOrg(arg1 string) ([]models.Service fake.getPlansVisibleToOrgArgsForCall = append(fake.getPlansVisibleToOrgArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPlansVisibleToOrgStub + fakeReturns := fake.getPlansVisibleToOrgReturns fake.recordInvocation("GetPlansVisibleToOrg", []interface{}{arg1}) fake.getPlansVisibleToOrgMutex.Unlock() - if fake.GetPlansVisibleToOrgStub != nil { - return fake.GetPlansVisibleToOrgStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPlansVisibleToOrgReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/actors/plugininstaller/plugin_downloader.go b/cf/actors/plugininstaller/plugin_downloader.go index b431d11d445..d6be89fcc27 100644 --- a/cf/actors/plugininstaller/plugin_downloader.go +++ b/cf/actors/plugininstaller/plugin_downloader.go @@ -7,9 +7,9 @@ import ( "runtime" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/downloader" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/downloader" ) type PluginDownloader struct { diff --git a/cf/actors/plugininstaller/plugin_installer.go b/cf/actors/plugininstaller/plugin_installer.go index d7b8724f178..cc173e17b62 100644 --- a/cf/actors/plugininstaller/plugin_installer.go +++ b/cf/actors/plugininstaller/plugin_installer.go @@ -1,11 +1,11 @@ package plugininstaller import ( - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/downloader" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/downloader" + "code.cloudfoundry.org/cli/v8/util" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginInstaller diff --git a/cf/actors/plugininstaller/plugin_installer_with_repo.go b/cf/actors/plugininstaller/plugin_installer_with_repo.go index e089a4ebc37..d8614463264 100644 --- a/cf/actors/plugininstaller/plugin_installer_with_repo.go +++ b/cf/actors/plugininstaller/plugin_installer_with_repo.go @@ -5,11 +5,11 @@ import ( "strings" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/util" ) type pluginInstallerWithRepo struct { @@ -41,7 +41,7 @@ func (installer *pluginInstallerWithRepo) Install(inputSourceFilepath string) st found := false sha1 := "" - for _, plugin := range findRepoCaseInsensity(pluginList, installer.RepoName) { + for _, plugin := range findRepoCaseIntensity(pluginList, installer.RepoName) { if strings.ToLower(plugin.Name) == targetPluginName { found = true outputSourceFilepath, sha1 = installer.PluginDownloader.downloadFromPlugin(plugin) @@ -73,7 +73,7 @@ func (installer *pluginInstallerWithRepo) getRepoFromConfig(repoName string) (mo return models.PluginRepo{}, errors.New(repoName + T(" not found")) } -func findRepoCaseInsensity(repoList map[string][]clipr.Plugin, repoName string) []clipr.Plugin { +func findRepoCaseIntensity(repoList map[string][]clipr.Plugin, repoName string) []clipr.Plugin { target := strings.ToLower(repoName) for k, repo := range repoList { if strings.ToLower(k) == target { diff --git a/cf/actors/plugininstaller/plugin_installer_without_repo.go b/cf/actors/plugininstaller/plugin_installer_without_repo.go index 7cf0bf97038..10b2787daef 100644 --- a/cf/actors/plugininstaller/plugin_installer_without_repo.go +++ b/cf/actors/plugininstaller/plugin_installer_without_repo.go @@ -5,8 +5,8 @@ import ( "path/filepath" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type pluginInstallerWithoutRepo struct { diff --git a/cf/actors/plugininstaller/plugininstallerfakes/fake_plugin_installer.go b/cf/actors/plugininstaller/plugininstallerfakes/fake_plugin_installer.go index fd496df7119..4b514135f15 100644 --- a/cf/actors/plugininstaller/plugininstallerfakes/fake_plugin_installer.go +++ b/cf/actors/plugininstaller/plugininstallerfakes/fake_plugin_installer.go @@ -4,7 +4,7 @@ package plugininstallerfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors/plugininstaller" + "code.cloudfoundry.org/cli/v8/cf/actors/plugininstaller" ) type FakePluginInstaller struct { @@ -29,15 +29,16 @@ func (fake *FakePluginInstaller) Install(arg1 string) string { fake.installArgsForCall = append(fake.installArgsForCall, struct { arg1 string }{arg1}) + stub := fake.InstallStub + fakeReturns := fake.installReturns fake.recordInvocation("Install", []interface{}{arg1}) fake.installMutex.Unlock() - if fake.InstallStub != nil { - return fake.InstallStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.installReturns return fakeReturns.result1 } diff --git a/cf/actors/pluginrepo/plugin_repo.go b/cf/actors/pluginrepo/plugin_repo.go index 56a6837867b..2196e5575bb 100644 --- a/cf/actors/pluginrepo/plugin_repo.go +++ b/cf/actors/pluginrepo/plugin_repo.go @@ -3,14 +3,14 @@ package pluginrepo import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginRepo @@ -27,18 +27,32 @@ func NewPluginRepo() PluginRepo { func (r pluginRepo) GetPlugins(repos []models.PluginRepo) (map[string][]clipr.Plugin, []string) { var pluginList clipr.PluginsJson - repoError := []string{} + var repoError []string repoPlugins := make(map[string][]clipr.Plugin) for _, repo := range repos { - resp, err := http.Get(getListEndpoint(repo.URL)) + // resp, err := http.Get(getListEndpoint(repo.URL)) + client := &http.Client{} + req, err := http.NewRequest("GET", getListEndpoint(repo.URL), nil) + if err != nil { + repoError = append(repoError, fmt.Sprintf(T("Error requesting from")+" '%s' - %s", repo.Name, err.Error())) + continue + } + + req.Header.Set("User-Agent", "golang_user_agent/1.0") + resp, err := client.Do(req) if err != nil { repoError = append(repoError, fmt.Sprintf(T("Error requesting from")+" '%s' - %s", repo.Name, err.Error())) continue } else { - defer resp.Body.Close() + defer func(Body io.ReadCloser) { + err := Body.Close() + if err != nil { + repoError = append(repoError, fmt.Sprintf(T("Error closing body")+" '%s' - %s", repo.Name, err.Error())) + } + }(resp.Body) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { repoError = append(repoError, fmt.Sprintf(T("Error reading response from")+" '%s' - %s ", repo.Name, err.Error())) continue diff --git a/cf/actors/pluginrepo/plugin_repo_suite_test.go b/cf/actors/pluginrepo/plugin_repo_suite_test.go index eb732390863..638c7d68db9 100644 --- a/cf/actors/pluginrepo/plugin_repo_suite_test.go +++ b/cf/actors/pluginrepo/plugin_repo_suite_test.go @@ -1,9 +1,9 @@ package pluginrepo_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/actors/pluginrepo/plugin_repo_test.go b/cf/actors/pluginrepo/plugin_repo_test.go index 913be5f931a..6bd5415ba86 100644 --- a/cf/actors/pluginrepo/plugin_repo_test.go +++ b/cf/actors/pluginrepo/plugin_repo_test.go @@ -5,11 +5,11 @@ import ( "net/http" "net/http/httptest" - . "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -30,15 +30,19 @@ var _ = Describe("PluginRepo", func() { BeforeEach(func() { testServer1CallCount = 0 h1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() testServer1CallCount++ fmt.Fprintln(w, `{"plugins":[]}`) + Expect(r.Header.Get("User-Agent")).NotTo(Equal("Go-http-client/1.1")) }) testServer1 = httptest.NewServer(h1) testServer2CallCount = 0 h2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() testServer2CallCount++ fmt.Fprintln(w, `{"plugins":[]}`) + Expect(r.Header.Get("User-Agent")).NotTo(Equal("Go-http-client/1.1")) }) testServer2 = httptest.NewServer(h2) @@ -87,6 +91,7 @@ var _ = Describe("PluginRepo", func() { Context("When data is valid", func() { BeforeEach(func() { h1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() fmt.Fprintln(w, `{"plugins":[ { "name":"plugin1", @@ -111,6 +116,7 @@ var _ = Describe("PluginRepo", func() { ] }] }`) + Expect(r.Header.Get("User-Agent")).NotTo(Equal("Go-http-client/1.1")) }) testServer1 = httptest.NewServer(h1) @@ -146,7 +152,9 @@ var _ = Describe("PluginRepo", func() { Context("json is invalid", func() { BeforeEach(func() { h1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() fmt.Fprintln(w, `"plugins":[]}`) + Expect(r.Header.Get("User-Agent")).NotTo(Equal("Go-http-client/1.1")) }) testServer1 = httptest.NewServer(h1) }) @@ -174,7 +182,9 @@ var _ = Describe("PluginRepo", func() { Context("when data is valid json, but not valid plugin repo data", func() { BeforeEach(func() { h1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer GinkgoRecover() fmt.Fprintln(w, `{"bad_plugin_tag":[]}`) + Expect(r.Header.Get("User-Agent")).NotTo(Equal("Go-http-client/1.1")) }) testServer1 = httptest.NewServer(h1) }) diff --git a/cf/actors/pluginrepo/pluginrepofakes/fake_plugin_repo.go b/cf/actors/pluginrepo/pluginrepofakes/fake_plugin_repo.go index 25c659ee0c6..25942527e6f 100644 --- a/cf/actors/pluginrepo/pluginrepofakes/fake_plugin_repo.go +++ b/cf/actors/pluginrepo/pluginrepofakes/fake_plugin_repo.go @@ -5,8 +5,8 @@ import ( "sync" "code.cloudfoundry.org/cli-plugin-repo/web" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakePluginRepo struct { @@ -38,15 +38,16 @@ func (fake *FakePluginRepo) GetPlugins(arg1 []models.PluginRepo) (map[string][]w fake.getPluginsArgsForCall = append(fake.getPluginsArgsForCall, struct { arg1 []models.PluginRepo }{arg1Copy}) + stub := fake.GetPluginsStub + fakeReturns := fake.getPluginsReturns fake.recordInvocation("GetPlugins", []interface{}{arg1Copy}) fake.getPluginsMutex.Unlock() - if fake.GetPluginsStub != nil { - return fake.GetPluginsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginsReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/actors/push.go b/cf/actors/push.go index 182e2b2f308..21232c308cd 100644 --- a/cf/actors/push.go +++ b/cf/actors/push.go @@ -7,11 +7,13 @@ import ( "path/filepath" "runtime" - "code.cloudfoundry.org/cli/cf/api/applicationbits" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/appfiles" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" + "errors" + + "code.cloudfoundry.org/cli/v8/cf/api/applicationbits" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" "code.cloudfoundry.org/gofileutils/fileutils" ) @@ -186,29 +188,29 @@ func (actor PushActorImpl) ValidateAppParams(apps []models.AppParams) []error { appName := app.Name if app.HealthCheckType != nil && *app.HealthCheckType != "http" && app.HealthCheckHTTPEndpoint != nil { - errs = append(errs, fmt.Errorf(T("Health check type must be 'http' to set a health check HTTP endpoint."))) + errs = append(errs, errors.New(T("Health check type must be 'http' to set a health check HTTP endpoint."))) } if app.Routes != nil { if app.Hosts != nil { - errs = append(errs, fmt.Errorf(T("Application {{.AppName}} must not be configured with both 'routes' and 'host'/'hosts'", map[string]interface{}{"AppName": appName}))) + errs = append(errs, errors.New(T("Application {{.AppName}} must not be configured with both 'routes' and 'host'/'hosts'", map[string]interface{}{"AppName": appName}))) } if app.Domains != nil { - errs = append(errs, fmt.Errorf(T("Application {{.AppName}} must not be configured with both 'routes' and 'domain'/'domains'", map[string]interface{}{"AppName": appName}))) + errs = append(errs, errors.New(T("Application {{.AppName}} must not be configured with both 'routes' and 'domain'/'domains'", map[string]interface{}{"AppName": appName}))) } if app.NoHostname != nil { - errs = append(errs, fmt.Errorf(T("Application {{.AppName}} must not be configured with both 'routes' and 'no-hostname'", map[string]interface{}{"AppName": appName}))) + errs = append(errs, errors.New(T("Application {{.AppName}} must not be configured with both 'routes' and 'no-hostname'", map[string]interface{}{"AppName": appName}))) } } if app.BuildpackURL != nil && app.DockerImage != nil { - errs = append(errs, fmt.Errorf(T("Application {{.AppName}} must not be configured with both 'buildpack' and 'docker'", map[string]interface{}{"AppName": appName}))) + errs = append(errs, errors.New(T("Application {{.AppName}} must not be configured with both 'buildpack' and 'docker'", map[string]interface{}{"AppName": appName}))) } if app.Path != nil && app.DockerImage != nil { - errs = append(errs, fmt.Errorf(T("Application {{.AppName}} must not be configured with both 'docker' and 'path'", map[string]interface{}{"AppName": appName}))) + errs = append(errs, errors.New(T("Application {{.AppName}} must not be configured with both 'docker' and 'path'", map[string]interface{}{"AppName": appName}))) } } diff --git a/cf/actors/push_test.go b/cf/actors/push_test.go index 33bd26b5961..46145cedf6c 100644 --- a/cf/actors/push_test.go +++ b/cf/actors/push_test.go @@ -8,14 +8,14 @@ import ( "path/filepath" "runtime" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/actors/actorsfakes" - "code.cloudfoundry.org/cli/cf/api/applicationbits/applicationbitsfakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/appfiles/appfilesfakes" - "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/actors/actorsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/applicationbits/applicationbitsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/appfiles/appfilesfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/routes.go b/cf/actors/routes.go index 0b360480504..d74119ca03c 100644 --- a/cf/actors/routes.go +++ b/cf/actors/routes.go @@ -5,12 +5,12 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/util/randomword" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/util/randomword" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RouteActor @@ -58,7 +58,7 @@ func (routeActor routeActor) CreateRandomTCPRoute(domain models.DomainFields) (m func (routeActor routeActor) FindOrCreateRoute(hostname string, domain models.DomainFields, path string, port int, useRandomPort bool) (models.Route, error) { var route models.Route var err error - //if tcp route use random port should skip route lookup + // if tcp route use random port should skip route lookup if useRandomPort && domain.RouterGroupType == tcp { err = new(errors.ModelNotFoundError) } else { @@ -233,7 +233,7 @@ func (routeActor routeActor) FindAndBindRoute(routeName string, app models.Appli func validateRoute(routeName string, domainType string, port int, path string) error { if domainType == tcp && path != "" { - return fmt.Errorf(T("Path not allowed in TCP route {{.RouteName}}", + return errors.New(T("Path not allowed in TCP route {{.RouteName}}", map[string]interface{}{ "RouteName": routeName, }, @@ -241,7 +241,7 @@ func validateRoute(routeName string, domainType string, port int, path string) e } if domainType == "" && port != 0 { - return fmt.Errorf(T("Port not allowed in HTTP route {{.RouteName}}", + return errors.New(T("Port not allowed in HTTP route {{.RouteName}}", map[string]interface{}{ "RouteName": routeName, }, @@ -288,7 +288,7 @@ func parseRoute(routeName string, findFunc func(domainName string) (models.Domai return routeParts[0], domain, false, nil } - return "", models.DomainFields{}, true, fmt.Errorf(T( + return "", models.DomainFields{}, true, errors.New(T( "The route {{.RouteName}} did not match any existing domains.", map[string]interface{}{ "RouteName": routeName, diff --git a/cf/actors/routes_test.go b/cf/actors/routes_test.go index 2fbab050aa5..c8be541120f 100644 --- a/cf/actors/routes_test.go +++ b/cf/actors/routes_test.go @@ -3,13 +3,13 @@ package actors_test import ( "errors" - . "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api/apifakes" - cferrors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/errors/errorsfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + cferrors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/errors/errorsfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/servicebuilder/service_builder.go b/cf/actors/servicebuilder/service_builder.go index c91f07a7b18..d719ba0034f 100644 --- a/cf/actors/servicebuilder/service_builder.go +++ b/cf/actors/servicebuilder/service_builder.go @@ -3,9 +3,9 @@ package servicebuilder import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceBuilder diff --git a/cf/actors/servicebuilder/service_builder_suite_test.go b/cf/actors/servicebuilder/service_builder_suite_test.go index 185a9e94d48..d1adac89d61 100644 --- a/cf/actors/servicebuilder/service_builder_suite_test.go +++ b/cf/actors/servicebuilder/service_builder_suite_test.go @@ -1,7 +1,7 @@ package servicebuilder_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/actors/servicebuilder/service_builder_test.go b/cf/actors/servicebuilder/service_builder_test.go index 16b91c8f02b..83a0290ce9c 100644 --- a/cf/actors/servicebuilder/service_builder_test.go +++ b/cf/actors/servicebuilder/service_builder_test.go @@ -3,13 +3,13 @@ package servicebuilder_test import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/planbuilder/planbuilderfakes" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder/planbuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/servicebuilder/servicebuilderfakes/fake_service_builder.go b/cf/actors/servicebuilder/servicebuilderfakes/fake_service_builder.go index 2a05297cc3b..0b1bdd3e359 100644 --- a/cf/actors/servicebuilder/servicebuilderfakes/fake_service_builder.go +++ b/cf/actors/servicebuilder/servicebuilderfakes/fake_service_builder.go @@ -4,8 +4,8 @@ package servicebuilderfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceBuilder struct { @@ -203,15 +203,16 @@ func (fake *FakeServiceBuilder) GetAllServices() ([]models.ServiceOffering, erro ret, specificReturn := fake.getAllServicesReturnsOnCall[len(fake.getAllServicesArgsForCall)] fake.getAllServicesArgsForCall = append(fake.getAllServicesArgsForCall, struct { }{}) + stub := fake.GetAllServicesStub + fakeReturns := fake.getAllServicesReturns fake.recordInvocation("GetAllServices", []interface{}{}) fake.getAllServicesMutex.Unlock() - if fake.GetAllServicesStub != nil { - return fake.GetAllServicesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAllServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -258,15 +259,16 @@ func (fake *FakeServiceBuilder) GetAllServicesWithPlans() ([]models.ServiceOffer ret, specificReturn := fake.getAllServicesWithPlansReturnsOnCall[len(fake.getAllServicesWithPlansArgsForCall)] fake.getAllServicesWithPlansArgsForCall = append(fake.getAllServicesWithPlansArgsForCall, struct { }{}) + stub := fake.GetAllServicesWithPlansStub + fakeReturns := fake.getAllServicesWithPlansReturns fake.recordInvocation("GetAllServicesWithPlans", []interface{}{}) fake.getAllServicesWithPlansMutex.Unlock() - if fake.GetAllServicesWithPlansStub != nil { - return fake.GetAllServicesWithPlansStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAllServicesWithPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -315,15 +317,16 @@ func (fake *FakeServiceBuilder) GetServiceByNameForOrg(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceByNameForOrgStub + fakeReturns := fake.getServiceByNameForOrgReturns fake.recordInvocation("GetServiceByNameForOrg", []interface{}{arg1, arg2}) fake.getServiceByNameForOrgMutex.Unlock() - if fake.GetServiceByNameForOrgStub != nil { - return fake.GetServiceByNameForOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceByNameForOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -379,15 +382,16 @@ func (fake *FakeServiceBuilder) GetServiceByNameForSpace(arg1 string, arg2 strin arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceByNameForSpaceStub + fakeReturns := fake.getServiceByNameForSpaceReturns fake.recordInvocation("GetServiceByNameForSpace", []interface{}{arg1, arg2}) fake.getServiceByNameForSpaceMutex.Unlock() - if fake.GetServiceByNameForSpaceStub != nil { - return fake.GetServiceByNameForSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceByNameForSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -443,15 +447,16 @@ func (fake *FakeServiceBuilder) GetServiceByNameForSpaceWithPlans(arg1 string, a arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceByNameForSpaceWithPlansStub + fakeReturns := fake.getServiceByNameForSpaceWithPlansReturns fake.recordInvocation("GetServiceByNameForSpaceWithPlans", []interface{}{arg1, arg2}) fake.getServiceByNameForSpaceWithPlansMutex.Unlock() - if fake.GetServiceByNameForSpaceWithPlansStub != nil { - return fake.GetServiceByNameForSpaceWithPlansStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceByNameForSpaceWithPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -506,15 +511,16 @@ func (fake *FakeServiceBuilder) GetServiceByNameWithPlans(arg1 string) (models.S fake.getServiceByNameWithPlansArgsForCall = append(fake.getServiceByNameWithPlansArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceByNameWithPlansStub + fakeReturns := fake.getServiceByNameWithPlansReturns fake.recordInvocation("GetServiceByNameWithPlans", []interface{}{arg1}) fake.getServiceByNameWithPlansMutex.Unlock() - if fake.GetServiceByNameWithPlansStub != nil { - return fake.GetServiceByNameWithPlansStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceByNameWithPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -569,15 +575,16 @@ func (fake *FakeServiceBuilder) GetServiceByNameWithPlansWithOrgNames(arg1 strin fake.getServiceByNameWithPlansWithOrgNamesArgsForCall = append(fake.getServiceByNameWithPlansWithOrgNamesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceByNameWithPlansWithOrgNamesStub + fakeReturns := fake.getServiceByNameWithPlansWithOrgNamesReturns fake.recordInvocation("GetServiceByNameWithPlansWithOrgNames", []interface{}{arg1}) fake.getServiceByNameWithPlansWithOrgNamesMutex.Unlock() - if fake.GetServiceByNameWithPlansWithOrgNamesStub != nil { - return fake.GetServiceByNameWithPlansWithOrgNamesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceByNameWithPlansWithOrgNamesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -633,15 +640,16 @@ func (fake *FakeServiceBuilder) GetServiceVisibleToOrg(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceVisibleToOrgStub + fakeReturns := fake.getServiceVisibleToOrgReturns fake.recordInvocation("GetServiceVisibleToOrg", []interface{}{arg1, arg2}) fake.getServiceVisibleToOrgMutex.Unlock() - if fake.GetServiceVisibleToOrgStub != nil { - return fake.GetServiceVisibleToOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceVisibleToOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -697,15 +705,16 @@ func (fake *FakeServiceBuilder) GetServicesByNameForSpaceWithPlans(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServicesByNameForSpaceWithPlansStub + fakeReturns := fake.getServicesByNameForSpaceWithPlansReturns fake.recordInvocation("GetServicesByNameForSpaceWithPlans", []interface{}{arg1, arg2}) fake.getServicesByNameForSpaceWithPlansMutex.Unlock() - if fake.GetServicesByNameForSpaceWithPlansStub != nil { - return fake.GetServicesByNameForSpaceWithPlansStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesByNameForSpaceWithPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -760,15 +769,16 @@ func (fake *FakeServiceBuilder) GetServicesForBroker(arg1 string) ([]models.Serv fake.getServicesForBrokerArgsForCall = append(fake.getServicesForBrokerArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicesForBrokerStub + fakeReturns := fake.getServicesForBrokerReturns fake.recordInvocation("GetServicesForBroker", []interface{}{arg1}) fake.getServicesForBrokerMutex.Unlock() - if fake.GetServicesForBrokerStub != nil { - return fake.GetServicesForBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesForBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -828,15 +838,16 @@ func (fake *FakeServiceBuilder) GetServicesForManyBrokers(arg1 []string) ([]mode fake.getServicesForManyBrokersArgsForCall = append(fake.getServicesForManyBrokersArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.GetServicesForManyBrokersStub + fakeReturns := fake.getServicesForManyBrokersReturns fake.recordInvocation("GetServicesForManyBrokers", []interface{}{arg1Copy}) fake.getServicesForManyBrokersMutex.Unlock() - if fake.GetServicesForManyBrokersStub != nil { - return fake.GetServicesForManyBrokersStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesForManyBrokersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -891,15 +902,16 @@ func (fake *FakeServiceBuilder) GetServicesForSpace(arg1 string) ([]models.Servi fake.getServicesForSpaceArgsForCall = append(fake.getServicesForSpaceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicesForSpaceStub + fakeReturns := fake.getServicesForSpaceReturns fake.recordInvocation("GetServicesForSpace", []interface{}{arg1}) fake.getServicesForSpaceMutex.Unlock() - if fake.GetServicesForSpaceStub != nil { - return fake.GetServicesForSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesForSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -954,15 +966,16 @@ func (fake *FakeServiceBuilder) GetServicesForSpaceWithPlans(arg1 string) ([]mod fake.getServicesForSpaceWithPlansArgsForCall = append(fake.getServicesForSpaceWithPlansArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicesForSpaceWithPlansStub + fakeReturns := fake.getServicesForSpaceWithPlansReturns fake.recordInvocation("GetServicesForSpaceWithPlans", []interface{}{arg1}) fake.getServicesForSpaceWithPlansMutex.Unlock() - if fake.GetServicesForSpaceWithPlansStub != nil { - return fake.GetServicesForSpaceWithPlansStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesForSpaceWithPlansReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1017,15 +1030,16 @@ func (fake *FakeServiceBuilder) GetServicesVisibleToOrg(arg1 string) ([]models.S fake.getServicesVisibleToOrgArgsForCall = append(fake.getServicesVisibleToOrgArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServicesVisibleToOrgStub + fakeReturns := fake.getServicesVisibleToOrgReturns fake.recordInvocation("GetServicesVisibleToOrg", []interface{}{arg1}) fake.getServicesVisibleToOrgMutex.Unlock() - if fake.GetServicesVisibleToOrgStub != nil { - return fake.GetServicesVisibleToOrgStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesVisibleToOrgReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/actors/services.go b/cf/actors/services.go index c776e317a30..bc081e0e714 100644 --- a/cf/actors/services.go +++ b/cf/actors/services.go @@ -1,10 +1,10 @@ package actors import ( - "code.cloudfoundry.org/cli/cf/actors/brokerbuilder" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/brokerbuilder" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceActor diff --git a/cf/actors/services_plans.go b/cf/actors/services_plans.go index 47bc690aff9..c40dd98e038 100644 --- a/cf/actors/services_plans.go +++ b/cf/actors/services_plans.go @@ -3,12 +3,12 @@ package actors import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServicePlanActor diff --git a/cf/actors/services_plans_test.go b/cf/actors/services_plans_test.go index 268494abd0e..7720bc2c1ad 100644 --- a/cf/actors/services_plans_test.go +++ b/cf/actors/services_plans_test.go @@ -1,16 +1,16 @@ package actors_test import ( - "code.cloudfoundry.org/cli/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/errors" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/actors/planbuilder/planbuilderfakes" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder/servicebuilderfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder/planbuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder/servicebuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/models" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/services_test.go b/cf/actors/services_test.go index fc846c2e552..f71ae92716e 100644 --- a/cf/actors/services_test.go +++ b/cf/actors/services_test.go @@ -1,14 +1,14 @@ package actors_test import ( - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/actors/brokerbuilder/brokerbuilderfakes" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder/servicebuilderfakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/actors/brokerbuilder/brokerbuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder/servicebuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/actors/userprint/plugin.go b/cf/actors/userprint/plugin.go index a5e4f2aab66..2474aa11a49 100644 --- a/cf/actors/userprint/plugin.go +++ b/cf/actors/userprint/plugin.go @@ -1,8 +1,8 @@ package userprint import ( - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type pluginPrinter struct { diff --git a/cf/actors/userprint/ui.go b/cf/actors/userprint/ui.go index e75ad01ea08..ad2ecb50393 100644 --- a/cf/actors/userprint/ui.go +++ b/cf/actors/userprint/ui.go @@ -1,9 +1,9 @@ package userprint import ( - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SpaceUsersUIPrinter struct { diff --git a/cf/actors/userprint/userprintfakes/fake_user_printer.go b/cf/actors/userprint/userprintfakes/fake_user_printer.go index 006670f0b36..e1a4e3e0f1e 100644 --- a/cf/actors/userprint/userprintfakes/fake_user_printer.go +++ b/cf/actors/userprint/userprintfakes/fake_user_printer.go @@ -4,7 +4,7 @@ package userprintfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/actors/userprint" + "code.cloudfoundry.org/cli/v8/cf/actors/userprint" ) type FakeUserPrinter struct { @@ -24,9 +24,10 @@ func (fake *FakeUserPrinter) PrintUsers(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.PrintUsersStub fake.recordInvocation("PrintUsers", []interface{}{arg1, arg2}) fake.printUsersMutex.Unlock() - if fake.PrintUsersStub != nil { + if stub != nil { fake.PrintUsersStub(arg1, arg2) } } diff --git a/cf/api/api_suite_test.go b/cf/api/api_suite_test.go index 98ae9aee9ec..44c036cb863 100644 --- a/cf/api/api_suite_test.go +++ b/cf/api/api_suite_test.go @@ -1,9 +1,9 @@ package api_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/apifakes/fake_app_summary_repository.go b/cf/api/apifakes/fake_app_summary_repository.go index 57f5838b1a1..85daa795d77 100644 --- a/cf/api/apifakes/fake_app_summary_repository.go +++ b/cf/api/apifakes/fake_app_summary_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeAppSummaryRepository struct { @@ -43,15 +43,16 @@ func (fake *FakeAppSummaryRepository) GetSummariesInCurrentSpace() ([]models.App ret, specificReturn := fake.getSummariesInCurrentSpaceReturnsOnCall[len(fake.getSummariesInCurrentSpaceArgsForCall)] fake.getSummariesInCurrentSpaceArgsForCall = append(fake.getSummariesInCurrentSpaceArgsForCall, struct { }{}) + stub := fake.GetSummariesInCurrentSpaceStub + fakeReturns := fake.getSummariesInCurrentSpaceReturns fake.recordInvocation("GetSummariesInCurrentSpace", []interface{}{}) fake.getSummariesInCurrentSpaceMutex.Unlock() - if fake.GetSummariesInCurrentSpaceStub != nil { - return fake.GetSummariesInCurrentSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSummariesInCurrentSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -99,15 +100,16 @@ func (fake *FakeAppSummaryRepository) GetSummary(arg1 string) (models.Applicatio fake.getSummaryArgsForCall = append(fake.getSummaryArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSummaryStub + fakeReturns := fake.getSummaryReturns fake.recordInvocation("GetSummary", []interface{}{arg1}) fake.getSummaryMutex.Unlock() - if fake.GetSummaryStub != nil { - return fake.GetSummaryStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSummaryReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_buildpack_bits_repository.go b/cf/api/apifakes/fake_buildpack_bits_repository.go index abe72109754..a821ea74c28 100644 --- a/cf/api/apifakes/fake_buildpack_bits_repository.go +++ b/cf/api/apifakes/fake_buildpack_bits_repository.go @@ -5,8 +5,8 @@ import ( "os" "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeBuildpackBitsRepository struct { @@ -48,15 +48,16 @@ func (fake *FakeBuildpackBitsRepository) CreateBuildpackZipFile(arg1 string) (*o fake.createBuildpackZipFileArgsForCall = append(fake.createBuildpackZipFileArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateBuildpackZipFileStub + fakeReturns := fake.createBuildpackZipFileReturns fake.recordInvocation("CreateBuildpackZipFile", []interface{}{arg1}) fake.createBuildpackZipFileMutex.Unlock() - if fake.CreateBuildpackZipFileStub != nil { - return fake.CreateBuildpackZipFileStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBuildpackZipFileReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -116,15 +117,16 @@ func (fake *FakeBuildpackBitsRepository) UploadBuildpack(arg1 models.Buildpack, arg2 *os.File arg3 string }{arg1, arg2, arg3}) + stub := fake.UploadBuildpackStub + fakeReturns := fake.uploadBuildpackReturns fake.recordInvocation("UploadBuildpack", []interface{}{arg1, arg2, arg3}) fake.uploadBuildpackMutex.Unlock() - if fake.UploadBuildpackStub != nil { - return fake.UploadBuildpackStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.uploadBuildpackReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_buildpack_repository.go b/cf/api/apifakes/fake_buildpack_repository.go index 305e43965bb..00152d709da 100644 --- a/cf/api/apifakes/fake_buildpack_repository.go +++ b/cf/api/apifakes/fake_buildpack_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeBuildpackRepository struct { @@ -113,15 +113,16 @@ func (fake *FakeBuildpackRepository) Create(arg1 string, arg2 *int, arg3 *bool, arg3 *bool arg4 *bool }{arg1, arg2, arg3, arg4}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3, arg4}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createReturns return fakeReturns.result1, fakeReturns.result2 } @@ -176,15 +177,16 @@ func (fake *FakeBuildpackRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -236,15 +238,16 @@ func (fake *FakeBuildpackRepository) FindByName(arg1 string) (models.Buildpack, fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -300,15 +303,16 @@ func (fake *FakeBuildpackRepository) FindByNameAndStack(arg1 string, arg2 string arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindByNameAndStackStub + fakeReturns := fake.findByNameAndStackReturns fake.recordInvocation("FindByNameAndStack", []interface{}{arg1, arg2}) fake.findByNameAndStackMutex.Unlock() - if fake.FindByNameAndStackStub != nil { - return fake.FindByNameAndStackStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameAndStackReturns return fakeReturns.result1, fakeReturns.result2 } @@ -363,15 +367,16 @@ func (fake *FakeBuildpackRepository) FindByNameWithNilStack(arg1 string) (models fake.findByNameWithNilStackArgsForCall = append(fake.findByNameWithNilStackArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameWithNilStackStub + fakeReturns := fake.findByNameWithNilStackReturns fake.recordInvocation("FindByNameWithNilStack", []interface{}{arg1}) fake.findByNameWithNilStackMutex.Unlock() - if fake.FindByNameWithNilStackStub != nil { - return fake.FindByNameWithNilStackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameWithNilStackReturns return fakeReturns.result1, fakeReturns.result2 } @@ -426,15 +431,16 @@ func (fake *FakeBuildpackRepository) ListBuildpacks(arg1 func(models.Buildpack) fake.listBuildpacksArgsForCall = append(fake.listBuildpacksArgsForCall, struct { arg1 func(models.Buildpack) bool }{arg1}) + stub := fake.ListBuildpacksStub + fakeReturns := fake.listBuildpacksReturns fake.recordInvocation("ListBuildpacks", []interface{}{arg1}) fake.listBuildpacksMutex.Unlock() - if fake.ListBuildpacksStub != nil { - return fake.ListBuildpacksStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listBuildpacksReturns return fakeReturns.result1 } @@ -486,15 +492,16 @@ func (fake *FakeBuildpackRepository) Update(arg1 models.Buildpack) (models.Build fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.Buildpack }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_client_repository.go b/cf/api/apifakes/fake_client_repository.go index f470961a958..3805c8a8f68 100644 --- a/cf/api/apifakes/fake_client_repository.go +++ b/cf/api/apifakes/fake_client_repository.go @@ -4,7 +4,7 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api" ) type FakeClientRepository struct { @@ -31,15 +31,16 @@ func (fake *FakeClientRepository) ClientExists(arg1 string) (bool, error) { fake.clientExistsArgsForCall = append(fake.clientExistsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ClientExistsStub + fakeReturns := fake.clientExistsReturns fake.recordInvocation("ClientExists", []interface{}{arg1}) fake.clientExistsMutex.Unlock() - if fake.ClientExistsStub != nil { - return fake.ClientExistsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.clientExistsReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_curl_repository.go b/cf/api/apifakes/fake_curl_repository.go index 5be62978a63..983aa4d175e 100644 --- a/cf/api/apifakes/fake_curl_repository.go +++ b/cf/api/apifakes/fake_curl_repository.go @@ -4,7 +4,7 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api" ) type FakeCurlRepository struct { @@ -41,15 +41,16 @@ func (fake *FakeCurlRepository) Request(arg1 string, arg2 string, arg3 string, a arg4 string arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.RequestStub + fakeReturns := fake.requestReturns fake.recordInvocation("Request", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.requestMutex.Unlock() - if fake.RequestStub != nil { - return fake.RequestStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.requestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/cf/api/apifakes/fake_domain_repository.go b/cf/api/apifakes/fake_domain_repository.go index d87faffe6d5..d022f2d2304 100644 --- a/cf/api/apifakes/fake_domain_repository.go +++ b/cf/api/apifakes/fake_domain_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeDomainRepository struct { @@ -134,15 +134,16 @@ func (fake *FakeDomainRepository) Create(arg1 string, arg2 string) (models.Domai arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createReturns return fakeReturns.result1, fakeReturns.result2 } @@ -198,15 +199,16 @@ func (fake *FakeDomainRepository) CreateSharedDomain(arg1 string, arg2 string) e arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateSharedDomainStub + fakeReturns := fake.createSharedDomainReturns fake.recordInvocation("CreateSharedDomain", []interface{}{arg1, arg2}) fake.createSharedDomainMutex.Unlock() - if fake.CreateSharedDomainStub != nil { - return fake.CreateSharedDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.createSharedDomainReturns return fakeReturns.result1 } @@ -258,15 +260,16 @@ func (fake *FakeDomainRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -318,15 +321,16 @@ func (fake *FakeDomainRepository) DeleteSharedDomain(arg1 string) error { fake.deleteSharedDomainArgsForCall = append(fake.deleteSharedDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteSharedDomainStub + fakeReturns := fake.deleteSharedDomainReturns fake.recordInvocation("DeleteSharedDomain", []interface{}{arg1}) fake.deleteSharedDomainMutex.Unlock() - if fake.DeleteSharedDomainStub != nil { - return fake.DeleteSharedDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteSharedDomainReturns return fakeReturns.result1 } @@ -379,15 +383,16 @@ func (fake *FakeDomainRepository) FindByNameInOrg(arg1 string, arg2 string) (mod arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindByNameInOrgStub + fakeReturns := fake.findByNameInOrgReturns fake.recordInvocation("FindByNameInOrg", []interface{}{arg1, arg2}) fake.findByNameInOrgMutex.Unlock() - if fake.FindByNameInOrgStub != nil { - return fake.FindByNameInOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameInOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -442,15 +447,16 @@ func (fake *FakeDomainRepository) FindPrivateByName(arg1 string) (models.DomainF fake.findPrivateByNameArgsForCall = append(fake.findPrivateByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindPrivateByNameStub + fakeReturns := fake.findPrivateByNameReturns fake.recordInvocation("FindPrivateByName", []interface{}{arg1}) fake.findPrivateByNameMutex.Unlock() - if fake.FindPrivateByNameStub != nil { - return fake.FindPrivateByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findPrivateByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -505,15 +511,16 @@ func (fake *FakeDomainRepository) FindSharedByName(arg1 string) (models.DomainFi fake.findSharedByNameArgsForCall = append(fake.findSharedByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindSharedByNameStub + fakeReturns := fake.findSharedByNameReturns fake.recordInvocation("FindSharedByName", []interface{}{arg1}) fake.findSharedByNameMutex.Unlock() - if fake.FindSharedByNameStub != nil { - return fake.FindSharedByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findSharedByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -569,15 +576,16 @@ func (fake *FakeDomainRepository) FirstOrDefault(arg1 string, arg2 *string) (mod arg1 string arg2 *string }{arg1, arg2}) + stub := fake.FirstOrDefaultStub + fakeReturns := fake.firstOrDefaultReturns fake.recordInvocation("FirstOrDefault", []interface{}{arg1, arg2}) fake.firstOrDefaultMutex.Unlock() - if fake.FirstOrDefaultStub != nil { - return fake.FirstOrDefaultStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.firstOrDefaultReturns return fakeReturns.result1, fakeReturns.result2 } @@ -633,15 +641,16 @@ func (fake *FakeDomainRepository) ListDomainsForOrg(arg1 string, arg2 func(model arg1 string arg2 func(models.DomainFields) bool }{arg1, arg2}) + stub := fake.ListDomainsForOrgStub + fakeReturns := fake.listDomainsForOrgReturns fake.recordInvocation("ListDomainsForOrg", []interface{}{arg1, arg2}) fake.listDomainsForOrgMutex.Unlock() - if fake.ListDomainsForOrgStub != nil { - return fake.ListDomainsForOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.listDomainsForOrgReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_route_repository.go b/cf/api/apifakes/fake_route_repository.go index 1400d7ee04a..e4a30c3d908 100644 --- a/cf/api/apifakes/fake_route_repository.go +++ b/cf/api/apifakes/fake_route_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRouteRepository struct { @@ -143,15 +143,16 @@ func (fake *FakeRouteRepository) Bind(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.BindStub + fakeReturns := fake.bindReturns fake.recordInvocation("Bind", []interface{}{arg1, arg2}) fake.bindMutex.Unlock() - if fake.BindStub != nil { - return fake.BindStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindReturns return fakeReturns.result1 } @@ -205,15 +206,16 @@ func (fake *FakeRouteRepository) CheckIfExists(arg1 string, arg2 models.DomainFi arg2 models.DomainFields arg3 string }{arg1, arg2, arg3}) + stub := fake.CheckIfExistsStub + fakeReturns := fake.checkIfExistsReturns fake.recordInvocation("CheckIfExists", []interface{}{arg1, arg2, arg3}) fake.checkIfExistsMutex.Unlock() - if fake.CheckIfExistsStub != nil { - return fake.CheckIfExistsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.checkIfExistsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -272,15 +274,16 @@ func (fake *FakeRouteRepository) Create(arg1 string, arg2 models.DomainFields, a arg4 int arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createReturns return fakeReturns.result1, fakeReturns.result2 } @@ -340,15 +343,16 @@ func (fake *FakeRouteRepository) CreateInSpace(arg1 string, arg2 string, arg3 st arg5 int arg6 bool }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.CreateInSpaceStub + fakeReturns := fake.createInSpaceReturns fake.recordInvocation("CreateInSpace", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.createInSpaceMutex.Unlock() - if fake.CreateInSpaceStub != nil { - return fake.CreateInSpaceStub(arg1, arg2, arg3, arg4, arg5, arg6) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createInSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -403,15 +407,16 @@ func (fake *FakeRouteRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -466,15 +471,16 @@ func (fake *FakeRouteRepository) Find(arg1 string, arg2 models.DomainFields, arg arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.FindStub + fakeReturns := fake.findReturns fake.recordInvocation("Find", []interface{}{arg1, arg2, arg3, arg4}) fake.findMutex.Unlock() - if fake.FindStub != nil { - return fake.FindStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findReturns return fakeReturns.result1, fakeReturns.result2 } @@ -529,15 +535,16 @@ func (fake *FakeRouteRepository) ListAllRoutes(arg1 func(models.Route) bool) err fake.listAllRoutesArgsForCall = append(fake.listAllRoutesArgsForCall, struct { arg1 func(models.Route) bool }{arg1}) + stub := fake.ListAllRoutesStub + fakeReturns := fake.listAllRoutesReturns fake.recordInvocation("ListAllRoutes", []interface{}{arg1}) fake.listAllRoutesMutex.Unlock() - if fake.ListAllRoutesStub != nil { - return fake.ListAllRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listAllRoutesReturns return fakeReturns.result1 } @@ -589,15 +596,16 @@ func (fake *FakeRouteRepository) ListRoutes(arg1 func(models.Route) bool) error fake.listRoutesArgsForCall = append(fake.listRoutesArgsForCall, struct { arg1 func(models.Route) bool }{arg1}) + stub := fake.ListRoutesStub + fakeReturns := fake.listRoutesReturns fake.recordInvocation("ListRoutes", []interface{}{arg1}) fake.listRoutesMutex.Unlock() - if fake.ListRoutesStub != nil { - return fake.ListRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listRoutesReturns return fakeReturns.result1 } @@ -650,15 +658,16 @@ func (fake *FakeRouteRepository) Unbind(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnbindStub + fakeReturns := fake.unbindReturns fake.recordInvocation("Unbind", []interface{}{arg1, arg2}) fake.unbindMutex.Unlock() - if fake.UnbindStub != nil { - return fake.UnbindStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_route_service_binding_repository.go b/cf/api/apifakes/fake_route_service_binding_repository.go index 2c93527c84a..1ca204faea2 100644 --- a/cf/api/apifakes/fake_route_service_binding_repository.go +++ b/cf/api/apifakes/fake_route_service_binding_repository.go @@ -4,7 +4,7 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api" ) type FakeRouteServiceBindingRepository struct { @@ -48,15 +48,16 @@ func (fake *FakeRouteServiceBindingRepository) Bind(arg1 string, arg2 string, ar arg3 bool arg4 string }{arg1, arg2, arg3, arg4}) + stub := fake.BindStub + fakeReturns := fake.bindReturns fake.recordInvocation("Bind", []interface{}{arg1, arg2, arg3, arg4}) fake.bindMutex.Unlock() - if fake.BindStub != nil { - return fake.BindStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindReturns return fakeReturns.result1 } @@ -110,15 +111,16 @@ func (fake *FakeRouteServiceBindingRepository) Unbind(arg1 string, arg2 string, arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.UnbindStub + fakeReturns := fake.unbindReturns fake.recordInvocation("Unbind", []interface{}{arg1, arg2, arg3}) fake.unbindMutex.Unlock() - if fake.UnbindStub != nil { - return fake.UnbindStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_routing_apirepository.go b/cf/api/apifakes/fake_routing_apirepository.go index e821850e54c..513dd5e9488 100644 --- a/cf/api/apifakes/fake_routing_apirepository.go +++ b/cf/api/apifakes/fake_routing_apirepository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRoutingAPIRepository struct { @@ -30,15 +30,16 @@ func (fake *FakeRoutingAPIRepository) ListRouterGroups(arg1 func(models.RouterGr fake.listRouterGroupsArgsForCall = append(fake.listRouterGroupsArgsForCall, struct { arg1 func(models.RouterGroup) bool }{arg1}) + stub := fake.ListRouterGroupsStub + fakeReturns := fake.listRouterGroupsReturns fake.recordInvocation("ListRouterGroups", []interface{}{arg1}) fake.listRouterGroupsMutex.Unlock() - if fake.ListRouterGroupsStub != nil { - return fake.ListRouterGroupsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listRouterGroupsReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_service_auth_token_repository.go b/cf/api/apifakes/fake_service_auth_token_repository.go index d68f7817ff0..aa44e75c5d7 100644 --- a/cf/api/apifakes/fake_service_auth_token_repository.go +++ b/cf/api/apifakes/fake_service_auth_token_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceAuthTokenRepository struct { @@ -78,15 +78,16 @@ func (fake *FakeServiceAuthTokenRepository) Create(arg1 models.ServiceAuthTokenF fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 models.ServiceAuthTokenFields }{arg1}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -138,15 +139,16 @@ func (fake *FakeServiceAuthTokenRepository) Delete(arg1 models.ServiceAuthTokenF fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 models.ServiceAuthTokenFields }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -197,15 +199,16 @@ func (fake *FakeServiceAuthTokenRepository) FindAll() ([]models.ServiceAuthToken ret, specificReturn := fake.findAllReturnsOnCall[len(fake.findAllArgsForCall)] fake.findAllArgsForCall = append(fake.findAllArgsForCall, struct { }{}) + stub := fake.FindAllStub + fakeReturns := fake.findAllReturns fake.recordInvocation("FindAll", []interface{}{}) fake.findAllMutex.Unlock() - if fake.FindAllStub != nil { - return fake.FindAllStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findAllReturns return fakeReturns.result1, fakeReturns.result2 } @@ -254,15 +257,16 @@ func (fake *FakeServiceAuthTokenRepository) FindByLabelAndProvider(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindByLabelAndProviderStub + fakeReturns := fake.findByLabelAndProviderReturns fake.recordInvocation("FindByLabelAndProvider", []interface{}{arg1, arg2}) fake.findByLabelAndProviderMutex.Unlock() - if fake.FindByLabelAndProviderStub != nil { - return fake.FindByLabelAndProviderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByLabelAndProviderReturns return fakeReturns.result1, fakeReturns.result2 } @@ -317,15 +321,16 @@ func (fake *FakeServiceAuthTokenRepository) Update(arg1 models.ServiceAuthTokenF fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.ServiceAuthTokenFields }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_service_binding_repository.go b/cf/api/apifakes/fake_service_binding_repository.go index 265da6a06a8..3d0fb7cbb29 100644 --- a/cf/api/apifakes/fake_service_binding_repository.go +++ b/cf/api/apifakes/fake_service_binding_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceBindingRepository struct { @@ -61,15 +61,16 @@ func (fake *FakeServiceBindingRepository) Create(arg1 string, arg2 string, arg3 arg2 string arg3 map[string]interface{} }{arg1, arg2, arg3}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -122,15 +123,16 @@ func (fake *FakeServiceBindingRepository) Delete(arg1 models.ServiceInstance, ar arg1 models.ServiceInstance arg2 string }{arg1, arg2}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1, arg2}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -185,15 +187,16 @@ func (fake *FakeServiceBindingRepository) ListAllForService(arg1 string) ([]mode fake.listAllForServiceArgsForCall = append(fake.listAllForServiceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ListAllForServiceStub + fakeReturns := fake.listAllForServiceReturns fake.recordInvocation("ListAllForService", []interface{}{arg1}) fake.listAllForServiceMutex.Unlock() - if fake.ListAllForServiceStub != nil { - return fake.ListAllForServiceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listAllForServiceReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_service_broker_repository.go b/cf/api/apifakes/fake_service_broker_repository.go index 90f1206df36..4c334680d9c 100644 --- a/cf/api/apifakes/fake_service_broker_repository.go +++ b/cf/api/apifakes/fake_service_broker_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceBrokerRepository struct { @@ -109,15 +109,16 @@ func (fake *FakeServiceBrokerRepository) Create(arg1 string, arg2 string, arg3 s arg4 string arg5 string }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -169,15 +170,16 @@ func (fake *FakeServiceBrokerRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -229,15 +231,16 @@ func (fake *FakeServiceBrokerRepository) FindByGUID(arg1 string) (models.Service fake.findByGUIDArgsForCall = append(fake.findByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByGUIDStub + fakeReturns := fake.findByGUIDReturns fake.recordInvocation("FindByGUID", []interface{}{arg1}) fake.findByGUIDMutex.Unlock() - if fake.FindByGUIDStub != nil { - return fake.FindByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -292,15 +295,16 @@ func (fake *FakeServiceBrokerRepository) FindByName(arg1 string) (models.Service fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -355,15 +359,16 @@ func (fake *FakeServiceBrokerRepository) ListServiceBrokers(arg1 func(models.Ser fake.listServiceBrokersArgsForCall = append(fake.listServiceBrokersArgsForCall, struct { arg1 func(models.ServiceBroker) bool }{arg1}) + stub := fake.ListServiceBrokersStub + fakeReturns := fake.listServiceBrokersReturns fake.recordInvocation("ListServiceBrokers", []interface{}{arg1}) fake.listServiceBrokersMutex.Unlock() - if fake.ListServiceBrokersStub != nil { - return fake.ListServiceBrokersStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listServiceBrokersReturns return fakeReturns.result1 } @@ -416,15 +421,16 @@ func (fake *FakeServiceBrokerRepository) Rename(arg1 string, arg2 string) error arg1 string arg2 string }{arg1, arg2}) + stub := fake.RenameStub + fakeReturns := fake.renameReturns fake.recordInvocation("Rename", []interface{}{arg1, arg2}) fake.renameMutex.Unlock() - if fake.RenameStub != nil { - return fake.RenameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.renameReturns return fakeReturns.result1 } @@ -476,15 +482,16 @@ func (fake *FakeServiceBrokerRepository) Update(arg1 models.ServiceBroker) error fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.ServiceBroker }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_service_key_repository.go b/cf/api/apifakes/fake_service_key_repository.go index d919c306d8a..d35406d274c 100644 --- a/cf/api/apifakes/fake_service_key_repository.go +++ b/cf/api/apifakes/fake_service_key_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceKeyRepository struct { @@ -72,15 +72,16 @@ func (fake *FakeServiceKeyRepository) CreateServiceKey(arg1 string, arg2 string, arg2 string arg3 map[string]interface{} }{arg1, arg2, arg3}) + stub := fake.CreateServiceKeyStub + fakeReturns := fake.createServiceKeyReturns fake.recordInvocation("CreateServiceKey", []interface{}{arg1, arg2, arg3}) fake.createServiceKeyMutex.Unlock() - if fake.CreateServiceKeyStub != nil { - return fake.CreateServiceKeyStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.createServiceKeyReturns return fakeReturns.result1 } @@ -132,15 +133,16 @@ func (fake *FakeServiceKeyRepository) DeleteServiceKey(arg1 string) error { fake.deleteServiceKeyArgsForCall = append(fake.deleteServiceKeyArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteServiceKeyStub + fakeReturns := fake.deleteServiceKeyReturns fake.recordInvocation("DeleteServiceKey", []interface{}{arg1}) fake.deleteServiceKeyMutex.Unlock() - if fake.DeleteServiceKeyStub != nil { - return fake.DeleteServiceKeyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteServiceKeyReturns return fakeReturns.result1 } @@ -193,15 +195,16 @@ func (fake *FakeServiceKeyRepository) GetServiceKey(arg1 string, arg2 string) (m arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceKeyStub + fakeReturns := fake.getServiceKeyReturns fake.recordInvocation("GetServiceKey", []interface{}{arg1, arg2}) fake.getServiceKeyMutex.Unlock() - if fake.GetServiceKeyStub != nil { - return fake.GetServiceKeyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceKeyReturns return fakeReturns.result1, fakeReturns.result2 } @@ -256,15 +259,16 @@ func (fake *FakeServiceKeyRepository) ListServiceKeys(arg1 string) ([]models.Ser fake.listServiceKeysArgsForCall = append(fake.listServiceKeysArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ListServiceKeysStub + fakeReturns := fake.listServiceKeysReturns fake.recordInvocation("ListServiceKeys", []interface{}{arg1}) fake.listServiceKeysMutex.Unlock() - if fake.ListServiceKeysStub != nil { - return fake.ListServiceKeysStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listServiceKeysReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_service_plan_repository.go b/cf/api/apifakes/fake_service_plan_repository.go index e650477f616..0f8d549e193 100644 --- a/cf/api/apifakes/fake_service_plan_repository.go +++ b/cf/api/apifakes/fake_service_plan_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServicePlanRepository struct { @@ -63,15 +63,16 @@ func (fake *FakeServicePlanRepository) ListPlansFromManyServices(arg1 []string) fake.listPlansFromManyServicesArgsForCall = append(fake.listPlansFromManyServicesArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.ListPlansFromManyServicesStub + fakeReturns := fake.listPlansFromManyServicesReturns fake.recordInvocation("ListPlansFromManyServices", []interface{}{arg1Copy}) fake.listPlansFromManyServicesMutex.Unlock() - if fake.ListPlansFromManyServicesStub != nil { - return fake.ListPlansFromManyServicesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listPlansFromManyServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -126,15 +127,16 @@ func (fake *FakeServicePlanRepository) Search(arg1 map[string]string) ([]models. fake.searchArgsForCall = append(fake.searchArgsForCall, struct { arg1 map[string]string }{arg1}) + stub := fake.SearchStub + fakeReturns := fake.searchReturns fake.recordInvocation("Search", []interface{}{arg1}) fake.searchMutex.Unlock() - if fake.SearchStub != nil { - return fake.SearchStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.searchReturns return fakeReturns.result1, fakeReturns.result2 } @@ -191,15 +193,16 @@ func (fake *FakeServicePlanRepository) Update(arg1 models.ServicePlanFields, arg arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1, arg2, arg3}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_service_plan_visibility_repository.go b/cf/api/apifakes/fake_service_plan_visibility_repository.go index dcf0e32cba8..75f4450775f 100644 --- a/cf/api/apifakes/fake_service_plan_visibility_repository.go +++ b/cf/api/apifakes/fake_service_plan_visibility_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServicePlanVisibilityRepository struct { @@ -68,15 +68,16 @@ func (fake *FakeServicePlanVisibilityRepository) Create(arg1 string, arg2 string arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -128,15 +129,16 @@ func (fake *FakeServicePlanVisibilityRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -187,15 +189,16 @@ func (fake *FakeServicePlanVisibilityRepository) List() ([]models.ServicePlanVis ret, specificReturn := fake.listReturnsOnCall[len(fake.listArgsForCall)] fake.listArgsForCall = append(fake.listArgsForCall, struct { }{}) + stub := fake.ListStub + fakeReturns := fake.listReturns fake.recordInvocation("List", []interface{}{}) fake.listMutex.Unlock() - if fake.ListStub != nil { - return fake.ListStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listReturns return fakeReturns.result1, fakeReturns.result2 } @@ -243,15 +246,16 @@ func (fake *FakeServicePlanVisibilityRepository) Search(arg1 map[string]string) fake.searchArgsForCall = append(fake.searchArgsForCall, struct { arg1 map[string]string }{arg1}) + stub := fake.SearchStub + fakeReturns := fake.searchReturns fake.recordInvocation("Search", []interface{}{arg1}) fake.searchMutex.Unlock() - if fake.SearchStub != nil { - return fake.SearchStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.searchReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_service_repository.go b/cf/api/apifakes/fake_service_repository.go index 752834cfad2..29258d23eb5 100644 --- a/cf/api/apifakes/fake_service_repository.go +++ b/cf/api/apifakes/fake_service_repository.go @@ -4,9 +4,9 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceRepository struct { @@ -259,15 +259,16 @@ func (fake *FakeServiceRepository) CreateServiceInstance(arg1 string, arg2 strin arg3 map[string]interface{} arg4 []string }{arg1, arg2, arg3, arg4Copy}) + stub := fake.CreateServiceInstanceStub + fakeReturns := fake.createServiceInstanceReturns fake.recordInvocation("CreateServiceInstance", []interface{}{arg1, arg2, arg3, arg4Copy}) fake.createServiceInstanceMutex.Unlock() - if fake.CreateServiceInstanceStub != nil { - return fake.CreateServiceInstanceStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.createServiceInstanceReturns return fakeReturns.result1 } @@ -319,15 +320,16 @@ func (fake *FakeServiceRepository) DeleteService(arg1 models.ServiceInstance) er fake.deleteServiceArgsForCall = append(fake.deleteServiceArgsForCall, struct { arg1 models.ServiceInstance }{arg1}) + stub := fake.DeleteServiceStub + fakeReturns := fake.deleteServiceReturns fake.recordInvocation("DeleteService", []interface{}{arg1}) fake.deleteServiceMutex.Unlock() - if fake.DeleteServiceStub != nil { - return fake.DeleteServiceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteServiceReturns return fakeReturns.result1 } @@ -379,15 +381,16 @@ func (fake *FakeServiceRepository) FindInstanceByName(arg1 string) (models.Servi fake.findInstanceByNameArgsForCall = append(fake.findInstanceByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindInstanceByNameStub + fakeReturns := fake.findInstanceByNameReturns fake.recordInvocation("FindInstanceByName", []interface{}{arg1}) fake.findInstanceByNameMutex.Unlock() - if fake.FindInstanceByNameStub != nil { - return fake.FindInstanceByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findInstanceByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -443,15 +446,16 @@ func (fake *FakeServiceRepository) FindServiceOfferingByLabelAndProvider(arg1 st arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindServiceOfferingByLabelAndProviderStub + fakeReturns := fake.findServiceOfferingByLabelAndProviderReturns fake.recordInvocation("FindServiceOfferingByLabelAndProvider", []interface{}{arg1, arg2}) fake.findServiceOfferingByLabelAndProviderMutex.Unlock() - if fake.FindServiceOfferingByLabelAndProviderStub != nil { - return fake.FindServiceOfferingByLabelAndProviderStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findServiceOfferingByLabelAndProviderReturns return fakeReturns.result1, fakeReturns.result2 } @@ -506,15 +510,16 @@ func (fake *FakeServiceRepository) FindServiceOfferingsByLabel(arg1 string) (mod fake.findServiceOfferingsByLabelArgsForCall = append(fake.findServiceOfferingsByLabelArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindServiceOfferingsByLabelStub + fakeReturns := fake.findServiceOfferingsByLabelReturns fake.recordInvocation("FindServiceOfferingsByLabel", []interface{}{arg1}) fake.findServiceOfferingsByLabelMutex.Unlock() - if fake.FindServiceOfferingsByLabelStub != nil { - return fake.FindServiceOfferingsByLabelStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findServiceOfferingsByLabelReturns return fakeReturns.result1, fakeReturns.result2 } @@ -570,15 +575,16 @@ func (fake *FakeServiceRepository) FindServiceOfferingsForSpaceByLabel(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindServiceOfferingsForSpaceByLabelStub + fakeReturns := fake.findServiceOfferingsForSpaceByLabelReturns fake.recordInvocation("FindServiceOfferingsForSpaceByLabel", []interface{}{arg1, arg2}) fake.findServiceOfferingsForSpaceByLabelMutex.Unlock() - if fake.FindServiceOfferingsForSpaceByLabelStub != nil { - return fake.FindServiceOfferingsForSpaceByLabelStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findServiceOfferingsForSpaceByLabelReturns return fakeReturns.result1, fakeReturns.result2 } @@ -633,15 +639,16 @@ func (fake *FakeServiceRepository) FindServicePlanByDescription(arg1 resources.S fake.findServicePlanByDescriptionArgsForCall = append(fake.findServicePlanByDescriptionArgsForCall, struct { arg1 resources.ServicePlanDescription }{arg1}) + stub := fake.FindServicePlanByDescriptionStub + fakeReturns := fake.findServicePlanByDescriptionReturns fake.recordInvocation("FindServicePlanByDescription", []interface{}{arg1}) fake.findServicePlanByDescriptionMutex.Unlock() - if fake.FindServicePlanByDescriptionStub != nil { - return fake.FindServicePlanByDescriptionStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findServicePlanByDescriptionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -695,15 +702,16 @@ func (fake *FakeServiceRepository) GetAllServiceOfferings() (models.ServiceOffer ret, specificReturn := fake.getAllServiceOfferingsReturnsOnCall[len(fake.getAllServiceOfferingsArgsForCall)] fake.getAllServiceOfferingsArgsForCall = append(fake.getAllServiceOfferingsArgsForCall, struct { }{}) + stub := fake.GetAllServiceOfferingsStub + fakeReturns := fake.getAllServiceOfferingsReturns fake.recordInvocation("GetAllServiceOfferings", []interface{}{}) fake.getAllServiceOfferingsMutex.Unlock() - if fake.GetAllServiceOfferingsStub != nil { - return fake.GetAllServiceOfferingsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAllServiceOfferingsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -751,15 +759,16 @@ func (fake *FakeServiceRepository) GetServiceInstanceCountForServicePlan(arg1 st fake.getServiceInstanceCountForServicePlanArgsForCall = append(fake.getServiceInstanceCountForServicePlanArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceInstanceCountForServicePlanStub + fakeReturns := fake.getServiceInstanceCountForServicePlanReturns fake.recordInvocation("GetServiceInstanceCountForServicePlan", []interface{}{arg1}) fake.getServiceInstanceCountForServicePlanMutex.Unlock() - if fake.GetServiceInstanceCountForServicePlanStub != nil { - return fake.GetServiceInstanceCountForServicePlanStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceInstanceCountForServicePlanReturns return fakeReturns.result1, fakeReturns.result2 } @@ -814,15 +823,16 @@ func (fake *FakeServiceRepository) GetServiceOfferingByGUID(arg1 string) (models fake.getServiceOfferingByGUIDArgsForCall = append(fake.getServiceOfferingByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceOfferingByGUIDStub + fakeReturns := fake.getServiceOfferingByGUIDReturns fake.recordInvocation("GetServiceOfferingByGUID", []interface{}{arg1}) fake.getServiceOfferingByGUIDMutex.Unlock() - if fake.GetServiceOfferingByGUIDStub != nil { - return fake.GetServiceOfferingByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceOfferingByGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -877,15 +887,16 @@ func (fake *FakeServiceRepository) GetServiceOfferingsForSpace(arg1 string) (mod fake.getServiceOfferingsForSpaceArgsForCall = append(fake.getServiceOfferingsForSpaceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceOfferingsForSpaceStub + fakeReturns := fake.getServiceOfferingsForSpaceReturns fake.recordInvocation("GetServiceOfferingsForSpace", []interface{}{arg1}) fake.getServiceOfferingsForSpaceMutex.Unlock() - if fake.GetServiceOfferingsForSpaceStub != nil { - return fake.GetServiceOfferingsForSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceOfferingsForSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -940,15 +951,16 @@ func (fake *FakeServiceRepository) ListServicesFromBroker(arg1 string) ([]models fake.listServicesFromBrokerArgsForCall = append(fake.listServicesFromBrokerArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ListServicesFromBrokerStub + fakeReturns := fake.listServicesFromBrokerReturns fake.recordInvocation("ListServicesFromBroker", []interface{}{arg1}) fake.listServicesFromBrokerMutex.Unlock() - if fake.ListServicesFromBrokerStub != nil { - return fake.ListServicesFromBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listServicesFromBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1008,15 +1020,16 @@ func (fake *FakeServiceRepository) ListServicesFromManyBrokers(arg1 []string) ([ fake.listServicesFromManyBrokersArgsForCall = append(fake.listServicesFromManyBrokersArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.ListServicesFromManyBrokersStub + fakeReturns := fake.listServicesFromManyBrokersReturns fake.recordInvocation("ListServicesFromManyBrokers", []interface{}{arg1Copy}) fake.listServicesFromManyBrokersMutex.Unlock() - if fake.ListServicesFromManyBrokersStub != nil { - return fake.ListServicesFromManyBrokersStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listServicesFromManyBrokersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1072,15 +1085,16 @@ func (fake *FakeServiceRepository) MigrateServicePlanFromV1ToV2(arg1 string, arg arg1 string arg2 string }{arg1, arg2}) + stub := fake.MigrateServicePlanFromV1ToV2Stub + fakeReturns := fake.migrateServicePlanFromV1ToV2Returns fake.recordInvocation("MigrateServicePlanFromV1ToV2", []interface{}{arg1, arg2}) fake.migrateServicePlanFromV1ToV2Mutex.Unlock() - if fake.MigrateServicePlanFromV1ToV2Stub != nil { - return fake.MigrateServicePlanFromV1ToV2Stub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.migrateServicePlanFromV1ToV2Returns return fakeReturns.result1, fakeReturns.result2 } @@ -1135,15 +1149,16 @@ func (fake *FakeServiceRepository) PurgeServiceInstance(arg1 models.ServiceInsta fake.purgeServiceInstanceArgsForCall = append(fake.purgeServiceInstanceArgsForCall, struct { arg1 models.ServiceInstance }{arg1}) + stub := fake.PurgeServiceInstanceStub + fakeReturns := fake.purgeServiceInstanceReturns fake.recordInvocation("PurgeServiceInstance", []interface{}{arg1}) fake.purgeServiceInstanceMutex.Unlock() - if fake.PurgeServiceInstanceStub != nil { - return fake.PurgeServiceInstanceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.purgeServiceInstanceReturns return fakeReturns.result1 } @@ -1195,15 +1210,16 @@ func (fake *FakeServiceRepository) PurgeServiceOffering(arg1 models.ServiceOffer fake.purgeServiceOfferingArgsForCall = append(fake.purgeServiceOfferingArgsForCall, struct { arg1 models.ServiceOffering }{arg1}) + stub := fake.PurgeServiceOfferingStub + fakeReturns := fake.purgeServiceOfferingReturns fake.recordInvocation("PurgeServiceOffering", []interface{}{arg1}) fake.purgeServiceOfferingMutex.Unlock() - if fake.PurgeServiceOfferingStub != nil { - return fake.PurgeServiceOfferingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.purgeServiceOfferingReturns return fakeReturns.result1 } @@ -1256,15 +1272,16 @@ func (fake *FakeServiceRepository) RenameService(arg1 models.ServiceInstance, ar arg1 models.ServiceInstance arg2 string }{arg1, arg2}) + stub := fake.RenameServiceStub + fakeReturns := fake.renameServiceReturns fake.recordInvocation("RenameService", []interface{}{arg1, arg2}) fake.renameServiceMutex.Unlock() - if fake.RenameServiceStub != nil { - return fake.RenameServiceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.renameServiceReturns return fakeReturns.result1 } @@ -1319,15 +1336,16 @@ func (fake *FakeServiceRepository) UpdateServiceInstance(arg1 string, arg2 strin arg3 map[string]interface{} arg4 *[]string }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateServiceInstanceStub + fakeReturns := fake.updateServiceInstanceReturns fake.recordInvocation("UpdateServiceInstance", []interface{}{arg1, arg2, arg3, arg4}) fake.updateServiceInstanceMutex.Unlock() - if fake.UpdateServiceInstanceStub != nil { - return fake.UpdateServiceInstanceStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateServiceInstanceReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_service_summary_repository.go b/cf/api/apifakes/fake_service_summary_repository.go index f2ca2905245..74801440ace 100644 --- a/cf/api/apifakes/fake_service_summary_repository.go +++ b/cf/api/apifakes/fake_service_summary_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeServiceSummaryRepository struct { @@ -30,15 +30,16 @@ func (fake *FakeServiceSummaryRepository) GetSummariesInCurrentSpace() ([]models ret, specificReturn := fake.getSummariesInCurrentSpaceReturnsOnCall[len(fake.getSummariesInCurrentSpaceArgsForCall)] fake.getSummariesInCurrentSpaceArgsForCall = append(fake.getSummariesInCurrentSpaceArgsForCall, struct { }{}) + stub := fake.GetSummariesInCurrentSpaceStub + fakeReturns := fake.getSummariesInCurrentSpaceReturns fake.recordInvocation("GetSummariesInCurrentSpace", []interface{}{}) fake.getSummariesInCurrentSpaceMutex.Unlock() - if fake.GetSummariesInCurrentSpaceStub != nil { - return fake.GetSummariesInCurrentSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSummariesInCurrentSpaceReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/apifakes/fake_user_provided_service_instance_repository.go b/cf/api/apifakes/fake_user_provided_service_instance_repository.go index 175e18d2bfc..a1ca45c678b 100644 --- a/cf/api/apifakes/fake_user_provided_service_instance_repository.go +++ b/cf/api/apifakes/fake_user_provided_service_instance_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeUserProvidedServiceInstanceRepository struct { @@ -66,15 +66,16 @@ func (fake *FakeUserProvidedServiceInstanceRepository) Create(arg1 string, arg2 arg4 map[string]interface{} arg5 []string }{arg1, arg2, arg3, arg4, arg5Copy}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3, arg4, arg5Copy}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -125,15 +126,16 @@ func (fake *FakeUserProvidedServiceInstanceRepository) GetSummaries() (models.Us ret, specificReturn := fake.getSummariesReturnsOnCall[len(fake.getSummariesArgsForCall)] fake.getSummariesArgsForCall = append(fake.getSummariesArgsForCall, struct { }{}) + stub := fake.GetSummariesStub + fakeReturns := fake.getSummariesReturns fake.recordInvocation("GetSummaries", []interface{}{}) fake.getSummariesMutex.Unlock() - if fake.GetSummariesStub != nil { - return fake.GetSummariesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSummariesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -181,15 +183,16 @@ func (fake *FakeUserProvidedServiceInstanceRepository) Update(arg1 models.Servic fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.ServiceInstanceFields }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/fake_user_repository.go b/cf/api/apifakes/fake_user_repository.go index 04fa96b9652..efd72173ac3 100644 --- a/cf/api/apifakes/fake_user_repository.go +++ b/cf/api/apifakes/fake_user_repository.go @@ -4,8 +4,8 @@ package apifakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeUserRepository struct { @@ -203,15 +203,16 @@ func (fake *FakeUserRepository) Create(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -263,15 +264,16 @@ func (fake *FakeUserRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -323,15 +325,16 @@ func (fake *FakeUserRepository) FindAllByUsername(arg1 string) ([]models.UserFie fake.findAllByUsernameArgsForCall = append(fake.findAllByUsernameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindAllByUsernameStub + fakeReturns := fake.findAllByUsernameReturns fake.recordInvocation("FindAllByUsername", []interface{}{arg1}) fake.findAllByUsernameMutex.Unlock() - if fake.FindAllByUsernameStub != nil { - return fake.FindAllByUsernameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findAllByUsernameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -386,15 +389,16 @@ func (fake *FakeUserRepository) FindByUsername(arg1 string) (models.UserFields, fake.findByUsernameArgsForCall = append(fake.findByUsernameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByUsernameStub + fakeReturns := fake.findByUsernameReturns fake.recordInvocation("FindByUsername", []interface{}{arg1}) fake.findByUsernameMutex.Unlock() - if fake.FindByUsernameStub != nil { - return fake.FindByUsernameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByUsernameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -450,15 +454,16 @@ func (fake *FakeUserRepository) ListUsersInOrgForRoleWithNoUAA(arg1 string, arg2 arg1 string arg2 models.Role }{arg1, arg2}) + stub := fake.ListUsersInOrgForRoleWithNoUAAStub + fakeReturns := fake.listUsersInOrgForRoleWithNoUAAReturns fake.recordInvocation("ListUsersInOrgForRoleWithNoUAA", []interface{}{arg1, arg2}) fake.listUsersInOrgForRoleWithNoUAAMutex.Unlock() - if fake.ListUsersInOrgForRoleWithNoUAAStub != nil { - return fake.ListUsersInOrgForRoleWithNoUAAStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listUsersInOrgForRoleWithNoUAAReturns return fakeReturns.result1, fakeReturns.result2 } @@ -514,15 +519,16 @@ func (fake *FakeUserRepository) ListUsersInSpaceForRoleWithNoUAA(arg1 string, ar arg1 string arg2 models.Role }{arg1, arg2}) + stub := fake.ListUsersInSpaceForRoleWithNoUAAStub + fakeReturns := fake.listUsersInSpaceForRoleWithNoUAAReturns fake.recordInvocation("ListUsersInSpaceForRoleWithNoUAA", []interface{}{arg1, arg2}) fake.listUsersInSpaceForRoleWithNoUAAMutex.Unlock() - if fake.ListUsersInSpaceForRoleWithNoUAAStub != nil { - return fake.ListUsersInSpaceForRoleWithNoUAAStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listUsersInSpaceForRoleWithNoUAAReturns return fakeReturns.result1, fakeReturns.result2 } @@ -579,15 +585,16 @@ func (fake *FakeUserRepository) SetOrgRoleByGUID(arg1 string, arg2 string, arg3 arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.SetOrgRoleByGUIDStub + fakeReturns := fake.setOrgRoleByGUIDReturns fake.recordInvocation("SetOrgRoleByGUID", []interface{}{arg1, arg2, arg3}) fake.setOrgRoleByGUIDMutex.Unlock() - if fake.SetOrgRoleByGUIDStub != nil { - return fake.SetOrgRoleByGUIDStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.setOrgRoleByGUIDReturns return fakeReturns.result1 } @@ -641,15 +648,16 @@ func (fake *FakeUserRepository) SetOrgRoleByUsername(arg1 string, arg2 string, a arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.SetOrgRoleByUsernameStub + fakeReturns := fake.setOrgRoleByUsernameReturns fake.recordInvocation("SetOrgRoleByUsername", []interface{}{arg1, arg2, arg3}) fake.setOrgRoleByUsernameMutex.Unlock() - if fake.SetOrgRoleByUsernameStub != nil { - return fake.SetOrgRoleByUsernameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.setOrgRoleByUsernameReturns return fakeReturns.result1 } @@ -704,15 +712,16 @@ func (fake *FakeUserRepository) SetSpaceRoleByGUID(arg1 string, arg2 string, arg arg3 string arg4 models.Role }{arg1, arg2, arg3, arg4}) + stub := fake.SetSpaceRoleByGUIDStub + fakeReturns := fake.setSpaceRoleByGUIDReturns fake.recordInvocation("SetSpaceRoleByGUID", []interface{}{arg1, arg2, arg3, arg4}) fake.setSpaceRoleByGUIDMutex.Unlock() - if fake.SetSpaceRoleByGUIDStub != nil { - return fake.SetSpaceRoleByGUIDStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.setSpaceRoleByGUIDReturns return fakeReturns.result1 } @@ -767,15 +776,16 @@ func (fake *FakeUserRepository) SetSpaceRoleByUsername(arg1 string, arg2 string, arg3 string arg4 models.Role }{arg1, arg2, arg3, arg4}) + stub := fake.SetSpaceRoleByUsernameStub + fakeReturns := fake.setSpaceRoleByUsernameReturns fake.recordInvocation("SetSpaceRoleByUsername", []interface{}{arg1, arg2, arg3, arg4}) fake.setSpaceRoleByUsernameMutex.Unlock() - if fake.SetSpaceRoleByUsernameStub != nil { - return fake.SetSpaceRoleByUsernameStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.setSpaceRoleByUsernameReturns return fakeReturns.result1 } @@ -829,15 +839,16 @@ func (fake *FakeUserRepository) UnsetOrgRoleByGUID(arg1 string, arg2 string, arg arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.UnsetOrgRoleByGUIDStub + fakeReturns := fake.unsetOrgRoleByGUIDReturns fake.recordInvocation("UnsetOrgRoleByGUID", []interface{}{arg1, arg2, arg3}) fake.unsetOrgRoleByGUIDMutex.Unlock() - if fake.UnsetOrgRoleByGUIDStub != nil { - return fake.UnsetOrgRoleByGUIDStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.unsetOrgRoleByGUIDReturns return fakeReturns.result1 } @@ -891,15 +902,16 @@ func (fake *FakeUserRepository) UnsetOrgRoleByUsername(arg1 string, arg2 string, arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.UnsetOrgRoleByUsernameStub + fakeReturns := fake.unsetOrgRoleByUsernameReturns fake.recordInvocation("UnsetOrgRoleByUsername", []interface{}{arg1, arg2, arg3}) fake.unsetOrgRoleByUsernameMutex.Unlock() - if fake.UnsetOrgRoleByUsernameStub != nil { - return fake.UnsetOrgRoleByUsernameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.unsetOrgRoleByUsernameReturns return fakeReturns.result1 } @@ -953,15 +965,16 @@ func (fake *FakeUserRepository) UnsetSpaceRoleByGUID(arg1 string, arg2 string, a arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.UnsetSpaceRoleByGUIDStub + fakeReturns := fake.unsetSpaceRoleByGUIDReturns fake.recordInvocation("UnsetSpaceRoleByGUID", []interface{}{arg1, arg2, arg3}) fake.unsetSpaceRoleByGUIDMutex.Unlock() - if fake.UnsetSpaceRoleByGUIDStub != nil { - return fake.UnsetSpaceRoleByGUIDStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.unsetSpaceRoleByGUIDReturns return fakeReturns.result1 } @@ -1015,15 +1028,16 @@ func (fake *FakeUserRepository) UnsetSpaceRoleByUsername(arg1 string, arg2 strin arg2 string arg3 models.Role }{arg1, arg2, arg3}) + stub := fake.UnsetSpaceRoleByUsernameStub + fakeReturns := fake.unsetSpaceRoleByUsernameReturns fake.recordInvocation("UnsetSpaceRoleByUsername", []interface{}{arg1, arg2, arg3}) fake.unsetSpaceRoleByUsernameMutex.Unlock() - if fake.UnsetSpaceRoleByUsernameStub != nil { - return fake.UnsetSpaceRoleByUsernameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.unsetSpaceRoleByUsernameReturns return fakeReturns.result1 } diff --git a/cf/api/apifakes/old_fake_app_summary_repo.go b/cf/api/apifakes/old_fake_app_summary_repo.go index 25c6de49828..fa376a99bc0 100644 --- a/cf/api/apifakes/old_fake_app_summary_repo.go +++ b/cf/api/apifakes/old_fake_app_summary_repo.go @@ -1,8 +1,8 @@ package apifakes import ( - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" ) type OldFakeAppSummaryRepo struct { diff --git a/cf/api/apifakes/old_fake_auth_token_repo.go b/cf/api/apifakes/old_fake_auth_token_repo.go index 4fb3576bad4..3ab8e080642 100644 --- a/cf/api/apifakes/old_fake_auth_token_repo.go +++ b/cf/api/apifakes/old_fake_auth_token_repo.go @@ -1,6 +1,6 @@ package apifakes -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type OldFakeAuthTokenRepo struct { CreatedServiceAuthTokenFields models.ServiceAuthTokenFields diff --git a/cf/api/apifakes/old_fake_buildpack_bits_repo.go b/cf/api/apifakes/old_fake_buildpack_bits_repo.go index b82b3a0e6d6..f620c1d107d 100644 --- a/cf/api/apifakes/old_fake_buildpack_bits_repo.go +++ b/cf/api/apifakes/old_fake_buildpack_bits_repo.go @@ -1,8 +1,8 @@ package apifakes import ( - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" ) type OldFakeBuildpackBitsRepository struct { diff --git a/cf/api/apifakes/old_fake_buildpack_repo.go b/cf/api/apifakes/old_fake_buildpack_repo.go index 1b361d6e7f6..75f276e8ed1 100644 --- a/cf/api/apifakes/old_fake_buildpack_repo.go +++ b/cf/api/apifakes/old_fake_buildpack_repo.go @@ -1,8 +1,8 @@ package apifakes import ( - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" ) type OldFakeBuildpackRepository struct { diff --git a/cf/api/apifakes/old_fake_cc_request.go b/cf/api/apifakes/old_fake_cc_request.go index 0b64b79c80d..3d520a18225 100644 --- a/cf/api/apifakes/old_fake_cc_request.go +++ b/cf/api/apifakes/old_fake_cc_request.go @@ -3,7 +3,7 @@ package apifakes import ( "net/http" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" ) func NewCloudControllerTestRequest(request testnet.TestRequest) testnet.TestRequest { diff --git a/cf/api/apifakes/old_fake_password_repo.go b/cf/api/apifakes/old_fake_password_repo.go index 53798334cdf..68c6c3cff7f 100644 --- a/cf/api/apifakes/old_fake_password_repo.go +++ b/cf/api/apifakes/old_fake_password_repo.go @@ -1,6 +1,6 @@ package apifakes -import "code.cloudfoundry.org/cli/cf/errors" +import "code.cloudfoundry.org/cli/v8/cf/errors" type OldFakePasswordRepo struct { Score string diff --git a/cf/api/apifakes/old_fake_service_key_repo.go b/cf/api/apifakes/old_fake_service_key_repo.go index fcc19904e9e..d5e40af8118 100644 --- a/cf/api/apifakes/old_fake_service_key_repo.go +++ b/cf/api/apifakes/old_fake_service_key_repo.go @@ -1,7 +1,7 @@ package apifakes import ( - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" ) type OldFakeServiceKeyRepo struct { diff --git a/cf/api/apifakes/old_fake_service_plan_repo.go b/cf/api/apifakes/old_fake_service_plan_repo.go index 832b2f0c3c4..ac0b0b05659 100644 --- a/cf/api/apifakes/old_fake_service_plan_repo.go +++ b/cf/api/apifakes/old_fake_service_plan_repo.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" ) type OldFakeServicePlanRepo struct { @@ -44,7 +44,7 @@ func (fake *OldFakeServicePlanRepo) Search(queryParams map[string]string) ([]mod } if queryParams == nil { - //return everything + // return everything var returnPlans []models.ServicePlanFields for _, value := range fake.SearchReturns { returnPlans = append(returnPlans, value...) diff --git a/cf/api/apifakes/old_fake_service_summary_repo.go b/cf/api/apifakes/old_fake_service_summary_repo.go index fed622ff3cb..5fce171683a 100644 --- a/cf/api/apifakes/old_fake_service_summary_repo.go +++ b/cf/api/apifakes/old_fake_service_summary_repo.go @@ -1,6 +1,6 @@ package apifakes -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type OldFakeServiceSummaryRepo struct { GetSummariesInCurrentSpaceInstances []models.ServiceInstance diff --git a/cf/api/app_summary.go b/cf/api/app_summary.go index 15a9b2387ad..d67ecb8b4c6 100644 --- a/cf/api/app_summary.go +++ b/cf/api/app_summary.go @@ -5,9 +5,9 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) type ApplicationSummaries struct { diff --git a/cf/api/app_summary_test.go b/cf/api/app_summary_test.go index a376f1714a5..6d2c7d6eaa1 100644 --- a/cf/api/app_summary_test.go +++ b/cf/api/app_summary_test.go @@ -5,15 +5,15 @@ import ( "net/http/httptest" "time" - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/appevents/app_events.go b/cf/api/appevents/app_events.go index a1bc966c830..b6463f62f3b 100644 --- a/cf/api/appevents/app_events.go +++ b/cf/api/appevents/app_events.go @@ -3,10 +3,10 @@ package appevents import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/appevents/app_events_suite_test.go b/cf/api/appevents/app_events_suite_test.go index efc415dbde3..6bd71155a9a 100644 --- a/cf/api/appevents/app_events_suite_test.go +++ b/cf/api/appevents/app_events_suite_test.go @@ -1,9 +1,9 @@ package appevents_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/appevents/app_events_test.go b/cf/api/appevents/app_events_test.go index 2e6c4b28763..7330fbd982b 100644 --- a/cf/api/appevents/app_events_test.go +++ b/cf/api/appevents/app_events_test.go @@ -6,15 +6,15 @@ import ( "time" - . "code.cloudfoundry.org/cli/cf/api/appevents" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/appevents" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/appevents/appeventsfakes/fake_app_events_repository.go b/cf/api/appevents/appeventsfakes/fake_app_events_repository.go index 601be0df596..2b854c8f306 100644 --- a/cf/api/appevents/appeventsfakes/fake_app_events_repository.go +++ b/cf/api/appevents/appeventsfakes/fake_app_events_repository.go @@ -4,8 +4,8 @@ package appeventsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appevents" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/appevents" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeAppEventsRepository struct { diff --git a/cf/api/appevents/appeventsfakes/fake_repository.go b/cf/api/appevents/appeventsfakes/fake_repository.go index 1c62f9dde9d..6afacd892fd 100644 --- a/cf/api/appevents/appeventsfakes/fake_repository.go +++ b/cf/api/appevents/appeventsfakes/fake_repository.go @@ -4,8 +4,8 @@ package appeventsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appevents" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/appevents" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRepository struct { @@ -34,15 +34,16 @@ func (fake *FakeRepository) RecentEvents(arg1 string, arg2 int64) ([]models.Even arg1 string arg2 int64 }{arg1, arg2}) + stub := fake.RecentEventsStub + fakeReturns := fake.recentEventsReturns fake.recordInvocation("RecentEvents", []interface{}{arg1, arg2}) fake.recentEventsMutex.Unlock() - if fake.RecentEventsStub != nil { - return fake.RecentEventsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.recentEventsReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/appfiles/app_files.go b/cf/api/appfiles/app_files.go index 473b27e1226..982006c46a5 100644 --- a/cf/api/appfiles/app_files.go +++ b/cf/api/appfiles/app_files.go @@ -3,8 +3,8 @@ package appfiles import ( "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/appfiles/app_files_suite_test.go b/cf/api/appfiles/app_files_suite_test.go index d4cbff6c4df..cda4809d9fb 100644 --- a/cf/api/appfiles/app_files_suite_test.go +++ b/cf/api/appfiles/app_files_suite_test.go @@ -1,9 +1,9 @@ package appfiles_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/appfiles/app_files_test.go b/cf/api/appfiles/app_files_test.go index f6f27f08d89..afdd65236ef 100644 --- a/cf/api/appfiles/app_files_test.go +++ b/cf/api/appfiles/app_files_test.go @@ -6,16 +6,16 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api/appfiles" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/appfiles" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/appfiles/appfilesfakes/fake_app_files_repository.go b/cf/api/appfiles/appfilesfakes/fake_app_files_repository.go index f3d46847d71..15b944270d1 100644 --- a/cf/api/appfiles/appfilesfakes/fake_app_files_repository.go +++ b/cf/api/appfiles/appfilesfakes/fake_app_files_repository.go @@ -4,7 +4,7 @@ package appfilesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appfiles" + "code.cloudfoundry.org/cli/v8/cf/api/appfiles" ) type FakeAppFilesRepository struct { diff --git a/cf/api/appfiles/appfilesfakes/fake_repository.go b/cf/api/appfiles/appfilesfakes/fake_repository.go index 38b0d22db35..a88e87f6a46 100644 --- a/cf/api/appfiles/appfilesfakes/fake_repository.go +++ b/cf/api/appfiles/appfilesfakes/fake_repository.go @@ -4,7 +4,7 @@ package appfilesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appfiles" + "code.cloudfoundry.org/cli/v8/cf/api/appfiles" ) type FakeRepository struct { @@ -35,15 +35,16 @@ func (fake *FakeRepository) ListFiles(arg1 string, arg2 int, arg3 string) (strin arg2 int arg3 string }{arg1, arg2, arg3}) + stub := fake.ListFilesStub + fakeReturns := fake.listFilesReturns fake.recordInvocation("ListFiles", []interface{}{arg1, arg2, arg3}) fake.listFilesMutex.Unlock() - if fake.ListFilesStub != nil { - return fake.ListFilesStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listFilesReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/appinstances/app_instances.go b/cf/api/appinstances/app_instances.go index 6a3ea086002..286426b1ad8 100644 --- a/cf/api/appinstances/app_instances.go +++ b/cf/api/appinstances/app_instances.go @@ -6,9 +6,9 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) type InstancesAPIResponse map[string]InstanceAPIResponse diff --git a/cf/api/appinstances/app_instances_suite_test.go b/cf/api/appinstances/app_instances_suite_test.go index aa0342e683f..72e6aaf0ba5 100644 --- a/cf/api/appinstances/app_instances_suite_test.go +++ b/cf/api/appinstances/app_instances_suite_test.go @@ -1,9 +1,9 @@ package appinstances_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/appinstances/app_instances_test.go b/cf/api/appinstances/app_instances_test.go index cdd41922769..59608720417 100644 --- a/cf/api/appinstances/app_instances_test.go +++ b/cf/api/appinstances/app_instances_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -64,7 +64,7 @@ var _ = Describe("AppInstancesRepo", func() { It("returns the error if the response is unsuccessful", func() { ts, handler, repo := createAppInstancesRepo([]testnet.TestRequest{ - deleteInstanceFromUnkownApp, + deleteInstanceFromUnknownApp, }) defer ts.Close() appGUID := "some-wrong-app-guid" @@ -128,7 +128,7 @@ var deleteInstanceRequest = apifakes.NewCloudControllerTestRequest(testnet.TestR Response: testnet.TestResponse{Status: http.StatusNoContent, Body: `{}`}, }) -var deleteInstanceFromUnkownApp = apifakes.NewCloudControllerTestRequest(testnet.TestRequest{ +var deleteInstanceFromUnknownApp = apifakes.NewCloudControllerTestRequest(testnet.TestRequest{ Method: "DELETE", Path: "/v2/apps/some-wrong-app-guid/instances/0", Response: testnet.TestResponse{Status: http.StatusNotFound, Body: `{}`}, diff --git a/cf/api/appinstances/appinstancesfakes/fake_app_instances_repository.go b/cf/api/appinstances/appinstancesfakes/fake_app_instances_repository.go index efd79f324e4..b11ceb274bf 100644 --- a/cf/api/appinstances/appinstancesfakes/fake_app_instances_repository.go +++ b/cf/api/appinstances/appinstancesfakes/fake_app_instances_repository.go @@ -4,8 +4,8 @@ package appinstancesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeAppInstancesRepository struct { diff --git a/cf/api/appinstances/appinstancesfakes/fake_repository.go b/cf/api/appinstances/appinstancesfakes/fake_repository.go index 74baf569a43..2372a5450de 100644 --- a/cf/api/appinstances/appinstancesfakes/fake_repository.go +++ b/cf/api/appinstances/appinstancesfakes/fake_repository.go @@ -4,8 +4,8 @@ package appinstancesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRepository struct { @@ -45,15 +45,16 @@ func (fake *FakeRepository) DeleteInstance(arg1 string, arg2 int) error { arg1 string arg2 int }{arg1, arg2}) + stub := fake.DeleteInstanceStub + fakeReturns := fake.deleteInstanceReturns fake.recordInvocation("DeleteInstance", []interface{}{arg1, arg2}) fake.deleteInstanceMutex.Unlock() - if fake.DeleteInstanceStub != nil { - return fake.DeleteInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteInstanceReturns return fakeReturns.result1 } @@ -105,15 +106,16 @@ func (fake *FakeRepository) GetInstances(arg1 string) ([]models.AppInstanceField fake.getInstancesArgsForCall = append(fake.getInstancesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetInstancesStub + fakeReturns := fake.getInstancesReturns fake.recordInvocation("GetInstances", []interface{}{arg1}) fake.getInstancesMutex.Unlock() - if fake.GetInstancesStub != nil { - return fake.GetInstancesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getInstancesReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/applicationbits/application_bits.go b/cf/api/applicationbits/application_bits.go index 1b16ae9d3cd..fe1bb996010 100644 --- a/cf/api/applicationbits/application_bits.go +++ b/cf/api/applicationbits/application_bits.go @@ -10,10 +10,10 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" "code.cloudfoundry.org/gofileutils/fileutils" ) diff --git a/cf/api/applicationbits/application_bits_suite_test.go b/cf/api/applicationbits/application_bits_suite_test.go index 0182f4602c9..d3f5dc3c2ef 100644 --- a/cf/api/applicationbits/application_bits_suite_test.go +++ b/cf/api/applicationbits/application_bits_suite_test.go @@ -1,9 +1,9 @@ package applicationbits_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/applicationbits/application_bits_test.go b/cf/api/applicationbits/application_bits_test.go index 50805984eb6..54d24025220 100644 --- a/cf/api/applicationbits/application_bits_test.go +++ b/cf/api/applicationbits/application_bits_test.go @@ -13,17 +13,17 @@ import ( "strings" "time" - testapi "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/applicationbits" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + testapi "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/applicationbits" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/applicationbits/applicationbitsfakes/fake_application_bits_repository.go b/cf/api/applicationbits/applicationbitsfakes/fake_application_bits_repository.go index 9c69ac9fdc9..b980aa2fdc9 100644 --- a/cf/api/applicationbits/applicationbitsfakes/fake_application_bits_repository.go +++ b/cf/api/applicationbits/applicationbitsfakes/fake_application_bits_repository.go @@ -5,8 +5,8 @@ import ( "os" "sync" - "code.cloudfoundry.org/cli/cf/api/applicationbits" - "code.cloudfoundry.org/cli/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/applicationbits" + "code.cloudfoundry.org/cli/v8/cf/api/resources" ) type FakeApplicationBitsRepository struct { diff --git a/cf/api/applicationbits/applicationbitsfakes/fake_repository.go b/cf/api/applicationbits/applicationbitsfakes/fake_repository.go index fd56c911702..1d15e1fafa9 100644 --- a/cf/api/applicationbits/applicationbitsfakes/fake_repository.go +++ b/cf/api/applicationbits/applicationbitsfakes/fake_repository.go @@ -5,8 +5,8 @@ import ( "os" "sync" - "code.cloudfoundry.org/cli/cf/api/applicationbits" - "code.cloudfoundry.org/cli/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/applicationbits" + "code.cloudfoundry.org/cli/v8/cf/api/resources" ) type FakeRepository struct { @@ -51,15 +51,16 @@ func (fake *FakeRepository) GetApplicationFiles(arg1 []resources.AppFileResource fake.getApplicationFilesArgsForCall = append(fake.getApplicationFilesArgsForCall, struct { arg1 []resources.AppFileResource }{arg1Copy}) + stub := fake.GetApplicationFilesStub + fakeReturns := fake.getApplicationFilesReturns fake.recordInvocation("GetApplicationFiles", []interface{}{arg1Copy}) fake.getApplicationFilesMutex.Unlock() - if fake.GetApplicationFilesStub != nil { - return fake.GetApplicationFilesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getApplicationFilesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -121,15 +122,16 @@ func (fake *FakeRepository) UploadBits(arg1 string, arg2 *os.File, arg3 []resour arg2 *os.File arg3 []resources.AppFileResource }{arg1, arg2, arg3Copy}) + stub := fake.UploadBitsStub + fakeReturns := fake.uploadBitsReturns fake.recordInvocation("UploadBits", []interface{}{arg1, arg2, arg3Copy}) fake.uploadBitsMutex.Unlock() - if fake.UploadBitsStub != nil { - return fake.UploadBitsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.uploadBitsReturns return fakeReturns.result1 } diff --git a/cf/api/applications/applications.go b/cf/api/applications/applications.go index 32058b5ba0f..efd8323ecf3 100644 --- a/cf/api/applications/applications.go +++ b/cf/api/applications/applications.go @@ -7,13 +7,13 @@ import ( "net/url" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/applications/applications_suite_test.go b/cf/api/applications/applications_suite_test.go index ec168a3a3b2..a987b0247a0 100644 --- a/cf/api/applications/applications_suite_test.go +++ b/cf/api/applications/applications_suite_test.go @@ -1,9 +1,9 @@ package applications_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/applications/applications_test.go b/cf/api/applications/applications_test.go index 64d5c3a5822..4668415ae98 100644 --- a/cf/api/applications/applications_test.go +++ b/cf/api/applications/applications_test.go @@ -8,20 +8,20 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/applications/applicationsfakes/fake_repository.go b/cf/api/applications/applicationsfakes/fake_repository.go index 0d7974f80d5..0a20bd6652b 100644 --- a/cf/api/applications/applicationsfakes/fake_repository.go +++ b/cf/api/applications/applicationsfakes/fake_repository.go @@ -4,8 +4,8 @@ package applicationsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRepository struct { @@ -134,15 +134,16 @@ func (fake *FakeRepository) Create(arg1 models.AppParams) (models.Application, e fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 models.AppParams }{arg1}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createReturns return fakeReturns.result1, fakeReturns.result2 } @@ -197,15 +198,16 @@ func (fake *FakeRepository) CreateRestageRequest(arg1 string) error { fake.createRestageRequestArgsForCall = append(fake.createRestageRequestArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateRestageRequestStub + fakeReturns := fake.createRestageRequestReturns fake.recordInvocation("CreateRestageRequest", []interface{}{arg1}) fake.createRestageRequestMutex.Unlock() - if fake.CreateRestageRequestStub != nil { - return fake.CreateRestageRequestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createRestageRequestReturns return fakeReturns.result1 } @@ -257,15 +259,16 @@ func (fake *FakeRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -317,15 +320,16 @@ func (fake *FakeRepository) GetApp(arg1 string) (models.Application, error) { fake.getAppArgsForCall = append(fake.getAppArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetAppStub + fakeReturns := fake.getAppReturns fake.recordInvocation("GetApp", []interface{}{arg1}) fake.getAppMutex.Unlock() - if fake.GetAppStub != nil { - return fake.GetAppStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAppReturns return fakeReturns.result1, fakeReturns.result2 } @@ -380,15 +384,16 @@ func (fake *FakeRepository) GetAppRoutes(arg1 string) ([]models.Route, error) { fake.getAppRoutesArgsForCall = append(fake.getAppRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetAppRoutesStub + fakeReturns := fake.getAppRoutesReturns fake.recordInvocation("GetAppRoutes", []interface{}{arg1}) fake.getAppRoutesMutex.Unlock() - if fake.GetAppRoutesStub != nil { - return fake.GetAppRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAppRoutesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -443,15 +448,16 @@ func (fake *FakeRepository) Read(arg1 string) (models.Application, error) { fake.readArgsForCall = append(fake.readArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ReadStub + fakeReturns := fake.readReturns fake.recordInvocation("Read", []interface{}{arg1}) fake.readMutex.Unlock() - if fake.ReadStub != nil { - return fake.ReadStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readReturns return fakeReturns.result1, fakeReturns.result2 } @@ -506,15 +512,16 @@ func (fake *FakeRepository) ReadEnv(arg1 string) (*models.Environment, error) { fake.readEnvArgsForCall = append(fake.readEnvArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ReadEnvStub + fakeReturns := fake.readEnvReturns fake.recordInvocation("ReadEnv", []interface{}{arg1}) fake.readEnvMutex.Unlock() - if fake.ReadEnvStub != nil { - return fake.ReadEnvStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readEnvReturns return fakeReturns.result1, fakeReturns.result2 } @@ -570,15 +577,16 @@ func (fake *FakeRepository) ReadFromSpace(arg1 string, arg2 string) (models.Appl arg1 string arg2 string }{arg1, arg2}) + stub := fake.ReadFromSpaceStub + fakeReturns := fake.readFromSpaceReturns fake.recordInvocation("ReadFromSpace", []interface{}{arg1, arg2}) fake.readFromSpaceMutex.Unlock() - if fake.ReadFromSpaceStub != nil { - return fake.ReadFromSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readFromSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -634,15 +642,16 @@ func (fake *FakeRepository) Update(arg1 string, arg2 models.AppParams) (models.A arg1 string arg2 models.AppParams }{arg1, arg2}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1, arg2}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/authentication/authentication.go b/cf/api/authentication/authentication.go index 5e0fc670c64..1405616319a 100644 --- a/cf/api/authentication/authentication.go +++ b/cf/api/authentication/authentication.go @@ -10,11 +10,11 @@ import ( "github.com/SermoDigital/jose/jws" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/util" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . TokenRefresher diff --git a/cf/api/authentication/authentication_suite_test.go b/cf/api/authentication/authentication_suite_test.go index 08310a8a382..f1062a9627c 100644 --- a/cf/api/authentication/authentication_suite_test.go +++ b/cf/api/authentication/authentication_suite_test.go @@ -1,9 +1,9 @@ package authentication_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/authentication/authentication_test.go b/cf/api/authentication/authentication_test.go index 8e69b9690f9..33586dbcde0 100644 --- a/cf/api/authentication/authentication_test.go +++ b/cf/api/authentication/authentication_test.go @@ -7,16 +7,16 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/authentication/authenticationfakes/fake_repository.go b/cf/api/authentication/authenticationfakes/fake_repository.go index fc59759766a..989a6961549 100644 --- a/cf/api/authentication/authenticationfakes/fake_repository.go +++ b/cf/api/authentication/authenticationfakes/fake_repository.go @@ -5,8 +5,8 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" ) type FakeRepository struct { @@ -91,15 +91,16 @@ func (fake *FakeRepository) Authenticate(arg1 map[string]string) error { fake.authenticateArgsForCall = append(fake.authenticateArgsForCall, struct { arg1 map[string]string }{arg1}) + stub := fake.AuthenticateStub + fakeReturns := fake.authenticateReturns fake.recordInvocation("Authenticate", []interface{}{arg1}) fake.authenticateMutex.Unlock() - if fake.AuthenticateStub != nil { - return fake.AuthenticateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.authenticateReturns return fakeReturns.result1 } @@ -151,15 +152,16 @@ func (fake *FakeRepository) Authorize(arg1 string) (string, error) { fake.authorizeArgsForCall = append(fake.authorizeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.AuthorizeStub + fakeReturns := fake.authorizeReturns fake.recordInvocation("Authorize", []interface{}{arg1}) fake.authorizeMutex.Unlock() - if fake.AuthorizeStub != nil { - return fake.AuthorizeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.authorizeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -213,9 +215,10 @@ func (fake *FakeRepository) DumpRequest(arg1 *http.Request) { fake.dumpRequestArgsForCall = append(fake.dumpRequestArgsForCall, struct { arg1 *http.Request }{arg1}) + stub := fake.DumpRequestStub fake.recordInvocation("DumpRequest", []interface{}{arg1}) fake.dumpRequestMutex.Unlock() - if fake.DumpRequestStub != nil { + if stub != nil { fake.DumpRequestStub(arg1) } } @@ -244,9 +247,10 @@ func (fake *FakeRepository) DumpResponse(arg1 *http.Response) { fake.dumpResponseArgsForCall = append(fake.dumpResponseArgsForCall, struct { arg1 *http.Response }{arg1}) + stub := fake.DumpResponseStub fake.recordInvocation("DumpResponse", []interface{}{arg1}) fake.dumpResponseMutex.Unlock() - if fake.DumpResponseStub != nil { + if stub != nil { fake.DumpResponseStub(arg1) } } @@ -275,15 +279,16 @@ func (fake *FakeRepository) GetLoginPromptsAndSaveUAAServerURL() (map[string]cor ret, specificReturn := fake.getLoginPromptsAndSaveUAAServerURLReturnsOnCall[len(fake.getLoginPromptsAndSaveUAAServerURLArgsForCall)] fake.getLoginPromptsAndSaveUAAServerURLArgsForCall = append(fake.getLoginPromptsAndSaveUAAServerURLArgsForCall, struct { }{}) + stub := fake.GetLoginPromptsAndSaveUAAServerURLStub + fakeReturns := fake.getLoginPromptsAndSaveUAAServerURLReturns fake.recordInvocation("GetLoginPromptsAndSaveUAAServerURL", []interface{}{}) fake.getLoginPromptsAndSaveUAAServerURLMutex.Unlock() - if fake.GetLoginPromptsAndSaveUAAServerURLStub != nil { - return fake.GetLoginPromptsAndSaveUAAServerURLStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getLoginPromptsAndSaveUAAServerURLReturns return fakeReturns.result1, fakeReturns.result2 } @@ -330,15 +335,16 @@ func (fake *FakeRepository) RefreshAuthToken() (string, error) { ret, specificReturn := fake.refreshAuthTokenReturnsOnCall[len(fake.refreshAuthTokenArgsForCall)] fake.refreshAuthTokenArgsForCall = append(fake.refreshAuthTokenArgsForCall, struct { }{}) + stub := fake.RefreshAuthTokenStub + fakeReturns := fake.refreshAuthTokenReturns fake.recordInvocation("RefreshAuthToken", []interface{}{}) fake.refreshAuthTokenMutex.Unlock() - if fake.RefreshAuthTokenStub != nil { - return fake.RefreshAuthTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAuthTokenReturns return fakeReturns.result1, fakeReturns.result2 } @@ -386,15 +392,16 @@ func (fake *FakeRepository) RefreshToken(arg1 string) (string, error) { fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{arg1}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/authentication/authenticationfakes/fake_token_refresher.go b/cf/api/authentication/authenticationfakes/fake_token_refresher.go index 7df7aadfc84..ec58f5485e2 100644 --- a/cf/api/authentication/authenticationfakes/fake_token_refresher.go +++ b/cf/api/authentication/authenticationfakes/fake_token_refresher.go @@ -4,7 +4,7 @@ package authenticationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" ) type FakeTokenRefresher struct { @@ -29,15 +29,16 @@ func (fake *FakeTokenRefresher) RefreshAuthToken() (string, error) { ret, specificReturn := fake.refreshAuthTokenReturnsOnCall[len(fake.refreshAuthTokenArgsForCall)] fake.refreshAuthTokenArgsForCall = append(fake.refreshAuthTokenArgsForCall, struct { }{}) + stub := fake.RefreshAuthTokenStub + fakeReturns := fake.refreshAuthTokenReturns fake.recordInvocation("RefreshAuthToken", []interface{}{}) fake.refreshAuthTokenMutex.Unlock() - if fake.RefreshAuthTokenStub != nil { - return fake.RefreshAuthTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAuthTokenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/buildpack_bits.go b/cf/api/buildpack_bits.go index a3dd4416071..801f0ccbfdf 100644 --- a/cf/api/buildpack_bits.go +++ b/cf/api/buildpack_bits.go @@ -16,13 +16,13 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/util" "code.cloudfoundry.org/gofileutils/fileutils" ) @@ -108,6 +108,7 @@ func (repo CloudControllerBuildpackBitsRepository) CreateBuildpackZipFile(buildp if err != nil { return nil, "", fmt.Errorf("%s: %s", T("Couldn't open buildpack file"), err.Error()) } + defer specifiedFile.Close() err = normalizeBuildpackArchive(specifiedFile, zipFileToUpload) if err != nil { return nil, "", zipErrorHelper(err) diff --git a/cf/api/buildpack_bits_test.go b/cf/api/buildpack_bits_test.go index 25892813695..ed7f35c6989 100644 --- a/cf/api/buildpack_bits_test.go +++ b/cf/api/buildpack_bits_test.go @@ -15,18 +15,18 @@ import ( "sort" "time" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/buildpacks.go b/cf/api/buildpacks.go index abb6206eafb..0541801ebc3 100644 --- a/cf/api/buildpacks.go +++ b/cf/api/buildpacks.go @@ -6,12 +6,12 @@ import ( "fmt" "net/url" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . BuildpackRepository diff --git a/cf/api/buildpacks_test.go b/cf/api/buildpacks_test.go index 55a91a7020b..73f851eafb1 100644 --- a/cf/api/buildpacks_test.go +++ b/cf/api/buildpacks_test.go @@ -5,18 +5,18 @@ import ( "net/http/httptest" "time" - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/clients.go b/cf/api/clients.go index d1d9476252e..c317a86c20b 100644 --- a/cf/api/clients.go +++ b/cf/api/clients.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ClientRepository diff --git a/cf/api/clients_test.go b/cf/api/clients_test.go index 717f762eb81..5a6d44e56b3 100644 --- a/cf/api/clients_test.go +++ b/cf/api/clients_test.go @@ -4,14 +4,14 @@ import ( "fmt" "net/http" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" diff --git a/cf/api/copyapplicationsource/copy_application_source.go b/cf/api/copyapplicationsource/copy_application_source.go index 06e6486cdc8..51a3ab66ecc 100644 --- a/cf/api/copyapplicationsource/copy_application_source.go +++ b/cf/api/copyapplicationsource/copy_application_source.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/copyapplicationsource/copy_application_source_suite_test.go b/cf/api/copyapplicationsource/copy_application_source_suite_test.go index 1586abe7d6c..13132289eff 100644 --- a/cf/api/copyapplicationsource/copy_application_source_suite_test.go +++ b/cf/api/copyapplicationsource/copy_application_source_suite_test.go @@ -1,9 +1,9 @@ package copyapplicationsource_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/copyapplicationsource/copy_application_source_test.go b/cf/api/copyapplicationsource/copy_application_source_test.go index e519900176c..87a90df724f 100644 --- a/cf/api/copyapplicationsource/copy_application_source_test.go +++ b/cf/api/copyapplicationsource/copy_application_source_test.go @@ -5,16 +5,16 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - . "code.cloudfoundry.org/cli/cf/api/copyapplicationsource" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + . "code.cloudfoundry.org/cli/v8/cf/api/copyapplicationsource" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/copyapplicationsource/copyapplicationsourcefakes/fake_repository.go b/cf/api/copyapplicationsource/copyapplicationsourcefakes/fake_repository.go index 3e4eb5f0137..1acf04ebc48 100644 --- a/cf/api/copyapplicationsource/copyapplicationsourcefakes/fake_repository.go +++ b/cf/api/copyapplicationsource/copyapplicationsourcefakes/fake_repository.go @@ -4,7 +4,7 @@ package copyapplicationsourcefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/copyapplicationsource" + "code.cloudfoundry.org/cli/v8/cf/api/copyapplicationsource" ) type FakeRepository struct { @@ -31,15 +31,16 @@ func (fake *FakeRepository) CopyApplication(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.CopyApplicationStub + fakeReturns := fake.copyApplicationReturns fake.recordInvocation("CopyApplication", []interface{}{arg1, arg2}) fake.copyApplicationMutex.Unlock() - if fake.CopyApplicationStub != nil { - return fake.CopyApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.copyApplicationReturns return fakeReturns.result1 } diff --git a/cf/api/curl.go b/cf/api/curl.go index dd09950d009..59968724d69 100644 --- a/cf/api/curl.go +++ b/cf/api/curl.go @@ -9,10 +9,10 @@ import ( "net/textproto" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . CurlRepository diff --git a/cf/api/curl_test.go b/cf/api/curl_test.go index 5d39bed01b5..c5c843c353e 100644 --- a/cf/api/curl_test.go +++ b/cf/api/curl_test.go @@ -6,17 +6,17 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/domains.go b/cf/api/domains.go index cb56fd65cb5..58a4d85544f 100644 --- a/cf/api/domains.go +++ b/cf/api/domains.go @@ -6,13 +6,13 @@ import ( "fmt" "net/url" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . DomainRepository diff --git a/cf/api/domains_test.go b/cf/api/domains_test.go index 8116787591f..e30e58976a2 100644 --- a/cf/api/domains_test.go +++ b/cf/api/domains_test.go @@ -5,19 +5,19 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/endpoints.go b/cf/api/endpoints.go index ce3e085ba8b..4d3d5a372f7 100644 --- a/cf/api/endpoints.go +++ b/cf/api/endpoints.go @@ -3,8 +3,8 @@ package api import ( "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" ) type RemoteInfoRepository struct { diff --git a/cf/api/endpoints_test.go b/cf/api/endpoints_test.go index 3783d368c3f..5bebc85afd9 100644 --- a/cf/api/endpoints_test.go +++ b/cf/api/endpoints_test.go @@ -10,15 +10,15 @@ import ( "strings" "time" - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/environmentvariablegroups/environment_variable_groups.go b/cf/api/environmentvariablegroups/environment_variable_groups.go index 296553615c1..bb8419b842f 100644 --- a/cf/api/environmentvariablegroups/environment_variable_groups.go +++ b/cf/api/environmentvariablegroups/environment_variable_groups.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/environmentvariablegroups/environment_variable_groups_suite_test.go b/cf/api/environmentvariablegroups/environment_variable_groups_suite_test.go index 350717a93f3..d1cd00431bb 100644 --- a/cf/api/environmentvariablegroups/environment_variable_groups_suite_test.go +++ b/cf/api/environmentvariablegroups/environment_variable_groups_suite_test.go @@ -1,9 +1,9 @@ package environmentvariablegroups_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/environmentvariablegroups/environment_variable_groups_test.go b/cf/api/environmentvariablegroups/environment_variable_groups_test.go index 66ae787604e..fe873b78f81 100644 --- a/cf/api/environmentvariablegroups/environment_variable_groups_test.go +++ b/cf/api/environmentvariablegroups/environment_variable_groups_test.go @@ -4,18 +4,18 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" "github.com/onsi/gomega/ghttp" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/environmentvariablegroups/environmentvariablegroupsfakes/fake_repository.go b/cf/api/environmentvariablegroups/environmentvariablegroupsfakes/fake_repository.go index 6bd8cefec96..4e41bb8512e 100644 --- a/cf/api/environmentvariablegroups/environmentvariablegroupsfakes/fake_repository.go +++ b/cf/api/environmentvariablegroups/environmentvariablegroupsfakes/fake_repository.go @@ -4,8 +4,8 @@ package environmentvariablegroupsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRepository struct { @@ -64,15 +64,16 @@ func (fake *FakeRepository) ListRunning() ([]models.EnvironmentVariable, error) ret, specificReturn := fake.listRunningReturnsOnCall[len(fake.listRunningArgsForCall)] fake.listRunningArgsForCall = append(fake.listRunningArgsForCall, struct { }{}) + stub := fake.ListRunningStub + fakeReturns := fake.listRunningReturns fake.recordInvocation("ListRunning", []interface{}{}) fake.listRunningMutex.Unlock() - if fake.ListRunningStub != nil { - return fake.ListRunningStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listRunningReturns return fakeReturns.result1, fakeReturns.result2 } @@ -119,15 +120,16 @@ func (fake *FakeRepository) ListStaging() ([]models.EnvironmentVariable, error) ret, specificReturn := fake.listStagingReturnsOnCall[len(fake.listStagingArgsForCall)] fake.listStagingArgsForCall = append(fake.listStagingArgsForCall, struct { }{}) + stub := fake.ListStagingStub + fakeReturns := fake.listStagingReturns fake.recordInvocation("ListStaging", []interface{}{}) fake.listStagingMutex.Unlock() - if fake.ListStagingStub != nil { - return fake.ListStagingStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listStagingReturns return fakeReturns.result1, fakeReturns.result2 } @@ -175,15 +177,16 @@ func (fake *FakeRepository) SetRunning(arg1 string) error { fake.setRunningArgsForCall = append(fake.setRunningArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRunningStub + fakeReturns := fake.setRunningReturns fake.recordInvocation("SetRunning", []interface{}{arg1}) fake.setRunningMutex.Unlock() - if fake.SetRunningStub != nil { - return fake.SetRunningStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.setRunningReturns return fakeReturns.result1 } @@ -235,15 +238,16 @@ func (fake *FakeRepository) SetStaging(arg1 string) error { fake.setStagingArgsForCall = append(fake.setStagingArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetStagingStub + fakeReturns := fake.setStagingReturns fake.recordInvocation("SetStaging", []interface{}{arg1}) fake.setStagingMutex.Unlock() - if fake.SetStagingStub != nil { - return fake.SetStagingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.setStagingReturns return fakeReturns.result1 } diff --git a/cf/api/featureflags/feature_flags.go b/cf/api/featureflags/feature_flags.go index e9a038236cc..5ea926c8734 100644 --- a/cf/api/featureflags/feature_flags.go +++ b/cf/api/featureflags/feature_flags.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . FeatureFlagRepository diff --git a/cf/api/featureflags/feature_flags_suite_test.go b/cf/api/featureflags/feature_flags_suite_test.go index 8c31682d15d..db79b4771ff 100644 --- a/cf/api/featureflags/feature_flags_suite_test.go +++ b/cf/api/featureflags/feature_flags_suite_test.go @@ -1,9 +1,9 @@ package featureflags_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/featureflags/feature_flags_test.go b/cf/api/featureflags/feature_flags_test.go index 0ade82cca6e..b88f7c83018 100644 --- a/cf/api/featureflags/feature_flags_test.go +++ b/cf/api/featureflags/feature_flags_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -92,7 +92,7 @@ var _ = Describe("Feature Flags Repository", func() { Expect(err).ToNot(HaveOccurred()) }) - Context("when given a non-existent feature flag", func() { + Context("when given a nonexistent feature flag", func() { BeforeEach(func() { setupTestServer(featureFlagsUpdateErrorRequest) }) diff --git a/cf/api/featureflags/featureflagsfakes/fake_feature_flag_repository.go b/cf/api/featureflags/featureflagsfakes/fake_feature_flag_repository.go index a68aa95f6b9..36dd12755aa 100644 --- a/cf/api/featureflags/featureflagsfakes/fake_feature_flag_repository.go +++ b/cf/api/featureflags/featureflagsfakes/fake_feature_flag_repository.go @@ -4,8 +4,8 @@ package featureflagsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeFeatureFlagRepository struct { @@ -56,15 +56,16 @@ func (fake *FakeFeatureFlagRepository) FindByName(arg1 string) (models.FeatureFl fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -118,15 +119,16 @@ func (fake *FakeFeatureFlagRepository) List() ([]models.FeatureFlag, error) { ret, specificReturn := fake.listReturnsOnCall[len(fake.listArgsForCall)] fake.listArgsForCall = append(fake.listArgsForCall, struct { }{}) + stub := fake.ListStub + fakeReturns := fake.listReturns fake.recordInvocation("List", []interface{}{}) fake.listMutex.Unlock() - if fake.ListStub != nil { - return fake.ListStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listReturns return fakeReturns.result1, fakeReturns.result2 } @@ -175,15 +177,16 @@ func (fake *FakeFeatureFlagRepository) Update(arg1 string, arg2 bool) error { arg1 string arg2 bool }{arg1, arg2}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1, arg2}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/logs/log_cache_message.go b/cf/api/logs/log_cache_message.go index 798b1653d3c..d54a83f6aa7 100644 --- a/cf/api/logs/log_cache_message.go +++ b/cf/api/logs/log_cache_message.go @@ -6,7 +6,7 @@ import ( "time" "unicode/utf8" - "code.cloudfoundry.org/cli/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ColorLogger diff --git a/cf/api/logs/log_cache_message_test.go b/cf/api/logs/log_cache_message_test.go index bc6abfbcaee..087b908c170 100644 --- a/cf/api/logs/log_cache_message_test.go +++ b/cf/api/logs/log_cache_message_test.go @@ -3,10 +3,10 @@ package logs_test import ( "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/api/logs/logsfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs/logsfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/logs/log_cache_repository.go b/cf/api/logs/log_cache_repository.go index e6c39836903..b17b4ebf130 100644 --- a/cf/api/logs/log_cache_repository.go +++ b/cf/api/logs/log_cache_repository.go @@ -3,8 +3,8 @@ package logs import ( "context" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type terminalColorLogger struct { diff --git a/cf/api/logs/log_cache_repository_test.go b/cf/api/logs/log_cache_repository_test.go index 0b3dfd01a9d..cc2a39b5f86 100644 --- a/cf/api/logs/log_cache_repository_test.go +++ b/cf/api/logs/log_cache_repository_test.go @@ -5,10 +5,10 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/cf/api/logs" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/logs/logs_suite_test.go b/cf/api/logs/logs_suite_test.go index de2eeeab96e..8d5d23f342c 100644 --- a/cf/api/logs/logs_suite_test.go +++ b/cf/api/logs/logs_suite_test.go @@ -1,7 +1,7 @@ package logs_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/logs/logsfakes/fake_color_logger.go b/cf/api/logs/logsfakes/fake_color_logger.go index 74720c02748..3996f22137d 100644 --- a/cf/api/logs/logsfakes/fake_color_logger.go +++ b/cf/api/logs/logsfakes/fake_color_logger.go @@ -4,7 +4,7 @@ package logsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs" ) type FakeColorLogger struct { @@ -51,15 +51,16 @@ func (fake *FakeColorLogger) LogStderrColor(arg1 string) string { fake.logStderrColorArgsForCall = append(fake.logStderrColorArgsForCall, struct { arg1 string }{arg1}) + stub := fake.LogStderrColorStub + fakeReturns := fake.logStderrColorReturns fake.recordInvocation("LogStderrColor", []interface{}{arg1}) fake.logStderrColorMutex.Unlock() - if fake.LogStderrColorStub != nil { - return fake.LogStderrColorStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.logStderrColorReturns return fakeReturns.result1 } @@ -111,15 +112,16 @@ func (fake *FakeColorLogger) LogStdoutColor(arg1 string) string { fake.logStdoutColorArgsForCall = append(fake.logStdoutColorArgsForCall, struct { arg1 string }{arg1}) + stub := fake.LogStdoutColorStub + fakeReturns := fake.logStdoutColorReturns fake.recordInvocation("LogStdoutColor", []interface{}{arg1}) fake.logStdoutColorMutex.Unlock() - if fake.LogStdoutColorStub != nil { - return fake.LogStdoutColorStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.logStdoutColorReturns return fakeReturns.result1 } @@ -171,15 +173,16 @@ func (fake *FakeColorLogger) LogSysHeaderColor(arg1 string) string { fake.logSysHeaderColorArgsForCall = append(fake.logSysHeaderColorArgsForCall, struct { arg1 string }{arg1}) + stub := fake.LogSysHeaderColorStub + fakeReturns := fake.logSysHeaderColorReturns fake.recordInvocation("LogSysHeaderColor", []interface{}{arg1}) fake.logSysHeaderColorMutex.Unlock() - if fake.LogSysHeaderColorStub != nil { - return fake.LogSysHeaderColorStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.logSysHeaderColorReturns return fakeReturns.result1 } diff --git a/cf/api/logs/logsfakes/fake_loggable.go b/cf/api/logs/logsfakes/fake_loggable.go index a89a655a1f7..467c0e451a1 100644 --- a/cf/api/logs/logsfakes/fake_loggable.go +++ b/cf/api/logs/logsfakes/fake_loggable.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs" ) type FakeLoggable struct { @@ -49,15 +49,16 @@ func (fake *FakeLoggable) GetSourceName() string { ret, specificReturn := fake.getSourceNameReturnsOnCall[len(fake.getSourceNameArgsForCall)] fake.getSourceNameArgsForCall = append(fake.getSourceNameArgsForCall, struct { }{}) + stub := fake.GetSourceNameStub + fakeReturns := fake.getSourceNameReturns fake.recordInvocation("GetSourceName", []interface{}{}) fake.getSourceNameMutex.Unlock() - if fake.GetSourceNameStub != nil { - return fake.GetSourceNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getSourceNameReturns return fakeReturns.result1 } @@ -102,15 +103,16 @@ func (fake *FakeLoggable) ToLog(arg1 *time.Location) string { fake.toLogArgsForCall = append(fake.toLogArgsForCall, struct { arg1 *time.Location }{arg1}) + stub := fake.ToLogStub + fakeReturns := fake.toLogReturns fake.recordInvocation("ToLog", []interface{}{arg1}) fake.toLogMutex.Unlock() - if fake.ToLogStub != nil { - return fake.ToLogStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.toLogReturns return fakeReturns.result1 } @@ -161,15 +163,16 @@ func (fake *FakeLoggable) ToSimpleLog() string { ret, specificReturn := fake.toSimpleLogReturnsOnCall[len(fake.toSimpleLogArgsForCall)] fake.toSimpleLogArgsForCall = append(fake.toSimpleLogArgsForCall, struct { }{}) + stub := fake.ToSimpleLogStub + fakeReturns := fake.toSimpleLogReturns fake.recordInvocation("ToSimpleLog", []interface{}{}) fake.toSimpleLogMutex.Unlock() - if fake.ToSimpleLogStub != nil { - return fake.ToSimpleLogStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.toSimpleLogReturns return fakeReturns.result1 } diff --git a/cf/api/logs/logsfakes/fake_repository.go b/cf/api/logs/logsfakes/fake_repository.go index 58c98a08a72..48cce75ae0a 100644 --- a/cf/api/logs/logsfakes/fake_repository.go +++ b/cf/api/logs/logsfakes/fake_repository.go @@ -4,7 +4,7 @@ package logsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs" ) type FakeRepository struct { @@ -41,9 +41,10 @@ func (fake *FakeRepository) Close() { fake.closeMutex.Lock() fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { + if stub != nil { fake.CloseStub() } } @@ -66,15 +67,16 @@ func (fake *FakeRepository) RecentLogsFor(arg1 string) ([]logs.Loggable, error) fake.recentLogsForArgsForCall = append(fake.recentLogsForArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RecentLogsForStub + fakeReturns := fake.recentLogsForReturns fake.recordInvocation("RecentLogsFor", []interface{}{arg1}) fake.recentLogsForMutex.Unlock() - if fake.RecentLogsForStub != nil { - return fake.RecentLogsForStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.recentLogsForReturns return fakeReturns.result1, fakeReturns.result2 } @@ -131,9 +133,10 @@ func (fake *FakeRepository) TailLogsFor(arg1 string, arg2 func(), arg3 chan<- lo arg3 chan<- logs.Loggable arg4 chan<- error }{arg1, arg2, arg3, arg4}) + stub := fake.TailLogsForStub fake.recordInvocation("TailLogsFor", []interface{}{arg1, arg2, arg3, arg4}) fake.tailLogsForMutex.Unlock() - if fake.TailLogsForStub != nil { + if stub != nil { fake.TailLogsForStub(arg1, arg2, arg3, arg4) } } diff --git a/cf/api/organizations/organizations.go b/cf/api/organizations/organizations.go index d376547ed76..3ea3a78e7b3 100644 --- a/cf/api/organizations/organizations.go +++ b/cf/api/organizations/organizations.go @@ -5,11 +5,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . OrganizationRepository diff --git a/cf/api/organizations/organizations_suite_test.go b/cf/api/organizations/organizations_suite_test.go index 967c5f0cba3..e86bfb1bb28 100644 --- a/cf/api/organizations/organizations_suite_test.go +++ b/cf/api/organizations/organizations_suite_test.go @@ -1,9 +1,9 @@ package organizations_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/organizations/organizations_test.go b/cf/api/organizations/organizations_test.go index ce3e458c910..530d7a83342 100644 --- a/cf/api/organizations/organizations_test.go +++ b/cf/api/organizations/organizations_test.go @@ -5,18 +5,18 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) @@ -107,7 +107,7 @@ var _ = Describe("Organization Repository", func() { Expect(len(orgs)).To(Equal(3)) }) - It("lists the orgs from the the /v2/orgs endpoint in alphabetical order", func() { + It("lists the orgs from the /v2/orgs endpoint in alphabetical order", func() { orgs, apiErr := repo.ListOrgs(0) Expect(len(orgs)).To(Equal(3)) diff --git a/cf/api/organizations/organizationsfakes/fake_organization_repository.go b/cf/api/organizations/organizationsfakes/fake_organization_repository.go index 316d80c421b..445c739dd44 100644 --- a/cf/api/organizations/organizationsfakes/fake_organization_repository.go +++ b/cf/api/organizations/organizationsfakes/fake_organization_repository.go @@ -4,8 +4,8 @@ package organizationsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeOrganizationRepository struct { @@ -116,15 +116,16 @@ func (fake *FakeOrganizationRepository) Create(arg1 models.Organization) error { fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 models.Organization }{arg1}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -176,15 +177,16 @@ func (fake *FakeOrganizationRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -236,15 +238,16 @@ func (fake *FakeOrganizationRepository) FindByName(arg1 string) (models.Organiza fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -304,15 +307,16 @@ func (fake *FakeOrganizationRepository) GetManyOrgsByGUID(arg1 []string) ([]mode fake.getManyOrgsByGUIDArgsForCall = append(fake.getManyOrgsByGUIDArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.GetManyOrgsByGUIDStub + fakeReturns := fake.getManyOrgsByGUIDReturns fake.recordInvocation("GetManyOrgsByGUID", []interface{}{arg1Copy}) fake.getManyOrgsByGUIDMutex.Unlock() - if fake.GetManyOrgsByGUIDStub != nil { - return fake.GetManyOrgsByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getManyOrgsByGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -367,15 +371,16 @@ func (fake *FakeOrganizationRepository) ListOrgs(arg1 int) ([]models.Organizatio fake.listOrgsArgsForCall = append(fake.listOrgsArgsForCall, struct { arg1 int }{arg1}) + stub := fake.ListOrgsStub + fakeReturns := fake.listOrgsReturns fake.recordInvocation("ListOrgs", []interface{}{arg1}) fake.listOrgsMutex.Unlock() - if fake.ListOrgsStub != nil { - return fake.ListOrgsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listOrgsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -431,15 +436,16 @@ func (fake *FakeOrganizationRepository) Rename(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.RenameStub + fakeReturns := fake.renameReturns fake.recordInvocation("Rename", []interface{}{arg1, arg2}) fake.renameMutex.Unlock() - if fake.RenameStub != nil { - return fake.RenameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.renameReturns return fakeReturns.result1 } @@ -492,15 +498,16 @@ func (fake *FakeOrganizationRepository) SharePrivateDomain(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.SharePrivateDomainStub + fakeReturns := fake.sharePrivateDomainReturns fake.recordInvocation("SharePrivateDomain", []interface{}{arg1, arg2}) fake.sharePrivateDomainMutex.Unlock() - if fake.SharePrivateDomainStub != nil { - return fake.SharePrivateDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.sharePrivateDomainReturns return fakeReturns.result1 } @@ -553,15 +560,16 @@ func (fake *FakeOrganizationRepository) UnsharePrivateDomain(arg1 string, arg2 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnsharePrivateDomainStub + fakeReturns := fake.unsharePrivateDomainReturns fake.recordInvocation("UnsharePrivateDomain", []interface{}{arg1, arg2}) fake.unsharePrivateDomainMutex.Unlock() - if fake.UnsharePrivateDomainStub != nil { - return fake.UnsharePrivateDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unsharePrivateDomainReturns return fakeReturns.result1 } diff --git a/cf/api/password/password.go b/cf/api/password/password.go index 639248f2b97..2b579f7a501 100644 --- a/cf/api/password/password.go +++ b/cf/api/password/password.go @@ -5,10 +5,10 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Repository diff --git a/cf/api/password/password_suite_test.go b/cf/api/password/password_suite_test.go index 4cc33137c4e..26cbe329a4a 100644 --- a/cf/api/password/password_suite_test.go +++ b/cf/api/password/password_suite_test.go @@ -1,9 +1,9 @@ package password_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/password/password_test.go b/cf/api/password/password_test.go index e862eeb0367..d34d9d5404c 100644 --- a/cf/api/password/password_test.go +++ b/cf/api/password/password_test.go @@ -5,16 +5,16 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api/password" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/password" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/password/passwordfakes/fake_repository.go b/cf/api/password/passwordfakes/fake_repository.go index 2ba9b6b5e18..f51e15aca92 100644 --- a/cf/api/password/passwordfakes/fake_repository.go +++ b/cf/api/password/passwordfakes/fake_repository.go @@ -4,7 +4,7 @@ package passwordfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/password" + "code.cloudfoundry.org/cli/v8/cf/api/password" ) type FakeRepository struct { @@ -31,15 +31,16 @@ func (fake *FakeRepository) UpdatePassword(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.UpdatePasswordStub + fakeReturns := fake.updatePasswordReturns fake.recordInvocation("UpdatePassword", []interface{}{arg1, arg2}) fake.updatePasswordMutex.Unlock() - if fake.UpdatePasswordStub != nil { - return fake.UpdatePasswordStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.updatePasswordReturns return fakeReturns.result1 } diff --git a/cf/api/quotas/quotas.go b/cf/api/quotas/quotas.go index 3781151ec11..f13d17b6b06 100644 --- a/cf/api/quotas/quotas.go +++ b/cf/api/quotas/quotas.go @@ -5,11 +5,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . QuotaRepository diff --git a/cf/api/quotas/quotas_suite_test.go b/cf/api/quotas/quotas_suite_test.go index ddfc0f192cc..5199e6cb471 100644 --- a/cf/api/quotas/quotas_suite_test.go +++ b/cf/api/quotas/quotas_suite_test.go @@ -1,9 +1,9 @@ package quotas_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/quotas/quotas_test.go b/cf/api/quotas/quotas_test.go index 5f74f846408..74e278c73e6 100644 --- a/cf/api/quotas/quotas_test.go +++ b/cf/api/quotas/quotas_test.go @@ -4,20 +4,20 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" "github.com/onsi/gomega/ghttp" "encoding/json" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/quotas/quotasfakes/fake_quota_repository.go b/cf/api/quotas/quotasfakes/fake_quota_repository.go index cd31317b515..b557c2341e0 100644 --- a/cf/api/quotas/quotasfakes/fake_quota_repository.go +++ b/cf/api/quotas/quotasfakes/fake_quota_repository.go @@ -4,8 +4,8 @@ package quotasfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeQuotaRepository struct { @@ -90,15 +90,16 @@ func (fake *FakeQuotaRepository) AssignQuotaToOrg(arg1 string, arg2 string) erro arg1 string arg2 string }{arg1, arg2}) + stub := fake.AssignQuotaToOrgStub + fakeReturns := fake.assignQuotaToOrgReturns fake.recordInvocation("AssignQuotaToOrg", []interface{}{arg1, arg2}) fake.assignQuotaToOrgMutex.Unlock() - if fake.AssignQuotaToOrgStub != nil { - return fake.AssignQuotaToOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.assignQuotaToOrgReturns return fakeReturns.result1 } @@ -150,15 +151,16 @@ func (fake *FakeQuotaRepository) Create(arg1 models.QuotaFields) error { fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 models.QuotaFields }{arg1}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -210,15 +212,16 @@ func (fake *FakeQuotaRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -269,15 +272,16 @@ func (fake *FakeQuotaRepository) FindAll() ([]models.QuotaFields, error) { ret, specificReturn := fake.findAllReturnsOnCall[len(fake.findAllArgsForCall)] fake.findAllArgsForCall = append(fake.findAllArgsForCall, struct { }{}) + stub := fake.FindAllStub + fakeReturns := fake.findAllReturns fake.recordInvocation("FindAll", []interface{}{}) fake.findAllMutex.Unlock() - if fake.FindAllStub != nil { - return fake.FindAllStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findAllReturns return fakeReturns.result1, fakeReturns.result2 } @@ -325,15 +329,16 @@ func (fake *FakeQuotaRepository) FindByName(arg1 string) (models.QuotaFields, er fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -388,15 +393,16 @@ func (fake *FakeQuotaRepository) Update(arg1 models.QuotaFields) error { fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.QuotaFields }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/repository_locator.go b/cf/api/repository_locator.go index ef80f3d7cc7..9cb7048b0f4 100644 --- a/cf/api/repository_locator.go +++ b/cf/api/repository_locator.go @@ -1,33 +1,34 @@ package api import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/cf/api/appevents" - api_appfiles "code.cloudfoundry.org/cli/cf/api/appfiles" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/api/applicationbits" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/api/copyapplicationsource" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/password" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - securitygroupspaces "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + v7action2 "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/cf/api/appevents" + api_appfiles "code.cloudfoundry.org/cli/v8/cf/api/appfiles" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/api/applicationbits" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/api/copyapplicationsource" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/password" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + securitygroupspaces "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type RepositoryLocator struct { @@ -100,7 +101,11 @@ func NewRepositoryLocator(config coreconfig.ReadWriter, gatewaysByName map[strin } logCacheURL := configV3.ConfigFile.LogCacheEndpoint - logCacheClient := command.NewLogCacheClient(logCacheURL, configV3, nil) + logCacheClient, err := logcache.NewClient(logCacheURL, configV3, nil, v7action2.NewDefaultKubernetesConfigGetter()) + if err != nil { + panic("handle this error!") + } + loc.logsRepo = logs.NewLogCacheRepository(logCacheClient, sharedaction.GetRecentLogs, sharedaction.GetStreamingLogs) loc.organizationRepo = organizations.NewCloudControllerOrganizationRepository(config, cloudControllerGateway) diff --git a/cf/api/resources/applications.go b/cf/api/resources/applications.go index 16e8e1a11b6..535ed651711 100644 --- a/cf/api/resources/applications.go +++ b/cf/api/resources/applications.go @@ -4,7 +4,7 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" ) type PaginatedApplicationResources struct { diff --git a/cf/api/resources/applications_test.go b/cf/api/resources/applications_test.go index dbf863e83e6..46af57fade2 100644 --- a/cf/api/resources/applications_test.go +++ b/cf/api/resources/applications_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "time" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/auth_tokens.go b/cf/api/resources/auth_tokens.go index e39dd918f19..94c6d667076 100644 --- a/cf/api/resources/auth_tokens.go +++ b/cf/api/resources/auth_tokens.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedAuthTokenResources struct { Resources []AuthTokenResource diff --git a/cf/api/resources/buildpacks.go b/cf/api/resources/buildpacks.go index 12db203a222..4e6993b9404 100644 --- a/cf/api/resources/buildpacks.go +++ b/cf/api/resources/buildpacks.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type BuildpackResource struct { Resource diff --git a/cf/api/resources/domains.go b/cf/api/resources/domains.go index 4a0488ae7c8..36b5421f519 100644 --- a/cf/api/resources/domains.go +++ b/cf/api/resources/domains.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type DomainResource struct { Resource diff --git a/cf/api/resources/events.go b/cf/api/resources/events.go index a94d520589e..5480d11dfb2 100644 --- a/cf/api/resources/events.go +++ b/cf/api/resources/events.go @@ -6,9 +6,9 @@ import ( "strings" "time" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/util/generic" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/util/generic" ) type EventResource interface { @@ -57,12 +57,12 @@ func (resource EventResourceOldV2) ToFields() models.EventFields { GUID: resource.Metadata.GUID, Name: T("app crashed"), Timestamp: resource.Entity.Timestamp, - Description: fmt.Sprintf(T("instance: {{.InstanceIndex}}, reason: {{.ExitDescription}}, exit_status: {{.ExitStatus}}", + Description: T("instance: {{.InstanceIndex}}, reason: {{.ExitDescription}}, exit_status: {{.ExitStatus}}", map[string]interface{}{ "InstanceIndex": resource.Entity.InstanceIndex, "ExitDescription": resource.Entity.ExitDescription, "ExitStatus": strconv.Itoa(resource.Entity.ExitStatus), - })), + }), } } diff --git a/cf/api/resources/events_test.go b/cf/api/resources/events_test.go index 23588ddc586..c2bd07aede3 100644 --- a/cf/api/resources/events_test.go +++ b/cf/api/resources/events_test.go @@ -5,8 +5,8 @@ import ( "time" - . "code.cloudfoundry.org/cli/cf/api/resources" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/feature_flags.go b/cf/api/resources/feature_flags.go index c800c492072..74d98babd93 100644 --- a/cf/api/resources/feature_flags.go +++ b/cf/api/resources/feature_flags.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type FeatureFlagResource struct { Entity models.FeatureFlag diff --git a/cf/api/resources/organizations.go b/cf/api/resources/organizations.go index de7677b6f7e..dc109565ad9 100644 --- a/cf/api/resources/organizations.go +++ b/cf/api/resources/organizations.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type OrganizationResource struct { Resource diff --git a/cf/api/resources/quotas.go b/cf/api/resources/quotas.go index be3234992b7..48ea9a5e225 100644 --- a/cf/api/resources/quotas.go +++ b/cf/api/resources/quotas.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedQuotaResources struct { Resources []QuotaResource diff --git a/cf/api/resources/quotas_test.go b/cf/api/resources/quotas_test.go index 48ec1db79a0..3306b6f37af 100644 --- a/cf/api/resources/quotas_test.go +++ b/cf/api/resources/quotas_test.go @@ -1,11 +1,11 @@ package resources_test import ( - . "code.cloudfoundry.org/cli/cf/api/resources" + . "code.cloudfoundry.org/cli/v8/cf/api/resources" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" "encoding/json" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/resources_test.go b/cf/api/resources/resources_test.go index bf510976af2..1ecf4c9b0fd 100644 --- a/cf/api/resources/resources_test.go +++ b/cf/api/resources/resources_test.go @@ -3,9 +3,9 @@ package resources_test import ( "testing" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/routes.go b/cf/api/resources/routes.go index 55e8ac47497..a21da2a76b6 100644 --- a/cf/api/resources/routes.go +++ b/cf/api/resources/routes.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type RouteResource struct { Resource diff --git a/cf/api/resources/security_groups.go b/cf/api/resources/security_groups.go index 5b4a58f3c20..120eed5d746 100644 --- a/cf/api/resources/security_groups.go +++ b/cf/api/resources/security_groups.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedSecurityGroupResources struct { Resources []SecurityGroupResource diff --git a/cf/api/resources/service_bindings.go b/cf/api/resources/service_bindings.go index df28cd11f6b..411026c719f 100644 --- a/cf/api/resources/service_bindings.go +++ b/cf/api/resources/service_bindings.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type ServiceBindingResource struct { Resource diff --git a/cf/api/resources/service_brokers.go b/cf/api/resources/service_brokers.go index ad37ad9ce43..e42fe2825da 100644 --- a/cf/api/resources/service_brokers.go +++ b/cf/api/resources/service_brokers.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type ServiceBrokerResource struct { Resource diff --git a/cf/api/resources/service_instances.go b/cf/api/resources/service_instances.go index a8315a66308..a13bb43b320 100644 --- a/cf/api/resources/service_instances.go +++ b/cf/api/resources/service_instances.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedServiceInstanceResources struct { TotalResults int `json:"total_results"` diff --git a/cf/api/resources/service_instances_test.go b/cf/api/resources/service_instances_test.go index 48e943ff6d3..9af6584bb59 100644 --- a/cf/api/resources/service_instances_test.go +++ b/cf/api/resources/service_instances_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" - . "code.cloudfoundry.org/cli/cf/api/resources" + . "code.cloudfoundry.org/cli/v8/cf/api/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/service_keys.go b/cf/api/resources/service_keys.go index 6727fe33101..c4731821aa6 100644 --- a/cf/api/resources/service_keys.go +++ b/cf/api/resources/service_keys.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type ServiceKeyResource struct { Resource diff --git a/cf/api/resources/service_keys_test.go b/cf/api/resources/service_keys_test.go index daa6af0a921..1680cfa90d9 100644 --- a/cf/api/resources/service_keys_test.go +++ b/cf/api/resources/service_keys_test.go @@ -3,9 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/cf/api/resources" + . "code.cloudfoundry.org/cli/v8/cf/api/resources" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/resources/service_offerings.go b/cf/api/resources/service_offerings.go index 5cc8cc26752..a86a41a78c7 100644 --- a/cf/api/resources/service_offerings.go +++ b/cf/api/resources/service_offerings.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strconv" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" ) type PaginatedServiceOfferingResources struct { diff --git a/cf/api/resources/service_plan_visibility.go b/cf/api/resources/service_plan_visibility.go index 939bb16c8a8..ac4fa03415a 100644 --- a/cf/api/resources/service_plan_visibility.go +++ b/cf/api/resources/service_plan_visibility.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type ServicePlanVisibilityResource struct { Resource diff --git a/cf/api/resources/service_plans.go b/cf/api/resources/service_plans.go index 1e310d00211..17566b912d2 100644 --- a/cf/api/resources/service_plans.go +++ b/cf/api/resources/service_plans.go @@ -3,7 +3,7 @@ package resources import ( "fmt" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" ) type ServicePlanResource struct { diff --git a/cf/api/resources/space_quotas.go b/cf/api/resources/space_quotas.go index 8a3d8658a43..98a76525381 100644 --- a/cf/api/resources/space_quotas.go +++ b/cf/api/resources/space_quotas.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedSpaceQuotaResources struct { Resources []SpaceQuotaResource diff --git a/cf/api/resources/spaces.go b/cf/api/resources/spaces.go index e081c3fed6c..293baa16cce 100644 --- a/cf/api/resources/spaces.go +++ b/cf/api/resources/spaces.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type SpaceResource struct { Resource diff --git a/cf/api/resources/stacks.go b/cf/api/resources/stacks.go index fd114673cde..98bcc209a5f 100644 --- a/cf/api/resources/stacks.go +++ b/cf/api/resources/stacks.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type PaginatedStackResources struct { Resources []StackResource diff --git a/cf/api/resources/users.go b/cf/api/resources/users.go index 61cbd23e463..6e7a3954225 100644 --- a/cf/api/resources/users.go +++ b/cf/api/resources/users.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/cf/models" +import "code.cloudfoundry.org/cli/v8/cf/models" type UserResource struct { Resource diff --git a/cf/api/route_service_binding_repository.go b/cf/api/route_service_binding_repository.go index 85215a48b17..6eff9be5527 100644 --- a/cf/api/route_service_binding_repository.go +++ b/cf/api/route_service_binding_repository.go @@ -7,8 +7,8 @@ import ( "io" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RouteServiceBindingRepository diff --git a/cf/api/route_service_binding_repository_test.go b/cf/api/route_service_binding_repository_test.go index e92593210fa..afc33fe2026 100644 --- a/cf/api/route_service_binding_repository_test.go +++ b/cf/api/route_service_binding_repository_test.go @@ -5,18 +5,18 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" "github.com/onsi/gomega/ghttp" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/routes.go b/cf/api/routes.go index 0fc4f405cf8..aeacee023d7 100644 --- a/cf/api/routes.go +++ b/cf/api/routes.go @@ -7,11 +7,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" "github.com/google/go-querystring/query" ) diff --git a/cf/api/routes_test.go b/cf/api/routes_test.go index cd46a0c2cad..40b5ba5c8f2 100644 --- a/cf/api/routes_test.go +++ b/cf/api/routes_test.go @@ -6,19 +6,19 @@ import ( "net/url" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/routing_api.go b/cf/api/routing_api.go index 08cf6fd970c..f045ab88034 100644 --- a/cf/api/routing_api.go +++ b/cf/api/routing_api.go @@ -3,9 +3,9 @@ package api import ( "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) type routingAPIRepository struct { diff --git a/cf/api/routing_api_test.go b/cf/api/routing_api_test.go index e900e062fdf..38311e2c9fc 100644 --- a/cf/api/routing_api_test.go +++ b/cf/api/routing_api_test.go @@ -6,15 +6,15 @@ import ( "strconv" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/securitygroups/defaults/defaults.go b/cf/api/securitygroups/defaults/defaults.go index 57e0e08d5d3..cfc9e629f48 100644 --- a/cf/api/securitygroups/defaults/defaults.go +++ b/cf/api/securitygroups/defaults/defaults.go @@ -3,10 +3,10 @@ package defaults import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) type DefaultSecurityGroupsRepoBase struct { diff --git a/cf/api/securitygroups/defaults/running/running.go b/cf/api/securitygroups/defaults/running/running.go index 879669a72f6..5a8018b0497 100644 --- a/cf/api/securitygroups/defaults/running/running.go +++ b/cf/api/securitygroups/defaults/running/running.go @@ -1,11 +1,11 @@ package running import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - . "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults" + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults" ) const urlPath = "/v2/config/running_security_groups" diff --git a/cf/api/securitygroups/defaults/running/running_suite_test.go b/cf/api/securitygroups/defaults/running/running_suite_test.go index 6905947b397..d071aca402c 100644 --- a/cf/api/securitygroups/defaults/running/running_suite_test.go +++ b/cf/api/securitygroups/defaults/running/running_suite_test.go @@ -1,9 +1,9 @@ package running_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/securitygroups/defaults/running/running_test.go b/cf/api/securitygroups/defaults/running/running_test.go index 82e2e17039a..9fb0868740b 100644 --- a/cf/api/securitygroups/defaults/running/running_test.go +++ b/cf/api/securitygroups/defaults/running/running_test.go @@ -5,18 +5,18 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/securitygroups/defaults/running/runningfakes/fake_security_groups_repo.go b/cf/api/securitygroups/defaults/running/runningfakes/fake_security_groups_repo.go index 22b51815f6d..faeaa275053 100644 --- a/cf/api/securitygroups/defaults/running/runningfakes/fake_security_groups_repo.go +++ b/cf/api/securitygroups/defaults/running/runningfakes/fake_security_groups_repo.go @@ -4,8 +4,8 @@ package runningfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeSecurityGroupsRepo struct { @@ -53,15 +53,16 @@ func (fake *FakeSecurityGroupsRepo) BindToRunningSet(arg1 string) error { fake.bindToRunningSetArgsForCall = append(fake.bindToRunningSetArgsForCall, struct { arg1 string }{arg1}) + stub := fake.BindToRunningSetStub + fakeReturns := fake.bindToRunningSetReturns fake.recordInvocation("BindToRunningSet", []interface{}{arg1}) fake.bindToRunningSetMutex.Unlock() - if fake.BindToRunningSetStub != nil { - return fake.BindToRunningSetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindToRunningSetReturns return fakeReturns.result1 } @@ -112,15 +113,16 @@ func (fake *FakeSecurityGroupsRepo) List() ([]models.SecurityGroupFields, error) ret, specificReturn := fake.listReturnsOnCall[len(fake.listArgsForCall)] fake.listArgsForCall = append(fake.listArgsForCall, struct { }{}) + stub := fake.ListStub + fakeReturns := fake.listReturns fake.recordInvocation("List", []interface{}{}) fake.listMutex.Unlock() - if fake.ListStub != nil { - return fake.ListStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listReturns return fakeReturns.result1, fakeReturns.result2 } @@ -168,15 +170,16 @@ func (fake *FakeSecurityGroupsRepo) UnbindFromRunningSet(arg1 string) error { fake.unbindFromRunningSetArgsForCall = append(fake.unbindFromRunningSetArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UnbindFromRunningSetStub + fakeReturns := fake.unbindFromRunningSetReturns fake.recordInvocation("UnbindFromRunningSet", []interface{}{arg1}) fake.unbindFromRunningSetMutex.Unlock() - if fake.UnbindFromRunningSetStub != nil { - return fake.UnbindFromRunningSetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindFromRunningSetReturns return fakeReturns.result1 } diff --git a/cf/api/securitygroups/defaults/staging/staging.go b/cf/api/securitygroups/defaults/staging/staging.go index d75143f1653..abafa4a1f5e 100644 --- a/cf/api/securitygroups/defaults/staging/staging.go +++ b/cf/api/securitygroups/defaults/staging/staging.go @@ -1,11 +1,11 @@ package staging import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - . "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults" + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults" ) const urlPath = "/v2/config/staging_security_groups" diff --git a/cf/api/securitygroups/defaults/staging/staging_suite_test.go b/cf/api/securitygroups/defaults/staging/staging_suite_test.go index 9c9776d5890..46ff3f88a74 100644 --- a/cf/api/securitygroups/defaults/staging/staging_suite_test.go +++ b/cf/api/securitygroups/defaults/staging/staging_suite_test.go @@ -1,9 +1,9 @@ package staging_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/securitygroups/defaults/staging/staging_test.go b/cf/api/securitygroups/defaults/staging/staging_test.go index c326a30f610..b4d2e1caee0 100644 --- a/cf/api/securitygroups/defaults/staging/staging_test.go +++ b/cf/api/securitygroups/defaults/staging/staging_test.go @@ -5,18 +5,18 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - . "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/securitygroups/defaults/staging/stagingfakes/fake_security_groups_repo.go b/cf/api/securitygroups/defaults/staging/stagingfakes/fake_security_groups_repo.go index 5b4f8a39bfd..0acd51612e2 100644 --- a/cf/api/securitygroups/defaults/staging/stagingfakes/fake_security_groups_repo.go +++ b/cf/api/securitygroups/defaults/staging/stagingfakes/fake_security_groups_repo.go @@ -4,8 +4,8 @@ package stagingfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeSecurityGroupsRepo struct { @@ -53,15 +53,16 @@ func (fake *FakeSecurityGroupsRepo) BindToStagingSet(arg1 string) error { fake.bindToStagingSetArgsForCall = append(fake.bindToStagingSetArgsForCall, struct { arg1 string }{arg1}) + stub := fake.BindToStagingSetStub + fakeReturns := fake.bindToStagingSetReturns fake.recordInvocation("BindToStagingSet", []interface{}{arg1}) fake.bindToStagingSetMutex.Unlock() - if fake.BindToStagingSetStub != nil { - return fake.BindToStagingSetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindToStagingSetReturns return fakeReturns.result1 } @@ -112,15 +113,16 @@ func (fake *FakeSecurityGroupsRepo) List() ([]models.SecurityGroupFields, error) ret, specificReturn := fake.listReturnsOnCall[len(fake.listArgsForCall)] fake.listArgsForCall = append(fake.listArgsForCall, struct { }{}) + stub := fake.ListStub + fakeReturns := fake.listReturns fake.recordInvocation("List", []interface{}{}) fake.listMutex.Unlock() - if fake.ListStub != nil { - return fake.ListStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listReturns return fakeReturns.result1, fakeReturns.result2 } @@ -168,15 +170,16 @@ func (fake *FakeSecurityGroupsRepo) UnbindFromStagingSet(arg1 string) error { fake.unbindFromStagingSetArgsForCall = append(fake.unbindFromStagingSetArgsForCall, struct { arg1 string }{arg1}) + stub := fake.UnbindFromStagingSetStub + fakeReturns := fake.unbindFromStagingSetReturns fake.recordInvocation("UnbindFromStagingSet", []interface{}{arg1}) fake.unbindFromStagingSetMutex.Unlock() - if fake.UnbindFromStagingSetStub != nil { - return fake.UnbindFromStagingSetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindFromStagingSetReturns return fakeReturns.result1 } diff --git a/cf/api/securitygroups/security_groups.go b/cf/api/securitygroups/security_groups.go index 4e72ff80857..86dddfc861b 100644 --- a/cf/api/securitygroups/security_groups.go +++ b/cf/api/securitygroups/security_groups.go @@ -4,11 +4,11 @@ import ( "fmt" "net/url" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SecurityGroupRepo diff --git a/cf/api/securitygroups/security_groups_suite_test.go b/cf/api/securitygroups/security_groups_suite_test.go index bd8a597549a..f35c5e93a00 100644 --- a/cf/api/securitygroups/security_groups_suite_test.go +++ b/cf/api/securitygroups/security_groups_suite_test.go @@ -1,9 +1,9 @@ package securitygroups_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/securitygroups/security_groups_test.go b/cf/api/securitygroups/security_groups_test.go index 950486f1f62..7360b1c0df9 100644 --- a/cf/api/securitygroups/security_groups_test.go +++ b/cf/api/securitygroups/security_groups_test.go @@ -5,19 +5,19 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/securitygroups/securitygroupsfakes/fake_security_group_repo.go b/cf/api/securitygroups/securitygroupsfakes/fake_security_group_repo.go index 7d6736c7f52..e6a9aca6eeb 100644 --- a/cf/api/securitygroups/securitygroupsfakes/fake_security_group_repo.go +++ b/cf/api/securitygroups/securitygroupsfakes/fake_security_group_repo.go @@ -4,8 +4,8 @@ package securitygroupsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeSecurityGroupRepo struct { @@ -85,15 +85,16 @@ func (fake *FakeSecurityGroupRepo) Create(arg1 string, arg2 []map[string]interfa arg1 string arg2 []map[string]interface{} }{arg1, arg2Copy}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2Copy}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -145,15 +146,16 @@ func (fake *FakeSecurityGroupRepo) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -204,15 +206,16 @@ func (fake *FakeSecurityGroupRepo) FindAll() ([]models.SecurityGroup, error) { ret, specificReturn := fake.findAllReturnsOnCall[len(fake.findAllArgsForCall)] fake.findAllArgsForCall = append(fake.findAllArgsForCall, struct { }{}) + stub := fake.FindAllStub + fakeReturns := fake.findAllReturns fake.recordInvocation("FindAll", []interface{}{}) fake.findAllMutex.Unlock() - if fake.FindAllStub != nil { - return fake.FindAllStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findAllReturns return fakeReturns.result1, fakeReturns.result2 } @@ -260,15 +263,16 @@ func (fake *FakeSecurityGroupRepo) Read(arg1 string) (models.SecurityGroup, erro fake.readArgsForCall = append(fake.readArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ReadStub + fakeReturns := fake.readReturns fake.recordInvocation("Read", []interface{}{arg1}) fake.readMutex.Unlock() - if fake.ReadStub != nil { - return fake.ReadStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readReturns return fakeReturns.result1, fakeReturns.result2 } @@ -329,15 +333,16 @@ func (fake *FakeSecurityGroupRepo) Update(arg1 string, arg2 []map[string]interfa arg1 string arg2 []map[string]interface{} }{arg1, arg2Copy}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1, arg2Copy}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/securitygroups/spaces/space_binder.go b/cf/api/securitygroups/spaces/space_binder.go index 16691d3a03d..4112df26d98 100644 --- a/cf/api/securitygroups/spaces/space_binder.go +++ b/cf/api/securitygroups/spaces/space_binder.go @@ -3,9 +3,9 @@ package spaces import ( "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SecurityGroupSpaceBinder diff --git a/cf/api/securitygroups/spaces/space_binder_test.go b/cf/api/securitygroups/spaces/space_binder_test.go index 5c592dd0984..7c1fcf06eab 100644 --- a/cf/api/securitygroups/spaces/space_binder_test.go +++ b/cf/api/securitygroups/spaces/space_binder_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/securitygroups/spaces/spacesfakes/fake_security_group_space_binder.go b/cf/api/securitygroups/spaces/spacesfakes/fake_security_group_space_binder.go index 768032bd026..d5620bf1d38 100644 --- a/cf/api/securitygroups/spaces/spacesfakes/fake_security_group_space_binder.go +++ b/cf/api/securitygroups/spaces/spacesfakes/fake_security_group_space_binder.go @@ -4,7 +4,7 @@ package spacesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces" ) type FakeSecurityGroupSpaceBinder struct { @@ -43,15 +43,16 @@ func (fake *FakeSecurityGroupSpaceBinder) BindSpace(arg1 string, arg2 string) er arg1 string arg2 string }{arg1, arg2}) + stub := fake.BindSpaceStub + fakeReturns := fake.bindSpaceReturns fake.recordInvocation("BindSpace", []interface{}{arg1, arg2}) fake.bindSpaceMutex.Unlock() - if fake.BindSpaceStub != nil { - return fake.BindSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindSpaceReturns return fakeReturns.result1 } @@ -104,15 +105,16 @@ func (fake *FakeSecurityGroupSpaceBinder) UnbindSpace(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnbindSpaceStub + fakeReturns := fake.unbindSpaceReturns fake.recordInvocation("UnbindSpace", []interface{}{arg1, arg2}) fake.unbindSpaceMutex.Unlock() - if fake.UnbindSpaceStub != nil { - return fake.UnbindSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindSpaceReturns return fakeReturns.result1 } diff --git a/cf/api/securitygroups/spaces/suite_test.go b/cf/api/securitygroups/spaces/suite_test.go index 4f5f14b2604..3eda6b8f7cc 100644 --- a/cf/api/securitygroups/spaces/suite_test.go +++ b/cf/api/securitygroups/spaces/suite_test.go @@ -1,9 +1,9 @@ package spaces_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/service_auth_tokens.go b/cf/api/service_auth_tokens.go index 931327e870d..0ac8af9ad0c 100644 --- a/cf/api/service_auth_tokens.go +++ b/cf/api/service_auth_tokens.go @@ -5,11 +5,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceAuthTokenRepository diff --git a/cf/api/service_auth_tokens_test.go b/cf/api/service_auth_tokens_test.go index df138ca79ab..e134158314b 100644 --- a/cf/api/service_auth_tokens_test.go +++ b/cf/api/service_auth_tokens_test.go @@ -5,19 +5,19 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/service_bindings.go b/cf/api/service_bindings.go index 05d9118e84a..f9c0cc69261 100644 --- a/cf/api/service_bindings.go +++ b/cf/api/service_bindings.go @@ -5,10 +5,10 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceBindingRepository diff --git a/cf/api/service_bindings_test.go b/cf/api/service_bindings_test.go index 4a94561309b..5c1b0509a58 100644 --- a/cf/api/service_bindings_test.go +++ b/cf/api/service_bindings_test.go @@ -4,16 +4,16 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/service_brokers.go b/cf/api/service_brokers.go index df0080320fd..d526bcf1edf 100644 --- a/cf/api/service_brokers.go +++ b/cf/api/service_brokers.go @@ -7,11 +7,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceBrokerRepository diff --git a/cf/api/service_brokers_test.go b/cf/api/service_brokers_test.go index 232f611c400..7a6290f664a 100644 --- a/cf/api/service_brokers_test.go +++ b/cf/api/service_brokers_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) @@ -203,7 +203,7 @@ var _ = Describe("Service Brokers Repo", func() { req := apifakes.NewCloudControllerTestRequest(testnet.TestRequest{ Method: "GET", Path: "/v2/service_brokers/bogus-guid", - //This error code may not reflect reality. Check it, change the code to match, and remove this comment. + // This error code may not reflect reality. Check it, change the code to match, and remove this comment. Response: testnet.TestResponse{Status: http.StatusNotFound, Body: `{"error_code":"ServiceBrokerNotFound","description":"Service Broker bogus-guid not found","code":270042}`}, }) diff --git a/cf/api/service_keys.go b/cf/api/service_keys.go index c7e2c006e98..285fc9dadfb 100644 --- a/cf/api/service_keys.go +++ b/cf/api/service_keys.go @@ -6,11 +6,11 @@ import ( "fmt" "net/url" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceKeyRepository diff --git a/cf/api/service_keys_test.go b/cf/api/service_keys_test.go index f8fb7a9cc1a..b9b9cc6df69 100644 --- a/cf/api/service_keys_test.go +++ b/cf/api/service_keys_test.go @@ -4,20 +4,20 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" "github.com/onsi/gomega/ghttp" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - . "code.cloudfoundry.org/cli/cf/api" + . "code.cloudfoundry.org/cli/v8/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/service_plan.go b/cf/api/service_plan.go index a2ad0291a9c..fa8b2515e2c 100644 --- a/cf/api/service_plan.go +++ b/cf/api/service_plan.go @@ -5,10 +5,10 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServicePlanRepository diff --git a/cf/api/service_plan_test.go b/cf/api/service_plan_test.go index 377e7314b94..9e3c418d5bc 100644 --- a/cf/api/service_plan_test.go +++ b/cf/api/service_plan_test.go @@ -5,18 +5,18 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/service_plan_visibility.go b/cf/api/service_plan_visibility.go index 9d2aed39a85..af858e3168f 100644 --- a/cf/api/service_plan_visibility.go +++ b/cf/api/service_plan_visibility.go @@ -4,10 +4,10 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServicePlanVisibilityRepository diff --git a/cf/api/service_plan_visibility_test.go b/cf/api/service_plan_visibility_test.go index 860e8a9b1e6..2f1aeb69b7c 100644 --- a/cf/api/service_plan_visibility_test.go +++ b/cf/api/service_plan_visibility_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/service_summary.go b/cf/api/service_summary.go index a1920e80086..9ab0767e450 100644 --- a/cf/api/service_summary.go +++ b/cf/api/service_summary.go @@ -3,9 +3,9 @@ package api import ( "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) type ServiceInstancesSummaries struct { diff --git a/cf/api/service_summary_test.go b/cf/api/service_summary_test.go index 39fa73f6975..44b9b9cc103 100644 --- a/cf/api/service_summary_test.go +++ b/cf/api/service_summary_test.go @@ -5,16 +5,16 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/services.go b/cf/api/services.go index 87e91e208ce..bf3b755cf8f 100644 --- a/cf/api/services.go +++ b/cf/api/services.go @@ -7,11 +7,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceRepository diff --git a/cf/api/services_test.go b/cf/api/services_test.go index c1a417e12c6..15bafd9ccbc 100644 --- a/cf/api/services_test.go +++ b/cf/api/services_test.go @@ -7,20 +7,20 @@ import ( "net/url" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/spacequotas/space_quotas.go b/cf/api/spacequotas/space_quotas.go index 07ab2cb248c..ae1deea717b 100644 --- a/cf/api/spacequotas/space_quotas.go +++ b/cf/api/spacequotas/space_quotas.go @@ -4,11 +4,11 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SpaceQuotaRepository diff --git a/cf/api/spacequotas/space_quotas_suite_test.go b/cf/api/spacequotas/space_quotas_suite_test.go index 0322194b783..2bc9535515f 100644 --- a/cf/api/spacequotas/space_quotas_suite_test.go +++ b/cf/api/spacequotas/space_quotas_suite_test.go @@ -1,9 +1,9 @@ package spacequotas_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/spacequotas/space_quotas_test.go b/cf/api/spacequotas/space_quotas_test.go index 8431c9961c2..f64ab51ee0e 100644 --- a/cf/api/spacequotas/space_quotas_test.go +++ b/cf/api/spacequotas/space_quotas_test.go @@ -5,18 +5,18 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" "github.com/onsi/gomega/ghttp" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/spacequotas/spacequotasfakes/fake_space_quota_repository.go b/cf/api/spacequotas/spacequotasfakes/fake_space_quota_repository.go index c80e8b605cf..6f9e678dcd2 100644 --- a/cf/api/spacequotas/spacequotasfakes/fake_space_quota_repository.go +++ b/cf/api/spacequotas/spacequotasfakes/fake_space_quota_repository.go @@ -4,8 +4,8 @@ package spacequotasfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeSpaceQuotaRepository struct { @@ -130,15 +130,16 @@ func (fake *FakeSpaceQuotaRepository) AssociateSpaceWithQuota(arg1 string, arg2 arg1 string arg2 string }{arg1, arg2}) + stub := fake.AssociateSpaceWithQuotaStub + fakeReturns := fake.associateSpaceWithQuotaReturns fake.recordInvocation("AssociateSpaceWithQuota", []interface{}{arg1, arg2}) fake.associateSpaceWithQuotaMutex.Unlock() - if fake.AssociateSpaceWithQuotaStub != nil { - return fake.AssociateSpaceWithQuotaStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.associateSpaceWithQuotaReturns return fakeReturns.result1 } @@ -190,15 +191,16 @@ func (fake *FakeSpaceQuotaRepository) Create(arg1 models.SpaceQuota) error { fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 models.SpaceQuota }{arg1}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.createReturns return fakeReturns.result1 } @@ -250,15 +252,16 @@ func (fake *FakeSpaceQuotaRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -310,15 +313,16 @@ func (fake *FakeSpaceQuotaRepository) FindByGUID(arg1 string) (models.SpaceQuota fake.findByGUIDArgsForCall = append(fake.findByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByGUIDStub + fakeReturns := fake.findByGUIDReturns fake.recordInvocation("FindByGUID", []interface{}{arg1}) fake.findByGUIDMutex.Unlock() - if fake.FindByGUIDStub != nil { - return fake.FindByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -373,15 +377,16 @@ func (fake *FakeSpaceQuotaRepository) FindByName(arg1 string) (models.SpaceQuota fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -437,15 +442,16 @@ func (fake *FakeSpaceQuotaRepository) FindByNameAndOrgGUID(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindByNameAndOrgGUIDStub + fakeReturns := fake.findByNameAndOrgGUIDReturns fake.recordInvocation("FindByNameAndOrgGUID", []interface{}{arg1, arg2}) fake.findByNameAndOrgGUIDMutex.Unlock() - if fake.FindByNameAndOrgGUIDStub != nil { - return fake.FindByNameAndOrgGUIDStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameAndOrgGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -500,15 +506,16 @@ func (fake *FakeSpaceQuotaRepository) FindByOrg(arg1 string) ([]models.SpaceQuot fake.findByOrgArgsForCall = append(fake.findByOrgArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByOrgStub + fakeReturns := fake.findByOrgReturns fake.recordInvocation("FindByOrg", []interface{}{arg1}) fake.findByOrgMutex.Unlock() - if fake.FindByOrgStub != nil { - return fake.FindByOrgStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -564,15 +571,16 @@ func (fake *FakeSpaceQuotaRepository) UnassignQuotaFromSpace(arg1 string, arg2 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnassignQuotaFromSpaceStub + fakeReturns := fake.unassignQuotaFromSpaceReturns fake.recordInvocation("UnassignQuotaFromSpace", []interface{}{arg1, arg2}) fake.unassignQuotaFromSpaceMutex.Unlock() - if fake.UnassignQuotaFromSpaceStub != nil { - return fake.UnassignQuotaFromSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unassignQuotaFromSpaceReturns return fakeReturns.result1 } @@ -624,15 +632,16 @@ func (fake *FakeSpaceQuotaRepository) Update(arg1 models.SpaceQuota) error { fake.updateArgsForCall = append(fake.updateArgsForCall, struct { arg1 models.SpaceQuota }{arg1}) + stub := fake.UpdateStub + fakeReturns := fake.updateReturns fake.recordInvocation("Update", []interface{}{arg1}) fake.updateMutex.Unlock() - if fake.UpdateStub != nil { - return fake.UpdateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateReturns return fakeReturns.result1 } diff --git a/cf/api/spaces/spaces.go b/cf/api/spaces/spaces.go index c7421629961..1c8b5fa96e8 100644 --- a/cf/api/spaces/spaces.go +++ b/cf/api/spaces/spaces.go @@ -6,11 +6,11 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SpaceRepository diff --git a/cf/api/spaces/spaces_suite_test.go b/cf/api/spaces/spaces_suite_test.go index 5e86e2aba4d..c4eef1158a3 100644 --- a/cf/api/spaces/spaces_suite_test.go +++ b/cf/api/spaces/spaces_suite_test.go @@ -1,9 +1,9 @@ package spaces_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/spaces/spaces_test.go b/cf/api/spaces/spaces_test.go index 26bdaa5b82a..d2357147073 100644 --- a/cf/api/spaces/spaces_test.go +++ b/cf/api/spaces/spaces_test.go @@ -6,18 +6,18 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api/spaces" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api/spaces" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api/spaces/spacesfakes/fake_space_repository.go b/cf/api/spaces/spacesfakes/fake_space_repository.go index 0112f8ec720..9eb74c45960 100644 --- a/cf/api/spaces/spacesfakes/fake_space_repository.go +++ b/cf/api/spaces/spacesfakes/fake_space_repository.go @@ -4,8 +4,8 @@ package spacesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeSpaceRepository struct { @@ -121,15 +121,16 @@ func (fake *FakeSpaceRepository) Create(arg1 string, arg2 string, arg3 string) ( arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.CreateStub + fakeReturns := fake.createReturns fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3}) fake.createMutex.Unlock() - if fake.CreateStub != nil { - return fake.CreateStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createReturns return fakeReturns.result1, fakeReturns.result2 } @@ -184,15 +185,16 @@ func (fake *FakeSpaceRepository) Delete(arg1 string) error { fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteStub + fakeReturns := fake.deleteReturns fake.recordInvocation("Delete", []interface{}{arg1}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.deleteReturns return fakeReturns.result1 } @@ -244,15 +246,16 @@ func (fake *FakeSpaceRepository) FindByName(arg1 string) (models.Space, error) { fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -308,15 +311,16 @@ func (fake *FakeSpaceRepository) FindByNameInOrg(arg1 string, arg2 string) (mode arg1 string arg2 string }{arg1, arg2}) + stub := fake.FindByNameInOrgStub + fakeReturns := fake.findByNameInOrgReturns fake.recordInvocation("FindByNameInOrg", []interface{}{arg1, arg2}) fake.findByNameInOrgMutex.Unlock() - if fake.FindByNameInOrgStub != nil { - return fake.FindByNameInOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameInOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -371,15 +375,16 @@ func (fake *FakeSpaceRepository) ListSpaces(arg1 func(models.Space) bool) error fake.listSpacesArgsForCall = append(fake.listSpacesArgsForCall, struct { arg1 func(models.Space) bool }{arg1}) + stub := fake.ListSpacesStub + fakeReturns := fake.listSpacesReturns fake.recordInvocation("ListSpaces", []interface{}{arg1}) fake.listSpacesMutex.Unlock() - if fake.ListSpacesStub != nil { - return fake.ListSpacesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.listSpacesReturns return fakeReturns.result1 } @@ -432,15 +437,16 @@ func (fake *FakeSpaceRepository) ListSpacesFromOrg(arg1 string, arg2 func(models arg1 string arg2 func(models.Space) bool }{arg1, arg2}) + stub := fake.ListSpacesFromOrgStub + fakeReturns := fake.listSpacesFromOrgReturns fake.recordInvocation("ListSpacesFromOrg", []interface{}{arg1, arg2}) fake.listSpacesFromOrgMutex.Unlock() - if fake.ListSpacesFromOrgStub != nil { - return fake.ListSpacesFromOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.listSpacesFromOrgReturns return fakeReturns.result1 } @@ -493,15 +499,16 @@ func (fake *FakeSpaceRepository) Rename(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.RenameStub + fakeReturns := fake.renameReturns fake.recordInvocation("Rename", []interface{}{arg1, arg2}) fake.renameMutex.Unlock() - if fake.RenameStub != nil { - return fake.RenameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.renameReturns return fakeReturns.result1 } @@ -554,15 +561,16 @@ func (fake *FakeSpaceRepository) SetAllowSSH(arg1 string, arg2 bool) error { arg1 string arg2 bool }{arg1, arg2}) + stub := fake.SetAllowSSHStub + fakeReturns := fake.setAllowSSHReturns fake.recordInvocation("SetAllowSSH", []interface{}{arg1, arg2}) fake.setAllowSSHMutex.Unlock() - if fake.SetAllowSSHStub != nil { - return fake.SetAllowSSHStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setAllowSSHReturns return fakeReturns.result1 } diff --git a/cf/api/stacks/stacks.go b/cf/api/stacks/stacks.go index 94c5136102c..7b6c4340620 100644 --- a/cf/api/stacks/stacks.go +++ b/cf/api/stacks/stacks.go @@ -4,13 +4,13 @@ import ( "fmt" "net/url" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . StackRepository @@ -41,7 +41,7 @@ func (repo CloudControllerStackRepository) FindByGUID(guid string) (models.Stack return models.Stack{}, errNotFound } - return models.Stack{}, fmt.Errorf(T("Error retrieving stacks: {{.Error}}", map[string]interface{}{ + return models.Stack{}, errors.New(T("Error retrieving stacks: {{.Error}}", map[string]interface{}{ "Error": err.Error(), })) } diff --git a/cf/api/stacks/stacks_suite_test.go b/cf/api/stacks/stacks_suite_test.go index 576f2248dc6..6e7423b53eb 100644 --- a/cf/api/stacks/stacks_suite_test.go +++ b/cf/api/stacks/stacks_suite_test.go @@ -1,9 +1,9 @@ package stacks_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/api/stacks/stacks_test.go b/cf/api/stacks/stacks_test.go index 183ec1543c3..ff08611890e 100644 --- a/cf/api/stacks/stacks_test.go +++ b/cf/api/stacks/stacks_test.go @@ -4,19 +4,19 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" "github.com/onsi/gomega/ghttp" - . "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/stacks/stacksfakes/fake_stack_repository.go b/cf/api/stacks/stacksfakes/fake_stack_repository.go index bd4f105e3ff..f3f608b5ba5 100644 --- a/cf/api/stacks/stacksfakes/fake_stack_repository.go +++ b/cf/api/stacks/stacksfakes/fake_stack_repository.go @@ -4,8 +4,8 @@ package stacksfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeStackRepository struct { @@ -56,15 +56,16 @@ func (fake *FakeStackRepository) FindAll() ([]models.Stack, error) { ret, specificReturn := fake.findAllReturnsOnCall[len(fake.findAllArgsForCall)] fake.findAllArgsForCall = append(fake.findAllArgsForCall, struct { }{}) + stub := fake.FindAllStub + fakeReturns := fake.findAllReturns fake.recordInvocation("FindAll", []interface{}{}) fake.findAllMutex.Unlock() - if fake.FindAllStub != nil { - return fake.FindAllStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findAllReturns return fakeReturns.result1, fakeReturns.result2 } @@ -112,15 +113,16 @@ func (fake *FakeStackRepository) FindByGUID(arg1 string) (models.Stack, error) { fake.findByGUIDArgsForCall = append(fake.findByGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByGUIDStub + fakeReturns := fake.findByGUIDReturns fake.recordInvocation("FindByGUID", []interface{}{arg1}) fake.findByGUIDMutex.Unlock() - if fake.FindByGUIDStub != nil { - return fake.FindByGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -175,15 +177,16 @@ func (fake *FakeStackRepository) FindByName(arg1 string) (models.Stack, error) { fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FindByNameStub + fakeReturns := fake.findByNameReturns fake.recordInvocation("FindByName", []interface{}{arg1}) fake.findByNameMutex.Unlock() - if fake.FindByNameStub != nil { - return fake.FindByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.findByNameReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/api/user_provided_service_instances.go b/cf/api/user_provided_service_instances.go index 2f19444dedc..3431ddca8b3 100644 --- a/cf/api/user_provided_service_instances.go +++ b/cf/api/user_provided_service_instances.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UserProvidedServiceInstanceRepository diff --git a/cf/api/user_provided_service_instances_test.go b/cf/api/user_provided_service_instances_test.go index fa99f542945..9366a86aaec 100644 --- a/cf/api/user_provided_service_instances_test.go +++ b/cf/api/user_provided_service_instances_test.go @@ -5,17 +5,17 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - - . "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + + . "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/api/users.go b/cf/api/users.go index bfe2c69520c..02b9136da70 100644 --- a/cf/api/users.go +++ b/cf/api/users.go @@ -9,12 +9,12 @@ import ( neturl "net/url" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" ) var orgRoleToPathMap = map[models.Role]string{ @@ -290,7 +290,7 @@ func userGUIDPath(apiEndpoint, userGUID, orgGUID string, role models.Role) (stri func (repo CloudControllerUserRepository) SetSpaceRoleByGUID(userGUID, spaceGUID, orgGUID string, role models.Role) error { rolePath, found := spaceRoleToPathMap[role] if !found { - return fmt.Errorf(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) + return errors.New(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) } err := repo.assocUserWithOrgByUserGUID(userGUID, orgGUID) @@ -312,8 +312,8 @@ func (repo CloudControllerUserRepository) SetSpaceRoleByUsername(username, space setOrgRoleErr := apiErrResponse{} apiErr = repo.assocUserWithOrgByUsername(username, orgGUID, &setOrgRoleErr) if setOrgRoleErr.Code == 10003 { - //operator lacking the privilege to set org role - //user might already be in org, so ignoring error and attempt to set space role + // operator lacking the privilege to set org role + // user might already be in org, so ignoring error and attempt to set space role } else if apiErr != nil { return } @@ -330,7 +330,7 @@ func (repo CloudControllerUserRepository) SetSpaceRoleByUsername(username, space func (repo CloudControllerUserRepository) UnsetSpaceRoleByGUID(userGUID, spaceGUID string, role models.Role) error { rolePath, found := spaceRoleToPathMap[role] if !found { - return fmt.Errorf(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) + return errors.New(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) } apiURL := fmt.Sprintf("/v2/spaces/%s/%s/%s", spaceGUID, rolePath, userGUID) @@ -343,7 +343,7 @@ func (repo CloudControllerUserRepository) checkSpaceRole(spaceGUID string, role rolePath, found := spaceRoleToPathMap[role] if !found { - apiErr = fmt.Errorf(T("Invalid Role {{.Role}}", + apiErr = errors.New(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) } @@ -373,7 +373,7 @@ func rolePath(role models.Role) (string, error) { path, found := orgRoleToPathMap[role] if !found { - return "", fmt.Errorf(T("Invalid Role {{.Role}}", + return "", errors.New(T("Invalid Role {{.Role}}", map[string]interface{}{"Role": role})) } return path, nil diff --git a/cf/api/users_test.go b/cf/api/users_test.go index e92facd57cd..e46ae03378f 100644 --- a/cf/api/users_test.go +++ b/cf/api/users_test.go @@ -4,17 +4,17 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) diff --git a/cf/api_versions.go b/cf/api_versions.go index 2c13a519810..bc5075625dc 100644 --- a/cf/api_versions.go +++ b/cf/api_versions.go @@ -1,6 +1,6 @@ package cf -import "github.com/blang/semver" +import "github.com/blang/semver/v4" var ( UserProvidedServiceTagsMinimumAPIVersion, _ = semver.Make("2.104.0") // #158233239,#157770881 diff --git a/cf/appfiles/app_files.go b/cf/appfiles/app_files.go index 216d1107676..482bf596983 100644 --- a/cf/appfiles/app_files.go +++ b/cf/appfiles/app_files.go @@ -9,7 +9,7 @@ import ( "path/filepath" "runtime" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" "code.cloudfoundry.org/gofileutils/fileutils" securejoin "github.com/cyphar/filepath-securejoin" ) diff --git a/cf/appfiles/app_files_suite_test.go b/cf/appfiles/app_files_suite_test.go index 402a19448c0..a0fd3395700 100644 --- a/cf/appfiles/app_files_suite_test.go +++ b/cf/appfiles/app_files_suite_test.go @@ -3,9 +3,9 @@ package appfiles_test import ( "testing" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/appfiles/app_files_test.go b/cf/appfiles/app_files_test.go index 1e186968d46..3625d902135 100644 --- a/cf/appfiles/app_files_test.go +++ b/cf/appfiles/app_files_test.go @@ -7,13 +7,13 @@ import ( "runtime" "strings" - "code.cloudfoundry.org/cli/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/appfiles" uuid "github.com/nu7hatch/gouuid" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" "code.cloudfoundry.org/gofileutils/fileutils" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -108,7 +108,8 @@ var _ = Describe("AppFiles", func() { Describe("CopyFiles", func() { It("copies only the files specified", func() { - copyDir := filepath.Join(fixturePath, "app-copy-test") + copyDir, err := filepath.Abs(filepath.Join(fixturePath, "app-copy-test")) + Expect(err).NotTo(HaveOccurred()) filesToCopy := []models.AppFileFields{ {Path: filepath.Join("dir1")}, @@ -117,7 +118,8 @@ var _ = Describe("AppFiles", func() { files := []string{} - fileutils.TempDir("copyToDir", func(tmpDir string, err error) { + fileutils.TempDir("copyToDir", func(tmpDir string, tmpErr error) { + Expect(tmpErr).NotTo(HaveOccurred()) copyErr := appFiles.CopyFiles(filesToCopy, copyDir, tmpDir) Expect(copyErr).ToNot(HaveOccurred()) diff --git a/cf/appfiles/appfilesfakes/fake_app_files.go b/cf/appfiles/appfilesfakes/fake_app_files.go index 2075d71e7cb..03716db7fc1 100644 --- a/cf/appfiles/appfilesfakes/fake_app_files.go +++ b/cf/appfiles/appfilesfakes/fake_app_files.go @@ -4,8 +4,8 @@ package appfilesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeAppFiles struct { @@ -68,15 +68,16 @@ func (fake *FakeAppFiles) AppFilesInDir(arg1 string) ([]models.AppFileFields, er fake.appFilesInDirArgsForCall = append(fake.appFilesInDirArgsForCall, struct { arg1 string }{arg1}) + stub := fake.AppFilesInDirStub + fakeReturns := fake.appFilesInDirReturns fake.recordInvocation("AppFilesInDir", []interface{}{arg1}) fake.appFilesInDirMutex.Unlock() - if fake.AppFilesInDirStub != nil { - return fake.AppFilesInDirStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.appFilesInDirReturns return fakeReturns.result1, fakeReturns.result2 } @@ -138,15 +139,16 @@ func (fake *FakeAppFiles) CopyFiles(arg1 []models.AppFileFields, arg2 string, ar arg2 string arg3 string }{arg1Copy, arg2, arg3}) + stub := fake.CopyFilesStub + fakeReturns := fake.copyFilesReturns fake.recordInvocation("CopyFiles", []interface{}{arg1Copy, arg2, arg3}) fake.copyFilesMutex.Unlock() - if fake.CopyFilesStub != nil { - return fake.CopyFilesStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.copyFilesReturns return fakeReturns.result1 } @@ -198,15 +200,16 @@ func (fake *FakeAppFiles) CountFiles(arg1 string) int64 { fake.countFilesArgsForCall = append(fake.countFilesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CountFilesStub + fakeReturns := fake.countFilesReturns fake.recordInvocation("CountFiles", []interface{}{arg1}) fake.countFilesMutex.Unlock() - if fake.CountFilesStub != nil { - return fake.CountFilesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.countFilesReturns return fakeReturns.result1 } @@ -259,15 +262,16 @@ func (fake *FakeAppFiles) WalkAppFiles(arg1 string, arg2 func(string, string) er arg1 string arg2 func(string, string) error }{arg1, arg2}) + stub := fake.WalkAppFilesStub + fakeReturns := fake.walkAppFilesReturns fake.recordInvocation("WalkAppFiles", []interface{}{arg1, arg2}) fake.walkAppFilesMutex.Unlock() - if fake.WalkAppFilesStub != nil { - return fake.WalkAppFilesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.walkAppFilesReturns return fakeReturns.result1 } diff --git a/cf/appfiles/appfilesfakes/fake_cf_ignore.go b/cf/appfiles/appfilesfakes/fake_cf_ignore.go index 3efcacff4b5..78a5a05bba2 100644 --- a/cf/appfiles/appfilesfakes/fake_cf_ignore.go +++ b/cf/appfiles/appfilesfakes/fake_cf_ignore.go @@ -4,7 +4,7 @@ package appfilesfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/appfiles" ) type FakeCfIgnore struct { @@ -29,15 +29,16 @@ func (fake *FakeCfIgnore) FileShouldBeIgnored(arg1 string) bool { fake.fileShouldBeIgnoredArgsForCall = append(fake.fileShouldBeIgnoredArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FileShouldBeIgnoredStub + fakeReturns := fake.fileShouldBeIgnoredReturns fake.recordInvocation("FileShouldBeIgnored", []interface{}{arg1}) fake.fileShouldBeIgnoredMutex.Unlock() - if fake.FileShouldBeIgnoredStub != nil { - return fake.FileShouldBeIgnoredStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.fileShouldBeIgnoredReturns return fakeReturns.result1 } diff --git a/cf/appfiles/appfilesfakes/fake_zipper.go b/cf/appfiles/appfilesfakes/fake_zipper.go index 1dff9a5b641..2278c9e8e51 100644 --- a/cf/appfiles/appfilesfakes/fake_zipper.go +++ b/cf/appfiles/appfilesfakes/fake_zipper.go @@ -5,7 +5,7 @@ import ( "os" "sync" - "code.cloudfoundry.org/cli/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/appfiles" ) type FakeZipper struct { @@ -67,15 +67,16 @@ func (fake *FakeZipper) GetZipSize(arg1 *os.File) (int64, error) { fake.getZipSizeArgsForCall = append(fake.getZipSizeArgsForCall, struct { arg1 *os.File }{arg1}) + stub := fake.GetZipSizeStub + fakeReturns := fake.getZipSizeReturns fake.recordInvocation("GetZipSize", []interface{}{arg1}) fake.getZipSizeMutex.Unlock() - if fake.GetZipSizeStub != nil { - return fake.GetZipSizeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getZipSizeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -130,15 +131,16 @@ func (fake *FakeZipper) IsZipFile(arg1 string) bool { fake.isZipFileArgsForCall = append(fake.isZipFileArgsForCall, struct { arg1 string }{arg1}) + stub := fake.IsZipFileStub + fakeReturns := fake.isZipFileReturns fake.recordInvocation("IsZipFile", []interface{}{arg1}) fake.isZipFileMutex.Unlock() - if fake.IsZipFileStub != nil { - return fake.IsZipFileStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isZipFileReturns return fakeReturns.result1 } @@ -191,15 +193,16 @@ func (fake *FakeZipper) Unzip(arg1 string, arg2 string) error { arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnzipStub + fakeReturns := fake.unzipReturns fake.recordInvocation("Unzip", []interface{}{arg1, arg2}) fake.unzipMutex.Unlock() - if fake.UnzipStub != nil { - return fake.UnzipStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unzipReturns return fakeReturns.result1 } @@ -252,15 +255,16 @@ func (fake *FakeZipper) Zip(arg1 string, arg2 *os.File) error { arg1 string arg2 *os.File }{arg1, arg2}) + stub := fake.ZipStub + fakeReturns := fake.zipReturns fake.recordInvocation("Zip", []interface{}{arg1, arg2}) fake.zipMutex.Unlock() - if fake.ZipStub != nil { - return fake.ZipStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.zipReturns return fakeReturns.result1 } diff --git a/cf/appfiles/cf_ignore.go b/cf/appfiles/cf_ignore.go index 6faecd3ed8e..abf37e85375 100644 --- a/cf/appfiles/cf_ignore.go +++ b/cf/appfiles/cf_ignore.go @@ -4,7 +4,7 @@ import ( "path" "strings" - "code.cloudfoundry.org/cli/cf/util/glob" + "code.cloudfoundry.org/cli/v8/cf/util/glob" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . CfIgnore diff --git a/cf/appfiles/cf_ignore_test.go b/cf/appfiles/cf_ignore_test.go index 5f10e52377f..3f597df10fa 100644 --- a/cf/appfiles/cf_ignore_test.go +++ b/cf/appfiles/cf_ignore_test.go @@ -1,8 +1,8 @@ package appfiles_test import ( - . "code.cloudfoundry.org/cli/cf/appfiles" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/appfiles" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -59,7 +59,7 @@ stuff/exclude.c`) Expect(ignore.FileShouldBeIgnored("stuff/include.c")).To(BeFalse()) }) - It("ignores certain commonly ingored files by default", func() { + It("ignores certain commonly ignored files by default", func() { ignore := NewCfIgnore(``) Expect(ignore.FileShouldBeIgnored(".git/objects")).To(BeTrue()) diff --git a/cf/appfiles/zipper.go b/cf/appfiles/zipper.go index 22bccb71e54..d422e15f0b7 100644 --- a/cf/appfiles/zipper.go +++ b/cf/appfiles/zipper.go @@ -9,7 +9,7 @@ import ( "path/filepath" "runtime" - "code.cloudfoundry.org/cli/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/errors" "code.cloudfoundry.org/gofileutils/fileutils" securejoin "github.com/cyphar/filepath-securejoin" ) diff --git a/cf/appfiles/zipper_test.go b/cf/appfiles/zipper_test.go index e57d0d02f29..bb1eed3be07 100644 --- a/cf/appfiles/zipper_test.go +++ b/cf/appfiles/zipper_test.go @@ -12,10 +12,10 @@ import ( "runtime" "strings" - . "code.cloudfoundry.org/cli/cf/appfiles" + . "code.cloudfoundry.org/cli/v8/cf/appfiles" "code.cloudfoundry.org/gofileutils/fileutils" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/cmd/cmd.go b/cf/cmd/cmd.go index d2c1a38264c..91d7d414e35 100644 --- a/cf/cmd/cmd.go +++ b/cf/cmd/cmd.go @@ -8,21 +8,21 @@ import ( "path/filepath" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commandsloader" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/cf/util/spellcheck" - "code.cloudfoundry.org/cli/plugin/rpc" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandsloader" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/util/spellcheck" + "code.cloudfoundry.org/cli/v8/plugin/rpc" netrpc "net/rpc" ) @@ -31,18 +31,18 @@ var cmdRegistry = commandregistry.Commands func Main(traceEnv string, args []string) { - //handle `cf -v` for cf version + // handle `cf -v` for cf version if len(args) == 2 && (args[1] == "-v" || args[1] == "--version") { args[1] = "version" } - //handles `cf` + // handles `cf` if len(args) == 1 { args = []string{args[0], "help"} } - //handles `cf [COMMAND] -h ...` - //rearrange args to `cf help COMMAND` and let `command help` to print out usage + // handles `cf [COMMAND] -h ...` + // rearrange args to `cf help COMMAND` and let `command help` to print out usage args = append([]string{args[0]}, handleHelp(args[1:])...) newArgs, isVerbose := handleVerbose(args) @@ -86,7 +86,7 @@ func Main(traceEnv string, args []string) { commandsloader.Load() - //run core command + // run core command cmdName := args[1] cmd := cmdRegistry.FindCommand(cmdName) if cmd != nil { @@ -137,7 +137,7 @@ func Main(traceEnv string, args []string) { os.Exit(0) } - //non core command, try plugin command + // non core command, try plugin command server := netrpc.NewServer() rpcService, err := rpc.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, rpc.NewCommandRunner(), deps.Logger, Writer, server) if err != nil { diff --git a/cf/cmd/writer_unix.go b/cf/cmd/writer_unix.go index bd301a68f5c..c357dbbfa86 100644 --- a/cf/cmd/writer_unix.go +++ b/cf/cmd/writer_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package cmd diff --git a/cf/cmd/writer_windows.go b/cf/cmd/writer_windows.go index 892f350bf92..2d9cab4980e 100644 --- a/cf/cmd/writer_windows.go +++ b/cf/cmd/writer_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package cmd diff --git a/cf/commandregistry/command.go b/cf/commandregistry/command.go index 5141c9bffd9..e73ed6999fa 100644 --- a/cf/commandregistry/command.go +++ b/cf/commandregistry/command.go @@ -1,8 +1,8 @@ package commandregistry import ( - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Command @@ -21,7 +21,7 @@ type CommandMetadata struct { Description string Flags map[string]flags.FlagSet SkipFlagParsing bool - TotalArgs int //Optional: number of required arguments to skip for flag verification + TotalArgs int // Optional: number of required arguments to skip for flag verification Hidden bool Examples []string } diff --git a/cf/commandregistry/command_registry_suite_test.go b/cf/commandregistry/command_registry_suite_test.go index 7eb9c7c7092..2aea6bddf13 100644 --- a/cf/commandregistry/command_registry_suite_test.go +++ b/cf/commandregistry/command_registry_suite_test.go @@ -1,7 +1,7 @@ package commandregistry_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commandregistry/commandregistryfakes/fake_command.go b/cf/commandregistry/commandregistryfakes/fake_command.go index 7941211b441..09296bf61fe 100644 --- a/cf/commandregistry/commandregistryfakes/fake_command.go +++ b/cf/commandregistry/commandregistryfakes/fake_command.go @@ -4,9 +4,9 @@ package commandregistryfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeCommand struct { @@ -67,15 +67,16 @@ func (fake *FakeCommand) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -126,15 +127,16 @@ func (fake *FakeCommand) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -180,15 +182,16 @@ func (fake *FakeCommand) Requirements(arg1 requirements.Factory, arg2 flags.Flag arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -244,15 +247,16 @@ func (fake *FakeCommand) SetDependency(arg1 commandregistry.Dependency, arg2 boo arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } diff --git a/cf/commandregistry/commandregistryfakes/fake_random_word_generator.go b/cf/commandregistry/commandregistryfakes/fake_random_word_generator.go index 5bb4798d2b6..84ed335e842 100644 --- a/cf/commandregistry/commandregistryfakes/fake_random_word_generator.go +++ b/cf/commandregistry/commandregistryfakes/fake_random_word_generator.go @@ -4,7 +4,7 @@ package commandregistryfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" ) type FakeRandomWordGenerator struct { @@ -27,15 +27,16 @@ func (fake *FakeRandomWordGenerator) Babble() string { ret, specificReturn := fake.babbleReturnsOnCall[len(fake.babbleArgsForCall)] fake.babbleArgsForCall = append(fake.babbleArgsForCall, struct { }{}) + stub := fake.BabbleStub + fakeReturns := fake.babbleReturns fake.recordInvocation("Babble", []interface{}{}) fake.babbleMutex.Unlock() - if fake.BabbleStub != nil { - return fake.BabbleStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.babbleReturns return fakeReturns.result1 } diff --git a/cf/commandregistry/dependency.go b/cf/commandregistry/dependency.go index 8360e9b8ed1..6633632313d 100644 --- a/cf/commandregistry/dependency.go +++ b/cf/commandregistry/dependency.go @@ -8,24 +8,24 @@ import ( "path/filepath" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/actors/brokerbuilder" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/plugin/models" - "code.cloudfoundry.org/cli/util" - "code.cloudfoundry.org/cli/util/randomword" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/actors/brokerbuilder" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/plugin/models" + "code.cloudfoundry.org/cli/v8/util" + "code.cloudfoundry.org/cli/v8/util/randomword" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RandomWordGenerator @@ -56,7 +56,7 @@ type Dependency struct { PushActor actors.PushActor RouteActor actors.RouteActor ChecksumUtil util.Sha1Checksum - WildcardDependency interface{} //use for injecting fakes + WildcardDependency interface{} // use for injecting fakes Logger trace.Printer } diff --git a/cf/commandregistry/dependency_test.go b/cf/commandregistry/dependency_test.go index 50879fbee8e..868b2f627b4 100644 --- a/cf/commandregistry/dependency_test.go +++ b/cf/commandregistry/dependency_test.go @@ -1,19 +1,19 @@ package commandregistry_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" "os" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Dependency", func() { var dependency commandregistry.Dependency - It("populates all fields by calling all the dependency contructors", func() { + It("populates all fields by calling all the dependency constructors", func() { fakeLogger := new(tracefakes.FakePrinter) dependency = commandregistry.NewDependency(os.Stdout, fakeLogger, "") diff --git a/cf/commandregistry/fakecommand/fake_command1.go b/cf/commandregistry/fakecommand/fake_command1.go index 46c6a7a4599..ecdf3feec69 100644 --- a/cf/commandregistry/fakecommand/fake_command1.go +++ b/cf/commandregistry/fakecommand/fake_command1.go @@ -3,9 +3,9 @@ package fakecommand import ( "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeCommand1 struct { diff --git a/cf/commandregistry/fakecommand/fake_command2.go b/cf/commandregistry/fakecommand/fake_command2.go index 0d15e461c83..ecc2d35a7a7 100644 --- a/cf/commandregistry/fakecommand/fake_command2.go +++ b/cf/commandregistry/fakecommand/fake_command2.go @@ -1,9 +1,9 @@ package fakecommand import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeCommand2 struct { diff --git a/cf/commandregistry/fakecommand/fake_command_max_length_name.go b/cf/commandregistry/fakecommand/fake_command_max_length_name.go index 1dacefa59db..2f56a52afdb 100644 --- a/cf/commandregistry/fakecommand/fake_command_max_length_name.go +++ b/cf/commandregistry/fakecommand/fake_command_max_length_name.go @@ -1,9 +1,9 @@ package fakecommand import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeCommand3 struct { diff --git a/cf/commandregistry/registry.go b/cf/commandregistry/registry.go index 2b7ee3cbf7f..2d995818b0d 100644 --- a/cf/commandregistry/registry.go +++ b/cf/commandregistry/registry.go @@ -6,13 +6,13 @@ import ( "strings" "unicode/utf8" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" - . "code.cloudfoundry.org/cli/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/terminal" ) var _ = initI18nFunc() @@ -35,9 +35,10 @@ func initI18nFunc() bool { T = Init(config) if err != nil { - fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", T(configErrTemplate, map[string]interface{}{ + msg := T(configErrTemplate, map[string]interface{}{ "FilePath": configv3.ConfigFilePath(), - }))) + }) + fmt.Fprintf(os.Stderr, "%s\n", msg) } return true } diff --git a/cf/commandregistry/registry_test.go b/cf/commandregistry/registry_test.go index f8c709fad4d..a55cb36d90b 100644 --- a/cf/commandregistry/registry_test.go +++ b/cf/commandregistry/registry_test.go @@ -3,14 +3,14 @@ package commandregistry_test import ( "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/commandregistry/fakecommand" + . "code.cloudfoundry.org/cli/v8/cf/commandregistry/fakecommand" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "code.cloudfoundry.org/cli/cf/i18n" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/api.go b/cf/commands/api.go index 8c448835745..dcc8987a6b7 100644 --- a/cf/commands/api.go +++ b/cf/commands/api.go @@ -4,14 +4,14 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type API struct { @@ -61,8 +61,8 @@ func (cmd API) Execute(c flags.FlagContext) error { } else if len(c.Args()) == 0 { if cmd.config.APIEndpoint() == "" { - cmd.ui.Say(fmt.Sprintf(T("No api endpoint set. Use '{{.Name}}' to set an endpoint", - map[string]interface{}{"Name": terminal.CommandColor(cf.Name + " api")}))) + cmd.ui.Say(T("No api endpoint set. Use '{{.Name}}' to set an endpoint", + map[string]interface{}{"Name": terminal.CommandColor(cf.Name + " api")})) } else { cmd.ui.Say(T("API endpoint: {{.APIEndpoint}} (API version: {{.APIVersion}})", map[string]interface{}{"APIEndpoint": terminal.EntityNameColor(cmd.config.APIEndpoint()), @@ -106,8 +106,8 @@ func (cmd API) setAPIEndpoint(endpoint string, skipSSL bool, cmdName string) err switch typedErr := err.(type) { case *errors.InvalidSSLCert: cfAPICommand := terminal.CommandColor(fmt.Sprintf("%s %s --skip-ssl-validation", cf.Name, cmdName)) - tipMessage := fmt.Sprintf(T("TIP: Use '{{.APICommand}}' to continue with an insecure API endpoint", - map[string]interface{}{"APICommand": cfAPICommand})) + tipMessage := T("TIP: Use '{{.APICommand}}' to continue with an insecure API endpoint", + map[string]interface{}{"APICommand": cfAPICommand}) return errors.New(T("Invalid SSL Cert for {{.URL}}\n{{.TipMessage}}", map[string]interface{}{"URL": typedErr.URL, "TipMessage": tipMessage})) default: diff --git a/cf/commands/api_test.go b/cf/commands/api_test.go index 294f00afa92..46ad3e1e2af 100644 --- a/cf/commands/api_test.go +++ b/cf/commands/api_test.go @@ -3,20 +3,20 @@ package commands_test import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("Api", func() { diff --git a/cf/commands/application/app.go b/cf/commands/application/app.go index de7ef2e8797..b011efa5af3 100644 --- a/cf/commands/application/app.go +++ b/cf/commands/application/app.go @@ -4,21 +4,21 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/uihelpers" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Displayer @@ -183,15 +183,15 @@ func (cmd *ShowApp) ShowApp(app models.Application, orgName, spaceName string) e uihelpers.ColoredInstanceState(instance), instance.Since.Format("2006-01-02 03:04:05 PM"), fmt.Sprintf("%.1f%%", instance.CPUUsage*100), - fmt.Sprintf(T("{{.MemUsage}} of {{.MemQuota}}", + T("{{.MemUsage}} of {{.MemQuota}}", map[string]interface{}{ "MemUsage": formatters.ByteSize(instance.MemUsage), - "MemQuota": formatters.ByteSize(instance.MemQuota)})), - fmt.Sprintf(T("{{.DiskUsage}} of {{.DiskQuota}}", + "MemQuota": formatters.ByteSize(instance.MemQuota)}), + T("{{.DiskUsage}} of {{.DiskQuota}}", map[string]interface{}{ "DiskUsage": formatters.ByteSize(instance.DiskUsage), - "DiskQuota": formatters.ByteSize(instance.DiskQuota)})), - fmt.Sprintf("%s", instance.Details), + "DiskQuota": formatters.ByteSize(instance.DiskQuota)}), + instance.Details, ) } diff --git a/cf/commands/application/app_test.go b/cf/commands/application/app_test.go index 7ca948da350..323c9fa357d 100644 --- a/cf/commands/application/app_test.go +++ b/cf/commands/application/app_test.go @@ -4,28 +4,28 @@ import ( "encoding/json" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/plugin/models" - - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/appinstances/appinstancesfakes" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/stacks/stacksfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/plugin/models" + + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances/appinstancesfakes" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -476,7 +476,7 @@ var _ = Describe("App", func() { getAppSummaryModel.State = "stopped" appSummaryRepo.GetSummaryReturns(getAppSummaryModel, nil) - var instances []models.AppInstanceFields //Very important since this is a nil body + var instances []models.AppInstanceFields // Very important since this is a nil body appInstancesRepo.GetInstancesReturns(instances, errors.New("Bonzi")) }) diff --git a/cf/commands/application/application_suite_test.go b/cf/commands/application/application_suite_test.go index 2067c9106ee..b6cb10befef 100644 --- a/cf/commands/application/application_suite_test.go +++ b/cf/commands/application/application_suite_test.go @@ -1,10 +1,10 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/application/applicationfakes/fake_app_displayer.go b/cf/commands/application/applicationfakes/fake_app_displayer.go index 95024a07f4b..0bd52af24af 100644 --- a/cf/commands/application/applicationfakes/fake_app_displayer.go +++ b/cf/commands/application/applicationfakes/fake_app_displayer.go @@ -1,10 +1,10 @@ package applicationfakes import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeAppDisplayer struct { diff --git a/cf/commands/application/applicationfakes/fake_displayer.go b/cf/commands/application/applicationfakes/fake_displayer.go index 29fd79fd744..80e180367b2 100644 --- a/cf/commands/application/applicationfakes/fake_displayer.go +++ b/cf/commands/application/applicationfakes/fake_displayer.go @@ -4,8 +4,8 @@ package applicationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeDisplayer struct { @@ -34,15 +34,16 @@ func (fake *FakeDisplayer) ShowApp(arg1 models.Application, arg2 string, arg3 st arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.ShowAppStub + fakeReturns := fake.showAppReturns fake.recordInvocation("ShowApp", []interface{}{arg1, arg2, arg3}) fake.showAppMutex.Unlock() - if fake.ShowAppStub != nil { - return fake.ShowAppStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.showAppReturns return fakeReturns.result1 } diff --git a/cf/commands/application/applicationfakes/fake_restarter.go b/cf/commands/application/applicationfakes/fake_restarter.go index 1ee736c2abf..6d03fbfd527 100644 --- a/cf/commands/application/applicationfakes/fake_restarter.go +++ b/cf/commands/application/applicationfakes/fake_restarter.go @@ -4,11 +4,11 @@ package applicationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeRestarter struct { @@ -84,15 +84,16 @@ func (fake *FakeRestarter) ApplicationRestart(arg1 models.Application, arg2 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.ApplicationRestartStub + fakeReturns := fake.applicationRestartReturns fake.recordInvocation("ApplicationRestart", []interface{}{arg1, arg2, arg3}) fake.applicationRestartMutex.Unlock() - if fake.ApplicationRestartStub != nil { - return fake.ApplicationRestartStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.applicationRestartReturns return fakeReturns.result1 } @@ -144,15 +145,16 @@ func (fake *FakeRestarter) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -203,15 +205,16 @@ func (fake *FakeRestarter) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -257,15 +260,16 @@ func (fake *FakeRestarter) Requirements(arg1 requirements.Factory, arg2 flags.Fl arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -321,15 +325,16 @@ func (fake *FakeRestarter) SetDependency(arg1 commandregistry.Dependency, arg2 b arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } diff --git a/cf/commands/application/applicationfakes/fake_staging_watcher.go b/cf/commands/application/applicationfakes/fake_staging_watcher.go index 6fdda4de082..c1b3d978db1 100644 --- a/cf/commands/application/applicationfakes/fake_staging_watcher.go +++ b/cf/commands/application/applicationfakes/fake_staging_watcher.go @@ -4,8 +4,8 @@ package applicationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeStagingWatcher struct { @@ -38,15 +38,16 @@ func (fake *FakeStagingWatcher) WatchStaging(arg1 models.Application, arg2 strin arg3 string arg4 func(app models.Application) (models.Application, error) }{arg1, arg2, arg3, arg4}) + stub := fake.WatchStagingStub + fakeReturns := fake.watchStagingReturns fake.recordInvocation("WatchStaging", []interface{}{arg1, arg2, arg3, arg4}) fake.watchStagingMutex.Unlock() - if fake.WatchStagingStub != nil { - return fake.WatchStagingStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.watchStagingReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/commands/application/applicationfakes/fake_starter.go b/cf/commands/application/applicationfakes/fake_starter.go index 43ff78cdc40..698fa3b07bc 100644 --- a/cf/commands/application/applicationfakes/fake_starter.go +++ b/cf/commands/application/applicationfakes/fake_starter.go @@ -4,11 +4,11 @@ package applicationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeStarter struct { @@ -91,15 +91,16 @@ func (fake *FakeStarter) ApplicationStart(arg1 models.Application, arg2 string, arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.ApplicationStartStub + fakeReturns := fake.applicationStartReturns fake.recordInvocation("ApplicationStart", []interface{}{arg1, arg2, arg3}) fake.applicationStartMutex.Unlock() - if fake.ApplicationStartStub != nil { - return fake.ApplicationStartStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.applicationStartReturns return fakeReturns.result1, fakeReturns.result2 } @@ -154,15 +155,16 @@ func (fake *FakeStarter) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -213,15 +215,16 @@ func (fake *FakeStarter) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -267,15 +270,16 @@ func (fake *FakeStarter) Requirements(arg1 requirements.Factory, arg2 flags.Flag arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -331,15 +335,16 @@ func (fake *FakeStarter) SetDependency(arg1 commandregistry.Dependency, arg2 boo arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } @@ -390,9 +395,10 @@ func (fake *FakeStarter) SetStartTimeoutInSeconds(arg1 int) { fake.setStartTimeoutInSecondsArgsForCall = append(fake.setStartTimeoutInSecondsArgsForCall, struct { arg1 int }{arg1}) + stub := fake.SetStartTimeoutInSecondsStub fake.recordInvocation("SetStartTimeoutInSeconds", []interface{}{arg1}) fake.setStartTimeoutInSecondsMutex.Unlock() - if fake.SetStartTimeoutInSecondsStub != nil { + if stub != nil { fake.SetStartTimeoutInSecondsStub(arg1) } } diff --git a/cf/commands/application/applicationfakes/fake_stopper.go b/cf/commands/application/applicationfakes/fake_stopper.go index fed79044c61..ff5d00623a4 100644 --- a/cf/commands/application/applicationfakes/fake_stopper.go +++ b/cf/commands/application/applicationfakes/fake_stopper.go @@ -4,11 +4,11 @@ package applicationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeStopper struct { @@ -86,15 +86,16 @@ func (fake *FakeStopper) ApplicationStop(arg1 models.Application, arg2 string, a arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.ApplicationStopStub + fakeReturns := fake.applicationStopReturns fake.recordInvocation("ApplicationStop", []interface{}{arg1, arg2, arg3}) fake.applicationStopMutex.Unlock() - if fake.ApplicationStopStub != nil { - return fake.ApplicationStopStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.applicationStopReturns return fakeReturns.result1, fakeReturns.result2 } @@ -149,15 +150,16 @@ func (fake *FakeStopper) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -208,15 +210,16 @@ func (fake *FakeStopper) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -262,15 +265,16 @@ func (fake *FakeStopper) Requirements(arg1 requirements.Factory, arg2 flags.Flag arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -326,15 +330,16 @@ func (fake *FakeStopper) SetDependency(arg1 commandregistry.Dependency, arg2 boo arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } diff --git a/cf/commands/application/apps.go b/cf/commands/application/apps.go index d77b38fff28..9b2e828e175 100644 --- a/cf/commands/application/apps.go +++ b/cf/commands/application/apps.go @@ -3,18 +3,18 @@ package application import ( "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/uihelpers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" ) type ListApps struct { diff --git a/cf/commands/application/apps_test.go b/cf/commands/application/apps_test.go index 1e12c35cbca..81d0cfa91b4 100644 --- a/cf/commands/application/apps_test.go +++ b/cf/commands/application/apps_test.go @@ -1,25 +1,25 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "os" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("list-apps command", func() { @@ -197,7 +197,7 @@ var _ = Describe("list-apps command", func() { }) Context("when an app's running instances is unknown", func() { - It("dipslays a '?' for running instances", func() { + It("displays a '?' for running instances", func() { appRoutes := []models.RouteSummary{ { Host: "app1", diff --git a/cf/commands/application/copy_source.go b/cf/commands/application/copy_source.go index a5c9b286bd5..6b6c909c92d 100644 --- a/cf/commands/application/copy_source.go +++ b/cf/commands/application/copy_source.go @@ -2,21 +2,20 @@ package application import ( "errors" - "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/api/copyapplicationsource" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/api/copyapplicationsource" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CopySource struct { @@ -76,7 +75,7 @@ func (cmd *CopySource) SetDependency(deps commandregistry.Dependency, pluginCall cmd.spaceRepo = deps.RepoLocator.GetSpaceRepository() cmd.copyAppSourceRepo = deps.RepoLocator.GetCopyApplicationSourceRepository() - //get command from registry for dependency + // get command from registry for dependency commandDep := commandregistry.Commands.FindCommand("restart") commandDep = commandDep.SetDependency(deps, false) cmd.appRestart = commandDep.(Restarter) @@ -171,7 +170,7 @@ func (cmd *CopySource) findSpaceFields(targetOrg, targetSpace string) (models.Sp } if !foundSpace { - return models.SpaceFields{}, fmt.Errorf(T("Could not find space {{.Space}} in organization {{.Org}}", + return models.SpaceFields{}, errors.New(T("Could not find space {{.Space}} in organization {{.Org}}", map[string]interface{}{ "Space": terminal.EntityNameColor(targetSpace), "Org": terminal.EntityNameColor(targetOrg), @@ -183,7 +182,7 @@ func (cmd *CopySource) findSpaceFields(targetOrg, targetSpace string) (models.Sp } func buildCopyString(sourceAppName, targetAppName, targetOrgName, targetSpaceName, username string) string { - return fmt.Sprintf(T("Copying source from app {{.SourceApp}} to target app {{.TargetApp}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", + return T("Copying source from app {{.SourceApp}} to target app {{.TargetApp}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ "SourceApp": terminal.EntityNameColor(sourceAppName), "TargetApp": terminal.EntityNameColor(targetAppName), @@ -191,6 +190,6 @@ func buildCopyString(sourceAppName, targetAppName, targetOrgName, targetSpaceNam "SpaceName": terminal.EntityNameColor(targetSpaceName), "Username": terminal.EntityNameColor(username), }, - )) + ) } diff --git a/cf/commands/application/copy_source_test.go b/cf/commands/application/copy_source_test.go index 5c7fb941e68..9556a66ead7 100644 --- a/cf/commands/application/copy_source_test.go +++ b/cf/commands/application/copy_source_test.go @@ -1,25 +1,25 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/api/copyapplicationsource/copyapplicationsourcefakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commands/application/applicationfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/api/copyapplicationsource/copyapplicationsourcefakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commands/application/applicationfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -48,7 +48,7 @@ var _ = Describe("CopySource", func() { deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo) deps.Config = config - //inject fake 'command dependency' into registry + // inject fake 'command dependency' into registry commandregistry.Register(appRestarter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("copy-source").SetDependency(deps, pluginCall)) @@ -64,11 +64,11 @@ var _ = Describe("CopySource", func() { orgRepo = new(organizationsfakes.FakeOrganizationRepository) config = testconfig.NewRepositoryWithDefaults() - //save original command and restore later + // save original command and restore later OriginalCommand = commandregistry.Commands.FindCommand("restart") appRestarter = new(applicationfakes.FakeRestarter) - //setup fakes to correctly interact with commandregistry + // setup fakes to correctly interact with commandregistry appRestarter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return appRestarter } @@ -203,7 +203,7 @@ var _ = Describe("CopySource", func() { }) Describe("when a space is provided, but not an org", func() { - It("sends the correct target appplication for the current org and target space", func() { + It("sends the correct target application for the current org and target space", func() { space := models.Space{} space.Name = "space-name" space.GUID = "model-space-guid" diff --git a/cf/commands/application/delete.go b/cf/commands/application/delete.go index caa784d5258..620e017032e 100644 --- a/cf/commands/application/delete.go +++ b/cf/commands/application/delete.go @@ -1,15 +1,15 @@ package application import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteApp struct { diff --git a/cf/commands/application/delete_test.go b/cf/commands/application/delete_test.go index d1f101ecf84..0e74875d229 100644 --- a/cf/commands/application/delete_test.go +++ b/cf/commands/application/delete_test.go @@ -1,21 +1,21 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete app command", func() { diff --git a/cf/commands/application/disable_ssh.go b/cf/commands/application/disable_ssh.go index 0f7f8f19235..1a7e0d6387e 100644 --- a/cf/commands/application/disable_ssh.go +++ b/cf/commands/application/disable_ssh.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DisableSSH struct { diff --git a/cf/commands/application/disable_ssh_test.go b/cf/commands/application/disable_ssh_test.go index 5dd2ad639e9..880242c7f8d 100644 --- a/cf/commands/application/disable_ssh_test.go +++ b/cf/commands/application/disable_ssh_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/enable_ssh.go b/cf/commands/application/enable_ssh.go index 6971c44a607..9deb7401b47 100644 --- a/cf/commands/application/enable_ssh.go +++ b/cf/commands/application/enable_ssh.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type EnableSSH struct { diff --git a/cf/commands/application/enable_ssh_test.go b/cf/commands/application/enable_ssh_test.go index e2da654049e..b11da7c9454 100644 --- a/cf/commands/application/enable_ssh_test.go +++ b/cf/commands/application/enable_ssh_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/env.go b/cf/commands/application/env.go index 0783a5fd993..82a3a16734a 100644 --- a/cf/commands/application/env.go +++ b/cf/commands/application/env.go @@ -5,15 +5,15 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Env struct { diff --git a/cf/commands/application/env_test.go b/cf/commands/application/env_test.go index b3ab8748f09..3f7561e4d13 100644 --- a/cf/commands/application/env_test.go +++ b/cf/commands/application/env_test.go @@ -1,19 +1,19 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/events.go b/cf/commands/application/events.go index 1c143d75317..d144a9e5383 100644 --- a/cf/commands/application/events.go +++ b/cf/commands/application/events.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/appevents" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/appevents" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Events struct { diff --git a/cf/commands/application/events_test.go b/cf/commands/application/events_test.go index b6252d8d410..ba30cf6219d 100644 --- a/cf/commands/application/events_test.go +++ b/cf/commands/application/events_test.go @@ -4,20 +4,20 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - - "code.cloudfoundry.org/cli/cf/api/appevents/appeventsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + + "code.cloudfoundry.org/cli/v8/cf/api/appevents/appeventsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/files.go b/cf/commands/application/files.go index 8584493eb53..bf29118af7c 100644 --- a/cf/commands/application/files.go +++ b/cf/commands/application/files.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/appfiles" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/appfiles" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Files struct { diff --git a/cf/commands/application/files_test.go b/cf/commands/application/files_test.go index 09cf81673e1..307a0316eb9 100644 --- a/cf/commands/application/files_test.go +++ b/cf/commands/application/files_test.go @@ -3,20 +3,20 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/appfiles/appfilesfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/appfiles/appfilesfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/get_health_check.go b/cf/commands/application/get_health_check.go index b0dd926cf6b..9b8a0d20e11 100644 --- a/cf/commands/application/get_health_check.go +++ b/cf/commands/application/get_health_check.go @@ -3,14 +3,14 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type GetHealthCheck struct { diff --git a/cf/commands/application/get_health_check_test.go b/cf/commands/application/get_health_check_test.go index f5ccd1002cd..5550b259166 100644 --- a/cf/commands/application/get_health_check_test.go +++ b/cf/commands/application/get_health_check_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/logs.go b/cf/commands/application/logs.go index 9bed3f1d754..e9de3a33950 100644 --- a/cf/commands/application/logs.go +++ b/cf/commands/application/logs.go @@ -4,15 +4,15 @@ import ( "fmt" "time" - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Logs struct { diff --git a/cf/commands/application/logs_test.go b/cf/commands/application/logs_test.go index 8da4d1416f1..20af94a7993 100644 --- a/cf/commands/application/logs_test.go +++ b/cf/commands/application/logs_test.go @@ -1,20 +1,20 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/api/logs/logsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs/logsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/push.go b/cf/commands/application/push.go index 8c48a7839a3..334f8cd5c3c 100644 --- a/cf/commands/application/push.go +++ b/cf/commands/application/push.go @@ -8,24 +8,24 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/appfiles" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/appfiles" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Push struct { @@ -122,17 +122,17 @@ func (cmd *Push) SetDependency(deps commandregistry.Dependency, pluginCall bool) cmd.config = deps.Config cmd.manifestRepo = deps.ManifestRepo - //set appStarter + // set appStarter appCommand := commandregistry.Commands.FindCommand("start") appCommand = appCommand.SetDependency(deps, false) cmd.appStarter = appCommand.(Starter) - //set appStopper + // set appStopper appCommand = commandregistry.Commands.FindCommand("stop") appCommand = appCommand.SetDependency(deps, false) cmd.appStopper = appCommand.(Stopper) - //set serviceBinder + // set serviceBinder appCommand = commandregistry.Commands.FindCommand("bind-service") appCommand = appCommand.SetDependency(deps, false) cmd.serviceBinder = appCommand.(service.Binder) @@ -438,7 +438,7 @@ func (cmd *Push) createAndBindRoute( case host != nil: hostname = *host case UseRandomPort: - //do nothing + // do nothing case UseRandomRoute: hostname = hostNameForString(app.Name) + "-" + cmd.wordGenerator.Babble() default: @@ -784,7 +784,7 @@ func (cmd *Push) getAppParamsFromContext(c flags.FlagContext) (models.AppParams, if c.String("t") != "" { timeout, err := strconv.Atoi(c.String("t")) if err != nil { - return models.AppParams{}, fmt.Errorf("Error: %s", fmt.Errorf(T("Invalid timeout param: {{.Timeout}}\n{{.Err}}", + return models.AppParams{}, fmt.Errorf("Error: %s", errors.New(T("Invalid timeout param: {{.Timeout}}\n{{.Err}}", map[string]interface{}{"Timeout": c.String("t"), "Err": err.Error()}))) } @@ -798,7 +798,7 @@ func (cmd *Push) getAppParamsFromContext(c flags.FlagContext) (models.AppParams, case "http", "none", "port", "process": appParams.HealthCheckType = &healthCheckType default: - return models.AppParams{}, fmt.Errorf("Error: %s", fmt.Errorf(T("Invalid health-check-type param: {{.healthCheckType}}", + return models.AppParams{}, fmt.Errorf("Error: %s", errors.New(T("Invalid health-check-type param: {{.healthCheckType}}", map[string]interface{}{"healthCheckType": healthCheckType}))) } diff --git a/cf/commands/application/push_test.go b/cf/commands/application/push_test.go index 4ef5a3c067a..ca6e01d0af0 100644 --- a/cf/commands/application/push_test.go +++ b/cf/commands/application/push_test.go @@ -5,32 +5,32 @@ import ( "path/filepath" "syscall" - "code.cloudfoundry.org/cli/cf/actors/actorsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" - "code.cloudfoundry.org/cli/cf/appfiles/appfilesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commandregistry/commandregistryfakes" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/commands/application/applicationfakes" - "code.cloudfoundry.org/cli/cf/commands/service/servicefakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/cf/manifest/manifestfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/actorsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/stacks/stacksfakes" + "code.cloudfoundry.org/cli/v8/cf/appfiles/appfilesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandregistry/commandregistryfakes" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/commands/application/applicationfakes" + "code.cloudfoundry.org/cli/v8/cf/commands/service/servicefakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/manifest/manifestfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) @@ -68,7 +68,7 @@ var _ = Describe("Push Command", func() { ) BeforeEach(func() { - //save original command dependences and restore later + // save original command dependences and restore later OriginalCommandStart = commandregistry.Commands.FindCommand("start") OriginalCommandStop = commandregistry.Commands.FindCommand("stop") OriginalCommandServiceBind = commandregistry.Commands.FindCommand("bind-service") @@ -83,7 +83,7 @@ var _ = Describe("Push Command", func() { minVersionReq = requirements.Passing{Type: "minVersionReq"} requirementsFactory.NewMinAPIVersionRequirementReturns(minVersionReq) - ui = &testterm.FakeUI{} //new(terminalfakes.FakeUI) + ui = &testterm.FakeUI{} // new(terminalfakes.FakeUI) configRepo = testconfig.NewRepositoryWithDefaults() manifestRepo = new(manifestfakes.FakeRepository) wordGenerator = new(commandregistryfakes.FakeRandomWordGenerator) @@ -117,7 +117,7 @@ var _ = Describe("Push Command", func() { deps.RepoLocator = deps.RepoLocator.SetStackRepository(stackRepo) deps.RepoLocator = deps.RepoLocator.SetAuthenticationRepository(authRepo) - //setup fake commands (counterfeiter) to correctly interact with commandregistry + // setup fake commands (counterfeiter) to correctly interact with commandregistry starter = new(applicationfakes.FakeStarter) starter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return starter @@ -132,7 +132,7 @@ var _ = Describe("Push Command", func() { stopper.MetaDataReturns(commandregistry.CommandMetadata{Name: "stop"}) commandregistry.Register(stopper) - //inject fake commands dependencies into registry + // inject fake commands dependencies into registry serviceBinder = new(servicefakes.OldFakeAppBinder) commandregistry.Register(serviceBinder) @@ -1764,7 +1764,7 @@ var _ = Describe("Push Command", func() { args = []string{"--no-hostname", "existing-app"} }) - It("binds the root domain route to an app with a pre-existing route", func() { + It("binds the root domain route to an app with a preexisting route", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(routeActor.FindOrCreateRouteCallCount()).To(Equal(1)) diff --git a/cf/commands/application/rename.go b/cf/commands/application/rename.go index 870217f8390..afb49cc5a1a 100644 --- a/cf/commands/application/rename.go +++ b/cf/commands/application/rename.go @@ -3,14 +3,14 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameApp struct { diff --git a/cf/commands/application/rename_test.go b/cf/commands/application/rename_test.go index 96b786a6341..03691b9ffbb 100644 --- a/cf/commands/application/rename_test.go +++ b/cf/commands/application/rename_test.go @@ -1,18 +1,18 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/restage.go b/cf/commands/application/restage.go index 248a2b0453c..c969e973afb 100644 --- a/cf/commands/application/restage.go +++ b/cf/commands/application/restage.go @@ -3,15 +3,15 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Restage struct { @@ -55,7 +55,7 @@ func (cmd *Restage) SetDependency(deps commandregistry.Dependency, pluginCall bo cmd.config = deps.Config cmd.appRepo = deps.RepoLocator.GetApplicationRepository() - //get command from registry for dependency + // get command from registry for dependency commandDep := commandregistry.Commands.FindCommand("start") commandDep = commandDep.SetDependency(deps, false) cmd.appStagingWatcher = commandDep.(StagingWatcher) diff --git a/cf/commands/application/restage_test.go b/cf/commands/application/restage_test.go index a933a4d0bd1..bc20b3b9b07 100644 --- a/cf/commands/application/restage_test.go +++ b/cf/commands/application/restage_test.go @@ -1,19 +1,19 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -34,7 +34,7 @@ var _ = Describe("restage command", func() { deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo) deps.Config = configRepo - //inject fake 'command dependency' into registry + // inject fake 'command dependency' into registry commandregistry.Register(stagingWatcher) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restage").SetDependency(deps, pluginCall)) @@ -54,7 +54,7 @@ var _ = Describe("restage command", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{}) - //save original command and restore later + // save original command and restore later OriginalCommand = commandregistry.Commands.FindCommand("start") stagingWatcher = &fakeStagingWatcher{} diff --git a/cf/commands/application/restart.go b/cf/commands/application/restart.go index 2668be291c0..cf9f8cf5d76 100644 --- a/cf/commands/application/restart.go +++ b/cf/commands/application/restart.go @@ -3,13 +3,13 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Restarter @@ -63,12 +63,12 @@ func (cmd *Restart) SetDependency(deps commandregistry.Dependency, pluginCall bo cmd.ui = deps.UI cmd.config = deps.Config - //get start for dependency + // get start for dependency starter := commandregistry.Commands.FindCommand("start") starter = starter.SetDependency(deps, false) cmd.starter = starter.(Starter) - //get stop for dependency + // get stop for dependency stopper := commandregistry.Commands.FindCommand("stop") stopper = stopper.SetDependency(deps, false) cmd.stopper = stopper.(Stopper) diff --git a/cf/commands/application/restart_app_instance.go b/cf/commands/application/restart_app_instance.go index c19dd6af3fd..db544a1eb88 100644 --- a/cf/commands/application/restart_app_instance.go +++ b/cf/commands/application/restart_app_instance.go @@ -5,13 +5,13 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RestartAppInstance struct { diff --git a/cf/commands/application/restart_app_instance_test.go b/cf/commands/application/restart_app_instance_test.go index 75b007b4cbe..ffe4d9dbba9 100644 --- a/cf/commands/application/restart_app_instance_test.go +++ b/cf/commands/application/restart_app_instance_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/appinstances/appinstancesfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances/appinstancesfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/restart_test.go b/cf/commands/application/restart_test.go index 0de6d4490f4..49f18fab892 100644 --- a/cf/commands/application/restart_test.go +++ b/cf/commands/application/restart_test.go @@ -3,19 +3,19 @@ package application_test import ( "os" - "code.cloudfoundry.org/cli/cf/commands/application/applicationfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commands/application/applicationfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -37,7 +37,7 @@ var _ = Describe("restart command", func() { deps.UI = ui deps.Config = config - //inject fake 'stopper and starter' into registry + // inject fake 'stopper and starter' into registry commandregistry.Register(starter) commandregistry.Register(stopper) @@ -63,11 +63,11 @@ var _ = Describe("restart command", func() { applicationReq = new(requirementsfakes.FakeApplicationRequirement) applicationReq.GetApplicationReturns(app) - //save original command and restore later + // save original command and restore later originalStart = commandregistry.Commands.FindCommand("start") originalStop = commandregistry.Commands.FindCommand("stop") - //setup fakes to correctly interact with commandregistry + // setup fakes to correctly interact with commandregistry starter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return starter } diff --git a/cf/commands/application/scale.go b/cf/commands/application/scale.go index b6bc67957f0..05485e10d75 100644 --- a/cf/commands/application/scale.go +++ b/cf/commands/application/scale.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Scale struct { @@ -66,7 +66,7 @@ func (cmd *Scale) SetDependency(deps commandregistry.Dependency, pluginCall bool cmd.config = deps.Config cmd.appRepo = deps.RepoLocator.GetApplicationRepository() - //get command from registry for dependency + // get command from registry for dependency commandDep := commandregistry.Commands.FindCommand("restart") commandDep = commandDep.SetDependency(deps, false) cmd.restarter = commandDep.(Restarter) diff --git a/cf/commands/application/scale_test.go b/cf/commands/application/scale_test.go index 9bd0a906908..131b88be0f5 100644 --- a/cf/commands/application/scale_test.go +++ b/cf/commands/application/scale_test.go @@ -1,20 +1,20 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application/applicationfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application/applicationfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("scale command", func() { @@ -34,7 +34,7 @@ var _ = Describe("scale command", func() { deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo) deps.Config = config - //inject fake 'command dependency' into registry + // inject fake 'command dependency' into registry commandregistry.Register(restarter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("scale").SetDependency(deps, pluginCall)) @@ -45,11 +45,11 @@ var _ = Describe("scale command", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{}) - //save original command and restore later + // save original command and restore later OriginalCommand = commandregistry.Commands.FindCommand("restart") restarter = new(applicationfakes.FakeRestarter) - //setup fakes to correctly interact with commandregistry + // setup fakes to correctly interact with commandregistry restarter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return restarter } diff --git a/cf/commands/application/set_env.go b/cf/commands/application/set_env.go index 30363830d61..104e61b8b96 100644 --- a/cf/commands/application/set_env.go +++ b/cf/commands/application/set_env.go @@ -3,15 +3,15 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetEnv struct { diff --git a/cf/commands/application/set_env_test.go b/cf/commands/application/set_env_test.go index 108dc7d8de4..526f2087099 100644 --- a/cf/commands/application/set_env_test.go +++ b/cf/commands/application/set_env_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/set_health_check.go b/cf/commands/application/set_health_check.go index 6a744a23def..50ecaf9039b 100644 --- a/cf/commands/application/set_health_check.go +++ b/cf/commands/application/set_health_check.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetHealthCheck struct { diff --git a/cf/commands/application/set_health_check_test.go b/cf/commands/application/set_health_check_test.go index bf62455c23d..234a321ff5a 100644 --- a/cf/commands/application/set_health_check_test.go +++ b/cf/commands/application/set_health_check_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/ssh.go b/cf/commands/application/ssh.go index f2a8e24481b..1fe8e7f74e1 100644 --- a/cf/commands/application/ssh.go +++ b/cf/commands/application/ssh.go @@ -8,17 +8,17 @@ import ( "golang.org/x/crypto/ssh" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/requirements" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" - "code.cloudfoundry.org/cli/cf/ssh/options" - sshTerminal "code.cloudfoundry.org/cli/cf/ssh/terminal" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/requirements" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" + "code.cloudfoundry.org/cli/v8/cf/ssh/options" + sshTerminal "code.cloudfoundry.org/cli/v8/cf/ssh/terminal" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SSH struct { @@ -95,7 +95,7 @@ func (cmd *SSH) SetDependency(deps commandregistry.Dependency, pluginCall bool) cmd.secureShell = deps.WildcardDependency.(sshCmd.SecureShell) } - //get ssh-code for dependency + // get ssh-code for dependency sshCodeGetter := commandregistry.Commands.FindCommand("ssh-code") sshCodeGetter = sshCodeGetter.SetDependency(deps, false) cmd.sshCodeGetter = sshCodeGetter.(commands.SSHCodeGetter) @@ -107,10 +107,10 @@ func (cmd *SSH) Execute(fc flags.FlagContext) error { if fc.IsSet("i") { instanceIndex := fc.Int("i") if instanceIndex < 0 { - return fmt.Errorf(T("The application instance index cannot be negative")) + return errors.New(T("The application instance index cannot be negative")) } if instanceIndex >= cmd.appReq.GetApplication().InstanceCount { - return fmt.Errorf(T("The specified application instance does not exist")) + return errors.New(T("The specified application instance does not exist")) } } @@ -125,7 +125,7 @@ func (cmd *SSH) Execute(fc flags.FlagContext) error { return errors.New(T("Error getting one time auth code: ") + err.Error()) } - //init secureShell if it is not already set by SetDependency() with fakes + // init secureShell if it is not already set by SetDependency() with fakes if cmd.secureShell == nil { cmd.secureShell = sshCmd.NewSecureShell( sshCmd.DefaultSecureDialer(), diff --git a/cf/commands/application/ssh_enabled.go b/cf/commands/application/ssh_enabled.go index 7152209b907..d49e209af2d 100644 --- a/cf/commands/application/ssh_enabled.go +++ b/cf/commands/application/ssh_enabled.go @@ -3,12 +3,12 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SSHEnabled struct { diff --git a/cf/commands/application/ssh_enabled_test.go b/cf/commands/application/ssh_enabled_test.go index 1ef7c05132e..d41c3e00e38 100644 --- a/cf/commands/application/ssh_enabled_test.go +++ b/cf/commands/application/ssh_enabled_test.go @@ -1,17 +1,17 @@ package application_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/ssh_test.go b/cf/commands/application/ssh_test.go index fe631c61fee..38993dff184 100644 --- a/cf/commands/application/ssh_test.go +++ b/cf/commands/application/ssh_test.go @@ -6,23 +6,23 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/commandsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/ssh/sshfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/commandsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/ssh/sshfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -47,12 +47,12 @@ var _ = Describe("SSH command", func() { requirementsFactory = new(requirementsfakes.FakeFactory) deps.Gateways = make(map[string]net.Gateway) - //save original command and restore later + // save original command and restore later originalSSHCodeGetter = commandregistry.Commands.FindCommand("ssh-code") sshCodeGetter = new(commandsfakes.FakeSSHCodeGetter) - //setup fakes to correctly interact with commandregistry + // setup fakes to correctly interact with commandregistry sshCodeGetter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return sshCodeGetter } @@ -60,7 +60,7 @@ var _ = Describe("SSH command", func() { }) AfterEach(func() { - //restore original command + // restore original command commandregistry.Register(originalSSHCodeGetter) }) @@ -68,7 +68,7 @@ var _ = Describe("SSH command", func() { deps.UI = ui deps.Config = configRepo - //inject fake 'sshCodeGetter' into registry + // inject fake 'sshCodeGetter' into registry commandregistry.Register(sshCodeGetter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("ssh").SetDependency(deps, pluginCall)) @@ -281,7 +281,7 @@ var _ = Describe("SSH command", func() { Context("Error when connecting", func() { It("notifies users", func() { - fakeSecureShell.ConnectReturns(errors.New("dial errorrr")) + fakeSecureShell.ConnectReturns(errors.New("dial error")) runCommand("my-app") diff --git a/cf/commands/application/start.go b/cf/commands/application/start.go index ee78184b8ee..d121c081adc 100644 --- a/cf/commands/application/start.go +++ b/cf/commands/application/start.go @@ -10,17 +10,17 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) const ( @@ -195,7 +195,7 @@ func (cmd *Start) WatchStaging(app models.Application, orgName, spaceName string } cmd.ui.Ok() - //detectedstartcommand on first push is not present until starting completes + // detectedstartcommand on first push is not present until starting completes startedApp, err := cmd.appRepo.GetApp(updatedApp.GUID) if err != nil { return models.Application{}, err @@ -340,7 +340,7 @@ func (cmd *Start) waitForOneRunningInstance(app models.Application) error { } if count.flapping > 0 || count.crashed > 0 { - return fmt.Errorf(T("Start unsuccessful\n\nTIP: use '{{.Command}}' for more information", + return errors.New(T("Start unsuccessful\n\nTIP: use '{{.Command}}' for more information", map[string]interface{}{"Command": terminal.CommandColor(fmt.Sprintf("%s logs %s --recent", cf.Name, app.Name))})) } @@ -393,40 +393,40 @@ func (cmd Start) fetchInstanceCount(appGUID string) (instanceCount, error) { } func instancesDetails(count instanceCount) string { - details := []string{fmt.Sprintf(T("{{.RunningCount}} of {{.TotalCount}} instances running", - map[string]interface{}{"RunningCount": count.running, "TotalCount": count.total}))} + details := []string{T("{{.RunningCount}} of {{.TotalCount}} instances running", + map[string]interface{}{"RunningCount": count.running, "TotalCount": count.total})} if count.starting > 0 { if len(count.startingDetails) == 0 { - details = append(details, fmt.Sprintf(T("{{.StartingCount}} starting", - map[string]interface{}{"StartingCount": count.starting}))) + details = append(details, T("{{.StartingCount}} starting", + map[string]interface{}{"StartingCount": count.starting})) } else { info := []string{} for d := range count.startingDetails { info = append(info, d) } sort.Strings(info) - details = append(details, fmt.Sprintf(T("{{.StartingCount}} starting ({{.Details}})", + details = append(details, T("{{.StartingCount}} starting ({{.Details}})", map[string]interface{}{ "StartingCount": count.starting, "Details": strings.Join(info, ", "), - }))) + })) } } if count.down > 0 { - details = append(details, fmt.Sprintf(T("{{.DownCount}} down", - map[string]interface{}{"DownCount": count.down}))) + details = append(details, T("{{.DownCount}} down", + map[string]interface{}{"DownCount": count.down})) } if count.flapping > 0 { - details = append(details, fmt.Sprintf(T("{{.FlappingCount}} failing", - map[string]interface{}{"FlappingCount": count.flapping}))) + details = append(details, T("{{.FlappingCount}} failing", + map[string]interface{}{"FlappingCount": count.flapping})) } if count.crashed > 0 { - details = append(details, fmt.Sprintf(T("{{.CrashedCount}} crashed", - map[string]interface{}{"CrashedCount": count.crashed}))) + details = append(details, T("{{.CrashedCount}} crashed", + map[string]interface{}{"CrashedCount": count.crashed})) } return strings.Join(details, ", ") diff --git a/cf/commands/application/start_test.go b/cf/commands/application/start_test.go index 8b161e40e37..4ecbd81502e 100644 --- a/cf/commands/application/start_test.go +++ b/cf/commands/application/start_test.go @@ -5,32 +5,32 @@ import ( "runtime" "time" - . "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/commands/application/applicationfakes" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - - "code.cloudfoundry.org/cli/cf/api/appinstances/appinstancesfakes" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/api/logs" - "code.cloudfoundry.org/cli/cf/api/logs/logsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/commands/application/applicationfakes" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + + "code.cloudfoundry.org/cli/v8/cf/api/appinstances/appinstancesfakes" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/logs" + "code.cloudfoundry.org/cli/v8/cf/api/logs/logsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" "sync" "sync/atomic" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -59,7 +59,7 @@ var _ = Describe("start command", func() { deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo) deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo) - //inject fake 'Start' into registry + // inject fake 'Start' into registry commandregistry.Register(displayApp) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("start").SetDependency(deps, false)) @@ -104,7 +104,7 @@ var _ = Describe("start command", func() { displayApp = new(applicationfakes.FakeAppDisplayer) - //save original command dependency and restore later + // save original command dependency and restore later originalAppCommand = commandregistry.Commands.FindCommand("app") defaultInstanceErrorCodes = []string{"", ""} @@ -291,14 +291,14 @@ var _ = Describe("start command", func() { }) Context("when the timeout happens exactly when the connection is established", func() { - //var startWait *sync.WaitGroup + // var startWait *sync.WaitGroup BeforeEach(func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{}) configRepo = testconfig.NewRepositoryWithDefaults() logRepo.TailLogsForStub = func(appGUID string, onConnect func(), logChan chan<- logs.Loggable, errChan chan<- error) { - //startWait.Wait() + // startWait.Wait() onConnect() } }) diff --git a/cf/commands/application/stop.go b/cf/commands/application/stop.go index c78385ae9fc..fa260899f4c 100644 --- a/cf/commands/application/stop.go +++ b/cf/commands/application/stop.go @@ -3,15 +3,15 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Stopper diff --git a/cf/commands/application/stop_test.go b/cf/commands/application/stop_test.go index 93c2c83c77c..391e7711ff4 100644 --- a/cf/commands/application/stop_test.go +++ b/cf/commands/application/stop_test.go @@ -3,19 +3,19 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/application" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/application/unset_env.go b/cf/commands/application/unset_env.go index f3754350cb4..92b261ff8a5 100644 --- a/cf/commands/application/unset_env.go +++ b/cf/commands/application/unset_env.go @@ -3,15 +3,15 @@ package application import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnsetEnv struct { diff --git a/cf/commands/application/unset_env_test.go b/cf/commands/application/unset_env_test.go index 3917233915f..640801fe5f4 100644 --- a/cf/commands/application/unset_env_test.go +++ b/cf/commands/application/unset_env_test.go @@ -3,18 +3,18 @@ package application_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/auth.go b/cf/commands/auth.go index f65539edfff..7e294a0f3e4 100644 --- a/cf/commands/auth.go +++ b/cf/commands/auth.go @@ -3,14 +3,14 @@ package commands import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Authenticate struct { diff --git a/cf/commands/auth_test.go b/cf/commands/auth_test.go index ec81d8e3617..26b14b1aaf6 100644 --- a/cf/commands/auth_test.go +++ b/cf/commands/auth_test.go @@ -3,22 +3,22 @@ package commands_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("auth command", func() { diff --git a/cf/commands/buildpack/buildpack_suite_test.go b/cf/commands/buildpack/buildpack_suite_test.go index 645b9c09487..8b93e4ee8e1 100644 --- a/cf/commands/buildpack/buildpack_suite_test.go +++ b/cf/commands/buildpack/buildpack_suite_test.go @@ -1,10 +1,10 @@ package buildpack_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/buildpack/buildpacks.go b/cf/commands/buildpack/buildpacks.go index 9971cce2136..33f657ecd6b 100644 --- a/cf/commands/buildpack/buildpacks.go +++ b/cf/commands/buildpack/buildpacks.go @@ -4,14 +4,14 @@ import ( "errors" "strconv" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListBuildpacks struct { diff --git a/cf/commands/buildpack/buildpacks_test.go b/cf/commands/buildpack/buildpacks_test.go index 03c1f8164a1..b4d9f1e926a 100644 --- a/cf/commands/buildpack/buildpacks_test.go +++ b/cf/commands/buildpack/buildpacks_test.go @@ -1,18 +1,18 @@ package buildpack_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commands/buildpack" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commands/buildpack" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -79,7 +79,7 @@ var _ = Describe("ListBuildpacks", func() { p3 := 15 t := true f := false - linux := "cflinuxfs2" + linux := "cflinuxfs4" buildpackRepo.Buildpacks = []models.Buildpack{ {Name: "Buildpack-1", Stack: linux, Position: &p1, Enabled: &t, Locked: &f}, @@ -92,9 +92,9 @@ var _ = Describe("ListBuildpacks", func() { Expect(ui.Outputs()).To(ContainSubstrings( []string{"Getting buildpacks"}, []string{"buildpack", "stack", "position", "enabled"}, - []string{"Buildpack-1", "cflinuxfs2", "5", "true", "false"}, - []string{"Buildpack-2", "cflinuxfs2", "10", "false", "true"}, - []string{"Buildpack-3", "cflinuxfs2", "15", "true", "false"}, + []string{"Buildpack-1", "cflinuxfs4", "5", "true", "false"}, + []string{"Buildpack-2", "cflinuxfs4", "10", "false", "true"}, + []string{"Buildpack-3", "cflinuxfs4", "15", "true", "false"}, )) }) diff --git a/cf/commands/buildpack/create_buildpack.go b/cf/commands/buildpack/create_buildpack.go index b04eceb9f05..b79ce3c6cc3 100644 --- a/cf/commands/buildpack/create_buildpack.go +++ b/cf/commands/buildpack/create_buildpack.go @@ -4,16 +4,16 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateBuildpack struct { @@ -115,7 +115,7 @@ func (cmd *CreateBuildpack) Execute(c flags.FlagContext) error { func (cmd CreateBuildpack) createBuildpack(buildpackName string, c flags.FlagContext) (buildpack models.Buildpack, apiErr error) { position, err := strconv.Atoi(c.Args()[2]) if err != nil { - apiErr = fmt.Errorf(T("Error {{.ErrorDescription}} is being passed in as the argument for 'Position' but 'Position' requires an integer. For more syntax help, see `cf create-buildpack -h`.", map[string]interface{}{"ErrorDescription": c.Args()[2]})) + apiErr = errors.New(T("Error {{.ErrorDescription}} is being passed in as the argument for 'Position' but 'Position' requires an integer. For more syntax help, see `cf create-buildpack -h`.", map[string]interface{}{"ErrorDescription": c.Args()[2]})) return } diff --git a/cf/commands/buildpack/create_buildpack_test.go b/cf/commands/buildpack/create_buildpack_test.go index aed50533098..38ca11c1ab3 100644 --- a/cf/commands/buildpack/create_buildpack_test.go +++ b/cf/commands/buildpack/create_buildpack_test.go @@ -3,17 +3,17 @@ package buildpack_test import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/buildpack/delete_buildpack.go b/cf/commands/buildpack/delete_buildpack.go index d46f119b5e6..3d49ce1f1b6 100644 --- a/cf/commands/buildpack/delete_buildpack.go +++ b/cf/commands/buildpack/delete_buildpack.go @@ -3,14 +3,14 @@ package buildpack import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteBuildpack struct { @@ -87,7 +87,7 @@ func (cmd *DeleteBuildpack) Execute(c flags.FlagContext) error { } switch err.(type) { - case nil: //do nothing + case nil: // do nothing case *errors.ModelNotFoundError: cmd.ui.Ok() if stack == "" { diff --git a/cf/commands/buildpack/delete_buildpack_test.go b/cf/commands/buildpack/delete_buildpack_test.go index 26b10588c77..8a80e696668 100644 --- a/cf/commands/buildpack/delete_buildpack_test.go +++ b/cf/commands/buildpack/delete_buildpack_test.go @@ -1,18 +1,18 @@ package buildpack_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-buildpack command", func() { @@ -79,7 +79,7 @@ var _ = Describe("delete-buildpack command", func() { }) Context("when the force flag is provided", func() { - It("does not prompt the user to delete the buildback", func() { + It("does not prompt the user to delete the buildpack", func() { runCommand("-f", "my-buildpack") Expect(buildpackRepo.DeleteBuildpackGUID).To(Equal("my-buildpack-guid")) diff --git a/cf/commands/buildpack/rename_buildpack.go b/cf/commands/buildpack/rename_buildpack.go index d9341db19d1..cc3ca0fa118 100644 --- a/cf/commands/buildpack/rename_buildpack.go +++ b/cf/commands/buildpack/rename_buildpack.go @@ -4,12 +4,12 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameBuildpack struct { diff --git a/cf/commands/buildpack/rename_buildpack_test.go b/cf/commands/buildpack/rename_buildpack_test.go index 316c82e8a0e..17449c44c0d 100644 --- a/cf/commands/buildpack/rename_buildpack_test.go +++ b/cf/commands/buildpack/rename_buildpack_test.go @@ -1,18 +1,18 @@ package buildpack_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("rename-buildpack command", func() { diff --git a/cf/commands/buildpack/update_buildpack.go b/cf/commands/buildpack/update_buildpack.go index a6d50a0bcc9..121e2ba019b 100644 --- a/cf/commands/buildpack/update_buildpack.go +++ b/cf/commands/buildpack/update_buildpack.go @@ -5,12 +5,12 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateBuildpack struct { diff --git a/cf/commands/buildpack/update_buildpack_test.go b/cf/commands/buildpack/update_buildpack_test.go index f2160f1c1ab..591eb1c75b9 100644 --- a/cf/commands/buildpack/update_buildpack_test.go +++ b/cf/commands/buildpack/update_buildpack_test.go @@ -4,16 +4,16 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/commands_suite_test.go b/cf/commands/commands_suite_test.go index 88f26b1a8f4..d2f20fe01f2 100644 --- a/cf/commands/commands_suite_test.go +++ b/cf/commands/commands_suite_test.go @@ -1,10 +1,10 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" diff --git a/cf/commands/commandsfakes/fake_sshcode_getter.go b/cf/commands/commandsfakes/fake_sshcode_getter.go index f7b1615709f..2a7be2c6d74 100644 --- a/cf/commands/commandsfakes/fake_sshcode_getter.go +++ b/cf/commands/commandsfakes/fake_sshcode_getter.go @@ -4,10 +4,10 @@ package commandsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeSSHCodeGetter struct { @@ -80,15 +80,16 @@ func (fake *FakeSSHCodeGetter) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -139,15 +140,16 @@ func (fake *FakeSSHCodeGetter) Get() (string, error) { ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] fake.getArgsForCall = append(fake.getArgsForCall, struct { }{}) + stub := fake.GetStub + fakeReturns := fake.getReturns fake.recordInvocation("Get", []interface{}{}) fake.getMutex.Unlock() - if fake.GetStub != nil { - return fake.GetStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getReturns return fakeReturns.result1, fakeReturns.result2 } @@ -194,15 +196,16 @@ func (fake *FakeSSHCodeGetter) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -248,15 +251,16 @@ func (fake *FakeSSHCodeGetter) Requirements(arg1 requirements.Factory, arg2 flag arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -312,15 +316,16 @@ func (fake *FakeSSHCodeGetter) SetDependency(arg1 commandregistry.Dependency, ar arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } diff --git a/cf/commands/config.go b/cf/commands/config.go index 83d003e59d3..ffceaecae63 100644 --- a/cf/commands/config.go +++ b/cf/commands/config.go @@ -4,13 +4,13 @@ import ( "errors" "sort" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ConfigCommands struct { diff --git a/cf/commands/config_test.go b/cf/commands/config_test.go index e758ddc0681..6d9b4f84e2d 100644 --- a/cf/commands/config_test.go +++ b/cf/commands/config_test.go @@ -1,15 +1,15 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -57,7 +57,7 @@ var _ = Describe("config command", func() { )) }) - It("fails with usage when a negative timout is passed", func() { + It("fails with usage when a negative timeout is passed", func() { runCommand("--async-timeout", "-555") Expect(ui.Outputs()).To(ContainSubstrings( []string{"Incorrect Usage"}, diff --git a/cf/commands/create_app_manifest.go b/cf/commands/create_app_manifest.go index b70141873df..3be17b30f6d 100644 --- a/cf/commands/create_app_manifest.go +++ b/cf/commands/create_app_manifest.go @@ -6,18 +6,18 @@ import ( "os" "sort" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/appinstances" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/appinstances" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateAppManifest struct { @@ -157,7 +157,7 @@ func (cmd *CreateAppManifest) createManifest(app models.Application) error { default: return errors.New(T("Failed to create manifest, unable to parse environment variable: ") + envVarKey) case float64: - //json.Unmarshal turn all numbers to float64 + // json.Unmarshal turn all numbers to float64 value := int(app.EnvironmentVars[envVarKey].(float64)) cmd.manifest.EnvironmentVars(app.Name, envVarKey, fmt.Sprintf("%d", value)) case bool: diff --git a/cf/commands/create_app_manifest_test.go b/cf/commands/create_app_manifest_test.go index 1d913ca8bbe..06902be18c4 100644 --- a/cf/commands/create_app_manifest_test.go +++ b/cf/commands/create_app_manifest_test.go @@ -4,25 +4,25 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/manifest/manifestfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/manifest/manifestfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/stacks/stacksfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" uuid "github.com/nu7hatch/gouuid" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/curl.go b/cf/commands/curl.go index 783577c3aa1..56e73279c20 100644 --- a/cf/commands/curl.go +++ b/cf/commands/curl.go @@ -10,17 +10,17 @@ import ( "path/filepath" "strings" - "code.cloudfoundry.org/cli/cf/flagcontext" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cfErrors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/flagcontext" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cfErrors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type Curl struct { @@ -54,7 +54,7 @@ func (cmd *Curl) MetaData() commandregistry.CommandMetadata { will be set to application/json. You may override headers with -H and the request method with -X. - For API documentation, please visit http://apidocs.cloudfoundry.org.`), + For API documentation, please visit http://v2-apidocs.cloudfoundry.org.`), }, Examples: []string{ `CF_NAME curl "/v2/apps" -X GET -H "Content-Type: application/x-www-form-urlencoded" -d 'q=name:myapp'`, diff --git a/cf/commands/curl_test.go b/cf/commands/curl_test.go index 1f62002b1ef..4de1023c19d 100644 --- a/cf/commands/curl_test.go +++ b/cf/commands/curl_test.go @@ -5,20 +5,20 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "code.cloudfoundry.org/gofileutils/fileutils" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/trace" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/trace" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -148,7 +148,7 @@ var _ = Describe("curl command", func() { Expect(ui.Outputs()).To(ContainSubstrings([]string{"The requested URL returned error: 500"})) }) - It("does not fail on HTTP erros if --fail is false", func() { + It("does not fail on HTTP errors if --fail is false", func() { runCurlWithInputs([]string{"--fail", "false", "/foo"}) Expect(curlRepo.FailOnHTTPError).To(Equal(false)) diff --git a/cf/commands/domain/create_domain.go b/cf/commands/domain/create_domain.go index b818e8540df..1b2bbf090de 100644 --- a/cf/commands/domain/create_domain.go +++ b/cf/commands/domain/create_domain.go @@ -3,13 +3,13 @@ package domain import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateDomain struct { diff --git a/cf/commands/domain/create_domain_test.go b/cf/commands/domain/create_domain_test.go index 42900f1f333..69e960f55cd 100644 --- a/cf/commands/domain/create_domain_test.go +++ b/cf/commands/domain/create_domain_test.go @@ -1,18 +1,18 @@ package domain_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/domain/create_shared_domain.go b/cf/commands/domain/create_shared_domain.go index ef6a1cae14b..fb3a8871f68 100644 --- a/cf/commands/domain/create_shared_domain.go +++ b/cf/commands/domain/create_shared_domain.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateSharedDomain struct { diff --git a/cf/commands/domain/create_shared_domain_test.go b/cf/commands/domain/create_shared_domain_test.go index aeb90c422a8..04129e75c02 100644 --- a/cf/commands/domain/create_shared_domain_test.go +++ b/cf/commands/domain/create_shared_domain_test.go @@ -3,21 +3,21 @@ package domain_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/cf/commands/domain" - "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commands/domain" + "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/domain/delete_domain.go b/cf/commands/domain/delete_domain.go index 09c650ba6b5..db7d43387f5 100644 --- a/cf/commands/domain/delete_domain.go +++ b/cf/commands/domain/delete_domain.go @@ -3,14 +3,14 @@ package domain import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteDomain struct { diff --git a/cf/commands/domain/delete_domain_test.go b/cf/commands/domain/delete_domain_test.go index 5dfbdf4a879..2a73296fe17 100644 --- a/cf/commands/domain/delete_domain_test.go +++ b/cf/commands/domain/delete_domain_test.go @@ -1,20 +1,20 @@ package domain_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-domain command", func() { diff --git a/cf/commands/domain/delete_shared_domain.go b/cf/commands/domain/delete_shared_domain.go index c8f966a1c87..9cd4d9048c3 100644 --- a/cf/commands/domain/delete_shared_domain.go +++ b/cf/commands/domain/delete_shared_domain.go @@ -3,14 +3,14 @@ package domain import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteSharedDomain struct { diff --git a/cf/commands/domain/delete_shared_domain_test.go b/cf/commands/domain/delete_shared_domain_test.go index 284406cb954..4eb18b779e4 100644 --- a/cf/commands/domain/delete_shared_domain_test.go +++ b/cf/commands/domain/delete_shared_domain_test.go @@ -1,19 +1,19 @@ package domain_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -50,7 +50,7 @@ var _ = Describe("delete-shared-domain command", func() { Expect(runCommand("foo.com")).To(BeFalse()) }) - It("fails if an organiztion is not targeted", func() { + It("fails if an organization is not targeted", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) targetedOrganizationReq := new(requirementsfakes.FakeTargetedOrgRequirement) @@ -86,7 +86,7 @@ var _ = Describe("delete-shared-domain command", func() { }) }) - Context("when logged in and targeted an organiztion", func() { + Context("when logged in and targeted an organization", func() { BeforeEach(func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement)) diff --git a/cf/commands/domain/domain_suite_test.go b/cf/commands/domain/domain_suite_test.go index c696c68d042..28f90a83a6e 100644 --- a/cf/commands/domain/domain_suite_test.go +++ b/cf/commands/domain/domain_suite_test.go @@ -1,10 +1,10 @@ package domain_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/domain/domains.go b/cf/commands/domain/domains.go index 8956bc42843..b62bc116d06 100644 --- a/cf/commands/domain/domains.go +++ b/cf/commands/domain/domains.go @@ -3,14 +3,14 @@ package domain import ( "errors" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListDomains struct { diff --git a/cf/commands/domain/domains_test.go b/cf/commands/domain/domains_test.go index 4ad9a0c1528..c1ff8d8cf82 100644 --- a/cf/commands/domain/domains_test.go +++ b/cf/commands/domain/domains_test.go @@ -3,22 +3,22 @@ package domain_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - - "code.cloudfoundry.org/cli/cf/commands/domain" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + + "code.cloudfoundry.org/cli/v8/cf/commands/domain" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/environmentvariablegroup/environmentvariablegroup_suite_test.go b/cf/commands/environmentvariablegroup/environmentvariablegroup_suite_test.go index 20c66b47a75..b3876818401 100644 --- a/cf/commands/environmentvariablegroup/environmentvariablegroup_suite_test.go +++ b/cf/commands/environmentvariablegroup/environmentvariablegroup_suite_test.go @@ -1,9 +1,9 @@ package environmentvariablegroup_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/environmentvariablegroup/running_environment_variable_group.go b/cf/commands/environmentvariablegroup/running_environment_variable_group.go index d123fcd468f..c1e210dd832 100644 --- a/cf/commands/environmentvariablegroup/running_environment_variable_group.go +++ b/cf/commands/environmentvariablegroup/running_environment_variable_group.go @@ -3,14 +3,14 @@ package environmentvariablegroup import ( "sort" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RunningEnvironmentVariableGroup struct { diff --git a/cf/commands/environmentvariablegroup/running_environment_variable_group_test.go b/cf/commands/environmentvariablegroup/running_environment_variable_group_test.go index 40d13e8f4ce..bbc8f3855cb 100644 --- a/cf/commands/environmentvariablegroup/running_environment_variable_group_test.go +++ b/cf/commands/environmentvariablegroup/running_environment_variable_group_test.go @@ -1,19 +1,19 @@ package environmentvariablegroup_test import ( - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/environmentvariablegroup" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/environmentvariablegroup" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/environmentvariablegroup/set_running_environment_variable_group.go b/cf/commands/environmentvariablegroup/set_running_environment_variable_group.go index 45430d558c2..10911a5aaf9 100644 --- a/cf/commands/environmentvariablegroup/set_running_environment_variable_group.go +++ b/cf/commands/environmentvariablegroup/set_running_environment_variable_group.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cf_errors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cf_errors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetRunningEnvironmentVariableGroup struct { diff --git a/cf/commands/environmentvariablegroup/set_running_environment_variable_group_test.go b/cf/commands/environmentvariablegroup/set_running_environment_variable_group_test.go index ea20e503d07..8c66fe9f8d7 100644 --- a/cf/commands/environmentvariablegroup/set_running_environment_variable_group_test.go +++ b/cf/commands/environmentvariablegroup/set_running_environment_variable_group_test.go @@ -1,17 +1,17 @@ package environmentvariablegroup_test import ( - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cf_errors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cf_errors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/environmentvariablegroup/set_staging_environment_variable_group.go b/cf/commands/environmentvariablegroup/set_staging_environment_variable_group.go index e995b8cf2e0..084e488507a 100644 --- a/cf/commands/environmentvariablegroup/set_staging_environment_variable_group.go +++ b/cf/commands/environmentvariablegroup/set_staging_environment_variable_group.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cf_errors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cf_errors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetStagingEnvironmentVariableGroup struct { diff --git a/cf/commands/environmentvariablegroup/set_staging_environment_variable_group_test.go b/cf/commands/environmentvariablegroup/set_staging_environment_variable_group_test.go index 48ec90e844b..dac48a7c4a4 100644 --- a/cf/commands/environmentvariablegroup/set_staging_environment_variable_group_test.go +++ b/cf/commands/environmentvariablegroup/set_staging_environment_variable_group_test.go @@ -1,17 +1,17 @@ package environmentvariablegroup_test import ( - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cf_errors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cf_errors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/environmentvariablegroup/staging_environment_variable_group.go b/cf/commands/environmentvariablegroup/staging_environment_variable_group.go index ba246d57fec..f6d0ecbb599 100644 --- a/cf/commands/environmentvariablegroup/staging_environment_variable_group.go +++ b/cf/commands/environmentvariablegroup/staging_environment_variable_group.go @@ -3,14 +3,14 @@ package environmentvariablegroup import ( "sort" - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type StagingEnvironmentVariableGroup struct { diff --git a/cf/commands/environmentvariablegroup/staging_environment_variable_group_test.go b/cf/commands/environmentvariablegroup/staging_environment_variable_group_test.go index 4ddc50cb20d..d2e109d37af 100644 --- a/cf/commands/environmentvariablegroup/staging_environment_variable_group_test.go +++ b/cf/commands/environmentvariablegroup/staging_environment_variable_group_test.go @@ -1,19 +1,19 @@ package environmentvariablegroup_test import ( - "code.cloudfoundry.org/cli/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/environmentvariablegroup" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/environmentvariablegroups/environmentvariablegroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/environmentvariablegroup" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/featureflag/disable_feature_flag.go b/cf/commands/featureflag/disable_feature_flag.go index 2ae884c2df7..c4d1e719b9a 100644 --- a/cf/commands/featureflag/disable_feature_flag.go +++ b/cf/commands/featureflag/disable_feature_flag.go @@ -3,13 +3,13 @@ package featureflag import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DisableFeatureFlag struct { diff --git a/cf/commands/featureflag/disable_feature_flag_test.go b/cf/commands/featureflag/disable_feature_flag_test.go index 91cc631fda7..f94304a86d3 100644 --- a/cf/commands/featureflag/disable_feature_flag_test.go +++ b/cf/commands/featureflag/disable_feature_flag_test.go @@ -3,16 +3,16 @@ package featureflag_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/featureflag/enable_feature_flag.go b/cf/commands/featureflag/enable_feature_flag.go index 196dc9cafc0..3493fbd52e7 100644 --- a/cf/commands/featureflag/enable_feature_flag.go +++ b/cf/commands/featureflag/enable_feature_flag.go @@ -3,13 +3,13 @@ package featureflag import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type EnableFeatureFlag struct { diff --git a/cf/commands/featureflag/enable_feature_flag_test.go b/cf/commands/featureflag/enable_feature_flag_test.go index 157eab5a4b0..203780e8830 100644 --- a/cf/commands/featureflag/enable_feature_flag_test.go +++ b/cf/commands/featureflag/enable_feature_flag_test.go @@ -3,16 +3,16 @@ package featureflag_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/featureflag/feature_flag.go b/cf/commands/featureflag/feature_flag.go index 284fc95c7c7..14df38e35a6 100644 --- a/cf/commands/featureflag/feature_flag.go +++ b/cf/commands/featureflag/feature_flag.go @@ -3,13 +3,13 @@ package featureflag import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ShowFeatureFlag struct { diff --git a/cf/commands/featureflag/feature_flag_test.go b/cf/commands/featureflag/feature_flag_test.go index 7f23cab5961..f32622b49a7 100644 --- a/cf/commands/featureflag/feature_flag_test.go +++ b/cf/commands/featureflag/feature_flag_test.go @@ -3,17 +3,17 @@ package featureflag_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/featureflag/feature_flags.go b/cf/commands/featureflag/feature_flags.go index 045e5575bc3..fa0a7c21763 100644 --- a/cf/commands/featureflag/feature_flags.go +++ b/cf/commands/featureflag/feature_flags.go @@ -1,13 +1,13 @@ package featureflag import ( - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListFeatureFlags struct { diff --git a/cf/commands/featureflag/feature_flags_test.go b/cf/commands/featureflag/feature_flags_test.go index 305c74e3bc9..e564e6ad5b9 100644 --- a/cf/commands/featureflag/feature_flags_test.go +++ b/cf/commands/featureflag/feature_flags_test.go @@ -3,19 +3,19 @@ package featureflag_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/featureflag" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/featureflag" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/featureflag/featureflag_suite_test.go b/cf/commands/featureflag/featureflag_suite_test.go index ebb4558e84d..9b6f42effc8 100644 --- a/cf/commands/featureflag/featureflag_suite_test.go +++ b/cf/commands/featureflag/featureflag_suite_test.go @@ -1,9 +1,9 @@ package featureflag_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/help.go b/cf/commands/help.go index 4415d7de931..0a6366786ab 100644 --- a/cf/commands/help.go +++ b/cf/commands/help.go @@ -4,14 +4,14 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/help" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/help" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type Help struct { @@ -53,7 +53,7 @@ func (cmd *Help) Execute(c flags.FlagContext) error { if commandregistry.Commands.CommandExists(cmdName) { cmd.ui.Say(commandregistry.Commands.CommandUsage(cmdName)) } else { - //check plugin commands + // check plugin commands found := false for _, meta := range cmd.config.Plugins() { for _, c := range meta.Commands { @@ -72,7 +72,7 @@ func (cmd *Help) Execute(c flags.FlagContext) error { if len(c.UsageDetails.Options) > 0 { output += "\n" + T("OPTIONS:") + "\n" - //find longest name length + // find longest name length l := 0 for n := range c.UsageDetails.Options { if len(n) > l { diff --git a/cf/commands/help_test.go b/cf/commands/help_test.go index 0ea5301bcad..17f84a50905 100644 --- a/cf/commands/help_test.go +++ b/cf/commands/help_test.go @@ -3,17 +3,17 @@ package commands_test import ( "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/commandsloader" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig/pluginconfigfakes" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/plugin" - - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/commandsloader" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig/pluginconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/plugin" + + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cf/commands/login.go b/cf/commands/login.go index 4dbea14d2e9..1f2fd7a9aa6 100644 --- a/cf/commands/login.go +++ b/cf/commands/login.go @@ -4,20 +4,20 @@ import ( "errors" "strconv" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" - - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) const maxLoginTries = 3 diff --git a/cf/commands/login_test.go b/cf/commands/login_test.go index 88993b7e210..04542d6d38c 100644 --- a/cf/commands/login_test.go +++ b/cf/commands/login_test.go @@ -3,21 +3,21 @@ package commands_test import ( "strconv" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("Login Command", func() { @@ -760,7 +760,7 @@ var _ = Describe("Login Command", func() { }) }) - Describe("and the login fails authenticaton", func() { + Describe("and the login fails authentication", func() { BeforeEach(func() { authRepo.AuthenticateReturns(errors.New("Error authenticating.")) diff --git a/cf/commands/logout.go b/cf/commands/logout.go index e74e6d58ae4..2b2dc6373b6 100644 --- a/cf/commands/logout.go +++ b/cf/commands/logout.go @@ -1,12 +1,12 @@ package commands import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Logout struct { diff --git a/cf/commands/logout_test.go b/cf/commands/logout_test.go index 7625ab8a4d1..d45c21067f9 100644 --- a/cf/commands/logout_test.go +++ b/cf/commands/logout_test.go @@ -1,13 +1,13 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/oauth_token.go b/cf/commands/oauth_token.go index 3013e9d9764..e2fc11de24b 100644 --- a/cf/commands/oauth_token.go +++ b/cf/commands/oauth_token.go @@ -1,14 +1,14 @@ package commands import ( - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type OAuthToken struct { diff --git a/cf/commands/oauth_token_test.go b/cf/commands/oauth_token_test.go index 7883c92691f..9d21b5c1414 100644 --- a/cf/commands/oauth_token_test.go +++ b/cf/commands/oauth_token_test.go @@ -3,21 +3,21 @@ package commands_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/organization/create_org.go b/cf/commands/organization/create_org.go index 598c20fc4d5..e9c37c1b1d9 100644 --- a/cf/commands/organization/create_org.go +++ b/cf/commands/organization/create_org.go @@ -3,19 +3,19 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateOrg struct { @@ -66,7 +66,7 @@ func (cmd *CreateOrg) SetDependency(deps commandregistry.Dependency, pluginCall cmd.quotaRepo = deps.RepoLocator.GetQuotaRepository() cmd.flagRepo = deps.RepoLocator.GetFeatureFlagRepository() - //get command from registry for dependency + // get command from registry for dependency commandDep := commandregistry.Commands.FindCommand("set-org-role") commandDep = commandDep.SetDependency(deps, false) cmd.orgRoleSetter = commandDep.(user.OrgRoleSetter) diff --git a/cf/commands/organization/create_org_test.go b/cf/commands/organization/create_org_test.go index d07907e6867..f912d2c2e2c 100644 --- a/cf/commands/organization/create_org_test.go +++ b/cf/commands/organization/create_org_test.go @@ -1,23 +1,23 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/commands/user/userfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commands/user/userfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -41,7 +41,7 @@ var _ = Describe("create-org command", func() { deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo) deps.Config = config - //inject fake 'command dependency' into registry + // inject fake 'command dependency' into registry commandregistry.Register(orgRoleSetter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-org").SetDependency(deps, pluginCall)) @@ -58,13 +58,13 @@ var _ = Describe("create-org command", func() { config.SetAPIVersion("2.36.9") orgRoleSetter = new(userfakes.FakeOrgRoleSetter) - //setup fakes to correctly interact with commandregistry + // setup fakes to correctly interact with commandregistry orgRoleSetter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return orgRoleSetter } orgRoleSetter.MetaDataReturns(commandregistry.CommandMetadata{Name: "set-org-role"}) - //save original command and restore later + // save original command and restore later OriginalCommand = commandregistry.Commands.FindCommand("set-org-role") }) @@ -187,7 +187,7 @@ var _ = Describe("create-org command", func() { }) }) - Context("when allowing a non-defualt quota", func() { + Context("when allowing a non-default quota", func() { var ( quota models.QuotaFields ) diff --git a/cf/commands/organization/delete_org.go b/cf/commands/organization/delete_org.go index de15697f965..6a2f1f37981 100644 --- a/cf/commands/organization/delete_org.go +++ b/cf/commands/organization/delete_org.go @@ -3,15 +3,15 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteOrg struct { diff --git a/cf/commands/organization/delete_org_test.go b/cf/commands/organization/delete_org_test.go index dc7eeac16f4..beaf416fca8 100644 --- a/cf/commands/organization/delete_org_test.go +++ b/cf/commands/organization/delete_org_test.go @@ -1,20 +1,20 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/organization/org.go b/cf/commands/organization/org.go index c8d2034267e..08365f833ab 100644 --- a/cf/commands/organization/org.go +++ b/cf/commands/organization/org.go @@ -5,16 +5,16 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type ShowOrg struct { diff --git a/cf/commands/organization/org_test.go b/cf/commands/organization/org_test.go index 5edc37bfe73..0237c1bb5c9 100644 --- a/cf/commands/organization/org_test.go +++ b/cf/commands/organization/org_test.go @@ -1,19 +1,19 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commands/organization" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commands/organization" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/organization/organization_suite_test.go b/cf/commands/organization/organization_suite_test.go index 4651be2cf18..23cc24193f8 100644 --- a/cf/commands/organization/organization_suite_test.go +++ b/cf/commands/organization/organization_suite_test.go @@ -1,9 +1,9 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/organization/orgs.go b/cf/commands/organization/orgs.go index 6168ccfc974..86e5ce8dc82 100644 --- a/cf/commands/organization/orgs.go +++ b/cf/commands/organization/orgs.go @@ -3,15 +3,15 @@ package organization import ( "errors" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) const orgLimit = 0 diff --git a/cf/commands/organization/orgs_test.go b/cf/commands/organization/orgs_test.go index 9d5d025f399..bbe42e981a4 100644 --- a/cf/commands/organization/orgs_test.go +++ b/cf/commands/organization/orgs_test.go @@ -3,23 +3,23 @@ package organization_test import ( "os" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commands/organization" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands/organization" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("orgs command", func() { diff --git a/cf/commands/organization/rename_org.go b/cf/commands/organization/rename_org.go index cbbf929bd2f..5ae28e00425 100644 --- a/cf/commands/organization/rename_org.go +++ b/cf/commands/organization/rename_org.go @@ -3,13 +3,13 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameOrg struct { diff --git a/cf/commands/organization/rename_org_test.go b/cf/commands/organization/rename_org_test.go index e75b34c17c8..ae507c61de2 100644 --- a/cf/commands/organization/rename_org_test.go +++ b/cf/commands/organization/rename_org_test.go @@ -1,19 +1,19 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("rename-org command", func() { diff --git a/cf/commands/organization/set_quota.go b/cf/commands/organization/set_quota.go index b743579a57b..6eb0b766e54 100644 --- a/cf/commands/organization/set_quota.go +++ b/cf/commands/organization/set_quota.go @@ -3,13 +3,13 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetQuota struct { diff --git a/cf/commands/organization/set_quota_test.go b/cf/commands/organization/set_quota_test.go index d12280f6907..56271a5a49a 100644 --- a/cf/commands/organization/set_quota_test.go +++ b/cf/commands/organization/set_quota_test.go @@ -1,18 +1,18 @@ package organization_test import ( - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/organization/share_private_domain.go b/cf/commands/organization/share_private_domain.go index 0e254c8efe0..99b19e6acc1 100644 --- a/cf/commands/organization/share_private_domain.go +++ b/cf/commands/organization/share_private_domain.go @@ -3,14 +3,14 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SharePrivateDomain struct { diff --git a/cf/commands/organization/unshare_private_domain.go b/cf/commands/organization/unshare_private_domain.go index 0f60dd0739c..2ab0eb147ed 100644 --- a/cf/commands/organization/unshare_private_domain.go +++ b/cf/commands/organization/unshare_private_domain.go @@ -3,14 +3,14 @@ package organization import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnsharePrivateDomain struct { diff --git a/cf/commands/passwd.go b/cf/commands/passwd.go index 51c9b1fa809..fcfb2ed224d 100644 --- a/cf/commands/passwd.go +++ b/cf/commands/passwd.go @@ -1,14 +1,14 @@ package commands import ( - "code.cloudfoundry.org/cli/cf/api/password" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/password" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Password struct { diff --git a/cf/commands/passwd_test.go b/cf/commands/passwd_test.go index 78d5e09b416..911b6629582 100644 --- a/cf/commands/passwd_test.go +++ b/cf/commands/passwd_test.go @@ -1,19 +1,19 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("password command", func() { diff --git a/cf/commands/plugin/install_plugin.go b/cf/commands/plugin/install_plugin.go index ac9c21d567f..e8ee1844c08 100644 --- a/cf/commands/plugin/install_plugin.go +++ b/cf/commands/plugin/install_plugin.go @@ -8,21 +8,21 @@ import ( "os/exec" "path/filepath" - "code.cloudfoundry.org/cli/cf/actors/plugininstaller" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/downloader" - "code.cloudfoundry.org/cli/plugin" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/cf/actors/plugininstaller" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/downloader" + "code.cloudfoundry.org/cli/v8/plugin" + "code.cloudfoundry.org/cli/v8/util" "code.cloudfoundry.org/gofileutils/fileutils" - pluginRPCService "code.cloudfoundry.org/cli/plugin/rpc" + pluginRPCService "code.cloudfoundry.org/cli/v8/plugin/rpc" ) type PluginInstall struct { @@ -78,8 +78,8 @@ func (cmd *PluginInstall) SetDependency(deps commandregistry.Dependency, pluginC cmd.pluginRepo = deps.PluginRepo cmd.checksum = deps.ChecksumUtil - //reset rpc registration in case there is other running instance, - //each service can only be registered once + // reset rpc registration in case there is other running instance, + // each service can only be registered once server := rpc.NewServer() rpcService, err := pluginRPCService.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, pluginRPCService.NewCommandRunner(), deps.Logger, cmd.ui.Writer(), server) @@ -220,7 +220,7 @@ func (cmd *PluginInstall) ensurePluginIsSafeForInstallation(pluginMetadata *plug } for _, pluginCmd := range pluginMetadata.Commands { - //check for command conflicting core commands/alias + // check for command conflicting core commands/alias if pluginCmd.Name == "help" || commandregistry.Commands.CommandExists(pluginCmd.Name) { return errors.New(T( "Command `{{.Command}}` in the plugin being installed is a native CF command/alias. Rename the `{{.Command}}` command in the plugin being installed in order to enable its installation and use.", @@ -230,7 +230,7 @@ func (cmd *PluginInstall) ensurePluginIsSafeForInstallation(pluginMetadata *plug ) } - //check for alias conflicting core command/alias + // check for alias conflicting core command/alias if pluginCmd.Alias == "help" || commandregistry.Commands.CommandExists(pluginCmd.Alias) { return errors.New(T( "Alias `{{.Command}}` in the plugin being installed is a native CF command/alias. Rename the `{{.Command}}` command in the plugin being installed in order to enable its installation and use.", @@ -243,7 +243,7 @@ func (cmd *PluginInstall) ensurePluginIsSafeForInstallation(pluginMetadata *plug for installedPluginName, installedPlugin := range plugins { for _, installedPluginCmd := range installedPlugin.Commands { - //check for command conflicting other plugin commands/alias + // check for command conflicting other plugin commands/alias if installedPluginCmd.Name == pluginCmd.Name || installedPluginCmd.Alias == pluginCmd.Name { return errors.New(T( "Command `{{.Command}}` is a command/alias in plugin '{{.PluginName}}'. You could try uninstalling plugin '{{.PluginName}}' and then install this plugin in order to invoke the `{{.Command}}` command. However, you should first fully understand the impact of uninstalling the existing '{{.PluginName}}' plugin.", @@ -254,7 +254,7 @@ func (cmd *PluginInstall) ensurePluginIsSafeForInstallation(pluginMetadata *plug ) } - //check for alias conflicting other plugin commands/alias + // check for alias conflicting other plugin commands/alias if pluginCmd.Alias != "" && (installedPluginCmd.Name == pluginCmd.Alias || installedPluginCmd.Alias == pluginCmd.Alias) { return errors.New(T( "Alias `{{.Command}}` is a command/alias in plugin '{{.PluginName}}'. You could try uninstalling plugin '{{.PluginName}}' and then install this plugin in order to invoke the `{{.Command}}` command. However, you should first fully understand the impact of uninstalling the existing '{{.PluginName}}' plugin.", diff --git a/cf/commands/plugin/install_plugin_test.go b/cf/commands/plugin/install_plugin_test.go index b0b3539a328..a4cf21bd40d 100644 --- a/cf/commands/plugin/install_plugin_test.go +++ b/cf/commands/plugin/install_plugin_test.go @@ -2,7 +2,6 @@ package plugin_test import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -10,26 +9,26 @@ import ( "runtime" "sync" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo/pluginrepofakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commandregistry/commandregistryfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig/pluginconfigfakes" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/util/utilfakes" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo/pluginrepofakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandregistry/commandregistryfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig/pluginconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/utilfakes" + "code.cloudfoundry.org/cli/v8/plugin" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -80,15 +79,15 @@ var _ = Describe("Install", func() { if err != nil { panic(err) } - test_1 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_1.exe") - test_2 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_2.exe") + test_1 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_1", "test_1.exe") + test_2 = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_2", "test_2.exe") test_curDir = filepath.Join("test_1.exe") - test_with_help = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_help.exe") - test_with_orgs = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs.exe") - test_with_orgs_short_name = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name.exe") - aliasConflicts = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "alias_conflicts.exe") + test_with_help = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_help", "test_with_help.exe") + test_with_orgs = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs", "test_with_orgs.exe") + test_with_orgs_short_name = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name", "test_with_orgs_short_name.exe") + aliasConflicts = filepath.Join(dir, "..", "..", "..", "fixtures", "plugins", "alias_conflicts", "alias_conflicts.exe") - homeDir, err = ioutil.TempDir(os.TempDir(), "plugins") + homeDir, err = os.MkdirTemp(os.TempDir(), "plugins") Expect(err).ToNot(HaveOccurred()) pluginDir = filepath.Join(homeDir, ".cf", "plugins") @@ -96,7 +95,7 @@ var _ = Describe("Install", func() { curDir, err = os.Getwd() Expect(err).ToNot(HaveOccurred()) - pluginFile, err = ioutil.TempFile("./", "test_plugin") + pluginFile, err = os.CreateTemp("./", "test_plugin") Expect(err).ToNot(HaveOccurred()) if runtime.GOOS != "windows" { @@ -111,7 +110,7 @@ var _ = Describe("Install", func() { }) runCommand := func(args ...string) bool { - // run command has races becuase it writes and erases temporary files, so the test runner should + // run command has races because it writes and erases temporary files, so the test runner should // really only run one of these at a time. Often the files are actual compiled exes in the test // fixtures path, so it's not easy to prevent the tests from sharing file handles runCmdMutex.Lock() @@ -541,7 +540,7 @@ var _ = Describe("Install", func() { runCommand(filepath.Join(curDir, pluginFile.Name()), "-f") Expect(ui.Outputs()).To(ContainSubstrings( []string{"Installing plugin"}, - []string{"The file", pluginFile.Name(), "already exists"}, + []string{"The file", filepath.Clean(pluginFile.Name()), "already exists"}, []string{"FAILED"}, )) }) @@ -559,7 +558,7 @@ var _ = Describe("Install", func() { curDir, err := os.Getwd() Expect(err).ToNot(HaveOccurred()) - err = os.Chdir("../../../fixtures/plugins") + err = os.Chdir("../../../fixtures/plugins/test_1") Expect(err).ToNot(HaveOccurred()) runCommand(test_curDir, "-f") diff --git a/cf/commands/plugin/plugin_suite_test.go b/cf/commands/plugin/plugin_suite_test.go index 624ec134409..5ee3845eb81 100644 --- a/cf/commands/plugin/plugin_suite_test.go +++ b/cf/commands/plugin/plugin_suite_test.go @@ -3,11 +3,11 @@ package plugin_test import ( "path/filepath" - "code.cloudfoundry.org/cli/cf/commands/plugin" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - "code.cloudfoundry.org/cli/cf/util/testhelpers/pluginbuilder" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commands/plugin" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/pluginbuilder" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" @@ -21,15 +21,15 @@ func TestPlugin(t *testing.T) { RegisterFailHandler(Fail) - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_help") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_orgs") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_orgs_short_name") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_with_push_short_name") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_1") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "test_2") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "empty_plugin") - pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins"), "alias_conflicts") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_help"), "test_with_help") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_orgs"), "test_with_orgs") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_orgs_short_name"), "test_with_orgs_short_name") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_push"), "test_with_push") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_with_push_short_name"), "test_with_push_short_name") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_1"), "test_1") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "test_2"), "test_2") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "empty_plugin"), "empty_plugin") + pluginbuilder.BuildTestBinary(filepath.Join("..", "..", "..", "fixtures", "plugins", "alias_conflicts"), "alias_conflicts") RunSpecs(t, "Plugin Suite") } diff --git a/cf/commands/plugin/plugins.go b/cf/commands/plugin/plugins.go index 844b1ff5768..ad5cd0ad182 100644 --- a/cf/commands/plugin/plugins.go +++ b/cf/commands/plugin/plugins.go @@ -4,14 +4,14 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/util" - "code.cloudfoundry.org/cli/util/sorting" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/util" + "code.cloudfoundry.org/cli/v8/util/sorting" ) type Plugins struct { diff --git a/cf/commands/plugin/plugins_test.go b/cf/commands/plugin/plugins_test.go index b0b6c4b54ce..80909fced82 100644 --- a/cf/commands/plugin/plugins_test.go +++ b/cf/commands/plugin/plugins_test.go @@ -3,18 +3,18 @@ package plugin_test import ( "net/rpc" - "code.cloudfoundry.org/cli/cf/commandregistry" - plugincmd "code.cloudfoundry.org/cli/cf/commands/plugin" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig/pluginconfigfakes" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + plugincmd "code.cloudfoundry.org/cli/v8/cf/commands/plugin" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig/pluginconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -48,7 +48,7 @@ var _ = Describe("Plugins", func() { It("computes and prints the sha1 checksum of the binary", func() { config.PluginsReturns(map[string]pluginconfig.PluginMetadata{ "Test1": { - Location: "../../../fixtures/plugins/test_1.go", + Location: "../../../fixtures/plugins/test_1/test_1.go", Version: plugin.VersionType{Major: 1, Minor: 2, Build: 3}, Commands: []plugin.Command{ {Name: "test_1_cmd1", HelpText: "help text for test_1_cmd1"}, @@ -157,7 +157,7 @@ var _ = Describe("Plugins", func() { It("does not list the plugin when it provides no available commands", func() { config.PluginsReturns(map[string]pluginconfig.PluginMetadata{ - "EmptyPlugin": {Location: "../../../fixtures/plugins/empty_plugin.exe"}, + "EmptyPlugin": {Location: "../../../fixtures/plugins/empty_plugin/empty_plugin.exe"}, }) runCommand() diff --git a/cf/commands/plugin/uninstall_plugin.go b/cf/commands/plugin/uninstall_plugin.go index 5d7574d7436..92ce488e04e 100644 --- a/cf/commands/plugin/uninstall_plugin.go +++ b/cf/commands/plugin/uninstall_plugin.go @@ -8,13 +8,13 @@ import ( "os/exec" "time" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - rpcService "code.cloudfoundry.org/cli/plugin/rpc" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + rpcService "code.cloudfoundry.org/cli/v8/plugin/rpc" ) type PluginUninstall struct { @@ -51,8 +51,8 @@ func (cmd *PluginUninstall) SetDependency(deps commandregistry.Dependency, plugi cmd.ui = deps.UI cmd.config = deps.PluginConfig - //reset rpc registration in case there is other running instance, - //each service can only be registered once + // reset rpc registration in case there is other running instance, + // each service can only be registered once server := rpc.NewServer() RPCService, err := rpcService.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, rpcService.NewCommandRunner(), deps.Logger, cmd.ui.Writer(), server) @@ -87,7 +87,7 @@ func (cmd *PluginUninstall) Execute(c flags.FlagContext) error { cmd.ui.Say("Error invoking plugin: " + warn.Error() + ". Process to uninstall ...") } - time.Sleep(500 * time.Millisecond) //prevent 'process being used' error in Windows + time.Sleep(500 * time.Millisecond) // prevent 'process being used' error in Windows err = os.Remove(pluginMetadata.Location) if err != nil { diff --git a/cf/commands/plugin/uninstall_plugin_test.go b/cf/commands/plugin/uninstall_plugin_test.go index e5e32911a7b..b59053147d5 100644 --- a/cf/commands/plugin/uninstall_plugin_test.go +++ b/cf/commands/plugin/uninstall_plugin_test.go @@ -1,22 +1,21 @@ package plugin_test import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" "code.cloudfoundry.org/gofileutils/fileutils" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -41,7 +40,7 @@ var _ = Describe("Uninstall", func() { requirementsFactory = new(requirementsfakes.FakeFactory) var err error - fakePluginRepoDir, err = ioutil.TempDir("", "plugins") + fakePluginRepoDir, err = os.MkdirTemp("", "plugins") Expect(err).ToNot(HaveOccurred()) fixtureDir := filepath.Join("..", "..", "..", "fixtures", "plugins") @@ -50,8 +49,8 @@ var _ = Describe("Uninstall", func() { err = os.MkdirAll(pluginDir, 0700) Expect(err).NotTo(HaveOccurred()) - fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_1.exe"), filepath.Join(pluginDir, "test_1.exe")) - fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_2.exe"), filepath.Join(pluginDir, "test_2.exe")) + fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_1", "test_1.exe"), filepath.Join(pluginDir, "test_1.exe")) + fileutils.CopyPathToPath(filepath.Join(fixtureDir, "test_2", "test_2.exe"), filepath.Join(pluginDir, "test_2.exe")) confighelpers.PluginRepoDir = func() string { return fakePluginRepoDir diff --git a/cf/commands/pluginrepo/add_plugin_repo.go b/cf/commands/pluginrepo/add_plugin_repo.go index b91f44bb42b..d5f699f1d88 100644 --- a/cf/commands/pluginrepo/add_plugin_repo.go +++ b/cf/commands/pluginrepo/add_plugin_repo.go @@ -10,16 +10,16 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type AddPluginRepo struct { diff --git a/cf/commands/pluginrepo/add_plugin_repo_test.go b/cf/commands/pluginrepo/add_plugin_repo_test.go index 2fd73ad6bc8..0577cce61b3 100644 --- a/cf/commands/pluginrepo/add_plugin_repo_test.go +++ b/cf/commands/pluginrepo/add_plugin_repo_test.go @@ -5,17 +5,17 @@ import ( "net/http" "net/http/httptest" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -191,7 +191,7 @@ var _ = Describe("add-plugin-repo", func() { Context("When connection could not be established", func() { It("prints a tip", func() { - callAddPluginRepo([]string{"repo", "https://broccoli.nonexistanttld:"}) + callAddPluginRepo([]string{"repo", "https://broccoli.nonexistenttld:"}) Expect(ui.Outputs()).To(ContainSubstrings( []string{"TIP: If you are behind a firewall and require an HTTP proxy, verify the https_proxy environment variable is correctly set. Else, check your network connection."}, diff --git a/cf/commands/pluginrepo/list_plugin_repos.go b/cf/commands/pluginrepo/list_plugin_repos.go index d7a1b0a6294..179a2c0a115 100644 --- a/cf/commands/pluginrepo/list_plugin_repos.go +++ b/cf/commands/pluginrepo/list_plugin_repos.go @@ -1,13 +1,13 @@ package pluginrepo import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ListPluginRepos struct { diff --git a/cf/commands/pluginrepo/list_plugin_repos_test.go b/cf/commands/pluginrepo/list_plugin_repos_test.go index fb562e2446a..34573931ff1 100644 --- a/cf/commands/pluginrepo/list_plugin_repos_test.go +++ b/cf/commands/pluginrepo/list_plugin_repos_test.go @@ -1,18 +1,18 @@ package pluginrepo_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/pluginrepo/plugin_repo_suite_test.go b/cf/commands/pluginrepo/plugin_repo_suite_test.go index ffdf5b8f1ec..c1ebd911a83 100644 --- a/cf/commands/pluginrepo/plugin_repo_suite_test.go +++ b/cf/commands/pluginrepo/plugin_repo_suite_test.go @@ -1,11 +1,11 @@ package pluginrepo_test import ( - "code.cloudfoundry.org/cli/cf/commands/pluginrepo" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/commands/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/pluginrepo/remove_plugin_repo.go b/cf/commands/pluginrepo/remove_plugin_repo.go index 6d4aa411e02..7a6b544f788 100644 --- a/cf/commands/pluginrepo/remove_plugin_repo.go +++ b/cf/commands/pluginrepo/remove_plugin_repo.go @@ -5,13 +5,13 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type RemovePluginRepo struct { diff --git a/cf/commands/pluginrepo/remove_plugin_repo_test.go b/cf/commands/pluginrepo/remove_plugin_repo_test.go index 7f181d2849f..ef2e41b1292 100644 --- a/cf/commands/pluginrepo/remove_plugin_repo_test.go +++ b/cf/commands/pluginrepo/remove_plugin_repo_test.go @@ -1,21 +1,21 @@ package pluginrepo_test import ( - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) -var _ = Describe("delte-plugin-repo", func() { +var _ = Describe("delete-plugin-repo", func() { var ( ui *testterm.FakeUI config coreconfig.Repository diff --git a/cf/commands/pluginrepo/repo_plugins.go b/cf/commands/pluginrepo/repo_plugins.go index dd0af956b9d..a2966c1b6e6 100644 --- a/cf/commands/pluginrepo/repo_plugins.go +++ b/cf/commands/pluginrepo/repo_plugins.go @@ -4,17 +4,17 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/cf/actors/pluginrepo" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type RepoPlugins struct { diff --git a/cf/commands/pluginrepo/repo_plugins_test.go b/cf/commands/pluginrepo/repo_plugins_test.go index 31149d37c97..06f91d35758 100644 --- a/cf/commands/pluginrepo/repo_plugins_test.go +++ b/cf/commands/pluginrepo/repo_plugins_test.go @@ -1,21 +1,21 @@ package pluginrepo_test import ( - "code.cloudfoundry.org/cli/cf/actors/pluginrepo/pluginrepofakes" - "code.cloudfoundry.org/cli/cf/commands/pluginrepo" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/actors/pluginrepo/pluginrepofakes" + "code.cloudfoundry.org/cli/v8/cf/commands/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" clipr "code.cloudfoundry.org/cli-plugin-repo/web" - "code.cloudfoundry.org/cli/cf/flags" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/quota/create_quota.go b/cf/commands/quota/create_quota.go index bfcce949868..d5733ec927e 100644 --- a/cf/commands/quota/create_quota.go +++ b/cf/commands/quota/create_quota.go @@ -5,17 +5,17 @@ import ( "encoding/json" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateQuota struct { diff --git a/cf/commands/quota/create_quota_test.go b/cf/commands/quota/create_quota_test.go index 1dc360d9290..824d58760a8 100644 --- a/cf/commands/quota/create_quota_test.go +++ b/cf/commands/quota/create_quota_test.go @@ -1,24 +1,24 @@ package quota_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "encoding/json" - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commands/quota" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commands/quota" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" ) var _ = Describe("create-quota command", func() { diff --git a/cf/commands/quota/delete_quota.go b/cf/commands/quota/delete_quota.go index d8e08d7fbb1..cd77cbbf253 100644 --- a/cf/commands/quota/delete_quota.go +++ b/cf/commands/quota/delete_quota.go @@ -3,14 +3,14 @@ package quota import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteQuota struct { diff --git a/cf/commands/quota/delete_quota_test.go b/cf/commands/quota/delete_quota_test.go index 15d7712d8c6..3ba0f048eb3 100644 --- a/cf/commands/quota/delete_quota_test.go +++ b/cf/commands/quota/delete_quota_test.go @@ -1,19 +1,19 @@ package quota_test import ( - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -114,19 +114,19 @@ var _ = Describe("delete-quota command", func() { Context("when finding the quota fails", func() { Context("when the quota provided does not exist", func() { BeforeEach(func() { - quotaRepo.FindByNameReturns(models.QuotaFields{}, errors.NewModelNotFoundError("Quota", "non-existent-quota")) + quotaRepo.FindByNameReturns(models.QuotaFields{}, errors.NewModelNotFoundError("Quota", "nonexistent-quota")) }) It("warns the user when that the quota does not exist", func() { - runCommand("-f", "non-existent-quota") + runCommand("-f", "nonexistent-quota") Expect(ui.Outputs()).To(ContainSubstrings( - []string{"Deleting", "non-existent-quota"}, + []string{"Deleting", "nonexistent-quota"}, []string{"OK"}, )) Expect(ui.WarnOutputs).To(ContainSubstrings( - []string{"non-existent-quota", "does not exist"}, + []string{"nonexistent-quota", "does not exist"}, )) }) }) diff --git a/cf/commands/quota/quota.go b/cf/commands/quota/quota.go index d1e91e8b5d5..e8ff2ee310d 100644 --- a/cf/commands/quota/quota.go +++ b/cf/commands/quota/quota.go @@ -4,16 +4,16 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type showQuota struct { diff --git a/cf/commands/quota/quota_suite_test.go b/cf/commands/quota/quota_suite_test.go index 6b85a5162bb..3a9948a836b 100644 --- a/cf/commands/quota/quota_suite_test.go +++ b/cf/commands/quota/quota_suite_test.go @@ -1,9 +1,9 @@ package quota_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/quota/quota_test.go b/cf/commands/quota/quota_test.go index a9cc5338bf8..dcdba474fd1 100644 --- a/cf/commands/quota/quota_test.go +++ b/cf/commands/quota/quota_test.go @@ -1,21 +1,21 @@ package quota_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("quota", func() { diff --git a/cf/commands/quota/quotas.go b/cf/commands/quota/quotas.go index ef9396576a8..bee2a80087a 100644 --- a/cf/commands/quota/quotas.go +++ b/cf/commands/quota/quotas.go @@ -4,16 +4,16 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListQuotas struct { diff --git a/cf/commands/quota/quotas_test.go b/cf/commands/quota/quotas_test.go index b1943718a40..9adec4fd717 100644 --- a/cf/commands/quota/quotas_test.go +++ b/cf/commands/quota/quotas_test.go @@ -1,22 +1,22 @@ package quota_test import ( - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/commands/quota" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/terminal" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commands/quota" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/quota/update_quota.go b/cf/commands/quota/update_quota.go index ead549e3791..4a159215d7b 100644 --- a/cf/commands/quota/update_quota.go +++ b/cf/commands/quota/update_quota.go @@ -6,14 +6,14 @@ import ( "encoding/json" - "code.cloudfoundry.org/cli/cf/api/quotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateQuota struct { diff --git a/cf/commands/quota/update_quota_test.go b/cf/commands/quota/update_quota_test.go index dfb4923fe34..df369d573af 100644 --- a/cf/commands/quota/update_quota_test.go +++ b/cf/commands/quota/update_quota_test.go @@ -1,24 +1,24 @@ package quota_test import ( - "code.cloudfoundry.org/cli/cf/api/quotas/quotasfakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - cmdsQuota "code.cloudfoundry.org/cli/cf/commands/quota" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/quotas/quotasfakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + cmdsQuota "code.cloudfoundry.org/cli/v8/cf/commands/quota" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "encoding/json" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/check_route.go b/cf/commands/route/check_route.go index 846d09ceeb6..4788ab890ba 100644 --- a/cf/commands/route/check_route.go +++ b/cf/commands/route/check_route.go @@ -4,13 +4,13 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CheckRoute struct { diff --git a/cf/commands/route/check_route_test.go b/cf/commands/route/check_route_test.go index b59505a9e91..89f49677e9d 100644 --- a/cf/commands/route/check_route_test.go +++ b/cf/commands/route/check_route_test.go @@ -3,21 +3,21 @@ package route_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/create_route.go b/cf/commands/route/create_route.go index d9c0cd3c707..87a73ff09a4 100644 --- a/cf/commands/route/create_route.go +++ b/cf/commands/route/create_route.go @@ -3,14 +3,14 @@ package route import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Creator diff --git a/cf/commands/route/create_route_test.go b/cf/commands/route/create_route_test.go index 2ba6aa71fe5..e5ea63c64dc 100644 --- a/cf/commands/route/create_route_test.go +++ b/cf/commands/route/create_route_test.go @@ -3,21 +3,21 @@ package route_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/delete_orphaned_routes.go b/cf/commands/route/delete_orphaned_routes.go index 7eb1ec04a23..ee121150347 100644 --- a/cf/commands/route/delete_orphaned_routes.go +++ b/cf/commands/route/delete_orphaned_routes.go @@ -3,14 +3,14 @@ package route import ( "errors" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteOrphanedRoutes struct { diff --git a/cf/commands/route/delete_orphaned_routes_test.go b/cf/commands/route/delete_orphaned_routes_test.go index f74e9de88cd..c887547eb85 100644 --- a/cf/commands/route/delete_orphaned_routes_test.go +++ b/cf/commands/route/delete_orphaned_routes_test.go @@ -1,20 +1,20 @@ package route_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/delete_route.go b/cf/commands/route/delete_route.go index 99eee02add9..07f9cec6f64 100644 --- a/cf/commands/route/delete_route.go +++ b/cf/commands/route/delete_route.go @@ -3,15 +3,15 @@ package route import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteRoute struct { diff --git a/cf/commands/route/delete_route_test.go b/cf/commands/route/delete_route_test.go index bbbc800b003..455c3597973 100644 --- a/cf/commands/route/delete_route_test.go +++ b/cf/commands/route/delete_route_test.go @@ -3,22 +3,22 @@ package route_test import ( "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/map_route.go b/cf/commands/route/map_route.go index 4c0c1f2a43d..f8a21354b5c 100644 --- a/cf/commands/route/map_route.go +++ b/cf/commands/route/map_route.go @@ -5,13 +5,13 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type MapRoute struct { @@ -100,7 +100,7 @@ func (cmd *MapRoute) SetDependency(deps commandregistry.Dependency, pluginCall b cmd.config = deps.Config cmd.routeRepo = deps.RepoLocator.GetRouteRepository() - //get create-route for dependency + // get create-route for dependency createRoute := commandregistry.Commands.FindCommand("create-route") createRoute = createRoute.SetDependency(deps, false) cmd.routeCreator = createRoute.(Creator) diff --git a/cf/commands/route/map_route_test.go b/cf/commands/route/map_route_test.go index 42cb38bb47b..573d8e505e7 100644 --- a/cf/commands/route/map_route_test.go +++ b/cf/commands/route/map_route_test.go @@ -3,24 +3,24 @@ package route_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/commands/route/routefakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/commands/route/routefakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/route/route_suite_test.go b/cf/commands/route/route_suite_test.go index e696c8249a4..1afd5fa0a30 100644 --- a/cf/commands/route/route_suite_test.go +++ b/cf/commands/route/route_suite_test.go @@ -1,9 +1,9 @@ package route_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/route/routefakes/fake_creator.go b/cf/commands/route/routefakes/fake_creator.go index b0118b6c417..000f25e1468 100644 --- a/cf/commands/route/routefakes/fake_creator.go +++ b/cf/commands/route/routefakes/fake_creator.go @@ -4,8 +4,8 @@ package routefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeCreator struct { @@ -42,15 +42,16 @@ func (fake *FakeCreator) CreateRoute(arg1 string, arg2 string, arg3 int, arg4 bo arg5 models.DomainFields arg6 models.SpaceFields }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.CreateRouteStub + fakeReturns := fake.createRouteReturns fake.recordInvocation("CreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.createRouteMutex.Unlock() - if fake.CreateRouteStub != nil { - return fake.CreateRouteStub(arg1, arg2, arg3, arg4, arg5, arg6) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createRouteReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/commands/route/routefakes/old_fake_route_creator.go b/cf/commands/route/routefakes/old_fake_route_creator.go index c95e3c09e21..fcadde7ba05 100644 --- a/cf/commands/route/routefakes/old_fake_route_creator.go +++ b/cf/commands/route/routefakes/old_fake_route_creator.go @@ -3,11 +3,11 @@ package routefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type OldFakeRouteCreator struct { diff --git a/cf/commands/route/routes.go b/cf/commands/route/routes.go index 7d298571034..dcd5513171d 100644 --- a/cf/commands/route/routes.go +++ b/cf/commands/route/routes.go @@ -5,15 +5,15 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListRoutes struct { @@ -53,7 +53,11 @@ func (cmd *ListRoutes) Requirements(requirementsFactory requirements.Factory, fc reqs := []requirements.Requirement{ usageReq, requirementsFactory.NewLoginRequirement(), - requirementsFactory.NewTargetedSpaceRequirement(), + } + + orglevel := fc.Bool("orglevel") + if !orglevel { + reqs = append(reqs, requirementsFactory.NewTargetedSpaceRequirement()) } return reqs, nil diff --git a/cf/commands/route/routes_test.go b/cf/commands/route/routes_test.go index 52f375a942f..57f1195fc24 100644 --- a/cf/commands/route/routes_test.go +++ b/cf/commands/route/routes_test.go @@ -3,22 +3,22 @@ package route_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/terminal" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commands/route" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("routes command", func() { @@ -64,6 +64,12 @@ var _ = Describe("routes command", func() { Expect(runCommand()).To(BeFalse()) }) + It("does not fail when an org is not targeted and --orglevel is an argument", func() { + requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Failing{Message: "not logged in"}) + + Expect(runCommand("--orglevel")).To(BeTrue()) + }) + Context("when arguments are provided", func() { var cmd commandregistry.Command var flagContext flags.FlagContext diff --git a/cf/commands/route/unmap_route.go b/cf/commands/route/unmap_route.go index a49f850d7ec..355d9ddf573 100644 --- a/cf/commands/route/unmap_route.go +++ b/cf/commands/route/unmap_route.go @@ -3,13 +3,13 @@ package route import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnmapRoute struct { diff --git a/cf/commands/route/unmap_route_test.go b/cf/commands/route/unmap_route_test.go index 592507b52e8..9c3d11582b1 100644 --- a/cf/commands/route/unmap_route_test.go +++ b/cf/commands/route/unmap_route_test.go @@ -3,23 +3,23 @@ package route_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/routergroups/router_groups.go b/cf/commands/routergroups/router_groups.go index 71f8fc8f629..a3f3a398276 100644 --- a/cf/commands/routergroups/router_groups.go +++ b/cf/commands/routergroups/router_groups.go @@ -3,14 +3,14 @@ package routergroups import ( "errors" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RouterGroups struct { diff --git a/cf/commands/routergroups/router_groups_test.go b/cf/commands/routergroups/router_groups_test.go index 232e7d4bebd..bf1d7f5f25e 100644 --- a/cf/commands/routergroups/router_groups_test.go +++ b/cf/commands/routergroups/router_groups_test.go @@ -3,19 +3,19 @@ package routergroups_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commands/routergroups" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commands/routergroups" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/routergroups/routergroups_suite_test.go b/cf/commands/routergroups/routergroups_suite_test.go index a2f69080617..6b3262689c4 100644 --- a/cf/commands/routergroups/routergroups_suite_test.go +++ b/cf/commands/routergroups/routergroups_suite_test.go @@ -1,9 +1,9 @@ package routergroups_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/securitygroup/bind_running_security_group.go b/cf/commands/securitygroup/bind_running_security_group.go index c2258fd452c..8d337fef36f 100644 --- a/cf/commands/securitygroup/bind_running_security_group.go +++ b/cf/commands/securitygroup/bind_running_security_group.go @@ -3,14 +3,14 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type bindToRunningGroup struct { diff --git a/cf/commands/securitygroup/bind_running_security_group_test.go b/cf/commands/securitygroup/bind_running_security_group_test.go index a4706c6327a..0a7605c6b06 100644 --- a/cf/commands/securitygroup/bind_running_security_group_test.go +++ b/cf/commands/securitygroup/bind_running_security_group_test.go @@ -3,19 +3,19 @@ package securitygroup_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running/runningfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running/runningfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/bind_security_group.go b/cf/commands/securitygroup/bind_security_group.go index 0f6d97f9969..d62bdfc619c 100644 --- a/cf/commands/securitygroup/bind_security_group.go +++ b/cf/commands/securitygroup/bind_security_group.go @@ -3,17 +3,17 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - sgbinder "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + sgbinder "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type BindSecurityGroup struct { diff --git a/cf/commands/securitygroup/bind_security_group_test.go b/cf/commands/securitygroup/bind_security_group_test.go index 1520177b180..1c4bf383d90 100644 --- a/cf/commands/securitygroup/bind_security_group_test.go +++ b/cf/commands/securitygroup/bind_security_group_test.go @@ -1,22 +1,22 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces/spacesfakes" - spacesapifakes "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces/spacesfakes" + spacesapifakes "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/bind_staging_security_group.go b/cf/commands/securitygroup/bind_staging_security_group.go index cb9daaa463b..dc14cec886c 100644 --- a/cf/commands/securitygroup/bind_staging_security_group.go +++ b/cf/commands/securitygroup/bind_staging_security_group.go @@ -3,14 +3,14 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type bindToStagingGroup struct { diff --git a/cf/commands/securitygroup/bind_staging_security_group_test.go b/cf/commands/securitygroup/bind_staging_security_group_test.go index 9b56dbd63f3..011ac8caf52 100644 --- a/cf/commands/securitygroup/bind_staging_security_group_test.go +++ b/cf/commands/securitygroup/bind_staging_security_group_test.go @@ -3,19 +3,19 @@ package securitygroup_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging/stagingfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging/stagingfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/create_security_group.go b/cf/commands/securitygroup/create_security_group.go index 03b0cb7265b..315b8c9400b 100644 --- a/cf/commands/securitygroup/create_security_group.go +++ b/cf/commands/securitygroup/create_security_group.go @@ -3,16 +3,16 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/json" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/json" ) type CreateSecurityGroup struct { diff --git a/cf/commands/securitygroup/create_security_group_test.go b/cf/commands/securitygroup/create_security_group_test.go index 38e7b62a920..2b6cb84c59e 100644 --- a/cf/commands/securitygroup/create_security_group_test.go +++ b/cf/commands/securitygroup/create_security_group_test.go @@ -4,18 +4,18 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -141,7 +141,7 @@ var _ = Describe("create-security-group command", func() { Expect(ui.Outputs()).To(ContainSubstrings( []string{"FAILED"}, []string{"Incorrect json format: file:", tempFile.Name()}, - []string{"Valid json file exampl"}, + []string{"Valid json file example"}, )) }) }) diff --git a/cf/commands/securitygroup/delete_security_group.go b/cf/commands/securitygroup/delete_security_group.go index 5b650d2cd0c..d912c58eab6 100644 --- a/cf/commands/securitygroup/delete_security_group.go +++ b/cf/commands/securitygroup/delete_security_group.go @@ -3,14 +3,14 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteSecurityGroup struct { diff --git a/cf/commands/securitygroup/delete_security_group_test.go b/cf/commands/securitygroup/delete_security_group_test.go index 973f90d5751..d5acac43aa5 100644 --- a/cf/commands/securitygroup/delete_security_group_test.go +++ b/cf/commands/securitygroup/delete_security_group_test.go @@ -1,19 +1,19 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/running_security_groups.go b/cf/commands/securitygroup/running_security_groups.go index ea1d979668a..fc1b4af4a24 100644 --- a/cf/commands/securitygroup/running_security_groups.go +++ b/cf/commands/securitygroup/running_security_groups.go @@ -1,13 +1,13 @@ package securitygroup import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type listRunningSecurityGroups struct { diff --git a/cf/commands/securitygroup/running_security_groups_test.go b/cf/commands/securitygroup/running_security_groups_test.go index 4d4287c8de2..d1d30179489 100644 --- a/cf/commands/securitygroup/running_security_groups_test.go +++ b/cf/commands/securitygroup/running_security_groups_test.go @@ -1,20 +1,20 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running/runningfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running/runningfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/security_group.go b/cf/commands/securitygroup/security_group.go index 8027bbceec7..fa5cfb79b01 100644 --- a/cf/commands/securitygroup/security_group.go +++ b/cf/commands/securitygroup/security_group.go @@ -4,14 +4,14 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ShowSecurityGroup struct { diff --git a/cf/commands/securitygroup/security_group_test.go b/cf/commands/securitygroup/security_group_test.go index d15204d755e..690e2277a98 100644 --- a/cf/commands/securitygroup/security_group_test.go +++ b/cf/commands/securitygroup/security_group_test.go @@ -1,19 +1,19 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/security_groups.go b/cf/commands/securitygroup/security_groups.go index e72e63370f6..3e9515fdecc 100644 --- a/cf/commands/securitygroup/security_groups.go +++ b/cf/commands/securitygroup/security_groups.go @@ -3,15 +3,15 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SecurityGroups struct { diff --git a/cf/commands/securitygroup/security_groups_test.go b/cf/commands/securitygroup/security_groups_test.go index fd97a16976f..8c288505bee 100644 --- a/cf/commands/securitygroup/security_groups_test.go +++ b/cf/commands/securitygroup/security_groups_test.go @@ -1,21 +1,21 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commands/securitygroup" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commands/securitygroup" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/staging_security_groups.go b/cf/commands/securitygroup/staging_security_groups.go index bdf730f1c0c..be4c6e7eab1 100644 --- a/cf/commands/securitygroup/staging_security_groups.go +++ b/cf/commands/securitygroup/staging_security_groups.go @@ -1,13 +1,13 @@ package securitygroup import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type listStagingSecurityGroups struct { diff --git a/cf/commands/securitygroup/staging_security_groups_test.go b/cf/commands/securitygroup/staging_security_groups_test.go index 169b8800cd8..23feb1a0fb6 100644 --- a/cf/commands/securitygroup/staging_security_groups_test.go +++ b/cf/commands/securitygroup/staging_security_groups_test.go @@ -1,20 +1,20 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging/stagingfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging/stagingfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/suite_test.go b/cf/commands/securitygroup/suite_test.go index aa752db5ab6..92a8043bbc0 100644 --- a/cf/commands/securitygroup/suite_test.go +++ b/cf/commands/securitygroup/suite_test.go @@ -1,9 +1,9 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/securitygroup/unbind_running_security_group.go b/cf/commands/securitygroup/unbind_running_security_group.go index 2e4bbc4192f..25c60801752 100644 --- a/cf/commands/securitygroup/unbind_running_security_group.go +++ b/cf/commands/securitygroup/unbind_running_security_group.go @@ -3,15 +3,15 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type unbindFromRunningGroup struct { diff --git a/cf/commands/securitygroup/unbind_running_security_group_test.go b/cf/commands/securitygroup/unbind_running_security_group_test.go index 04befbbd77f..a88725e1ee1 100644 --- a/cf/commands/securitygroup/unbind_running_security_group_test.go +++ b/cf/commands/securitygroup/unbind_running_security_group_test.go @@ -1,20 +1,20 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/running/runningfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/running/runningfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/unbind_security_group.go b/cf/commands/securitygroup/unbind_security_group.go index ca1159d28c6..d56a34bf692 100644 --- a/cf/commands/securitygroup/unbind_security_group.go +++ b/cf/commands/securitygroup/unbind_security_group.go @@ -3,16 +3,16 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - sgbinder "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + sgbinder "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnbindSecurityGroup struct { diff --git a/cf/commands/securitygroup/unbind_security_group_test.go b/cf/commands/securitygroup/unbind_security_group_test.go index 2a2ada51faa..e9db0e205c3 100644 --- a/cf/commands/securitygroup/unbind_security_group_test.go +++ b/cf/commands/securitygroup/unbind_security_group_test.go @@ -3,21 +3,21 @@ package securitygroup_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/spaces/spacesfakes" - spacesapifakes "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/spaces/spacesfakes" + spacesapifakes "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/unbind_staging_security_group.go b/cf/commands/securitygroup/unbind_staging_security_group.go index c47897625e2..a81ed3f3537 100644 --- a/cf/commands/securitygroup/unbind_staging_security_group.go +++ b/cf/commands/securitygroup/unbind_staging_security_group.go @@ -3,15 +3,15 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type unbindFromStagingGroup struct { diff --git a/cf/commands/securitygroup/unbind_staging_security_group_test.go b/cf/commands/securitygroup/unbind_staging_security_group_test.go index c2aebeaf587..1d4f942bce8 100644 --- a/cf/commands/securitygroup/unbind_staging_security_group_test.go +++ b/cf/commands/securitygroup/unbind_staging_security_group_test.go @@ -1,20 +1,20 @@ package securitygroup_test import ( - "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults/staging/stagingfakes" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/defaults/staging/stagingfakes" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/securitygroup/update_security_group.go b/cf/commands/securitygroup/update_security_group.go index d249bded6c1..c43e0d98213 100644 --- a/cf/commands/securitygroup/update_security_group.go +++ b/cf/commands/securitygroup/update_security_group.go @@ -3,15 +3,15 @@ package securitygroup import ( "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/api/securitygroups" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/json" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/json" ) type UpdateSecurityGroup struct { diff --git a/cf/commands/securitygroup/update_security_group_test.go b/cf/commands/securitygroup/update_security_group_test.go index d748bdd4a31..cfbd9da6f13 100644 --- a/cf/commands/securitygroup/update_security_group_test.go +++ b/cf/commands/securitygroup/update_security_group_test.go @@ -4,19 +4,19 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/api/securitygroups/securitygroupsfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/securitygroups/securitygroupsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/bind_route_service.go b/cf/commands/service/bind_route_service.go index 6cf791376cb..4818f339c3c 100644 --- a/cf/commands/service/bind_route_service.go +++ b/cf/commands/service/bind_route_service.go @@ -4,15 +4,15 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flagcontext" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flagcontext" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type BindRouteService struct { diff --git a/cf/commands/service/bind_route_service_test.go b/cf/commands/service/bind_route_service_test.go index be47e719549..631b01513d7 100644 --- a/cf/commands/service/bind_route_service_test.go +++ b/cf/commands/service/bind_route_service_test.go @@ -5,21 +5,21 @@ import ( "net/http" "os" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/bind_service.go b/cf/commands/service/bind_service.go index 7acdb3c8755..aec4cd7c4a8 100644 --- a/cf/commands/service/bind_service.go +++ b/cf/commands/service/bind_service.go @@ -3,17 +3,17 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/json" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/json" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Binder diff --git a/cf/commands/service/bind_service_test.go b/cf/commands/service/bind_service_test.go index 4eadc1d693d..c0c2065c99a 100644 --- a/cf/commands/service/bind_service_test.go +++ b/cf/commands/service/bind_service_test.go @@ -5,20 +5,20 @@ import ( "net/http" "os" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("bind-service command", func() { diff --git a/cf/commands/service/create_service.go b/cf/commands/service/create_service.go index 62b75952d31..e1a7510d706 100644 --- a/cf/commands/service/create_service.go +++ b/cf/commands/service/create_service.go @@ -3,18 +3,18 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/uihelpers" - "code.cloudfoundry.org/cli/cf/util/json" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" + "code.cloudfoundry.org/cli/v8/cf/util/json" ) type CreateService struct { diff --git a/cf/commands/service/create_service_test.go b/cf/commands/service/create_service_test.go index cc620d91a04..59cb61572d3 100644 --- a/cf/commands/service/create_service_test.go +++ b/cf/commands/service/create_service_test.go @@ -5,24 +5,24 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/actors/servicebuilder/servicebuilderfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder/servicebuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("create-service command", func() { @@ -109,7 +109,7 @@ var _ = Describe("create-service command", func() { }) Context("when passing in tags", func() { - It("sucessfully creates a service and passes the tags as json", func() { + It("successfully creates a service and passes the tags as json", func() { callCreateService([]string{"cleardb", "spark", "my-cleardb-service", "-t", "tag1, tag2,tag3, tag4"}) Expect(ui.Outputs()).To(ContainSubstrings( @@ -252,7 +252,7 @@ var _ = Describe("create-service command", func() { []string{"Creating service instance", "my-free-cleardb-service", "my-org", "my-space", "my-user"}, []string{"OK"}, )) - Expect(ui.Outputs()).NotTo(ContainSubstrings([]string{"will incurr a cost"})) + Expect(ui.Outputs()).NotTo(ContainSubstrings([]string{"will incur a cost"})) }) It("warns the user when the service is not free", func() { diff --git a/cf/commands/service/create_user_provided_service.go b/cf/commands/service/create_user_provided_service.go index c56846f61b6..bf3ec4a7a0f 100644 --- a/cf/commands/service/create_user_provided_service.go +++ b/cf/commands/service/create_user_provided_service.go @@ -4,19 +4,19 @@ import ( "encoding/json" "strings" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/flagcontext" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/uihelpers" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/flagcontext" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateUserProvidedService struct { diff --git a/cf/commands/service/create_user_provided_service_test.go b/cf/commands/service/create_user_provided_service_test.go index 60831dbfa0d..e37564419f1 100644 --- a/cf/commands/service/create_user_provided_service_test.go +++ b/cf/commands/service/create_user_provided_service_test.go @@ -5,20 +5,20 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "github.com/blang/semver" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "github.com/blang/semver/v4" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -277,7 +277,7 @@ var _ = Describe("CreateUserProvidedService", func() { flagContext.Parse("service-instance", "-t", "tag1, tag2, tag3, tag4") }) - It("sucessfully creates a service instance and passes the tags as json", func() { + It("successfully creates a service instance and passes the tags as json", func() { Expect(runCLIErr).NotTo(HaveOccurred()) Expect(serviceInstanceRepo.CreateCallCount()).To(Equal(1)) _, _, _, _, tags := serviceInstanceRepo.CreateArgsForCall(0) diff --git a/cf/commands/service/delete_service.go b/cf/commands/service/delete_service.go index c069134ade0..a4356e6da19 100644 --- a/cf/commands/service/delete_service.go +++ b/cf/commands/service/delete_service.go @@ -3,14 +3,14 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteService struct { diff --git a/cf/commands/service/delete_service_test.go b/cf/commands/service/delete_service_test.go index ec43cb68985..f757112c49b 100644 --- a/cf/commands/service/delete_service_test.go +++ b/cf/commands/service/delete_service_test.go @@ -1,20 +1,20 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-service command", func() { diff --git a/cf/commands/service/marketplace.go b/cf/commands/service/marketplace.go index 83df62512e5..3d563c0ab4c 100644 --- a/cf/commands/service/marketplace.go +++ b/cf/commands/service/marketplace.go @@ -6,15 +6,15 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/actors/servicebuilder" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type MarketplaceServices struct { diff --git a/cf/commands/service/marketplace_test.go b/cf/commands/service/marketplace_test.go index 8b59d72809c..42f7f85a946 100644 --- a/cf/commands/service/marketplace_test.go +++ b/cf/commands/service/marketplace_test.go @@ -1,21 +1,21 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/actors/servicebuilder/servicebuilderfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/servicebuilder/servicebuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commands/service" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("marketplace command", func() { diff --git a/cf/commands/service/migrate_service_instances.go b/cf/commands/service/migrate_service_instances.go index 6424d85884b..9b626954f9e 100644 --- a/cf/commands/service/migrate_service_instances.go +++ b/cf/commands/service/migrate_service_instances.go @@ -3,17 +3,17 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type MigrateServiceInstances struct { diff --git a/cf/commands/service/migrate_service_instances_test.go b/cf/commands/service/migrate_service_instances_test.go index 8dc41f27b8e..050a14849a7 100644 --- a/cf/commands/service/migrate_service_instances_test.go +++ b/cf/commands/service/migrate_service_instances_test.go @@ -1,20 +1,20 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("migrating service instances from v1 to v2", func() { diff --git a/cf/commands/service/purge_service_instance.go b/cf/commands/service/purge_service_instance.go index 3a29865c962..56a90e4869e 100644 --- a/cf/commands/service/purge_service_instance.go +++ b/cf/commands/service/purge_service_instance.go @@ -3,13 +3,13 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type PurgeServiceInstance struct { diff --git a/cf/commands/service/purge_service_instance_test.go b/cf/commands/service/purge_service_instance_test.go index 5f16b97eda1..e8c2cb9643c 100644 --- a/cf/commands/service/purge_service_instance_test.go +++ b/cf/commands/service/purge_service_instance_test.go @@ -3,23 +3,23 @@ package service_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - cferrors "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + cferrors "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/purge_service_offering.go b/cf/commands/service/purge_service_offering.go index 4c55e772b89..de11a529cdc 100644 --- a/cf/commands/service/purge_service_offering.go +++ b/cf/commands/service/purge_service_offering.go @@ -3,15 +3,15 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type PurgeServiceOffering struct { diff --git a/cf/commands/service/purge_service_offering_test.go b/cf/commands/service/purge_service_offering_test.go index a39407fe959..3b4c777ebfa 100644 --- a/cf/commands/service/purge_service_offering_test.go +++ b/cf/commands/service/purge_service_offering_test.go @@ -1,21 +1,21 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/rename_service.go b/cf/commands/service/rename_service.go index 9557ebe3e5c..e3e8461d6a3 100644 --- a/cf/commands/service/rename_service.go +++ b/cf/commands/service/rename_service.go @@ -3,15 +3,15 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameService struct { diff --git a/cf/commands/service/rename_service_test.go b/cf/commands/service/rename_service_test.go index 8c6c604eca7..ac043a6777d 100644 --- a/cf/commands/service/rename_service_test.go +++ b/cf/commands/service/rename_service_test.go @@ -1,18 +1,18 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/service.go b/cf/commands/service/service.go index ce9faaa8a67..d4f19f5e2a7 100644 --- a/cf/commands/service/service.go +++ b/cf/commands/service/service.go @@ -4,14 +4,14 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type ShowService struct { diff --git a/cf/commands/service/service_suite_test.go b/cf/commands/service/service_suite_test.go index f06bc59dd97..c089fb54b4b 100644 --- a/cf/commands/service/service_suite_test.go +++ b/cf/commands/service/service_suite_test.go @@ -1,9 +1,9 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/service/service_test.go b/cf/commands/service/service_test.go index 9c624c1ecd5..5df35ba8285 100644 --- a/cf/commands/service/service_test.go +++ b/cf/commands/service/service_test.go @@ -1,22 +1,22 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" "fmt" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/servicefakes/fake_app_binder.go b/cf/commands/service/servicefakes/fake_app_binder.go index 6ac63f8dc6e..748e4374178 100644 --- a/cf/commands/service/servicefakes/fake_app_binder.go +++ b/cf/commands/service/servicefakes/fake_app_binder.go @@ -1,10 +1,10 @@ package servicefakes import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type OldFakeAppBinder struct { diff --git a/cf/commands/service/servicefakes/fake_binder.go b/cf/commands/service/servicefakes/fake_binder.go index b6ad688476c..82b342912f6 100644 --- a/cf/commands/service/servicefakes/fake_binder.go +++ b/cf/commands/service/servicefakes/fake_binder.go @@ -4,8 +4,8 @@ package servicefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeBinder struct { @@ -34,15 +34,16 @@ func (fake *FakeBinder) BindApplication(arg1 models.Application, arg2 models.Ser arg2 models.ServiceInstance arg3 map[string]interface{} }{arg1, arg2, arg3}) + stub := fake.BindApplicationStub + fakeReturns := fake.bindApplicationReturns fake.recordInvocation("BindApplication", []interface{}{arg1, arg2, arg3}) fake.bindApplicationMutex.Unlock() - if fake.BindApplicationStub != nil { - return fake.BindApplicationStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.bindApplicationReturns return fakeReturns.result1 } diff --git a/cf/commands/service/servicefakes/fake_route_service_unbinder.go b/cf/commands/service/servicefakes/fake_route_service_unbinder.go index a8790fdbe71..e848c6137e4 100644 --- a/cf/commands/service/servicefakes/fake_route_service_unbinder.go +++ b/cf/commands/service/servicefakes/fake_route_service_unbinder.go @@ -4,8 +4,8 @@ package servicefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeRouteServiceUnbinder struct { @@ -32,15 +32,16 @@ func (fake *FakeRouteServiceUnbinder) UnbindRoute(arg1 models.Route, arg2 models arg1 models.Route arg2 models.ServiceInstance }{arg1, arg2}) + stub := fake.UnbindRouteStub + fakeReturns := fake.unbindRouteReturns fake.recordInvocation("UnbindRoute", []interface{}{arg1, arg2}) fake.unbindRouteMutex.Unlock() - if fake.UnbindRouteStub != nil { - return fake.UnbindRouteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.unbindRouteReturns return fakeReturns.result1 } diff --git a/cf/commands/service/services.go b/cf/commands/service/services.go index e13ab149fa8..0c8a04732c8 100644 --- a/cf/commands/service/services.go +++ b/cf/commands/service/services.go @@ -3,15 +3,15 @@ package service import ( "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListServices struct { diff --git a/cf/commands/service/services_test.go b/cf/commands/service/services_test.go index 631df7ced8a..b7fa202c087 100644 --- a/cf/commands/service/services_test.go +++ b/cf/commands/service/services_test.go @@ -3,24 +3,24 @@ package service_test import ( "os" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - - "code.cloudfoundry.org/cli/cf/commands/service" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + + "code.cloudfoundry.org/cli/v8/cf/commands/service" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/unbind_route_service.go b/cf/commands/service/unbind_route_service.go index 258cfa9d535..6e650da2199 100644 --- a/cf/commands/service/unbind_route_service.go +++ b/cf/commands/service/unbind_route_service.go @@ -4,15 +4,15 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RouteServiceUnbinder diff --git a/cf/commands/service/unbind_route_service_test.go b/cf/commands/service/unbind_route_service_test.go index efd55a40c62..65a5068b151 100644 --- a/cf/commands/service/unbind_route_service_test.go +++ b/cf/commands/service/unbind_route_service_test.go @@ -3,21 +3,21 @@ package service_test import ( "net/http" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/service/unbind_service.go b/cf/commands/service/unbind_service.go index 7f3f0a9c855..eeb67a4dc74 100644 --- a/cf/commands/service/unbind_service.go +++ b/cf/commands/service/unbind_service.go @@ -3,13 +3,13 @@ package service import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnbindService struct { diff --git a/cf/commands/service/unbind_service_test.go b/cf/commands/service/unbind_service_test.go index f90c2910cbb..8aa2a9b5b92 100644 --- a/cf/commands/service/unbind_service_test.go +++ b/cf/commands/service/unbind_service_test.go @@ -1,19 +1,19 @@ package service_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("unbind-service command", func() { @@ -99,7 +99,7 @@ var _ = Describe("unbind-service command", func() { serviceBindingRepo.DeleteReturns(false, nil) }) - It("warns the user the the service instance does not exist", func() { + It("warns the user the service instance does not exist", func() { callUnbindService([]string{"my-app", "my-service"}) Expect(ui.Outputs()).To(ContainSubstrings( diff --git a/cf/commands/service/update_service.go b/cf/commands/service/update_service.go index 25eecda7a95..6b9f2019bc6 100644 --- a/cf/commands/service/update_service.go +++ b/cf/commands/service/update_service.go @@ -1,21 +1,21 @@ package service import ( - "code.cloudfoundry.org/cli/cf/uihelpers" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" "errors" "fmt" "strings" - "code.cloudfoundry.org/cli/cf/actors/planbuilder" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/json" + "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/json" ) type UpdateService struct { diff --git a/cf/commands/service/update_service_test.go b/cf/commands/service/update_service_test.go index b484ea1ba9a..6548f5d0c31 100644 --- a/cf/commands/service/update_service_test.go +++ b/cf/commands/service/update_service_test.go @@ -5,20 +5,20 @@ import ( "io/ioutil" "os" - planbuilderfakes "code.cloudfoundry.org/cli/cf/actors/planbuilder/planbuilderfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + planbuilderfakes "code.cloudfoundry.org/cli/v8/cf/actors/planbuilder/planbuilderfakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("update-service command", func() { diff --git a/cf/commands/service/update_user_provided_service.go b/cf/commands/service/update_user_provided_service.go index 1c91365f713..50772b9ee48 100644 --- a/cf/commands/service/update_user_provided_service.go +++ b/cf/commands/service/update_user_provided_service.go @@ -6,17 +6,17 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/flagcontext" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/uihelpers" - - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flagcontext" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/uihelpers" + + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateUserProvidedService struct { diff --git a/cf/commands/service/update_user_provided_service_test.go b/cf/commands/service/update_user_provided_service_test.go index 962f397e0a9..bcf516ab00a 100644 --- a/cf/commands/service/update_user_provided_service_test.go +++ b/cf/commands/service/update_user_provided_service_test.go @@ -5,21 +5,21 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "github.com/blang/semver" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "github.com/blang/semver/v4" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -275,7 +275,7 @@ var _ = Describe("UpdateUserProvidedService", func() { flagContext.Parse("service-instance", "-t", "tag1, tag2, tag3, tag4") }) - It("sucessfully updates the service instance and passes the tags as json", func() { + It("successfully updates the service instance and passes the tags as json", func() { Expect(runCLIErr).NotTo(HaveOccurred()) Expect(serviceInstanceRepo.UpdateCallCount()).To(Equal(1)) serviceInstanceFields := serviceInstanceRepo.UpdateArgsForCall(0) diff --git a/cf/commands/serviceaccess/disable_service_access.go b/cf/commands/serviceaccess/disable_service_access.go index ae0fa27bf26..712e57c80af 100644 --- a/cf/commands/serviceaccess/disable_service_access.go +++ b/cf/commands/serviceaccess/disable_service_access.go @@ -3,14 +3,14 @@ package serviceaccess import ( "fmt" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DisableServiceAccess struct { diff --git a/cf/commands/serviceaccess/disable_service_access_test.go b/cf/commands/serviceaccess/disable_service_access_test.go index e9d7fc026c4..07d346da24e 100644 --- a/cf/commands/serviceaccess/disable_service_access_test.go +++ b/cf/commands/serviceaccess/disable_service_access_test.go @@ -3,17 +3,17 @@ package serviceaccess_test import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/actorsfakes" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/actorsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -60,7 +60,7 @@ var _ = Describe("disable-service-access command", func() { Expect(runCommand([]string{"foo"})).To(BeFalse()) }) - It("fails with usage when it does not recieve any arguments", func() { + It("fails with usage when it does not receive any arguments", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) runCommand(nil) Expect(ui.Outputs()).To(ContainSubstrings( diff --git a/cf/commands/serviceaccess/enable_service_access.go b/cf/commands/serviceaccess/enable_service_access.go index 17a2edfdb92..bb8a12a543e 100644 --- a/cf/commands/serviceaccess/enable_service_access.go +++ b/cf/commands/serviceaccess/enable_service_access.go @@ -3,15 +3,15 @@ package serviceaccess import ( "fmt" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type EnableServiceAccess struct { diff --git a/cf/commands/serviceaccess/enable_service_access_test.go b/cf/commands/serviceaccess/enable_service_access_test.go index a0fbdeb0334..4a8223000a1 100644 --- a/cf/commands/serviceaccess/enable_service_access_test.go +++ b/cf/commands/serviceaccess/enable_service_access_test.go @@ -3,18 +3,18 @@ package serviceaccess_test import ( "errors" - "code.cloudfoundry.org/cli/cf/actors/actorsfakes" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/actorsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -59,7 +59,7 @@ var _ = Describe("enable-service-access command", func() { Expect(runCommand([]string{"foo"})).To(BeFalse()) }) - It("fails with usage when it does not recieve any arguments", func() { + It("fails with usage when it does not receive any arguments", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) runCommand(nil) Expect(ui.Outputs()).To(ContainSubstrings( diff --git a/cf/commands/serviceaccess/service_access.go b/cf/commands/serviceaccess/service_access.go index 0a3ecf62897..efa30f36a97 100644 --- a/cf/commands/serviceaccess/service_access.go +++ b/cf/commands/serviceaccess/service_access.go @@ -1,18 +1,17 @@ package serviceaccess import ( - "fmt" "strings" - "code.cloudfoundry.org/cli/cf/actors" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/actors" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ServiceAccess struct { @@ -124,7 +123,7 @@ func (cmd *ServiceAccess) Execute(c flags.FlagContext) error { func (cmd ServiceAccess) printTable(brokers []models.ServiceBroker) error { for _, serviceBroker := range brokers { - cmd.ui.Say(fmt.Sprintf(T("broker: {{.Name}}", map[string]interface{}{"Name": serviceBroker.Name}))) + cmd.ui.Say(T("broker: {{.Name}}", map[string]interface{}{"Name": serviceBroker.Name})) table := cmd.ui.Table([]string{"", T("service"), T("plan"), T("access"), T("orgs")}) for _, service := range serviceBroker.Services { diff --git a/cf/commands/serviceaccess/service_access_test.go b/cf/commands/serviceaccess/service_access_test.go index 9775ea1a0be..74bb134834a 100644 --- a/cf/commands/serviceaccess/service_access_test.go +++ b/cf/commands/serviceaccess/service_access_test.go @@ -4,21 +4,21 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/cf/actors/actorsfakes" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/serviceaccess" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/actors/actorsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/serviceaccess" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/serviceaccess/serviceaccess_suite_test.go b/cf/commands/serviceaccess/serviceaccess_suite_test.go index 371f4481067..a1fd82a9624 100644 --- a/cf/commands/serviceaccess/serviceaccess_suite_test.go +++ b/cf/commands/serviceaccess/serviceaccess_suite_test.go @@ -1,10 +1,10 @@ package serviceaccess_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/serviceauthtoken/create_service_auth_token.go b/cf/commands/serviceauthtoken/create_service_auth_token.go index 1adfd140eb2..7b8fdeadb68 100644 --- a/cf/commands/serviceauthtoken/create_service_auth_token.go +++ b/cf/commands/serviceauthtoken/create_service_auth_token.go @@ -3,15 +3,15 @@ package serviceauthtoken import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateServiceAuthTokenFields struct { diff --git a/cf/commands/serviceauthtoken/create_service_auth_token_test.go b/cf/commands/serviceauthtoken/create_service_auth_token_test.go index 9005700b265..ecb5297b856 100644 --- a/cf/commands/serviceauthtoken/create_service_auth_token_test.go +++ b/cf/commands/serviceauthtoken/create_service_auth_token_test.go @@ -1,18 +1,18 @@ package serviceauthtoken_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/serviceauthtoken/delete_service_auth_token.go b/cf/commands/serviceauthtoken/delete_service_auth_token.go index c83b9814163..7206bc90187 100644 --- a/cf/commands/serviceauthtoken/delete_service_auth_token.go +++ b/cf/commands/serviceauthtoken/delete_service_auth_token.go @@ -3,16 +3,16 @@ package serviceauthtoken import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteServiceAuthTokenFields struct { diff --git a/cf/commands/serviceauthtoken/delete_service_auth_token_test.go b/cf/commands/serviceauthtoken/delete_service_auth_token_test.go index 04e5a1bb1df..90080b775f8 100644 --- a/cf/commands/serviceauthtoken/delete_service_auth_token_test.go +++ b/cf/commands/serviceauthtoken/delete_service_auth_token_test.go @@ -1,21 +1,21 @@ package serviceauthtoken_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-service-auth-token command", func() { diff --git a/cf/commands/serviceauthtoken/service_auth_tokens.go b/cf/commands/serviceauthtoken/service_auth_tokens.go index d9b3898b436..c592dba41b7 100644 --- a/cf/commands/serviceauthtoken/service_auth_tokens.go +++ b/cf/commands/serviceauthtoken/service_auth_tokens.go @@ -1,14 +1,14 @@ package serviceauthtoken import ( - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListServiceAuthTokens struct { diff --git a/cf/commands/serviceauthtoken/service_auth_tokens_test.go b/cf/commands/serviceauthtoken/service_auth_tokens_test.go index eabbb105d24..188b2c18f29 100644 --- a/cf/commands/serviceauthtoken/service_auth_tokens_test.go +++ b/cf/commands/serviceauthtoken/service_auth_tokens_test.go @@ -1,20 +1,20 @@ package serviceauthtoken_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commands/serviceauthtoken" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commands/serviceauthtoken" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/serviceauthtoken/serviceauthtoken_suite_test.go b/cf/commands/serviceauthtoken/serviceauthtoken_suite_test.go index 12972c6beb8..dee6aa79100 100644 --- a/cf/commands/serviceauthtoken/serviceauthtoken_suite_test.go +++ b/cf/commands/serviceauthtoken/serviceauthtoken_suite_test.go @@ -1,9 +1,9 @@ package serviceauthtoken_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/serviceauthtoken/update_service_auth_token.go b/cf/commands/serviceauthtoken/update_service_auth_token.go index 744f00a978e..42b6f50906e 100644 --- a/cf/commands/serviceauthtoken/update_service_auth_token.go +++ b/cf/commands/serviceauthtoken/update_service_auth_token.go @@ -3,14 +3,14 @@ package serviceauthtoken import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateServiceAuthTokenFields struct { diff --git a/cf/commands/serviceauthtoken/update_service_auth_token_test.go b/cf/commands/serviceauthtoken/update_service_auth_token_test.go index 93a1531e9c3..c29490d586d 100644 --- a/cf/commands/serviceauthtoken/update_service_auth_token_test.go +++ b/cf/commands/serviceauthtoken/update_service_auth_token_test.go @@ -1,18 +1,18 @@ package serviceauthtoken_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicebroker/create_service_broker.go b/cf/commands/servicebroker/create_service_broker.go index db3aaf3ae0a..1fdccee90e2 100644 --- a/cf/commands/servicebroker/create_service_broker.go +++ b/cf/commands/servicebroker/create_service_broker.go @@ -3,13 +3,13 @@ package servicebroker import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateServiceBroker struct { diff --git a/cf/commands/servicebroker/create_service_broker_test.go b/cf/commands/servicebroker/create_service_broker_test.go index 247ff85b80b..c06f9056fc6 100644 --- a/cf/commands/servicebroker/create_service_broker_test.go +++ b/cf/commands/servicebroker/create_service_broker_test.go @@ -3,19 +3,19 @@ package servicebroker_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/servicebroker" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/servicebroker" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicebroker/delete_service_broker.go b/cf/commands/servicebroker/delete_service_broker.go index 46951793977..35cc4f551b1 100644 --- a/cf/commands/servicebroker/delete_service_broker.go +++ b/cf/commands/servicebroker/delete_service_broker.go @@ -3,14 +3,14 @@ package servicebroker import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteServiceBroker struct { diff --git a/cf/commands/servicebroker/delete_service_broker_test.go b/cf/commands/servicebroker/delete_service_broker_test.go index 6f78edb6fd4..a9bf55ec95f 100644 --- a/cf/commands/servicebroker/delete_service_broker_test.go +++ b/cf/commands/servicebroker/delete_service_broker_test.go @@ -1,18 +1,18 @@ package servicebroker_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicebroker/rename_service_broker.go b/cf/commands/servicebroker/rename_service_broker.go index 0f367b2a55e..25558d30613 100644 --- a/cf/commands/servicebroker/rename_service_broker.go +++ b/cf/commands/servicebroker/rename_service_broker.go @@ -3,13 +3,13 @@ package servicebroker import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameServiceBroker struct { diff --git a/cf/commands/servicebroker/rename_service_broker_test.go b/cf/commands/servicebroker/rename_service_broker_test.go index edf124c29a2..939d12498a0 100644 --- a/cf/commands/servicebroker/rename_service_broker_test.go +++ b/cf/commands/servicebroker/rename_service_broker_test.go @@ -1,17 +1,17 @@ package servicebroker_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicebroker/service_brokers.go b/cf/commands/servicebroker/service_brokers.go index 72a20de68cb..d2c20847f00 100644 --- a/cf/commands/servicebroker/service_brokers.go +++ b/cf/commands/servicebroker/service_brokers.go @@ -3,14 +3,14 @@ package servicebroker import ( "sort" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListServiceBrokers struct { diff --git a/cf/commands/servicebroker/service_brokers_test.go b/cf/commands/servicebroker/service_brokers_test.go index 4ac1dfd2423..18948f48ced 100644 --- a/cf/commands/servicebroker/service_brokers_test.go +++ b/cf/commands/servicebroker/service_brokers_test.go @@ -3,23 +3,23 @@ package servicebroker_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "strings" - "code.cloudfoundry.org/cli/cf/commands/servicebroker" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands/servicebroker" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("service-brokers command", func() { diff --git a/cf/commands/servicebroker/servicebroker_suite_test.go b/cf/commands/servicebroker/servicebroker_suite_test.go index e0da03b6405..a2a5a19307b 100644 --- a/cf/commands/servicebroker/servicebroker_suite_test.go +++ b/cf/commands/servicebroker/servicebroker_suite_test.go @@ -1,9 +1,9 @@ package servicebroker_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/servicebroker/update_service_broker.go b/cf/commands/servicebroker/update_service_broker.go index 375111bd054..bf713c1400d 100644 --- a/cf/commands/servicebroker/update_service_broker.go +++ b/cf/commands/servicebroker/update_service_broker.go @@ -3,13 +3,13 @@ package servicebroker import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateServiceBroker struct { diff --git a/cf/commands/servicebroker/update_service_broker_test.go b/cf/commands/servicebroker/update_service_broker_test.go index 51a61dc14f8..8da871cbb2b 100644 --- a/cf/commands/servicebroker/update_service_broker_test.go +++ b/cf/commands/servicebroker/update_service_broker_test.go @@ -1,19 +1,19 @@ package servicebroker_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("update-service-broker command", func() { diff --git a/cf/commands/servicekey/create_service_key.go b/cf/commands/servicekey/create_service_key.go index 1c202774f90..c6f1b1c1f60 100644 --- a/cf/commands/servicekey/create_service_key.go +++ b/cf/commands/servicekey/create_service_key.go @@ -3,16 +3,16 @@ package servicekey import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/util/json" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/util/json" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type CreateServiceKey struct { diff --git a/cf/commands/servicekey/create_service_key_test.go b/cf/commands/servicekey/create_service_key_test.go index 3dcd00a9417..e90eadb8147 100644 --- a/cf/commands/servicekey/create_service_key_test.go +++ b/cf/commands/servicekey/create_service_key_test.go @@ -4,21 +4,21 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicekey/delete_service_key.go b/cf/commands/servicekey/delete_service_key.go index 9ad4934b2e1..c2fec0e5595 100644 --- a/cf/commands/servicekey/delete_service_key.go +++ b/cf/commands/servicekey/delete_service_key.go @@ -3,15 +3,15 @@ package servicekey import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type DeleteServiceKey struct { diff --git a/cf/commands/servicekey/delete_service_key_test.go b/cf/commands/servicekey/delete_service_key_test.go index ef29fee4b80..5bc7ff1563e 100644 --- a/cf/commands/servicekey/delete_service_key_test.go +++ b/cf/commands/servicekey/delete_service_key_test.go @@ -1,21 +1,21 @@ package servicekey_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicekey/service_key.go b/cf/commands/servicekey/service_key.go index df3101514c0..96624da6616 100644 --- a/cf/commands/servicekey/service_key.go +++ b/cf/commands/servicekey/service_key.go @@ -4,15 +4,15 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ServiceKey struct { diff --git a/cf/commands/servicekey/service_key_test.go b/cf/commands/servicekey/service_key_test.go index 5e20e7172bd..e7d3fdcaba9 100644 --- a/cf/commands/servicekey/service_key_test.go +++ b/cf/commands/servicekey/service_key_test.go @@ -1,21 +1,21 @@ package servicekey_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicekey/service_keys.go b/cf/commands/servicekey/service_keys.go index 8289c83b7e1..7d7ee2a0b9c 100644 --- a/cf/commands/servicekey/service_keys.go +++ b/cf/commands/servicekey/service_keys.go @@ -3,14 +3,14 @@ package servicekey import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ServiceKeys struct { diff --git a/cf/commands/servicekey/service_keys_test.go b/cf/commands/servicekey/service_keys_test.go index 23e9366a552..5165daad9d2 100644 --- a/cf/commands/servicekey/service_keys_test.go +++ b/cf/commands/servicekey/service_keys_test.go @@ -3,20 +3,20 @@ package servicekey_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/api/apifakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/servicekey/servicekey_suite_test.go b/cf/commands/servicekey/servicekey_suite_test.go index 0f2ce691219..c6c7919aca9 100644 --- a/cf/commands/servicekey/servicekey_suite_test.go +++ b/cf/commands/servicekey/servicekey_suite_test.go @@ -3,10 +3,10 @@ package servicekey_test import ( "testing" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/space/allow_space_ssh.go b/cf/commands/space/allow_space_ssh.go index 7254ddf9330..180dfd2e0b0 100644 --- a/cf/commands/space/allow_space_ssh.go +++ b/cf/commands/space/allow_space_ssh.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type AllowSpaceSSH struct { diff --git a/cf/commands/space/allow_space_ssh_test.go b/cf/commands/space/allow_space_ssh_test.go index a853ff71a20..330d966f449 100644 --- a/cf/commands/space/allow_space_ssh_test.go +++ b/cf/commands/space/allow_space_ssh_test.go @@ -3,18 +3,18 @@ package space_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/space/create_space.go b/cf/commands/space/create_space.go index bb862ee4db6..0e29f2d1003 100644 --- a/cf/commands/space/create_space.go +++ b/cf/commands/space/create_space.go @@ -3,20 +3,20 @@ package space import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateSpace struct { @@ -73,7 +73,7 @@ func (cmd *CreateSpace) SetDependency(deps commandregistry.Dependency, pluginCal cmd.userRepo = deps.RepoLocator.GetUserRepository() cmd.spaceQuotaRepo = deps.RepoLocator.GetSpaceQuotaRepository() - //get command from registry for dependency + // get command from registry for dependency commandDep := commandregistry.Commands.FindCommand("set-space-role") commandDep = commandDep.SetDependency(deps, false) cmd.spaceRoleSetter = commandDep.(user.SpaceRoleSetter) diff --git a/cf/commands/space/create_space_test.go b/cf/commands/space/create_space_test.go index a1ddd8c9089..a86eeed6d02 100644 --- a/cf/commands/space/create_space_test.go +++ b/cf/commands/space/create_space_test.go @@ -1,24 +1,24 @@ package space_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -47,7 +47,7 @@ var _ = Describe("create-space command", func() { deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo) deps.Config = configRepo - //inject fake 'command dependency' into registry + // inject fake 'command dependency' into registry commandregistry.Register(spaceRoleSetter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-space").SetDependency(deps, pluginCall)) @@ -75,7 +75,7 @@ var _ = Describe("create-space command", func() { GUID: "my-org-guid", } - //save original command and restore later + // save original command and restore later OriginalCommand = commandregistry.Commands.FindCommand("set-space-role") spaceRepo = new(spacesfakes.FakeSpaceRepository) diff --git a/cf/commands/space/delete_space.go b/cf/commands/space/delete_space.go index 90268df5b07..370d1fa5786 100644 --- a/cf/commands/space/delete_space.go +++ b/cf/commands/space/delete_space.go @@ -3,16 +3,16 @@ package space import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteSpace struct { diff --git a/cf/commands/space/delete_space_test.go b/cf/commands/space/delete_space_test.go index 88e49ef4ac2..de7236b6321 100644 --- a/cf/commands/space/delete_space_test.go +++ b/cf/commands/space/delete_space_test.go @@ -3,20 +3,20 @@ package space_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-space command", func() { diff --git a/cf/commands/space/disallow_space_ssh.go b/cf/commands/space/disallow_space_ssh.go index 8095f19a8ff..840e3eef56f 100644 --- a/cf/commands/space/disallow_space_ssh.go +++ b/cf/commands/space/disallow_space_ssh.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DisallowSpaceSSH struct { diff --git a/cf/commands/space/disallow_space_ssh_test.go b/cf/commands/space/disallow_space_ssh_test.go index bf0b8daa557..b5356f96f9a 100644 --- a/cf/commands/space/disallow_space_ssh_test.go +++ b/cf/commands/space/disallow_space_ssh_test.go @@ -3,18 +3,18 @@ package space_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/space/rename_space.go b/cf/commands/space/rename_space.go index 92bfdb47787..e6a03e764d2 100644 --- a/cf/commands/space/rename_space.go +++ b/cf/commands/space/rename_space.go @@ -3,13 +3,13 @@ package space import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type RenameSpace struct { diff --git a/cf/commands/space/rename_space_test.go b/cf/commands/space/rename_space_test.go index f6d8b6fbc61..5ff5d43ae9d 100644 --- a/cf/commands/space/rename_space_test.go +++ b/cf/commands/space/rename_space_test.go @@ -3,19 +3,19 @@ package space_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("rename-space command", func() { diff --git a/cf/commands/space/space.go b/cf/commands/space/space.go index e169568d62f..d777b6f1b5b 100644 --- a/cf/commands/space/space.go +++ b/cf/commands/space/space.go @@ -4,17 +4,17 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ShowSpace struct { diff --git a/cf/commands/space/space_ssh_allowed.go b/cf/commands/space/space_ssh_allowed.go index bf4c70ec3b6..fe86fda48cb 100644 --- a/cf/commands/space/space_ssh_allowed.go +++ b/cf/commands/space/space_ssh_allowed.go @@ -3,13 +3,13 @@ package space import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SSHAllowed struct { diff --git a/cf/commands/space/space_ssh_allowed_test.go b/cf/commands/space/space_ssh_allowed_test.go index bad3f51ee7d..ddc3ca7c95b 100644 --- a/cf/commands/space/space_ssh_allowed_test.go +++ b/cf/commands/space/space_ssh_allowed_test.go @@ -3,14 +3,14 @@ package space_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/space/space_suite_test.go b/cf/commands/space/space_suite_test.go index 8c04e5387b9..ac4e524c322 100644 --- a/cf/commands/space/space_suite_test.go +++ b/cf/commands/space/space_suite_test.go @@ -1,9 +1,9 @@ package space_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/space/space_test.go b/cf/commands/space/space_test.go index 200f6e9d5d5..025e7a85485 100644 --- a/cf/commands/space/space_test.go +++ b/cf/commands/space/space_test.go @@ -1,22 +1,22 @@ package space_test import ( - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commands/space" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commands/space" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("space command", func() { diff --git a/cf/commands/space/spaces.go b/cf/commands/space/spaces.go index 951c40c0268..bd88551534c 100644 --- a/cf/commands/space/spaces.go +++ b/cf/commands/space/spaces.go @@ -3,15 +3,15 @@ package space import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type ListSpaces struct { diff --git a/cf/commands/space/spaces_test.go b/cf/commands/space/spaces_test.go index aa8fac60222..426532a5c07 100644 --- a/cf/commands/space/spaces_test.go +++ b/cf/commands/space/spaces_test.go @@ -4,22 +4,22 @@ import ( "errors" "os" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/plugin/models" - - "code.cloudfoundry.org/cli/cf/commands/space" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" + + "code.cloudfoundry.org/cli/v8/cf/commands/space" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/spacequota/create_space_quota.go b/cf/commands/spacequota/create_space_quota.go index 876c580c531..a9ffa7fa32e 100644 --- a/cf/commands/spacequota/create_space_quota.go +++ b/cf/commands/spacequota/create_space_quota.go @@ -5,17 +5,17 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateSpaceQuota struct { diff --git a/cf/commands/spacequota/create_space_quota_test.go b/cf/commands/spacequota/create_space_quota_test.go index 50ae6dcb3e1..2675257e3e4 100644 --- a/cf/commands/spacequota/create_space_quota_test.go +++ b/cf/commands/spacequota/create_space_quota_test.go @@ -3,22 +3,22 @@ package spacequota_test import ( "encoding/json" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - - "code.cloudfoundry.org/cli/cf/api/resources" - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commands/spacequota" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + + "code.cloudfoundry.org/cli/v8/cf/api/resources" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commands/spacequota" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -143,7 +143,7 @@ var _ = Describe("create-space-quota", func() { )) }) - It("sets the instance memory limit to unlimiited", func() { + It("sets the instance memory limit to unlimited", func() { Expect(quotaRepo.CreateArgsForCall(0).InstanceMemoryLimit).To(Equal(int64(-1))) }) @@ -272,7 +272,7 @@ var _ = Describe("create-space-quota", func() { cmd.SetDependency(deps, false) }) - It("alets the user when creating the quota fails", func() { + It("alerts the user when creating the quota fails", func() { Expect(runCLIErr).To(HaveOccurred()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"Creating space quota", "my-quota", "my-org"}, diff --git a/cf/commands/spacequota/delete_space_quota.go b/cf/commands/spacequota/delete_space_quota.go index d23a6b04e48..63287a5a1ac 100644 --- a/cf/commands/spacequota/delete_space_quota.go +++ b/cf/commands/spacequota/delete_space_quota.go @@ -3,15 +3,15 @@ package spacequota import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type DeleteSpaceQuota struct { diff --git a/cf/commands/spacequota/delete_space_quota_test.go b/cf/commands/spacequota/delete_space_quota_test.go index db65d8fc42b..eaff7039258 100644 --- a/cf/commands/spacequota/delete_space_quota_test.go +++ b/cf/commands/spacequota/delete_space_quota_test.go @@ -1,20 +1,20 @@ package spacequota_test import ( - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -129,19 +129,19 @@ var _ = Describe("delete-space-quota command", func() { Context("when finding the quota fails", func() { Context("when the quota provided does not exist", func() { BeforeEach(func() { - quotaRepo.FindByNameReturns(models.SpaceQuota{}, errors.NewModelNotFoundError("Quota", "non-existent-quota")) + quotaRepo.FindByNameReturns(models.SpaceQuota{}, errors.NewModelNotFoundError("Quota", "nonexistent-quota")) }) It("warns the user when that the quota does not exist", func() { - runCommand("-f", "non-existent-quota") + runCommand("-f", "nonexistent-quota") Expect(ui.Outputs()).To(ContainSubstrings( - []string{"Deleting", "non-existent-quota"}, + []string{"Deleting", "nonexistent-quota"}, []string{"OK"}, )) Expect(ui.WarnOutputs).To(ContainSubstrings( - []string{"non-existent-quota", "does not exist"}, + []string{"nonexistent-quota", "does not exist"}, )) }) }) diff --git a/cf/commands/spacequota/set_space_quota.go b/cf/commands/spacequota/set_space_quota.go index 0829c3734a5..2069fd21402 100644 --- a/cf/commands/spacequota/set_space_quota.go +++ b/cf/commands/spacequota/set_space_quota.go @@ -4,14 +4,14 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SetSpaceQuota struct { diff --git a/cf/commands/spacequota/set_space_quota_test.go b/cf/commands/spacequota/set_space_quota_test.go index 96dd5200224..9d8cb51aaad 100644 --- a/cf/commands/spacequota/set_space_quota_test.go +++ b/cf/commands/spacequota/set_space_quota_test.go @@ -1,20 +1,20 @@ package spacequota_test import ( - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commands/spacequota" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commands/spacequota" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/spacequota/space_quota.go b/cf/commands/spacequota/space_quota.go index 52d134a9f20..3f3a0224fa6 100644 --- a/cf/commands/spacequota/space_quota.go +++ b/cf/commands/spacequota/space_quota.go @@ -3,14 +3,14 @@ package spacequota import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type SpaceQuota struct { diff --git a/cf/commands/spacequota/space_quota_test.go b/cf/commands/spacequota/space_quota_test.go index 9bacb6fe12c..c8a40f9da83 100644 --- a/cf/commands/spacequota/space_quota_test.go +++ b/cf/commands/spacequota/space_quota_test.go @@ -1,19 +1,19 @@ package spacequota_test import ( - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/spacequota/space_quotas.go b/cf/commands/spacequota/space_quotas.go index 563b449f78e..40baae6cefa 100644 --- a/cf/commands/spacequota/space_quotas.go +++ b/cf/commands/spacequota/space_quotas.go @@ -4,14 +4,14 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListSpaceQuotas struct { diff --git a/cf/commands/spacequota/space_quotas_test.go b/cf/commands/spacequota/space_quotas_test.go index 755c83e1f3d..58ec0a231ad 100644 --- a/cf/commands/spacequota/space_quotas_test.go +++ b/cf/commands/spacequota/space_quotas_test.go @@ -1,21 +1,21 @@ package spacequota_test import ( - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "code.cloudfoundry.org/cli/cf/commands/spacequota" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + "code.cloudfoundry.org/cli/v8/cf/commands/spacequota" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/spacequota/spacequota_suite_test.go b/cf/commands/spacequota/spacequota_suite_test.go index f3f921a78e8..821c0186f85 100644 --- a/cf/commands/spacequota/spacequota_suite_test.go +++ b/cf/commands/spacequota/spacequota_suite_test.go @@ -1,9 +1,9 @@ package spacequota_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/spacequota/unset_space_quota.go b/cf/commands/spacequota/unset_space_quota.go index d603e4a7b71..7fcdfc09dcb 100644 --- a/cf/commands/spacequota/unset_space_quota.go +++ b/cf/commands/spacequota/unset_space_quota.go @@ -3,14 +3,14 @@ package spacequota import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnsetSpaceQuota struct { diff --git a/cf/commands/spacequota/unset_space_quota_test.go b/cf/commands/spacequota/unset_space_quota_test.go index 9f71ab70d9f..1938e840e05 100644 --- a/cf/commands/spacequota/unset_space_quota_test.go +++ b/cf/commands/spacequota/unset_space_quota_test.go @@ -3,19 +3,19 @@ package spacequota_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/spacequota/update_space_quota.go b/cf/commands/spacequota/update_space_quota.go index e006966cc69..716e250feb9 100644 --- a/cf/commands/spacequota/update_space_quota.go +++ b/cf/commands/spacequota/update_space_quota.go @@ -6,14 +6,14 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/cf/api/spacequotas" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UpdateSpaceQuota struct { diff --git a/cf/commands/spacequota/update_space_quota_test.go b/cf/commands/spacequota/update_space_quota_test.go index fad0c96b6e8..f9eb0a253c4 100644 --- a/cf/commands/spacequota/update_space_quota_test.go +++ b/cf/commands/spacequota/update_space_quota_test.go @@ -3,19 +3,19 @@ package spacequota_test import ( "encoding/json" - "code.cloudfoundry.org/cli/cf/api/spacequotas/spacequotasfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/cf/api/spacequotas/spacequotasfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/ssh_code.go b/cf/commands/ssh_code.go index 57d3e3a2f4a..75fca000450 100644 --- a/cf/commands/ssh_code.go +++ b/cf/commands/ssh_code.go @@ -3,14 +3,14 @@ package commands import ( "errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SSHCodeGetter diff --git a/cf/commands/ssh_code_test.go b/cf/commands/ssh_code_test.go index e281c4bd2c7..15cf61a112d 100644 --- a/cf/commands/ssh_code_test.go +++ b/cf/commands/ssh_code_test.go @@ -3,20 +3,20 @@ package commands_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/stack.go b/cf/commands/stack.go index 8374503ba4d..e064aec8172 100644 --- a/cf/commands/stack.go +++ b/cf/commands/stack.go @@ -3,13 +3,13 @@ package commands import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListStack struct { diff --git a/cf/commands/stack_test.go b/cf/commands/stack_test.go index 82e9639a0df..f62822eb59d 100644 --- a/cf/commands/stack_test.go +++ b/cf/commands/stack_test.go @@ -3,20 +3,20 @@ package commands_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/stacks/stacksfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("stack command", func() { diff --git a/cf/commands/stacks.go b/cf/commands/stacks.go index a2899eac905..d7606b2d3a7 100644 --- a/cf/commands/stacks.go +++ b/cf/commands/stacks.go @@ -1,13 +1,13 @@ package commands import ( - "code.cloudfoundry.org/cli/cf/api/stacks" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/stacks" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ListStacks struct { diff --git a/cf/commands/stacks_test.go b/cf/commands/stacks_test.go index 72b24a0e770..b45c23f5f25 100644 --- a/cf/commands/stacks_test.go +++ b/cf/commands/stacks_test.go @@ -1,21 +1,21 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/stacks/stacksfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commands" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("stacks command", func() { diff --git a/cf/commands/target.go b/cf/commands/target.go index 107ddb96fae..025e57ea127 100644 --- a/cf/commands/target.go +++ b/cf/commands/target.go @@ -3,16 +3,16 @@ package commands import ( "fmt" - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type Target struct { @@ -111,7 +111,7 @@ func (cmd Target) setOrganization(orgName string) error { org, apiErr := cmd.orgRepo.FindByName(orgName) if apiErr != nil { - return fmt.Errorf(T("Could not target org.\n{{.APIErr}}", + return errors.New(T("Could not target org.\n{{.APIErr}}", map[string]interface{}{"APIErr": apiErr.Error()})) } @@ -128,7 +128,7 @@ func (cmd Target) setSpace(spaceName string) error { space, apiErr := cmd.spaceRepo.FindByName(spaceName) if apiErr != nil { - return fmt.Errorf(T("Unable to access space {{.SpaceName}}.\n{{.APIErr}}", + return errors.New(T("Unable to access space {{.SpaceName}}.\n{{.APIErr}}", map[string]interface{}{"SpaceName": spaceName, "APIErr": apiErr.Error()})) } diff --git a/cf/commands/target_test.go b/cf/commands/target_test.go index b1e972bb9bb..2480c13df94 100644 --- a/cf/commands/target_test.go +++ b/cf/commands/target_test.go @@ -1,24 +1,24 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf/commands" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commands" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("target command", func() { diff --git a/cf/commands/user/create_user.go b/cf/commands/user/create_user.go index 9076dd1d6ed..f198019e7b5 100644 --- a/cf/commands/user/create_user.go +++ b/cf/commands/user/create_user.go @@ -3,15 +3,15 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type CreateUser struct { diff --git a/cf/commands/user/create_user_test.go b/cf/commands/user/create_user_test.go index e7598400d72..38351dce55f 100644 --- a/cf/commands/user/create_user_test.go +++ b/cf/commands/user/create_user_test.go @@ -1,19 +1,19 @@ package user_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/cf/commandregistry" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("Create user command", func() { diff --git a/cf/commands/user/delete_user.go b/cf/commands/user/delete_user.go index 2d5dbd16855..3b90036484d 100644 --- a/cf/commands/user/delete_user.go +++ b/cf/commands/user/delete_user.go @@ -3,14 +3,14 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type DeleteUser struct { @@ -76,7 +76,7 @@ func (cmd *DeleteUser) Execute(c flags.FlagContext) error { switch err.(type) { case nil: if len(users) > 1 { - return fmt.Errorf(T( + return errors.New(T( "Error deleting user {{.Username}} \nThe user exists in multiple origins.", map[string]interface{}{ "Username": username, diff --git a/cf/commands/user/delete_user_test.go b/cf/commands/user/delete_user_test.go index 1359ec124e7..43608c313f3 100644 --- a/cf/commands/user/delete_user_test.go +++ b/cf/commands/user/delete_user_test.go @@ -1,20 +1,20 @@ package user_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("delete-user command", func() { @@ -124,7 +124,7 @@ var _ = Describe("delete-user command", func() { }, nil) }) - It("returns a muliple users found error", func() { + It("returns a multiple users found error", func() { runCommand("user-name") Expect(ui.Outputs()).To(ContainSubstrings( diff --git a/cf/commands/user/org_users.go b/cf/commands/user/org_users.go index 3d24c6e94f0..158473c288a 100644 --- a/cf/commands/user/org_users.go +++ b/cf/commands/user/org_users.go @@ -3,16 +3,16 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/actors/userprint" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/actors/userprint" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type OrgUsers struct { diff --git a/cf/commands/user/org_users_test.go b/cf/commands/user/org_users_test.go index 0866fe1952e..4e83195456a 100644 --- a/cf/commands/user/org_users_test.go +++ b/cf/commands/user/org_users_test.go @@ -1,23 +1,23 @@ package user_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - plugin_models "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("org-users command", func() { @@ -85,7 +85,7 @@ var _ = Describe("org-users command", func() { requirementsFactory.NewOrganizationRequirementReturns(organizationReq) }) - Context("shows friendly messaage when no users in ORG_MANAGER role", func() { + Context("shows friendly message when no users in ORG_MANAGER role", func() { It("shows the special users in the given org", func() { userRepo.ListUsersInOrgForRoleWithNoUAAStub = func(_ string, roleName models.Role) ([]models.UserFields, error) { userFields := map[models.Role][]models.UserFields{ @@ -117,7 +117,7 @@ var _ = Describe("org-users command", func() { }) }) - Context("shows friendly messaage when no users in BILLING_MANAGER role", func() { + Context("shows friendly message when no users in BILLING_MANAGER role", func() { It("shows the special users in the given org", func() { userRepo.ListUsersInOrgForRoleWithNoUAAStub = func(_ string, roleName models.Role) ([]models.UserFields, error) { userFields := map[models.Role][]models.UserFields{ @@ -149,7 +149,7 @@ var _ = Describe("org-users command", func() { }) }) - Context("shows friendly messaage when no users in ORG_AUDITOR role", func() { + Context("shows friendly message when no users in ORG_AUDITOR role", func() { It("shows the special users in the given org", func() { userRepo.ListUsersInOrgForRoleWithNoUAAStub = func(_ string, roleName models.Role) ([]models.UserFields, error) { userFields := map[models.Role][]models.UserFields{ diff --git a/cf/commands/user/set_org_role.go b/cf/commands/user/set_org_role.go index d87a84f1168..9137bb8158a 100644 --- a/cf/commands/user/set_org_role.go +++ b/cf/commands/user/set_org_role.go @@ -3,15 +3,15 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . OrgRoleSetter diff --git a/cf/commands/user/set_org_role_test.go b/cf/commands/user/set_org_role_test.go index 89cc51fdcc6..a19140fe1c3 100644 --- a/cf/commands/user/set_org_role_test.go +++ b/cf/commands/user/set_org_role_test.go @@ -3,21 +3,21 @@ package user_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/user/set_space_role.go b/cf/commands/user/set_space_role.go index 14329d26bc4..e8ba7636f19 100644 --- a/cf/commands/user/set_space_role.go +++ b/cf/commands/user/set_space_role.go @@ -3,17 +3,17 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SpaceRoleSetter diff --git a/cf/commands/user/set_space_role_test.go b/cf/commands/user/set_space_role_test.go index 3ddbff740f0..e6323cfb1f8 100644 --- a/cf/commands/user/set_space_role_test.go +++ b/cf/commands/user/set_space_role_test.go @@ -3,22 +3,22 @@ package user_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/user/space_users.go b/cf/commands/user/space_users.go index 0764b130451..8e108553265 100644 --- a/cf/commands/user/space_users.go +++ b/cf/commands/user/space_users.go @@ -3,17 +3,17 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/actors/userprint" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/actors/userprint" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin/models" ) type SpaceUsers struct { diff --git a/cf/commands/user/space_users_test.go b/cf/commands/user/space_users_test.go index 8af719a732b..5faba3b843e 100644 --- a/cf/commands/user/space_users_test.go +++ b/cf/commands/user/space_users_test.go @@ -3,24 +3,24 @@ package user_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - plugin_models "code.cloudfoundry.org/cli/plugin/models" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) var _ = Describe("space-users command", func() { diff --git a/cf/commands/user/unset_org_role.go b/cf/commands/user/unset_org_role.go index 7f97312132d..f5cd3c88412 100644 --- a/cf/commands/user/unset_org_role.go +++ b/cf/commands/user/unset_org_role.go @@ -3,15 +3,15 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnsetOrgRole struct { diff --git a/cf/commands/user/unset_org_role_test.go b/cf/commands/user/unset_org_role_test.go index 60c6191fd48..829c512d7de 100644 --- a/cf/commands/user/unset_org_role_test.go +++ b/cf/commands/user/unset_org_role_test.go @@ -3,21 +3,21 @@ package user_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - testapi "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + testapi "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/user/unset_space_role.go b/cf/commands/user/unset_space_role.go index 2697e8b57f6..bca44206f00 100644 --- a/cf/commands/user/unset_space_role.go +++ b/cf/commands/user/unset_space_role.go @@ -3,16 +3,16 @@ package user import ( "fmt" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/featureflags" - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type UnsetSpaceRole struct { diff --git a/cf/commands/user/unset_space_role_test.go b/cf/commands/user/unset_space_role_test.go index 13c7cd1b130..f475b0fcaa5 100644 --- a/cf/commands/user/unset_space_role_test.go +++ b/cf/commands/user/unset_space_role_test.go @@ -3,22 +3,22 @@ package user_test import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/featureflags/featureflagsfakes" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/featureflags/featureflagsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commands/user/user_suite_test.go b/cf/commands/user/user_suite_test.go index 64a29949870..444c4c2b0fd 100644 --- a/cf/commands/user/user_suite_test.go +++ b/cf/commands/user/user_suite_test.go @@ -1,9 +1,9 @@ package user_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commands/user/userfakes/fake_org_role_setter.go b/cf/commands/user/userfakes/fake_org_role_setter.go index 0acf6936607..fda20fff6e1 100644 --- a/cf/commands/user/userfakes/fake_org_role_setter.go +++ b/cf/commands/user/userfakes/fake_org_role_setter.go @@ -4,11 +4,11 @@ package userfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeOrgRoleSetter struct { @@ -83,15 +83,16 @@ func (fake *FakeOrgRoleSetter) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -142,15 +143,16 @@ func (fake *FakeOrgRoleSetter) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -196,15 +198,16 @@ func (fake *FakeOrgRoleSetter) Requirements(arg1 requirements.Factory, arg2 flag arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -260,15 +263,16 @@ func (fake *FakeOrgRoleSetter) SetDependency(arg1 commandregistry.Dependency, ar arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } @@ -323,15 +327,16 @@ func (fake *FakeOrgRoleSetter) SetOrgRole(arg1 string, arg2 models.Role, arg3 st arg3 string arg4 string }{arg1, arg2, arg3, arg4}) + stub := fake.SetOrgRoleStub + fakeReturns := fake.setOrgRoleReturns fake.recordInvocation("SetOrgRole", []interface{}{arg1, arg2, arg3, arg4}) fake.setOrgRoleMutex.Unlock() - if fake.SetOrgRoleStub != nil { - return fake.SetOrgRoleStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.setOrgRoleReturns return fakeReturns.result1 } diff --git a/cf/commands/user/userfakes/fake_space_role_setter.go b/cf/commands/user/userfakes/fake_space_role_setter.go index 5499c3d74a9..75af3d43dbb 100644 --- a/cf/commands/user/userfakes/fake_space_role_setter.go +++ b/cf/commands/user/userfakes/fake_space_role_setter.go @@ -4,11 +4,11 @@ package userfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands/user" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeSpaceRoleSetter struct { @@ -85,15 +85,16 @@ func (fake *FakeSpaceRoleSetter) Execute(arg1 flags.FlagContext) error { fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 flags.FlagContext }{arg1}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -144,15 +145,16 @@ func (fake *FakeSpaceRoleSetter) MetaData() commandregistry.CommandMetadata { ret, specificReturn := fake.metaDataReturnsOnCall[len(fake.metaDataArgsForCall)] fake.metaDataArgsForCall = append(fake.metaDataArgsForCall, struct { }{}) + stub := fake.MetaDataStub + fakeReturns := fake.metaDataReturns fake.recordInvocation("MetaData", []interface{}{}) fake.metaDataMutex.Unlock() - if fake.MetaDataStub != nil { - return fake.MetaDataStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.metaDataReturns return fakeReturns.result1 } @@ -198,15 +200,16 @@ func (fake *FakeSpaceRoleSetter) Requirements(arg1 requirements.Factory, arg2 fl arg1 requirements.Factory arg2 flags.FlagContext }{arg1, arg2}) + stub := fake.RequirementsStub + fakeReturns := fake.requirementsReturns fake.recordInvocation("Requirements", []interface{}{arg1, arg2}) fake.requirementsMutex.Unlock() - if fake.RequirementsStub != nil { - return fake.RequirementsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requirementsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -262,15 +265,16 @@ func (fake *FakeSpaceRoleSetter) SetDependency(arg1 commandregistry.Dependency, arg1 commandregistry.Dependency arg2 bool }{arg1, arg2}) + stub := fake.SetDependencyStub + fakeReturns := fake.setDependencyReturns fake.recordInvocation("SetDependency", []interface{}{arg1, arg2}) fake.setDependencyMutex.Unlock() - if fake.SetDependencyStub != nil { - return fake.SetDependencyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setDependencyReturns return fakeReturns.result1 } @@ -327,15 +331,16 @@ func (fake *FakeSpaceRoleSetter) SetSpaceRole(arg1 models.Space, arg2 string, ar arg5 string arg6 string }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.SetSpaceRoleStub + fakeReturns := fake.setSpaceRoleReturns fake.recordInvocation("SetSpaceRole", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.setSpaceRoleMutex.Unlock() - if fake.SetSpaceRoleStub != nil { - return fake.SetSpaceRoleStub(arg1, arg2, arg3, arg4, arg5, arg6) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1 } - fakeReturns := fake.setSpaceRoleReturns return fakeReturns.result1 } diff --git a/cf/commands/version.go b/cf/commands/version.go index 13c76e8b7de..e954e07c967 100644 --- a/cf/commands/version.go +++ b/cf/commands/version.go @@ -3,13 +3,13 @@ package commands import ( "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/version" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/version" ) type Version struct { diff --git a/cf/commands/version_test.go b/cf/commands/version_test.go index b46cffed951..c1afb54bfe3 100644 --- a/cf/commands/version_test.go +++ b/cf/commands/version_test.go @@ -1,14 +1,14 @@ package commands_test import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/flags" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" - "code.cloudfoundry.org/cli/cf" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/commandsloader/commands_loader.go b/cf/commandsloader/commands_loader.go index 5e884cb60dd..7de27cfd186 100644 --- a/cf/commandsloader/commands_loader.go +++ b/cf/commandsloader/commands_loader.go @@ -1,27 +1,27 @@ package commandsloader import ( - "code.cloudfoundry.org/cli/cf/commands" - "code.cloudfoundry.org/cli/cf/commands/application" - "code.cloudfoundry.org/cli/cf/commands/buildpack" - "code.cloudfoundry.org/cli/cf/commands/domain" - "code.cloudfoundry.org/cli/cf/commands/environmentvariablegroup" - "code.cloudfoundry.org/cli/cf/commands/featureflag" - "code.cloudfoundry.org/cli/cf/commands/organization" - "code.cloudfoundry.org/cli/cf/commands/plugin" - "code.cloudfoundry.org/cli/cf/commands/pluginrepo" - "code.cloudfoundry.org/cli/cf/commands/quota" - "code.cloudfoundry.org/cli/cf/commands/route" - "code.cloudfoundry.org/cli/cf/commands/routergroups" - "code.cloudfoundry.org/cli/cf/commands/securitygroup" - "code.cloudfoundry.org/cli/cf/commands/service" - "code.cloudfoundry.org/cli/cf/commands/serviceaccess" - "code.cloudfoundry.org/cli/cf/commands/serviceauthtoken" - "code.cloudfoundry.org/cli/cf/commands/servicebroker" - "code.cloudfoundry.org/cli/cf/commands/servicekey" - "code.cloudfoundry.org/cli/cf/commands/space" - "code.cloudfoundry.org/cli/cf/commands/spacequota" - "code.cloudfoundry.org/cli/cf/commands/user" + "code.cloudfoundry.org/cli/v8/cf/commands" + "code.cloudfoundry.org/cli/v8/cf/commands/application" + "code.cloudfoundry.org/cli/v8/cf/commands/buildpack" + "code.cloudfoundry.org/cli/v8/cf/commands/domain" + "code.cloudfoundry.org/cli/v8/cf/commands/environmentvariablegroup" + "code.cloudfoundry.org/cli/v8/cf/commands/featureflag" + "code.cloudfoundry.org/cli/v8/cf/commands/organization" + "code.cloudfoundry.org/cli/v8/cf/commands/plugin" + "code.cloudfoundry.org/cli/v8/cf/commands/pluginrepo" + "code.cloudfoundry.org/cli/v8/cf/commands/quota" + "code.cloudfoundry.org/cli/v8/cf/commands/route" + "code.cloudfoundry.org/cli/v8/cf/commands/routergroups" + "code.cloudfoundry.org/cli/v8/cf/commands/securitygroup" + "code.cloudfoundry.org/cli/v8/cf/commands/service" + "code.cloudfoundry.org/cli/v8/cf/commands/serviceaccess" + "code.cloudfoundry.org/cli/v8/cf/commands/serviceauthtoken" + "code.cloudfoundry.org/cli/v8/cf/commands/servicebroker" + "code.cloudfoundry.org/cli/v8/cf/commands/servicekey" + "code.cloudfoundry.org/cli/v8/cf/commands/space" + "code.cloudfoundry.org/cli/v8/cf/commands/spacequota" + "code.cloudfoundry.org/cli/v8/cf/commands/user" ) /******************* diff --git a/cf/commandsloader/commands_loader_suite_test.go b/cf/commandsloader/commands_loader_suite_test.go index 4850f44e7a0..4ef049b794a 100644 --- a/cf/commandsloader/commands_loader_suite_test.go +++ b/cf/commandsloader/commands_loader_suite_test.go @@ -1,7 +1,7 @@ package commandsloader_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/commandsloader/commands_loader_test.go b/cf/commandsloader/commands_loader_test.go index 08add8487d2..b543a0729a6 100644 --- a/cf/commandsloader/commands_loader_test.go +++ b/cf/commandsloader/commands_loader_test.go @@ -6,9 +6,9 @@ import ( "path/filepath" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/commandsloader" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/commandsloader" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/configuration/config_disk_persistor_test.go b/cf/configuration/config_disk_persistor_test.go index e1a8dd25b11..cfb392a4792 100644 --- a/cf/configuration/config_disk_persistor_test.go +++ b/cf/configuration/config_disk_persistor_test.go @@ -5,8 +5,8 @@ import ( "io/ioutil" "os" - . "code.cloudfoundry.org/cli/cf/configuration" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/configuration/config_disk_persistor_unix.go b/cf/configuration/config_disk_persistor_unix.go index b1d45200ba0..bdbfb3ddf08 100644 --- a/cf/configuration/config_disk_persistor_unix.go +++ b/cf/configuration/config_disk_persistor_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package configuration diff --git a/cf/configuration/config_disk_persistor_win.go b/cf/configuration/config_disk_persistor_win.go index 859d252a858..663a7689887 100644 --- a/cf/configuration/config_disk_persistor_win.go +++ b/cf/configuration/config_disk_persistor_win.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package configuration diff --git a/cf/configuration/configuration_suite_test.go b/cf/configuration/configuration_suite_test.go index c9832177aa4..19e49fb066e 100644 --- a/cf/configuration/configuration_suite_test.go +++ b/cf/configuration/configuration_suite_test.go @@ -1,7 +1,7 @@ package configuration_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/configuration/configurationfakes/fake_data_interface.go b/cf/configuration/configurationfakes/fake_data_interface.go index 3746d42ee7b..6b3646d1841 100644 --- a/cf/configuration/configurationfakes/fake_data_interface.go +++ b/cf/configuration/configurationfakes/fake_data_interface.go @@ -4,7 +4,7 @@ package configurationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration" ) type FakeDataInterface struct { @@ -40,15 +40,16 @@ func (fake *FakeDataInterface) JSONMarshalV3() ([]byte, error) { ret, specificReturn := fake.jSONMarshalV3ReturnsOnCall[len(fake.jSONMarshalV3ArgsForCall)] fake.jSONMarshalV3ArgsForCall = append(fake.jSONMarshalV3ArgsForCall, struct { }{}) + stub := fake.JSONMarshalV3Stub + fakeReturns := fake.jSONMarshalV3Returns fake.recordInvocation("JSONMarshalV3", []interface{}{}) fake.jSONMarshalV3Mutex.Unlock() - if fake.JSONMarshalV3Stub != nil { - return fake.JSONMarshalV3Stub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.jSONMarshalV3Returns return fakeReturns.result1, fakeReturns.result2 } @@ -101,15 +102,16 @@ func (fake *FakeDataInterface) JSONUnmarshalV3(arg1 []byte) error { fake.jSONUnmarshalV3ArgsForCall = append(fake.jSONUnmarshalV3ArgsForCall, struct { arg1 []byte }{arg1Copy}) + stub := fake.JSONUnmarshalV3Stub + fakeReturns := fake.jSONUnmarshalV3Returns fake.recordInvocation("JSONUnmarshalV3", []interface{}{arg1Copy}) fake.jSONUnmarshalV3Mutex.Unlock() - if fake.JSONUnmarshalV3Stub != nil { - return fake.JSONUnmarshalV3Stub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.jSONUnmarshalV3Returns return fakeReturns.result1 } diff --git a/cf/configuration/configurationfakes/fake_persistor.go b/cf/configuration/configurationfakes/fake_persistor.go index 3283bb555d5..8685197a54c 100644 --- a/cf/configuration/configurationfakes/fake_persistor.go +++ b/cf/configuration/configurationfakes/fake_persistor.go @@ -4,7 +4,7 @@ package configurationfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration" ) type FakePersistor struct { @@ -52,9 +52,10 @@ func (fake *FakePersistor) Delete() { fake.deleteMutex.Lock() fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { }{}) + stub := fake.DeleteStub fake.recordInvocation("Delete", []interface{}{}) fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { + if stub != nil { fake.DeleteStub() } } @@ -76,15 +77,16 @@ func (fake *FakePersistor) Exists() bool { ret, specificReturn := fake.existsReturnsOnCall[len(fake.existsArgsForCall)] fake.existsArgsForCall = append(fake.existsArgsForCall, struct { }{}) + stub := fake.ExistsStub + fakeReturns := fake.existsReturns fake.recordInvocation("Exists", []interface{}{}) fake.existsMutex.Unlock() - if fake.ExistsStub != nil { - return fake.ExistsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.existsReturns return fakeReturns.result1 } @@ -129,15 +131,16 @@ func (fake *FakePersistor) Load(arg1 configuration.DataInterface) error { fake.loadArgsForCall = append(fake.loadArgsForCall, struct { arg1 configuration.DataInterface }{arg1}) + stub := fake.LoadStub + fakeReturns := fake.loadReturns fake.recordInvocation("Load", []interface{}{arg1}) fake.loadMutex.Unlock() - if fake.LoadStub != nil { - return fake.LoadStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.loadReturns return fakeReturns.result1 } @@ -189,15 +192,16 @@ func (fake *FakePersistor) Save(arg1 configuration.DataInterface) error { fake.saveArgsForCall = append(fake.saveArgsForCall, struct { arg1 configuration.DataInterface }{arg1}) + stub := fake.SaveStub + fakeReturns := fake.saveReturns fake.recordInvocation("Save", []interface{}{arg1}) fake.saveMutex.Unlock() - if fake.SaveStub != nil { - return fake.SaveStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.saveReturns return fakeReturns.result1 } diff --git a/cf/configuration/coreconfig/access_token_test.go b/cf/configuration/coreconfig/access_token_test.go index fea832b1527..0e5277ef177 100644 --- a/cf/configuration/coreconfig/access_token_test.go +++ b/cf/configuration/coreconfig/access_token_test.go @@ -1,8 +1,8 @@ package coreconfig_test import ( - . "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/configuration/coreconfig/api_config_refresher.go b/cf/configuration/coreconfig/api_config_refresher.go index 3e933ce4775..79236697640 100644 --- a/cf/configuration/coreconfig/api_config_refresher.go +++ b/cf/configuration/coreconfig/api_config_refresher.go @@ -3,7 +3,7 @@ package coreconfig import ( "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . EndpointRepository diff --git a/cf/configuration/coreconfig/api_config_refresher_test.go b/cf/configuration/coreconfig/api_config_refresher_test.go index 74bf0c4be6a..59034b598c2 100644 --- a/cf/configuration/coreconfig/api_config_refresher_test.go +++ b/cf/configuration/coreconfig/api_config_refresher_test.go @@ -1,12 +1,12 @@ package coreconfig_test import ( - . "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + . "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig/coreconfigfakes" - "code.cloudfoundry.org/cli/cf/i18n" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig/coreconfigfakes" + "code.cloudfoundry.org/cli/v8/cf/i18n" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/configuration/coreconfig/config_data.go b/cf/configuration/coreconfig/config_data.go index a5314a124c4..3039b314dae 100644 --- a/cf/configuration/coreconfig/config_data.go +++ b/cf/configuration/coreconfig/config_data.go @@ -3,8 +3,8 @@ package coreconfig import ( "encoding/json" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type AuthPromptType string @@ -33,6 +33,7 @@ type Data struct { LogCacheEndPoint string MinCLIVersion string MinRecommendedCLIVersion string + NetworkPolicyV1Endpoint string OrganizationFields models.OrganizationFields PluginRepos []models.PluginRepo RefreshToken string diff --git a/cf/configuration/coreconfig/config_data_test.go b/cf/configuration/coreconfig/config_data_test.go index d1eeb3c3cb4..db56d8e12fe 100644 --- a/cf/configuration/coreconfig/config_data_test.go +++ b/cf/configuration/coreconfig/config_data_test.go @@ -1,10 +1,10 @@ package coreconfig_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -55,7 +55,8 @@ var _ = Describe("V3 Config files", func() { } ], "MinCLIVersion": "6.0.0", - "MinRecommendedCLIVersion": "6.9.0" + "MinRecommendedCLIVersion": "6.9.0", + "NetworkPolicyV1Endpoint": "the-network-policy-endpoint" }` // V2 by virtue of ConfigVersion only @@ -104,7 +105,8 @@ var _ = Describe("V3 Config files", func() { } ], "MinCLIVersion": "6.0.0", - "MinRecommendedCLIVersion": "6.9.0" + "MinRecommendedCLIVersion": "6.9.0", + "NetworkPolicyV1Endpoint": "the-network-policy-endpoint" }` Describe("NewData", func() { @@ -133,6 +135,7 @@ var _ = Describe("V3 Config files", func() { SSHOAuthClient: "ssh-oauth-client-id", MinCLIVersion: "6.0.0", MinRecommendedCLIVersion: "6.9.0", + NetworkPolicyV1Endpoint: "the-network-policy-endpoint", OrganizationFields: models.OrganizationFields{ GUID: "the-org-guid", Name: "the-org", @@ -185,6 +188,7 @@ var _ = Describe("V3 Config files", func() { SSHOAuthClient: "ssh-oauth-client-id", MinCLIVersion: "6.0.0", MinRecommendedCLIVersion: "6.9.0", + NetworkPolicyV1Endpoint: "the-network-policy-endpoint", OrganizationFields: models.OrganizationFields{ GUID: "the-org-guid", Name: "the-org", diff --git a/cf/configuration/coreconfig/config_repository.go b/cf/configuration/coreconfig/config_repository.go index d3a60069ad6..4e7a90e3d50 100644 --- a/cf/configuration/coreconfig/config_repository.go +++ b/cf/configuration/coreconfig/config_repository.go @@ -4,10 +4,10 @@ import ( "strings" "sync" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/version" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/version" + "github.com/blang/semver/v4" ) type ConfigRepository struct { @@ -40,7 +40,7 @@ func NewRepositoryFromFilepath(filepath string, errorHandler func(error)) Reposi func NewRepositoryFromPersistor(persistor configuration.Persistor, errorHandler func(error)) Repository { data := NewData() if !persistor.Exists() { - //set default plugin repo + // set default plugin repo data.PluginRepos = append(data.PluginRepos, models.PluginRepo{ Name: "CF-Community", URL: "https://plugins.cloudfoundry.org", diff --git a/cf/configuration/coreconfig/config_repository_test.go b/cf/configuration/coreconfig/config_repository_test.go index 230a0c90ded..ed6447787af 100644 --- a/cf/configuration/coreconfig/config_repository_test.go +++ b/cf/configuration/coreconfig/config_repository_test.go @@ -5,14 +5,14 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/configurationfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/version" - "github.com/blang/semver" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/configurationfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/version" + "github.com/blang/semver/v4" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/configuration/coreconfig/core_config_suite_test.go b/cf/configuration/coreconfig/core_config_suite_test.go index 238306a5195..9ae20fe8ef3 100644 --- a/cf/configuration/coreconfig/core_config_suite_test.go +++ b/cf/configuration/coreconfig/core_config_suite_test.go @@ -1,7 +1,7 @@ package coreconfig_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/configuration/coreconfig/coreconfigfakes/fake_endpoint_repository.go b/cf/configuration/coreconfig/coreconfigfakes/fake_endpoint_repository.go index aaf2b94c6f3..9875b6c3c83 100644 --- a/cf/configuration/coreconfig/coreconfigfakes/fake_endpoint_repository.go +++ b/cf/configuration/coreconfig/coreconfigfakes/fake_endpoint_repository.go @@ -4,7 +4,7 @@ package coreconfigfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" ) type FakeEndpointRepository struct { @@ -33,15 +33,16 @@ func (fake *FakeEndpointRepository) GetCCInfo(arg1 string) (*coreconfig.CCInfo, fake.getCCInfoArgsForCall = append(fake.getCCInfoArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetCCInfoStub + fakeReturns := fake.getCCInfoReturns fake.recordInvocation("GetCCInfo", []interface{}{arg1}) fake.getCCInfoMutex.Unlock() - if fake.GetCCInfoStub != nil { - return fake.GetCCInfoStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getCCInfoReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/cf/configuration/coreconfig/coreconfigfakes/fake_read_writer.go b/cf/configuration/coreconfig/coreconfigfakes/fake_read_writer.go index c1fffbea2ed..6e02f9ec129 100644 --- a/cf/configuration/coreconfig/coreconfigfakes/fake_read_writer.go +++ b/cf/configuration/coreconfig/coreconfigfakes/fake_read_writer.go @@ -4,9 +4,9 @@ package coreconfigfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + semver "github.com/blang/semver/v4" ) type FakeReadWriter struct { @@ -480,15 +480,16 @@ func (fake *FakeReadWriter) APIEndpoint() string { ret, specificReturn := fake.aPIEndpointReturnsOnCall[len(fake.aPIEndpointArgsForCall)] fake.aPIEndpointArgsForCall = append(fake.aPIEndpointArgsForCall, struct { }{}) + stub := fake.APIEndpointStub + fakeReturns := fake.aPIEndpointReturns fake.recordInvocation("APIEndpoint", []interface{}{}) fake.aPIEndpointMutex.Unlock() - if fake.APIEndpointStub != nil { - return fake.APIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIEndpointReturns return fakeReturns.result1 } @@ -532,15 +533,16 @@ func (fake *FakeReadWriter) APIVersion() string { ret, specificReturn := fake.aPIVersionReturnsOnCall[len(fake.aPIVersionArgsForCall)] fake.aPIVersionArgsForCall = append(fake.aPIVersionArgsForCall, struct { }{}) + stub := fake.APIVersionStub + fakeReturns := fake.aPIVersionReturns fake.recordInvocation("APIVersion", []interface{}{}) fake.aPIVersionMutex.Unlock() - if fake.APIVersionStub != nil { - return fake.APIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIVersionReturns return fakeReturns.result1 } @@ -584,15 +586,16 @@ func (fake *FakeReadWriter) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -636,15 +639,16 @@ func (fake *FakeReadWriter) AsyncTimeout() uint { ret, specificReturn := fake.asyncTimeoutReturnsOnCall[len(fake.asyncTimeoutArgsForCall)] fake.asyncTimeoutArgsForCall = append(fake.asyncTimeoutArgsForCall, struct { }{}) + stub := fake.AsyncTimeoutStub + fakeReturns := fake.asyncTimeoutReturns fake.recordInvocation("AsyncTimeout", []interface{}{}) fake.asyncTimeoutMutex.Unlock() - if fake.AsyncTimeoutStub != nil { - return fake.AsyncTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.asyncTimeoutReturns return fakeReturns.result1 } @@ -688,15 +692,16 @@ func (fake *FakeReadWriter) AuthenticationEndpoint() string { ret, specificReturn := fake.authenticationEndpointReturnsOnCall[len(fake.authenticationEndpointArgsForCall)] fake.authenticationEndpointArgsForCall = append(fake.authenticationEndpointArgsForCall, struct { }{}) + stub := fake.AuthenticationEndpointStub + fakeReturns := fake.authenticationEndpointReturns fake.recordInvocation("AuthenticationEndpoint", []interface{}{}) fake.authenticationEndpointMutex.Unlock() - if fake.AuthenticationEndpointStub != nil { - return fake.AuthenticationEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.authenticationEndpointReturns return fakeReturns.result1 } @@ -740,15 +745,16 @@ func (fake *FakeReadWriter) CLIVersion() string { ret, specificReturn := fake.cLIVersionReturnsOnCall[len(fake.cLIVersionArgsForCall)] fake.cLIVersionArgsForCall = append(fake.cLIVersionArgsForCall, struct { }{}) + stub := fake.CLIVersionStub + fakeReturns := fake.cLIVersionReturns fake.recordInvocation("CLIVersion", []interface{}{}) fake.cLIVersionMutex.Unlock() - if fake.CLIVersionStub != nil { - return fake.CLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.cLIVersionReturns return fakeReturns.result1 } @@ -791,9 +797,10 @@ func (fake *FakeReadWriter) ClearSession() { fake.clearSessionMutex.Lock() fake.clearSessionArgsForCall = append(fake.clearSessionArgsForCall, struct { }{}) + stub := fake.ClearSessionStub fake.recordInvocation("ClearSession", []interface{}{}) fake.clearSessionMutex.Unlock() - if fake.ClearSessionStub != nil { + if stub != nil { fake.ClearSessionStub() } } @@ -815,15 +822,16 @@ func (fake *FakeReadWriter) ColorEnabled() string { ret, specificReturn := fake.colorEnabledReturnsOnCall[len(fake.colorEnabledArgsForCall)] fake.colorEnabledArgsForCall = append(fake.colorEnabledArgsForCall, struct { }{}) + stub := fake.ColorEnabledStub + fakeReturns := fake.colorEnabledReturns fake.recordInvocation("ColorEnabled", []interface{}{}) fake.colorEnabledMutex.Unlock() - if fake.ColorEnabledStub != nil { - return fake.ColorEnabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.colorEnabledReturns return fakeReturns.result1 } @@ -867,15 +875,16 @@ func (fake *FakeReadWriter) DopplerEndpoint() string { ret, specificReturn := fake.dopplerEndpointReturnsOnCall[len(fake.dopplerEndpointArgsForCall)] fake.dopplerEndpointArgsForCall = append(fake.dopplerEndpointArgsForCall, struct { }{}) + stub := fake.DopplerEndpointStub + fakeReturns := fake.dopplerEndpointReturns fake.recordInvocation("DopplerEndpoint", []interface{}{}) fake.dopplerEndpointMutex.Unlock() - if fake.DopplerEndpointStub != nil { - return fake.DopplerEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dopplerEndpointReturns return fakeReturns.result1 } @@ -919,15 +928,16 @@ func (fake *FakeReadWriter) HasAPIEndpoint() bool { ret, specificReturn := fake.hasAPIEndpointReturnsOnCall[len(fake.hasAPIEndpointArgsForCall)] fake.hasAPIEndpointArgsForCall = append(fake.hasAPIEndpointArgsForCall, struct { }{}) + stub := fake.HasAPIEndpointStub + fakeReturns := fake.hasAPIEndpointReturns fake.recordInvocation("HasAPIEndpoint", []interface{}{}) fake.hasAPIEndpointMutex.Unlock() - if fake.HasAPIEndpointStub != nil { - return fake.HasAPIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasAPIEndpointReturns return fakeReturns.result1 } @@ -971,15 +981,16 @@ func (fake *FakeReadWriter) HasOrganization() bool { ret, specificReturn := fake.hasOrganizationReturnsOnCall[len(fake.hasOrganizationArgsForCall)] fake.hasOrganizationArgsForCall = append(fake.hasOrganizationArgsForCall, struct { }{}) + stub := fake.HasOrganizationStub + fakeReturns := fake.hasOrganizationReturns fake.recordInvocation("HasOrganization", []interface{}{}) fake.hasOrganizationMutex.Unlock() - if fake.HasOrganizationStub != nil { - return fake.HasOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasOrganizationReturns return fakeReturns.result1 } @@ -1023,15 +1034,16 @@ func (fake *FakeReadWriter) HasSpace() bool { ret, specificReturn := fake.hasSpaceReturnsOnCall[len(fake.hasSpaceArgsForCall)] fake.hasSpaceArgsForCall = append(fake.hasSpaceArgsForCall, struct { }{}) + stub := fake.HasSpaceStub + fakeReturns := fake.hasSpaceReturns fake.recordInvocation("HasSpace", []interface{}{}) fake.hasSpaceMutex.Unlock() - if fake.HasSpaceStub != nil { - return fake.HasSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasSpaceReturns return fakeReturns.result1 } @@ -1075,15 +1087,16 @@ func (fake *FakeReadWriter) IsLoggedIn() bool { ret, specificReturn := fake.isLoggedInReturnsOnCall[len(fake.isLoggedInArgsForCall)] fake.isLoggedInArgsForCall = append(fake.isLoggedInArgsForCall, struct { }{}) + stub := fake.IsLoggedInStub + fakeReturns := fake.isLoggedInReturns fake.recordInvocation("IsLoggedIn", []interface{}{}) fake.isLoggedInMutex.Unlock() - if fake.IsLoggedInStub != nil { - return fake.IsLoggedInStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isLoggedInReturns return fakeReturns.result1 } @@ -1128,15 +1141,16 @@ func (fake *FakeReadWriter) IsMinAPIVersion(arg1 semver.Version) bool { fake.isMinAPIVersionArgsForCall = append(fake.isMinAPIVersionArgsForCall, struct { arg1 semver.Version }{arg1}) + stub := fake.IsMinAPIVersionStub + fakeReturns := fake.isMinAPIVersionReturns fake.recordInvocation("IsMinAPIVersion", []interface{}{arg1}) fake.isMinAPIVersionMutex.Unlock() - if fake.IsMinAPIVersionStub != nil { - return fake.IsMinAPIVersionStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isMinAPIVersionReturns return fakeReturns.result1 } @@ -1188,15 +1202,16 @@ func (fake *FakeReadWriter) IsMinCLIVersion(arg1 string) bool { fake.isMinCLIVersionArgsForCall = append(fake.isMinCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.IsMinCLIVersionStub + fakeReturns := fake.isMinCLIVersionReturns fake.recordInvocation("IsMinCLIVersion", []interface{}{arg1}) fake.isMinCLIVersionMutex.Unlock() - if fake.IsMinCLIVersionStub != nil { - return fake.IsMinCLIVersionStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isMinCLIVersionReturns return fakeReturns.result1 } @@ -1247,15 +1262,16 @@ func (fake *FakeReadWriter) IsSSLDisabled() bool { ret, specificReturn := fake.isSSLDisabledReturnsOnCall[len(fake.isSSLDisabledArgsForCall)] fake.isSSLDisabledArgsForCall = append(fake.isSSLDisabledArgsForCall, struct { }{}) + stub := fake.IsSSLDisabledStub + fakeReturns := fake.isSSLDisabledReturns fake.recordInvocation("IsSSLDisabled", []interface{}{}) fake.isSSLDisabledMutex.Unlock() - if fake.IsSSLDisabledStub != nil { - return fake.IsSSLDisabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isSSLDisabledReturns return fakeReturns.result1 } @@ -1299,15 +1315,16 @@ func (fake *FakeReadWriter) Locale() string { ret, specificReturn := fake.localeReturnsOnCall[len(fake.localeArgsForCall)] fake.localeArgsForCall = append(fake.localeArgsForCall, struct { }{}) + stub := fake.LocaleStub + fakeReturns := fake.localeReturns fake.recordInvocation("Locale", []interface{}{}) fake.localeMutex.Unlock() - if fake.LocaleStub != nil { - return fake.LocaleStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.localeReturns return fakeReturns.result1 } @@ -1351,15 +1368,16 @@ func (fake *FakeReadWriter) LogCacheEndpoint() string { ret, specificReturn := fake.logCacheEndpointReturnsOnCall[len(fake.logCacheEndpointArgsForCall)] fake.logCacheEndpointArgsForCall = append(fake.logCacheEndpointArgsForCall, struct { }{}) + stub := fake.LogCacheEndpointStub + fakeReturns := fake.logCacheEndpointReturns fake.recordInvocation("LogCacheEndpoint", []interface{}{}) fake.logCacheEndpointMutex.Unlock() - if fake.LogCacheEndpointStub != nil { - return fake.LogCacheEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.logCacheEndpointReturns return fakeReturns.result1 } @@ -1403,15 +1421,16 @@ func (fake *FakeReadWriter) MinCLIVersion() string { ret, specificReturn := fake.minCLIVersionReturnsOnCall[len(fake.minCLIVersionArgsForCall)] fake.minCLIVersionArgsForCall = append(fake.minCLIVersionArgsForCall, struct { }{}) + stub := fake.MinCLIVersionStub + fakeReturns := fake.minCLIVersionReturns fake.recordInvocation("MinCLIVersion", []interface{}{}) fake.minCLIVersionMutex.Unlock() - if fake.MinCLIVersionStub != nil { - return fake.MinCLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.minCLIVersionReturns return fakeReturns.result1 } @@ -1455,15 +1474,16 @@ func (fake *FakeReadWriter) MinRecommendedCLIVersion() string { ret, specificReturn := fake.minRecommendedCLIVersionReturnsOnCall[len(fake.minRecommendedCLIVersionArgsForCall)] fake.minRecommendedCLIVersionArgsForCall = append(fake.minRecommendedCLIVersionArgsForCall, struct { }{}) + stub := fake.MinRecommendedCLIVersionStub + fakeReturns := fake.minRecommendedCLIVersionReturns fake.recordInvocation("MinRecommendedCLIVersion", []interface{}{}) fake.minRecommendedCLIVersionMutex.Unlock() - if fake.MinRecommendedCLIVersionStub != nil { - return fake.MinRecommendedCLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.minRecommendedCLIVersionReturns return fakeReturns.result1 } @@ -1507,15 +1527,16 @@ func (fake *FakeReadWriter) OrganizationFields() models.OrganizationFields { ret, specificReturn := fake.organizationFieldsReturnsOnCall[len(fake.organizationFieldsArgsForCall)] fake.organizationFieldsArgsForCall = append(fake.organizationFieldsArgsForCall, struct { }{}) + stub := fake.OrganizationFieldsStub + fakeReturns := fake.organizationFieldsReturns fake.recordInvocation("OrganizationFields", []interface{}{}) fake.organizationFieldsMutex.Unlock() - if fake.OrganizationFieldsStub != nil { - return fake.OrganizationFieldsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.organizationFieldsReturns return fakeReturns.result1 } @@ -1559,15 +1580,16 @@ func (fake *FakeReadWriter) PluginRepos() []models.PluginRepo { ret, specificReturn := fake.pluginReposReturnsOnCall[len(fake.pluginReposArgsForCall)] fake.pluginReposArgsForCall = append(fake.pluginReposArgsForCall, struct { }{}) + stub := fake.PluginReposStub + fakeReturns := fake.pluginReposReturns fake.recordInvocation("PluginRepos", []interface{}{}) fake.pluginReposMutex.Unlock() - if fake.PluginReposStub != nil { - return fake.PluginReposStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginReposReturns return fakeReturns.result1 } @@ -1611,15 +1633,16 @@ func (fake *FakeReadWriter) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -1663,15 +1686,16 @@ func (fake *FakeReadWriter) RoutingAPIEndpoint() string { ret, specificReturn := fake.routingAPIEndpointReturnsOnCall[len(fake.routingAPIEndpointArgsForCall)] fake.routingAPIEndpointArgsForCall = append(fake.routingAPIEndpointArgsForCall, struct { }{}) + stub := fake.RoutingAPIEndpointStub + fakeReturns := fake.routingAPIEndpointReturns fake.recordInvocation("RoutingAPIEndpoint", []interface{}{}) fake.routingAPIEndpointMutex.Unlock() - if fake.RoutingAPIEndpointStub != nil { - return fake.RoutingAPIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.routingAPIEndpointReturns return fakeReturns.result1 } @@ -1715,15 +1739,16 @@ func (fake *FakeReadWriter) SSHOAuthClient() string { ret, specificReturn := fake.sSHOAuthClientReturnsOnCall[len(fake.sSHOAuthClientArgsForCall)] fake.sSHOAuthClientArgsForCall = append(fake.sSHOAuthClientArgsForCall, struct { }{}) + stub := fake.SSHOAuthClientStub + fakeReturns := fake.sSHOAuthClientReturns fake.recordInvocation("SSHOAuthClient", []interface{}{}) fake.sSHOAuthClientMutex.Unlock() - if fake.SSHOAuthClientStub != nil { - return fake.SSHOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.sSHOAuthClientReturns return fakeReturns.result1 } @@ -1767,9 +1792,10 @@ func (fake *FakeReadWriter) SetAPIEndpoint(arg1 string) { fake.setAPIEndpointArgsForCall = append(fake.setAPIEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAPIEndpointStub fake.recordInvocation("SetAPIEndpoint", []interface{}{arg1}) fake.setAPIEndpointMutex.Unlock() - if fake.SetAPIEndpointStub != nil { + if stub != nil { fake.SetAPIEndpointStub(arg1) } } @@ -1798,9 +1824,10 @@ func (fake *FakeReadWriter) SetAPIVersion(arg1 string) { fake.setAPIVersionArgsForCall = append(fake.setAPIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAPIVersionStub fake.recordInvocation("SetAPIVersion", []interface{}{arg1}) fake.setAPIVersionMutex.Unlock() - if fake.SetAPIVersionStub != nil { + if stub != nil { fake.SetAPIVersionStub(arg1) } } @@ -1829,9 +1856,10 @@ func (fake *FakeReadWriter) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -1860,9 +1888,10 @@ func (fake *FakeReadWriter) SetAsyncTimeout(arg1 uint) { fake.setAsyncTimeoutArgsForCall = append(fake.setAsyncTimeoutArgsForCall, struct { arg1 uint }{arg1}) + stub := fake.SetAsyncTimeoutStub fake.recordInvocation("SetAsyncTimeout", []interface{}{arg1}) fake.setAsyncTimeoutMutex.Unlock() - if fake.SetAsyncTimeoutStub != nil { + if stub != nil { fake.SetAsyncTimeoutStub(arg1) } } @@ -1891,9 +1920,10 @@ func (fake *FakeReadWriter) SetAuthenticationEndpoint(arg1 string) { fake.setAuthenticationEndpointArgsForCall = append(fake.setAuthenticationEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAuthenticationEndpointStub fake.recordInvocation("SetAuthenticationEndpoint", []interface{}{arg1}) fake.setAuthenticationEndpointMutex.Unlock() - if fake.SetAuthenticationEndpointStub != nil { + if stub != nil { fake.SetAuthenticationEndpointStub(arg1) } } @@ -1922,9 +1952,10 @@ func (fake *FakeReadWriter) SetCLIVersion(arg1 string) { fake.setCLIVersionArgsForCall = append(fake.setCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetCLIVersionStub fake.recordInvocation("SetCLIVersion", []interface{}{arg1}) fake.setCLIVersionMutex.Unlock() - if fake.SetCLIVersionStub != nil { + if stub != nil { fake.SetCLIVersionStub(arg1) } } @@ -1953,9 +1984,10 @@ func (fake *FakeReadWriter) SetColorEnabled(arg1 string) { fake.setColorEnabledArgsForCall = append(fake.setColorEnabledArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetColorEnabledStub fake.recordInvocation("SetColorEnabled", []interface{}{arg1}) fake.setColorEnabledMutex.Unlock() - if fake.SetColorEnabledStub != nil { + if stub != nil { fake.SetColorEnabledStub(arg1) } } @@ -1984,9 +2016,10 @@ func (fake *FakeReadWriter) SetDopplerEndpoint(arg1 string) { fake.setDopplerEndpointArgsForCall = append(fake.setDopplerEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetDopplerEndpointStub fake.recordInvocation("SetDopplerEndpoint", []interface{}{arg1}) fake.setDopplerEndpointMutex.Unlock() - if fake.SetDopplerEndpointStub != nil { + if stub != nil { fake.SetDopplerEndpointStub(arg1) } } @@ -2015,9 +2048,10 @@ func (fake *FakeReadWriter) SetLocale(arg1 string) { fake.setLocaleArgsForCall = append(fake.setLocaleArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetLocaleStub fake.recordInvocation("SetLocale", []interface{}{arg1}) fake.setLocaleMutex.Unlock() - if fake.SetLocaleStub != nil { + if stub != nil { fake.SetLocaleStub(arg1) } } @@ -2046,9 +2080,10 @@ func (fake *FakeReadWriter) SetLogCacheEndpoint(arg1 string) { fake.setLogCacheEndpointArgsForCall = append(fake.setLogCacheEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetLogCacheEndpointStub fake.recordInvocation("SetLogCacheEndpoint", []interface{}{arg1}) fake.setLogCacheEndpointMutex.Unlock() - if fake.SetLogCacheEndpointStub != nil { + if stub != nil { fake.SetLogCacheEndpointStub(arg1) } } @@ -2077,9 +2112,10 @@ func (fake *FakeReadWriter) SetMinCLIVersion(arg1 string) { fake.setMinCLIVersionArgsForCall = append(fake.setMinCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetMinCLIVersionStub fake.recordInvocation("SetMinCLIVersion", []interface{}{arg1}) fake.setMinCLIVersionMutex.Unlock() - if fake.SetMinCLIVersionStub != nil { + if stub != nil { fake.SetMinCLIVersionStub(arg1) } } @@ -2108,9 +2144,10 @@ func (fake *FakeReadWriter) SetMinRecommendedCLIVersion(arg1 string) { fake.setMinRecommendedCLIVersionArgsForCall = append(fake.setMinRecommendedCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetMinRecommendedCLIVersionStub fake.recordInvocation("SetMinRecommendedCLIVersion", []interface{}{arg1}) fake.setMinRecommendedCLIVersionMutex.Unlock() - if fake.SetMinRecommendedCLIVersionStub != nil { + if stub != nil { fake.SetMinRecommendedCLIVersionStub(arg1) } } @@ -2139,9 +2176,10 @@ func (fake *FakeReadWriter) SetOrganizationFields(arg1 models.OrganizationFields fake.setOrganizationFieldsArgsForCall = append(fake.setOrganizationFieldsArgsForCall, struct { arg1 models.OrganizationFields }{arg1}) + stub := fake.SetOrganizationFieldsStub fake.recordInvocation("SetOrganizationFields", []interface{}{arg1}) fake.setOrganizationFieldsMutex.Unlock() - if fake.SetOrganizationFieldsStub != nil { + if stub != nil { fake.SetOrganizationFieldsStub(arg1) } } @@ -2170,9 +2208,10 @@ func (fake *FakeReadWriter) SetPluginRepo(arg1 models.PluginRepo) { fake.setPluginRepoArgsForCall = append(fake.setPluginRepoArgsForCall, struct { arg1 models.PluginRepo }{arg1}) + stub := fake.SetPluginRepoStub fake.recordInvocation("SetPluginRepo", []interface{}{arg1}) fake.setPluginRepoMutex.Unlock() - if fake.SetPluginRepoStub != nil { + if stub != nil { fake.SetPluginRepoStub(arg1) } } @@ -2201,9 +2240,10 @@ func (fake *FakeReadWriter) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } @@ -2232,9 +2272,10 @@ func (fake *FakeReadWriter) SetRoutingAPIEndpoint(arg1 string) { fake.setRoutingAPIEndpointArgsForCall = append(fake.setRoutingAPIEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRoutingAPIEndpointStub fake.recordInvocation("SetRoutingAPIEndpoint", []interface{}{arg1}) fake.setRoutingAPIEndpointMutex.Unlock() - if fake.SetRoutingAPIEndpointStub != nil { + if stub != nil { fake.SetRoutingAPIEndpointStub(arg1) } } @@ -2263,9 +2304,10 @@ func (fake *FakeReadWriter) SetSSHOAuthClient(arg1 string) { fake.setSSHOAuthClientArgsForCall = append(fake.setSSHOAuthClientArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetSSHOAuthClientStub fake.recordInvocation("SetSSHOAuthClient", []interface{}{arg1}) fake.setSSHOAuthClientMutex.Unlock() - if fake.SetSSHOAuthClientStub != nil { + if stub != nil { fake.SetSSHOAuthClientStub(arg1) } } @@ -2294,9 +2336,10 @@ func (fake *FakeReadWriter) SetSSLDisabled(arg1 bool) { fake.setSSLDisabledArgsForCall = append(fake.setSSLDisabledArgsForCall, struct { arg1 bool }{arg1}) + stub := fake.SetSSLDisabledStub fake.recordInvocation("SetSSLDisabled", []interface{}{arg1}) fake.setSSLDisabledMutex.Unlock() - if fake.SetSSLDisabledStub != nil { + if stub != nil { fake.SetSSLDisabledStub(arg1) } } @@ -2325,9 +2368,10 @@ func (fake *FakeReadWriter) SetSpaceFields(arg1 models.SpaceFields) { fake.setSpaceFieldsArgsForCall = append(fake.setSpaceFieldsArgsForCall, struct { arg1 models.SpaceFields }{arg1}) + stub := fake.SetSpaceFieldsStub fake.recordInvocation("SetSpaceFields", []interface{}{arg1}) fake.setSpaceFieldsMutex.Unlock() - if fake.SetSpaceFieldsStub != nil { + if stub != nil { fake.SetSpaceFieldsStub(arg1) } } @@ -2356,9 +2400,10 @@ func (fake *FakeReadWriter) SetTrace(arg1 string) { fake.setTraceArgsForCall = append(fake.setTraceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetTraceStub fake.recordInvocation("SetTrace", []interface{}{arg1}) fake.setTraceMutex.Unlock() - if fake.SetTraceStub != nil { + if stub != nil { fake.SetTraceStub(arg1) } } @@ -2387,9 +2432,10 @@ func (fake *FakeReadWriter) SetUAAGrantType(arg1 string) { fake.setUAAGrantTypeArgsForCall = append(fake.setUAAGrantTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAGrantTypeStub fake.recordInvocation("SetUAAGrantType", []interface{}{arg1}) fake.setUAAGrantTypeMutex.Unlock() - if fake.SetUAAGrantTypeStub != nil { + if stub != nil { fake.SetUAAGrantTypeStub(arg1) } } @@ -2418,9 +2464,10 @@ func (fake *FakeReadWriter) SetUAAOAuthClient(arg1 string) { fake.setUAAOAuthClientArgsForCall = append(fake.setUAAOAuthClientArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAOAuthClientStub fake.recordInvocation("SetUAAOAuthClient", []interface{}{arg1}) fake.setUAAOAuthClientMutex.Unlock() - if fake.SetUAAOAuthClientStub != nil { + if stub != nil { fake.SetUAAOAuthClientStub(arg1) } } @@ -2449,9 +2496,10 @@ func (fake *FakeReadWriter) SetUAAOAuthClientSecret(arg1 string) { fake.setUAAOAuthClientSecretArgsForCall = append(fake.setUAAOAuthClientSecretArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAOAuthClientSecretStub fake.recordInvocation("SetUAAOAuthClientSecret", []interface{}{arg1}) fake.setUAAOAuthClientSecretMutex.Unlock() - if fake.SetUAAOAuthClientSecretStub != nil { + if stub != nil { fake.SetUAAOAuthClientSecretStub(arg1) } } @@ -2480,9 +2528,10 @@ func (fake *FakeReadWriter) SetUaaEndpoint(arg1 string) { fake.setUaaEndpointArgsForCall = append(fake.setUaaEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUaaEndpointStub fake.recordInvocation("SetUaaEndpoint", []interface{}{arg1}) fake.setUaaEndpointMutex.Unlock() - if fake.SetUaaEndpointStub != nil { + if stub != nil { fake.SetUaaEndpointStub(arg1) } } @@ -2511,15 +2560,16 @@ func (fake *FakeReadWriter) SpaceFields() models.SpaceFields { ret, specificReturn := fake.spaceFieldsReturnsOnCall[len(fake.spaceFieldsArgsForCall)] fake.spaceFieldsArgsForCall = append(fake.spaceFieldsArgsForCall, struct { }{}) + stub := fake.SpaceFieldsStub + fakeReturns := fake.spaceFieldsReturns fake.recordInvocation("SpaceFields", []interface{}{}) fake.spaceFieldsMutex.Unlock() - if fake.SpaceFieldsStub != nil { - return fake.SpaceFieldsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.spaceFieldsReturns return fakeReturns.result1 } @@ -2563,15 +2613,16 @@ func (fake *FakeReadWriter) Trace() string { ret, specificReturn := fake.traceReturnsOnCall[len(fake.traceArgsForCall)] fake.traceArgsForCall = append(fake.traceArgsForCall, struct { }{}) + stub := fake.TraceStub + fakeReturns := fake.traceReturns fake.recordInvocation("Trace", []interface{}{}) fake.traceMutex.Unlock() - if fake.TraceStub != nil { - return fake.TraceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.traceReturns return fakeReturns.result1 } @@ -2615,15 +2666,16 @@ func (fake *FakeReadWriter) UAAGrantType() string { ret, specificReturn := fake.uAAGrantTypeReturnsOnCall[len(fake.uAAGrantTypeArgsForCall)] fake.uAAGrantTypeArgsForCall = append(fake.uAAGrantTypeArgsForCall, struct { }{}) + stub := fake.UAAGrantTypeStub + fakeReturns := fake.uAAGrantTypeReturns fake.recordInvocation("UAAGrantType", []interface{}{}) fake.uAAGrantTypeMutex.Unlock() - if fake.UAAGrantTypeStub != nil { - return fake.UAAGrantTypeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAGrantTypeReturns return fakeReturns.result1 } @@ -2667,15 +2719,16 @@ func (fake *FakeReadWriter) UAAOAuthClient() string { ret, specificReturn := fake.uAAOAuthClientReturnsOnCall[len(fake.uAAOAuthClientArgsForCall)] fake.uAAOAuthClientArgsForCall = append(fake.uAAOAuthClientArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientStub + fakeReturns := fake.uAAOAuthClientReturns fake.recordInvocation("UAAOAuthClient", []interface{}{}) fake.uAAOAuthClientMutex.Unlock() - if fake.UAAOAuthClientStub != nil { - return fake.UAAOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientReturns return fakeReturns.result1 } @@ -2719,15 +2772,16 @@ func (fake *FakeReadWriter) UAAOAuthClientSecret() string { ret, specificReturn := fake.uAAOAuthClientSecretReturnsOnCall[len(fake.uAAOAuthClientSecretArgsForCall)] fake.uAAOAuthClientSecretArgsForCall = append(fake.uAAOAuthClientSecretArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientSecretStub + fakeReturns := fake.uAAOAuthClientSecretReturns fake.recordInvocation("UAAOAuthClientSecret", []interface{}{}) fake.uAAOAuthClientSecretMutex.Unlock() - if fake.UAAOAuthClientSecretStub != nil { - return fake.UAAOAuthClientSecretStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientSecretReturns return fakeReturns.result1 } @@ -2771,15 +2825,16 @@ func (fake *FakeReadWriter) UaaEndpoint() string { ret, specificReturn := fake.uaaEndpointReturnsOnCall[len(fake.uaaEndpointArgsForCall)] fake.uaaEndpointArgsForCall = append(fake.uaaEndpointArgsForCall, struct { }{}) + stub := fake.UaaEndpointStub + fakeReturns := fake.uaaEndpointReturns fake.recordInvocation("UaaEndpoint", []interface{}{}) fake.uaaEndpointMutex.Unlock() - if fake.UaaEndpointStub != nil { - return fake.UaaEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uaaEndpointReturns return fakeReturns.result1 } @@ -2823,9 +2878,10 @@ func (fake *FakeReadWriter) UnSetPluginRepo(arg1 int) { fake.unSetPluginRepoArgsForCall = append(fake.unSetPluginRepoArgsForCall, struct { arg1 int }{arg1}) + stub := fake.UnSetPluginRepoStub fake.recordInvocation("UnSetPluginRepo", []interface{}{arg1}) fake.unSetPluginRepoMutex.Unlock() - if fake.UnSetPluginRepoStub != nil { + if stub != nil { fake.UnSetPluginRepoStub(arg1) } } @@ -2854,15 +2910,16 @@ func (fake *FakeReadWriter) UserEmail() string { ret, specificReturn := fake.userEmailReturnsOnCall[len(fake.userEmailArgsForCall)] fake.userEmailArgsForCall = append(fake.userEmailArgsForCall, struct { }{}) + stub := fake.UserEmailStub + fakeReturns := fake.userEmailReturns fake.recordInvocation("UserEmail", []interface{}{}) fake.userEmailMutex.Unlock() - if fake.UserEmailStub != nil { - return fake.UserEmailStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.userEmailReturns return fakeReturns.result1 } @@ -2906,15 +2963,16 @@ func (fake *FakeReadWriter) UserGUID() string { ret, specificReturn := fake.userGUIDReturnsOnCall[len(fake.userGUIDArgsForCall)] fake.userGUIDArgsForCall = append(fake.userGUIDArgsForCall, struct { }{}) + stub := fake.UserGUIDStub + fakeReturns := fake.userGUIDReturns fake.recordInvocation("UserGUID", []interface{}{}) fake.userGUIDMutex.Unlock() - if fake.UserGUIDStub != nil { - return fake.UserGUIDStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.userGUIDReturns return fakeReturns.result1 } @@ -2958,15 +3016,16 @@ func (fake *FakeReadWriter) Username() string { ret, specificReturn := fake.usernameReturnsOnCall[len(fake.usernameArgsForCall)] fake.usernameArgsForCall = append(fake.usernameArgsForCall, struct { }{}) + stub := fake.UsernameStub + fakeReturns := fake.usernameReturns fake.recordInvocation("Username", []interface{}{}) fake.usernameMutex.Unlock() - if fake.UsernameStub != nil { - return fake.UsernameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.usernameReturns return fakeReturns.result1 } diff --git a/cf/configuration/coreconfig/coreconfigfakes/fake_repository.go b/cf/configuration/coreconfig/coreconfigfakes/fake_repository.go index e12917d2b46..a14839bd576 100644 --- a/cf/configuration/coreconfig/coreconfigfakes/fake_repository.go +++ b/cf/configuration/coreconfig/coreconfigfakes/fake_repository.go @@ -4,9 +4,9 @@ package coreconfigfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + semver "github.com/blang/semver/v4" ) type FakeRepository struct { @@ -484,15 +484,16 @@ func (fake *FakeRepository) APIEndpoint() string { ret, specificReturn := fake.aPIEndpointReturnsOnCall[len(fake.aPIEndpointArgsForCall)] fake.aPIEndpointArgsForCall = append(fake.aPIEndpointArgsForCall, struct { }{}) + stub := fake.APIEndpointStub + fakeReturns := fake.aPIEndpointReturns fake.recordInvocation("APIEndpoint", []interface{}{}) fake.aPIEndpointMutex.Unlock() - if fake.APIEndpointStub != nil { - return fake.APIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIEndpointReturns return fakeReturns.result1 } @@ -536,15 +537,16 @@ func (fake *FakeRepository) APIVersion() string { ret, specificReturn := fake.aPIVersionReturnsOnCall[len(fake.aPIVersionArgsForCall)] fake.aPIVersionArgsForCall = append(fake.aPIVersionArgsForCall, struct { }{}) + stub := fake.APIVersionStub + fakeReturns := fake.aPIVersionReturns fake.recordInvocation("APIVersion", []interface{}{}) fake.aPIVersionMutex.Unlock() - if fake.APIVersionStub != nil { - return fake.APIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIVersionReturns return fakeReturns.result1 } @@ -588,15 +590,16 @@ func (fake *FakeRepository) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -640,15 +643,16 @@ func (fake *FakeRepository) AsyncTimeout() uint { ret, specificReturn := fake.asyncTimeoutReturnsOnCall[len(fake.asyncTimeoutArgsForCall)] fake.asyncTimeoutArgsForCall = append(fake.asyncTimeoutArgsForCall, struct { }{}) + stub := fake.AsyncTimeoutStub + fakeReturns := fake.asyncTimeoutReturns fake.recordInvocation("AsyncTimeout", []interface{}{}) fake.asyncTimeoutMutex.Unlock() - if fake.AsyncTimeoutStub != nil { - return fake.AsyncTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.asyncTimeoutReturns return fakeReturns.result1 } @@ -692,15 +696,16 @@ func (fake *FakeRepository) AuthenticationEndpoint() string { ret, specificReturn := fake.authenticationEndpointReturnsOnCall[len(fake.authenticationEndpointArgsForCall)] fake.authenticationEndpointArgsForCall = append(fake.authenticationEndpointArgsForCall, struct { }{}) + stub := fake.AuthenticationEndpointStub + fakeReturns := fake.authenticationEndpointReturns fake.recordInvocation("AuthenticationEndpoint", []interface{}{}) fake.authenticationEndpointMutex.Unlock() - if fake.AuthenticationEndpointStub != nil { - return fake.AuthenticationEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.authenticationEndpointReturns return fakeReturns.result1 } @@ -744,15 +749,16 @@ func (fake *FakeRepository) CLIVersion() string { ret, specificReturn := fake.cLIVersionReturnsOnCall[len(fake.cLIVersionArgsForCall)] fake.cLIVersionArgsForCall = append(fake.cLIVersionArgsForCall, struct { }{}) + stub := fake.CLIVersionStub + fakeReturns := fake.cLIVersionReturns fake.recordInvocation("CLIVersion", []interface{}{}) fake.cLIVersionMutex.Unlock() - if fake.CLIVersionStub != nil { - return fake.CLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.cLIVersionReturns return fakeReturns.result1 } @@ -795,9 +801,10 @@ func (fake *FakeRepository) ClearSession() { fake.clearSessionMutex.Lock() fake.clearSessionArgsForCall = append(fake.clearSessionArgsForCall, struct { }{}) + stub := fake.ClearSessionStub fake.recordInvocation("ClearSession", []interface{}{}) fake.clearSessionMutex.Unlock() - if fake.ClearSessionStub != nil { + if stub != nil { fake.ClearSessionStub() } } @@ -818,9 +825,10 @@ func (fake *FakeRepository) Close() { fake.closeMutex.Lock() fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { + if stub != nil { fake.CloseStub() } } @@ -842,15 +850,16 @@ func (fake *FakeRepository) ColorEnabled() string { ret, specificReturn := fake.colorEnabledReturnsOnCall[len(fake.colorEnabledArgsForCall)] fake.colorEnabledArgsForCall = append(fake.colorEnabledArgsForCall, struct { }{}) + stub := fake.ColorEnabledStub + fakeReturns := fake.colorEnabledReturns fake.recordInvocation("ColorEnabled", []interface{}{}) fake.colorEnabledMutex.Unlock() - if fake.ColorEnabledStub != nil { - return fake.ColorEnabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.colorEnabledReturns return fakeReturns.result1 } @@ -894,15 +903,16 @@ func (fake *FakeRepository) DopplerEndpoint() string { ret, specificReturn := fake.dopplerEndpointReturnsOnCall[len(fake.dopplerEndpointArgsForCall)] fake.dopplerEndpointArgsForCall = append(fake.dopplerEndpointArgsForCall, struct { }{}) + stub := fake.DopplerEndpointStub + fakeReturns := fake.dopplerEndpointReturns fake.recordInvocation("DopplerEndpoint", []interface{}{}) fake.dopplerEndpointMutex.Unlock() - if fake.DopplerEndpointStub != nil { - return fake.DopplerEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dopplerEndpointReturns return fakeReturns.result1 } @@ -946,15 +956,16 @@ func (fake *FakeRepository) HasAPIEndpoint() bool { ret, specificReturn := fake.hasAPIEndpointReturnsOnCall[len(fake.hasAPIEndpointArgsForCall)] fake.hasAPIEndpointArgsForCall = append(fake.hasAPIEndpointArgsForCall, struct { }{}) + stub := fake.HasAPIEndpointStub + fakeReturns := fake.hasAPIEndpointReturns fake.recordInvocation("HasAPIEndpoint", []interface{}{}) fake.hasAPIEndpointMutex.Unlock() - if fake.HasAPIEndpointStub != nil { - return fake.HasAPIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasAPIEndpointReturns return fakeReturns.result1 } @@ -998,15 +1009,16 @@ func (fake *FakeRepository) HasOrganization() bool { ret, specificReturn := fake.hasOrganizationReturnsOnCall[len(fake.hasOrganizationArgsForCall)] fake.hasOrganizationArgsForCall = append(fake.hasOrganizationArgsForCall, struct { }{}) + stub := fake.HasOrganizationStub + fakeReturns := fake.hasOrganizationReturns fake.recordInvocation("HasOrganization", []interface{}{}) fake.hasOrganizationMutex.Unlock() - if fake.HasOrganizationStub != nil { - return fake.HasOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasOrganizationReturns return fakeReturns.result1 } @@ -1050,15 +1062,16 @@ func (fake *FakeRepository) HasSpace() bool { ret, specificReturn := fake.hasSpaceReturnsOnCall[len(fake.hasSpaceArgsForCall)] fake.hasSpaceArgsForCall = append(fake.hasSpaceArgsForCall, struct { }{}) + stub := fake.HasSpaceStub + fakeReturns := fake.hasSpaceReturns fake.recordInvocation("HasSpace", []interface{}{}) fake.hasSpaceMutex.Unlock() - if fake.HasSpaceStub != nil { - return fake.HasSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasSpaceReturns return fakeReturns.result1 } @@ -1102,15 +1115,16 @@ func (fake *FakeRepository) IsLoggedIn() bool { ret, specificReturn := fake.isLoggedInReturnsOnCall[len(fake.isLoggedInArgsForCall)] fake.isLoggedInArgsForCall = append(fake.isLoggedInArgsForCall, struct { }{}) + stub := fake.IsLoggedInStub + fakeReturns := fake.isLoggedInReturns fake.recordInvocation("IsLoggedIn", []interface{}{}) fake.isLoggedInMutex.Unlock() - if fake.IsLoggedInStub != nil { - return fake.IsLoggedInStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isLoggedInReturns return fakeReturns.result1 } @@ -1155,15 +1169,16 @@ func (fake *FakeRepository) IsMinAPIVersion(arg1 semver.Version) bool { fake.isMinAPIVersionArgsForCall = append(fake.isMinAPIVersionArgsForCall, struct { arg1 semver.Version }{arg1}) + stub := fake.IsMinAPIVersionStub + fakeReturns := fake.isMinAPIVersionReturns fake.recordInvocation("IsMinAPIVersion", []interface{}{arg1}) fake.isMinAPIVersionMutex.Unlock() - if fake.IsMinAPIVersionStub != nil { - return fake.IsMinAPIVersionStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isMinAPIVersionReturns return fakeReturns.result1 } @@ -1215,15 +1230,16 @@ func (fake *FakeRepository) IsMinCLIVersion(arg1 string) bool { fake.isMinCLIVersionArgsForCall = append(fake.isMinCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.IsMinCLIVersionStub + fakeReturns := fake.isMinCLIVersionReturns fake.recordInvocation("IsMinCLIVersion", []interface{}{arg1}) fake.isMinCLIVersionMutex.Unlock() - if fake.IsMinCLIVersionStub != nil { - return fake.IsMinCLIVersionStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isMinCLIVersionReturns return fakeReturns.result1 } @@ -1274,15 +1290,16 @@ func (fake *FakeRepository) IsSSLDisabled() bool { ret, specificReturn := fake.isSSLDisabledReturnsOnCall[len(fake.isSSLDisabledArgsForCall)] fake.isSSLDisabledArgsForCall = append(fake.isSSLDisabledArgsForCall, struct { }{}) + stub := fake.IsSSLDisabledStub + fakeReturns := fake.isSSLDisabledReturns fake.recordInvocation("IsSSLDisabled", []interface{}{}) fake.isSSLDisabledMutex.Unlock() - if fake.IsSSLDisabledStub != nil { - return fake.IsSSLDisabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isSSLDisabledReturns return fakeReturns.result1 } @@ -1326,15 +1343,16 @@ func (fake *FakeRepository) Locale() string { ret, specificReturn := fake.localeReturnsOnCall[len(fake.localeArgsForCall)] fake.localeArgsForCall = append(fake.localeArgsForCall, struct { }{}) + stub := fake.LocaleStub + fakeReturns := fake.localeReturns fake.recordInvocation("Locale", []interface{}{}) fake.localeMutex.Unlock() - if fake.LocaleStub != nil { - return fake.LocaleStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.localeReturns return fakeReturns.result1 } @@ -1378,15 +1396,16 @@ func (fake *FakeRepository) LogCacheEndpoint() string { ret, specificReturn := fake.logCacheEndpointReturnsOnCall[len(fake.logCacheEndpointArgsForCall)] fake.logCacheEndpointArgsForCall = append(fake.logCacheEndpointArgsForCall, struct { }{}) + stub := fake.LogCacheEndpointStub + fakeReturns := fake.logCacheEndpointReturns fake.recordInvocation("LogCacheEndpoint", []interface{}{}) fake.logCacheEndpointMutex.Unlock() - if fake.LogCacheEndpointStub != nil { - return fake.LogCacheEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.logCacheEndpointReturns return fakeReturns.result1 } @@ -1430,15 +1449,16 @@ func (fake *FakeRepository) MinCLIVersion() string { ret, specificReturn := fake.minCLIVersionReturnsOnCall[len(fake.minCLIVersionArgsForCall)] fake.minCLIVersionArgsForCall = append(fake.minCLIVersionArgsForCall, struct { }{}) + stub := fake.MinCLIVersionStub + fakeReturns := fake.minCLIVersionReturns fake.recordInvocation("MinCLIVersion", []interface{}{}) fake.minCLIVersionMutex.Unlock() - if fake.MinCLIVersionStub != nil { - return fake.MinCLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.minCLIVersionReturns return fakeReturns.result1 } @@ -1482,15 +1502,16 @@ func (fake *FakeRepository) MinRecommendedCLIVersion() string { ret, specificReturn := fake.minRecommendedCLIVersionReturnsOnCall[len(fake.minRecommendedCLIVersionArgsForCall)] fake.minRecommendedCLIVersionArgsForCall = append(fake.minRecommendedCLIVersionArgsForCall, struct { }{}) + stub := fake.MinRecommendedCLIVersionStub + fakeReturns := fake.minRecommendedCLIVersionReturns fake.recordInvocation("MinRecommendedCLIVersion", []interface{}{}) fake.minRecommendedCLIVersionMutex.Unlock() - if fake.MinRecommendedCLIVersionStub != nil { - return fake.MinRecommendedCLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.minRecommendedCLIVersionReturns return fakeReturns.result1 } @@ -1534,15 +1555,16 @@ func (fake *FakeRepository) OrganizationFields() models.OrganizationFields { ret, specificReturn := fake.organizationFieldsReturnsOnCall[len(fake.organizationFieldsArgsForCall)] fake.organizationFieldsArgsForCall = append(fake.organizationFieldsArgsForCall, struct { }{}) + stub := fake.OrganizationFieldsStub + fakeReturns := fake.organizationFieldsReturns fake.recordInvocation("OrganizationFields", []interface{}{}) fake.organizationFieldsMutex.Unlock() - if fake.OrganizationFieldsStub != nil { - return fake.OrganizationFieldsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.organizationFieldsReturns return fakeReturns.result1 } @@ -1586,15 +1608,16 @@ func (fake *FakeRepository) PluginRepos() []models.PluginRepo { ret, specificReturn := fake.pluginReposReturnsOnCall[len(fake.pluginReposArgsForCall)] fake.pluginReposArgsForCall = append(fake.pluginReposArgsForCall, struct { }{}) + stub := fake.PluginReposStub + fakeReturns := fake.pluginReposReturns fake.recordInvocation("PluginRepos", []interface{}{}) fake.pluginReposMutex.Unlock() - if fake.PluginReposStub != nil { - return fake.PluginReposStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginReposReturns return fakeReturns.result1 } @@ -1638,15 +1661,16 @@ func (fake *FakeRepository) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -1690,15 +1714,16 @@ func (fake *FakeRepository) RoutingAPIEndpoint() string { ret, specificReturn := fake.routingAPIEndpointReturnsOnCall[len(fake.routingAPIEndpointArgsForCall)] fake.routingAPIEndpointArgsForCall = append(fake.routingAPIEndpointArgsForCall, struct { }{}) + stub := fake.RoutingAPIEndpointStub + fakeReturns := fake.routingAPIEndpointReturns fake.recordInvocation("RoutingAPIEndpoint", []interface{}{}) fake.routingAPIEndpointMutex.Unlock() - if fake.RoutingAPIEndpointStub != nil { - return fake.RoutingAPIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.routingAPIEndpointReturns return fakeReturns.result1 } @@ -1742,15 +1767,16 @@ func (fake *FakeRepository) SSHOAuthClient() string { ret, specificReturn := fake.sSHOAuthClientReturnsOnCall[len(fake.sSHOAuthClientArgsForCall)] fake.sSHOAuthClientArgsForCall = append(fake.sSHOAuthClientArgsForCall, struct { }{}) + stub := fake.SSHOAuthClientStub + fakeReturns := fake.sSHOAuthClientReturns fake.recordInvocation("SSHOAuthClient", []interface{}{}) fake.sSHOAuthClientMutex.Unlock() - if fake.SSHOAuthClientStub != nil { - return fake.SSHOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.sSHOAuthClientReturns return fakeReturns.result1 } @@ -1794,9 +1820,10 @@ func (fake *FakeRepository) SetAPIEndpoint(arg1 string) { fake.setAPIEndpointArgsForCall = append(fake.setAPIEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAPIEndpointStub fake.recordInvocation("SetAPIEndpoint", []interface{}{arg1}) fake.setAPIEndpointMutex.Unlock() - if fake.SetAPIEndpointStub != nil { + if stub != nil { fake.SetAPIEndpointStub(arg1) } } @@ -1825,9 +1852,10 @@ func (fake *FakeRepository) SetAPIVersion(arg1 string) { fake.setAPIVersionArgsForCall = append(fake.setAPIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAPIVersionStub fake.recordInvocation("SetAPIVersion", []interface{}{arg1}) fake.setAPIVersionMutex.Unlock() - if fake.SetAPIVersionStub != nil { + if stub != nil { fake.SetAPIVersionStub(arg1) } } @@ -1856,9 +1884,10 @@ func (fake *FakeRepository) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -1887,9 +1916,10 @@ func (fake *FakeRepository) SetAsyncTimeout(arg1 uint) { fake.setAsyncTimeoutArgsForCall = append(fake.setAsyncTimeoutArgsForCall, struct { arg1 uint }{arg1}) + stub := fake.SetAsyncTimeoutStub fake.recordInvocation("SetAsyncTimeout", []interface{}{arg1}) fake.setAsyncTimeoutMutex.Unlock() - if fake.SetAsyncTimeoutStub != nil { + if stub != nil { fake.SetAsyncTimeoutStub(arg1) } } @@ -1918,9 +1948,10 @@ func (fake *FakeRepository) SetAuthenticationEndpoint(arg1 string) { fake.setAuthenticationEndpointArgsForCall = append(fake.setAuthenticationEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAuthenticationEndpointStub fake.recordInvocation("SetAuthenticationEndpoint", []interface{}{arg1}) fake.setAuthenticationEndpointMutex.Unlock() - if fake.SetAuthenticationEndpointStub != nil { + if stub != nil { fake.SetAuthenticationEndpointStub(arg1) } } @@ -1949,9 +1980,10 @@ func (fake *FakeRepository) SetCLIVersion(arg1 string) { fake.setCLIVersionArgsForCall = append(fake.setCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetCLIVersionStub fake.recordInvocation("SetCLIVersion", []interface{}{arg1}) fake.setCLIVersionMutex.Unlock() - if fake.SetCLIVersionStub != nil { + if stub != nil { fake.SetCLIVersionStub(arg1) } } @@ -1980,9 +2012,10 @@ func (fake *FakeRepository) SetColorEnabled(arg1 string) { fake.setColorEnabledArgsForCall = append(fake.setColorEnabledArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetColorEnabledStub fake.recordInvocation("SetColorEnabled", []interface{}{arg1}) fake.setColorEnabledMutex.Unlock() - if fake.SetColorEnabledStub != nil { + if stub != nil { fake.SetColorEnabledStub(arg1) } } @@ -2011,9 +2044,10 @@ func (fake *FakeRepository) SetDopplerEndpoint(arg1 string) { fake.setDopplerEndpointArgsForCall = append(fake.setDopplerEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetDopplerEndpointStub fake.recordInvocation("SetDopplerEndpoint", []interface{}{arg1}) fake.setDopplerEndpointMutex.Unlock() - if fake.SetDopplerEndpointStub != nil { + if stub != nil { fake.SetDopplerEndpointStub(arg1) } } @@ -2042,9 +2076,10 @@ func (fake *FakeRepository) SetLocale(arg1 string) { fake.setLocaleArgsForCall = append(fake.setLocaleArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetLocaleStub fake.recordInvocation("SetLocale", []interface{}{arg1}) fake.setLocaleMutex.Unlock() - if fake.SetLocaleStub != nil { + if stub != nil { fake.SetLocaleStub(arg1) } } @@ -2073,9 +2108,10 @@ func (fake *FakeRepository) SetLogCacheEndpoint(arg1 string) { fake.setLogCacheEndpointArgsForCall = append(fake.setLogCacheEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetLogCacheEndpointStub fake.recordInvocation("SetLogCacheEndpoint", []interface{}{arg1}) fake.setLogCacheEndpointMutex.Unlock() - if fake.SetLogCacheEndpointStub != nil { + if stub != nil { fake.SetLogCacheEndpointStub(arg1) } } @@ -2104,9 +2140,10 @@ func (fake *FakeRepository) SetMinCLIVersion(arg1 string) { fake.setMinCLIVersionArgsForCall = append(fake.setMinCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetMinCLIVersionStub fake.recordInvocation("SetMinCLIVersion", []interface{}{arg1}) fake.setMinCLIVersionMutex.Unlock() - if fake.SetMinCLIVersionStub != nil { + if stub != nil { fake.SetMinCLIVersionStub(arg1) } } @@ -2135,9 +2172,10 @@ func (fake *FakeRepository) SetMinRecommendedCLIVersion(arg1 string) { fake.setMinRecommendedCLIVersionArgsForCall = append(fake.setMinRecommendedCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetMinRecommendedCLIVersionStub fake.recordInvocation("SetMinRecommendedCLIVersion", []interface{}{arg1}) fake.setMinRecommendedCLIVersionMutex.Unlock() - if fake.SetMinRecommendedCLIVersionStub != nil { + if stub != nil { fake.SetMinRecommendedCLIVersionStub(arg1) } } @@ -2166,9 +2204,10 @@ func (fake *FakeRepository) SetOrganizationFields(arg1 models.OrganizationFields fake.setOrganizationFieldsArgsForCall = append(fake.setOrganizationFieldsArgsForCall, struct { arg1 models.OrganizationFields }{arg1}) + stub := fake.SetOrganizationFieldsStub fake.recordInvocation("SetOrganizationFields", []interface{}{arg1}) fake.setOrganizationFieldsMutex.Unlock() - if fake.SetOrganizationFieldsStub != nil { + if stub != nil { fake.SetOrganizationFieldsStub(arg1) } } @@ -2197,9 +2236,10 @@ func (fake *FakeRepository) SetPluginRepo(arg1 models.PluginRepo) { fake.setPluginRepoArgsForCall = append(fake.setPluginRepoArgsForCall, struct { arg1 models.PluginRepo }{arg1}) + stub := fake.SetPluginRepoStub fake.recordInvocation("SetPluginRepo", []interface{}{arg1}) fake.setPluginRepoMutex.Unlock() - if fake.SetPluginRepoStub != nil { + if stub != nil { fake.SetPluginRepoStub(arg1) } } @@ -2228,9 +2268,10 @@ func (fake *FakeRepository) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } @@ -2259,9 +2300,10 @@ func (fake *FakeRepository) SetRoutingAPIEndpoint(arg1 string) { fake.setRoutingAPIEndpointArgsForCall = append(fake.setRoutingAPIEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRoutingAPIEndpointStub fake.recordInvocation("SetRoutingAPIEndpoint", []interface{}{arg1}) fake.setRoutingAPIEndpointMutex.Unlock() - if fake.SetRoutingAPIEndpointStub != nil { + if stub != nil { fake.SetRoutingAPIEndpointStub(arg1) } } @@ -2290,9 +2332,10 @@ func (fake *FakeRepository) SetSSHOAuthClient(arg1 string) { fake.setSSHOAuthClientArgsForCall = append(fake.setSSHOAuthClientArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetSSHOAuthClientStub fake.recordInvocation("SetSSHOAuthClient", []interface{}{arg1}) fake.setSSHOAuthClientMutex.Unlock() - if fake.SetSSHOAuthClientStub != nil { + if stub != nil { fake.SetSSHOAuthClientStub(arg1) } } @@ -2321,9 +2364,10 @@ func (fake *FakeRepository) SetSSLDisabled(arg1 bool) { fake.setSSLDisabledArgsForCall = append(fake.setSSLDisabledArgsForCall, struct { arg1 bool }{arg1}) + stub := fake.SetSSLDisabledStub fake.recordInvocation("SetSSLDisabled", []interface{}{arg1}) fake.setSSLDisabledMutex.Unlock() - if fake.SetSSLDisabledStub != nil { + if stub != nil { fake.SetSSLDisabledStub(arg1) } } @@ -2352,9 +2396,10 @@ func (fake *FakeRepository) SetSpaceFields(arg1 models.SpaceFields) { fake.setSpaceFieldsArgsForCall = append(fake.setSpaceFieldsArgsForCall, struct { arg1 models.SpaceFields }{arg1}) + stub := fake.SetSpaceFieldsStub fake.recordInvocation("SetSpaceFields", []interface{}{arg1}) fake.setSpaceFieldsMutex.Unlock() - if fake.SetSpaceFieldsStub != nil { + if stub != nil { fake.SetSpaceFieldsStub(arg1) } } @@ -2383,9 +2428,10 @@ func (fake *FakeRepository) SetTrace(arg1 string) { fake.setTraceArgsForCall = append(fake.setTraceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetTraceStub fake.recordInvocation("SetTrace", []interface{}{arg1}) fake.setTraceMutex.Unlock() - if fake.SetTraceStub != nil { + if stub != nil { fake.SetTraceStub(arg1) } } @@ -2414,9 +2460,10 @@ func (fake *FakeRepository) SetUAAGrantType(arg1 string) { fake.setUAAGrantTypeArgsForCall = append(fake.setUAAGrantTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAGrantTypeStub fake.recordInvocation("SetUAAGrantType", []interface{}{arg1}) fake.setUAAGrantTypeMutex.Unlock() - if fake.SetUAAGrantTypeStub != nil { + if stub != nil { fake.SetUAAGrantTypeStub(arg1) } } @@ -2445,9 +2492,10 @@ func (fake *FakeRepository) SetUAAOAuthClient(arg1 string) { fake.setUAAOAuthClientArgsForCall = append(fake.setUAAOAuthClientArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAOAuthClientStub fake.recordInvocation("SetUAAOAuthClient", []interface{}{arg1}) fake.setUAAOAuthClientMutex.Unlock() - if fake.SetUAAOAuthClientStub != nil { + if stub != nil { fake.SetUAAOAuthClientStub(arg1) } } @@ -2476,9 +2524,10 @@ func (fake *FakeRepository) SetUAAOAuthClientSecret(arg1 string) { fake.setUAAOAuthClientSecretArgsForCall = append(fake.setUAAOAuthClientSecretArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAOAuthClientSecretStub fake.recordInvocation("SetUAAOAuthClientSecret", []interface{}{arg1}) fake.setUAAOAuthClientSecretMutex.Unlock() - if fake.SetUAAOAuthClientSecretStub != nil { + if stub != nil { fake.SetUAAOAuthClientSecretStub(arg1) } } @@ -2507,9 +2556,10 @@ func (fake *FakeRepository) SetUaaEndpoint(arg1 string) { fake.setUaaEndpointArgsForCall = append(fake.setUaaEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUaaEndpointStub fake.recordInvocation("SetUaaEndpoint", []interface{}{arg1}) fake.setUaaEndpointMutex.Unlock() - if fake.SetUaaEndpointStub != nil { + if stub != nil { fake.SetUaaEndpointStub(arg1) } } @@ -2538,15 +2588,16 @@ func (fake *FakeRepository) SpaceFields() models.SpaceFields { ret, specificReturn := fake.spaceFieldsReturnsOnCall[len(fake.spaceFieldsArgsForCall)] fake.spaceFieldsArgsForCall = append(fake.spaceFieldsArgsForCall, struct { }{}) + stub := fake.SpaceFieldsStub + fakeReturns := fake.spaceFieldsReturns fake.recordInvocation("SpaceFields", []interface{}{}) fake.spaceFieldsMutex.Unlock() - if fake.SpaceFieldsStub != nil { - return fake.SpaceFieldsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.spaceFieldsReturns return fakeReturns.result1 } @@ -2590,15 +2641,16 @@ func (fake *FakeRepository) Trace() string { ret, specificReturn := fake.traceReturnsOnCall[len(fake.traceArgsForCall)] fake.traceArgsForCall = append(fake.traceArgsForCall, struct { }{}) + stub := fake.TraceStub + fakeReturns := fake.traceReturns fake.recordInvocation("Trace", []interface{}{}) fake.traceMutex.Unlock() - if fake.TraceStub != nil { - return fake.TraceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.traceReturns return fakeReturns.result1 } @@ -2642,15 +2694,16 @@ func (fake *FakeRepository) UAAGrantType() string { ret, specificReturn := fake.uAAGrantTypeReturnsOnCall[len(fake.uAAGrantTypeArgsForCall)] fake.uAAGrantTypeArgsForCall = append(fake.uAAGrantTypeArgsForCall, struct { }{}) + stub := fake.UAAGrantTypeStub + fakeReturns := fake.uAAGrantTypeReturns fake.recordInvocation("UAAGrantType", []interface{}{}) fake.uAAGrantTypeMutex.Unlock() - if fake.UAAGrantTypeStub != nil { - return fake.UAAGrantTypeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAGrantTypeReturns return fakeReturns.result1 } @@ -2694,15 +2747,16 @@ func (fake *FakeRepository) UAAOAuthClient() string { ret, specificReturn := fake.uAAOAuthClientReturnsOnCall[len(fake.uAAOAuthClientArgsForCall)] fake.uAAOAuthClientArgsForCall = append(fake.uAAOAuthClientArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientStub + fakeReturns := fake.uAAOAuthClientReturns fake.recordInvocation("UAAOAuthClient", []interface{}{}) fake.uAAOAuthClientMutex.Unlock() - if fake.UAAOAuthClientStub != nil { - return fake.UAAOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientReturns return fakeReturns.result1 } @@ -2746,15 +2800,16 @@ func (fake *FakeRepository) UAAOAuthClientSecret() string { ret, specificReturn := fake.uAAOAuthClientSecretReturnsOnCall[len(fake.uAAOAuthClientSecretArgsForCall)] fake.uAAOAuthClientSecretArgsForCall = append(fake.uAAOAuthClientSecretArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientSecretStub + fakeReturns := fake.uAAOAuthClientSecretReturns fake.recordInvocation("UAAOAuthClientSecret", []interface{}{}) fake.uAAOAuthClientSecretMutex.Unlock() - if fake.UAAOAuthClientSecretStub != nil { - return fake.UAAOAuthClientSecretStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientSecretReturns return fakeReturns.result1 } @@ -2798,15 +2853,16 @@ func (fake *FakeRepository) UaaEndpoint() string { ret, specificReturn := fake.uaaEndpointReturnsOnCall[len(fake.uaaEndpointArgsForCall)] fake.uaaEndpointArgsForCall = append(fake.uaaEndpointArgsForCall, struct { }{}) + stub := fake.UaaEndpointStub + fakeReturns := fake.uaaEndpointReturns fake.recordInvocation("UaaEndpoint", []interface{}{}) fake.uaaEndpointMutex.Unlock() - if fake.UaaEndpointStub != nil { - return fake.UaaEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uaaEndpointReturns return fakeReturns.result1 } @@ -2850,9 +2906,10 @@ func (fake *FakeRepository) UnSetPluginRepo(arg1 int) { fake.unSetPluginRepoArgsForCall = append(fake.unSetPluginRepoArgsForCall, struct { arg1 int }{arg1}) + stub := fake.UnSetPluginRepoStub fake.recordInvocation("UnSetPluginRepo", []interface{}{arg1}) fake.unSetPluginRepoMutex.Unlock() - if fake.UnSetPluginRepoStub != nil { + if stub != nil { fake.UnSetPluginRepoStub(arg1) } } @@ -2881,15 +2938,16 @@ func (fake *FakeRepository) UserEmail() string { ret, specificReturn := fake.userEmailReturnsOnCall[len(fake.userEmailArgsForCall)] fake.userEmailArgsForCall = append(fake.userEmailArgsForCall, struct { }{}) + stub := fake.UserEmailStub + fakeReturns := fake.userEmailReturns fake.recordInvocation("UserEmail", []interface{}{}) fake.userEmailMutex.Unlock() - if fake.UserEmailStub != nil { - return fake.UserEmailStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.userEmailReturns return fakeReturns.result1 } @@ -2933,15 +2991,16 @@ func (fake *FakeRepository) UserGUID() string { ret, specificReturn := fake.userGUIDReturnsOnCall[len(fake.userGUIDArgsForCall)] fake.userGUIDArgsForCall = append(fake.userGUIDArgsForCall, struct { }{}) + stub := fake.UserGUIDStub + fakeReturns := fake.userGUIDReturns fake.recordInvocation("UserGUID", []interface{}{}) fake.userGUIDMutex.Unlock() - if fake.UserGUIDStub != nil { - return fake.UserGUIDStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.userGUIDReturns return fakeReturns.result1 } @@ -2985,15 +3044,16 @@ func (fake *FakeRepository) Username() string { ret, specificReturn := fake.usernameReturnsOnCall[len(fake.usernameArgsForCall)] fake.usernameArgsForCall = append(fake.usernameArgsForCall, struct { }{}) + stub := fake.UsernameStub + fakeReturns := fake.usernameReturns fake.recordInvocation("Username", []interface{}{}) fake.usernameMutex.Unlock() - if fake.UsernameStub != nil { - return fake.UsernameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.usernameReturns return fakeReturns.result1 } diff --git a/cf/configuration/pluginconfig/plugin_config.go b/cf/configuration/pluginconfig/plugin_config.go index c2212f7f880..ae82e07547b 100644 --- a/cf/configuration/pluginconfig/plugin_config.go +++ b/cf/configuration/pluginconfig/plugin_config.go @@ -3,7 +3,7 @@ package pluginconfig import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginConfiguration @@ -74,7 +74,7 @@ func (c *PluginConfig) ListCommands() []string { } func (c *PluginConfig) init() { - //only read from disk if it was never read + // only read from disk if it was never read c.initOnce.Do(func() { err := c.persistor.Load(c.data) if err != nil { diff --git a/cf/configuration/pluginconfig/plugin_config_test.go b/cf/configuration/pluginconfig/plugin_config_test.go index e7e0703cd54..a0088ed7815 100644 --- a/cf/configuration/pluginconfig/plugin_config_test.go +++ b/cf/configuration/pluginconfig/plugin_config_test.go @@ -5,13 +5,13 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - . "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + . "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/plugin" - "code.cloudfoundry.org/cli/cf/configuration/configurationfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/configurationfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -83,7 +83,7 @@ var _ = Describe("PluginConfig", func() { } metadata = PluginMetadata{ - Location: "../../../fixtures/plugins/test_1.exe", + Location: "../../../fixtures/plugins/test_1/test_1.exe", Commands: commands1, } }) @@ -110,9 +110,9 @@ var _ = Describe("PluginConfig", func() { }) It("returns a list of plugin executables and their location", func() { - Expect(plugins["Test1"].Location).To(Equal("../../../fixtures/plugins/test_1.exe")) + Expect(plugins["Test1"].Location).To(Equal("../../../fixtures/plugins/test_1/test_1.exe")) Expect(plugins["Test1"].Commands).To(Equal(commands1)) - Expect(plugins["Test2"].Location).To(Equal("../../../fixtures/plugins/test_2.exe")) + Expect(plugins["Test2"].Location).To(Equal("../../../fixtures/plugins/test_2/test_2.exe")) Expect(plugins["Test2"].Commands).To(Equal(commands2)) }) }) diff --git a/cf/configuration/pluginconfig/plugin_data.go b/cf/configuration/pluginconfig/plugin_data.go index 9d9cebe4907..a08bc3c81ed 100644 --- a/cf/configuration/pluginconfig/plugin_data.go +++ b/cf/configuration/pluginconfig/plugin_data.go @@ -3,7 +3,7 @@ package pluginconfig import ( "encoding/json" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type PluginData struct { diff --git a/cf/configuration/pluginconfig/plugin_suite_test.go b/cf/configuration/pluginconfig/plugin_suite_test.go index e80a11b0ecb..d8297546bfd 100644 --- a/cf/configuration/pluginconfig/plugin_suite_test.go +++ b/cf/configuration/pluginconfig/plugin_suite_test.go @@ -1,7 +1,7 @@ package pluginconfig_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/configuration/pluginconfig/pluginconfigfakes/fake_plugin_configuration.go b/cf/configuration/pluginconfig/pluginconfigfakes/fake_plugin_configuration.go index 42220dae934..123892e6ad4 100644 --- a/cf/configuration/pluginconfig/pluginconfigfakes/fake_plugin_configuration.go +++ b/cf/configuration/pluginconfig/pluginconfigfakes/fake_plugin_configuration.go @@ -4,7 +4,7 @@ package pluginconfigfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" ) type FakePluginConfiguration struct { @@ -58,15 +58,16 @@ func (fake *FakePluginConfiguration) GetPluginPath() string { ret, specificReturn := fake.getPluginPathReturnsOnCall[len(fake.getPluginPathArgsForCall)] fake.getPluginPathArgsForCall = append(fake.getPluginPathArgsForCall, struct { }{}) + stub := fake.GetPluginPathStub + fakeReturns := fake.getPluginPathReturns fake.recordInvocation("GetPluginPath", []interface{}{}) fake.getPluginPathMutex.Unlock() - if fake.GetPluginPathStub != nil { - return fake.GetPluginPathStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getPluginPathReturns return fakeReturns.result1 } @@ -110,15 +111,16 @@ func (fake *FakePluginConfiguration) ListCommands() []string { ret, specificReturn := fake.listCommandsReturnsOnCall[len(fake.listCommandsArgsForCall)] fake.listCommandsArgsForCall = append(fake.listCommandsArgsForCall, struct { }{}) + stub := fake.ListCommandsStub + fakeReturns := fake.listCommandsReturns fake.recordInvocation("ListCommands", []interface{}{}) fake.listCommandsMutex.Unlock() - if fake.ListCommandsStub != nil { - return fake.ListCommandsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.listCommandsReturns return fakeReturns.result1 } @@ -162,15 +164,16 @@ func (fake *FakePluginConfiguration) Plugins() map[string]pluginconfig.PluginMet ret, specificReturn := fake.pluginsReturnsOnCall[len(fake.pluginsArgsForCall)] fake.pluginsArgsForCall = append(fake.pluginsArgsForCall, struct { }{}) + stub := fake.PluginsStub + fakeReturns := fake.pluginsReturns fake.recordInvocation("Plugins", []interface{}{}) fake.pluginsMutex.Unlock() - if fake.PluginsStub != nil { - return fake.PluginsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginsReturns return fakeReturns.result1 } @@ -214,9 +217,10 @@ func (fake *FakePluginConfiguration) RemovePlugin(arg1 string) { fake.removePluginArgsForCall = append(fake.removePluginArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RemovePluginStub fake.recordInvocation("RemovePlugin", []interface{}{arg1}) fake.removePluginMutex.Unlock() - if fake.RemovePluginStub != nil { + if stub != nil { fake.RemovePluginStub(arg1) } } @@ -246,9 +250,10 @@ func (fake *FakePluginConfiguration) SetPlugin(arg1 string, arg2 pluginconfig.Pl arg1 string arg2 pluginconfig.PluginMetadata }{arg1, arg2}) + stub := fake.SetPluginStub fake.recordInvocation("SetPlugin", []interface{}{arg1, arg2}) fake.setPluginMutex.Unlock() - if fake.SetPluginStub != nil { + if stub != nil { fake.SetPluginStub(arg1, arg2) } } diff --git a/cf/errors/access_denied_error.go b/cf/errors/access_denied_error.go index 36fb366d8aa..1d0f755b4e5 100644 --- a/cf/errors/access_denied_error.go +++ b/cf/errors/access_denied_error.go @@ -1,6 +1,6 @@ package errors -import . "code.cloudfoundry.org/cli/cf/i18n" +import . "code.cloudfoundry.org/cli/v8/cf/i18n" type AccessDeniedError struct { } diff --git a/cf/errors/ambiguous_model_error.go b/cf/errors/ambiguous_model_error.go index 071745bcf01..03057eee08f 100644 --- a/cf/errors/ambiguous_model_error.go +++ b/cf/errors/ambiguous_model_error.go @@ -3,7 +3,7 @@ package errors import ( "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type AmbiguousModelError struct { diff --git a/cf/errors/curl_http_error.go b/cf/errors/curl_http_error.go index 4883e943c4a..15894557ebb 100644 --- a/cf/errors/curl_http_error.go +++ b/cf/errors/curl_http_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type CurlHTTPError struct { diff --git a/cf/errors/empty_dir_error.go b/cf/errors/empty_dir_error.go index 8cca87afa04..86e270f191c 100644 --- a/cf/errors/empty_dir_error.go +++ b/cf/errors/empty_dir_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type EmptyDirError struct { diff --git a/cf/errors/errorsfakes/fake_httperror.go b/cf/errors/errorsfakes/fake_httperror.go index ee993fdd855..315710b6837 100644 --- a/cf/errors/errorsfakes/fake_httperror.go +++ b/cf/errors/errorsfakes/fake_httperror.go @@ -4,7 +4,7 @@ package errorsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/errors" ) type FakeHTTPError struct { @@ -47,15 +47,16 @@ func (fake *FakeHTTPError) Error() string { ret, specificReturn := fake.errorReturnsOnCall[len(fake.errorArgsForCall)] fake.errorArgsForCall = append(fake.errorArgsForCall, struct { }{}) + stub := fake.ErrorStub + fakeReturns := fake.errorReturns fake.recordInvocation("Error", []interface{}{}) fake.errorMutex.Unlock() - if fake.ErrorStub != nil { - return fake.ErrorStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.errorReturns return fakeReturns.result1 } @@ -99,15 +100,16 @@ func (fake *FakeHTTPError) ErrorCode() string { ret, specificReturn := fake.errorCodeReturnsOnCall[len(fake.errorCodeArgsForCall)] fake.errorCodeArgsForCall = append(fake.errorCodeArgsForCall, struct { }{}) + stub := fake.ErrorCodeStub + fakeReturns := fake.errorCodeReturns fake.recordInvocation("ErrorCode", []interface{}{}) fake.errorCodeMutex.Unlock() - if fake.ErrorCodeStub != nil { - return fake.ErrorCodeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.errorCodeReturns return fakeReturns.result1 } @@ -151,15 +153,16 @@ func (fake *FakeHTTPError) StatusCode() int { ret, specificReturn := fake.statusCodeReturnsOnCall[len(fake.statusCodeArgsForCall)] fake.statusCodeArgsForCall = append(fake.statusCodeArgsForCall, struct { }{}) + stub := fake.StatusCodeStub + fakeReturns := fake.statusCodeReturns fake.recordInvocation("StatusCode", []interface{}{}) fake.statusCodeMutex.Unlock() - if fake.StatusCodeStub != nil { - return fake.StatusCodeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.statusCodeReturns return fakeReturns.result1 } diff --git a/cf/errors/gateway_error.go b/cf/errors/gateway_error.go index 22d908bbed3..c0a19243ac3 100644 --- a/cf/errors/gateway_error.go +++ b/cf/errors/gateway_error.go @@ -3,7 +3,7 @@ package errors import ( "fmt" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type AsyncTimeoutError struct { diff --git a/cf/errors/http_error.go b/cf/errors/http_error.go index bb8e1f60b08..9979923dfda 100644 --- a/cf/errors/http_error.go +++ b/cf/errors/http_error.go @@ -3,7 +3,7 @@ package errors import ( "fmt" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . HTTPError diff --git a/cf/errors/invalid_ssl_cert_error.go b/cf/errors/invalid_ssl_cert_error.go index 70f81d7af1d..61880c1deda 100644 --- a/cf/errors/invalid_ssl_cert_error.go +++ b/cf/errors/invalid_ssl_cert_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type InvalidSSLCert struct { diff --git a/cf/errors/invalid_token_error.go b/cf/errors/invalid_token_error.go index 4860758669f..8b9a4386557 100644 --- a/cf/errors/invalid_token_error.go +++ b/cf/errors/invalid_token_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type InvalidTokenError struct { diff --git a/cf/errors/model_already_exists_error.go b/cf/errors/model_already_exists_error.go index ef8b832dc6b..904d4e73700 100644 --- a/cf/errors/model_already_exists_error.go +++ b/cf/errors/model_already_exists_error.go @@ -3,7 +3,7 @@ package errors import ( "fmt" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ModelAlreadyExistsError struct { diff --git a/cf/errors/model_not_found_error.go b/cf/errors/model_not_found_error.go index d41611978d2..0ca7acf811a 100644 --- a/cf/errors/model_not_found_error.go +++ b/cf/errors/model_not_found_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ModelNotFoundError struct { diff --git a/cf/errors/not_authorized_error.go b/cf/errors/not_authorized_error.go index 4e9160bde13..af012463d66 100644 --- a/cf/errors/not_authorized_error.go +++ b/cf/errors/not_authorized_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type NotAuthorizedError struct { diff --git a/cf/errors/service_association_error.go b/cf/errors/service_association_error.go index 34ae899c037..c0d5d2b2cc9 100644 --- a/cf/errors/service_association_error.go +++ b/cf/errors/service_association_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type ServiceAssociationError struct { diff --git a/cf/errors/unbindable_service_error.go b/cf/errors/unbindable_service_error.go index 35a788a9a12..9564a7dc74b 100644 --- a/cf/errors/unbindable_service_error.go +++ b/cf/errors/unbindable_service_error.go @@ -1,7 +1,7 @@ package errors import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type UnbindableServiceError struct { diff --git a/cf/flagcontext/flag_content_helper_test.go b/cf/flagcontext/flag_content_helper_test.go index 622ed20a6e3..65b1fd8ea82 100644 --- a/cf/flagcontext/flag_content_helper_test.go +++ b/cf/flagcontext/flag_content_helper_test.go @@ -4,10 +4,10 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/cf/flagcontext" + "code.cloudfoundry.org/cli/v8/cf/flagcontext" "code.cloudfoundry.org/gofileutils/fileutils" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/flagcontext/util_suite_test.go b/cf/flagcontext/util_suite_test.go index 5717be16120..3a3e05bbd3b 100644 --- a/cf/flagcontext/util_suite_test.go +++ b/cf/flagcontext/util_suite_test.go @@ -1,7 +1,7 @@ package flagcontext_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/flags/flag_constructor_test.go b/cf/flags/flag_constructor_test.go index c2dc66d9511..ca5b124029b 100644 --- a/cf/flags/flag_constructor_test.go +++ b/cf/flags/flag_constructor_test.go @@ -1,8 +1,8 @@ package flags_test import ( - "code.cloudfoundry.org/cli/cf/flags" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/flags/flags_suite_test.go b/cf/flags/flags_suite_test.go index 0b3071f62e0..605e48cfa8f 100644 --- a/cf/flags/flags_suite_test.go +++ b/cf/flags/flags_suite_test.go @@ -1,7 +1,7 @@ package flags_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/flags/flags_test.go b/cf/flags/flags_test.go index 1b29cd2978e..fb6545a8911 100644 --- a/cf/flags/flags_test.go +++ b/cf/flags/flags_test.go @@ -1,14 +1,14 @@ package flags_test import ( - "code.cloudfoundry.org/cli/cf/flags" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Flags", func() { Describe("FlagContext", func() { - Describe("Parsing and retriving values", func() { + Describe("Parsing and retrieving values", func() { var ( fCtx flags.FlagContext cmdFlagMap map[string]flags.FlagSet @@ -73,7 +73,7 @@ var _ = Describe("Flags", func() { Ω(fCtx.Bool("skip2")).To(Equal(true), "skip2 should be true") Ω(fCtx.Bool("name")).To(Equal(false), "name should be false") Ω(fCtx.String("name")).To(Equal("johndoe"), "name should be johndoe") - Expect(fCtx.Bool("non-exisit-flag")).To(Equal(false)) + Expect(fCtx.Bool("non-exist-flag")).To(Equal(false)) }) It("sets Bool() to return true if bool flag is provided with invalid value", func() { @@ -90,7 +90,7 @@ var _ = Describe("Flags", func() { Ω(fCtx.Bool("skip")).To(Equal(true), "skip should be true") Ω(fCtx.Bool("name")).To(Equal(false), "name should be false") - Expect(fCtx.Bool("non-exisit-flag")).To(Equal(false)) + Expect(fCtx.Bool("non-exist-flag")).To(Equal(false)) }) It("sets String() to return provided value when a string flag is provided", func() { diff --git a/cf/flags/flags_usage_test.go b/cf/flags/flags_usage_test.go index 1badd41b4b0..27650bd9500 100644 --- a/cf/flags/flags_usage_test.go +++ b/cf/flags/flags_usage_test.go @@ -3,8 +3,8 @@ package flags_test import ( "strings" - "code.cloudfoundry.org/cli/cf/flags" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/flags" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/flags/stringSlice.go b/cf/flags/stringSlice.go index bac798714da..5e809b163b8 100644 --- a/cf/flags/stringSlice.go +++ b/cf/flags/stringSlice.go @@ -1,6 +1,6 @@ package flags -//StringSlice flag can be define multiple times in the arguments +// StringSlice flag can be define multiple times in the arguments type StringSliceFlag struct { Name string Value []string diff --git a/cf/formatters/bools.go b/cf/formatters/bools.go index 4ce3d0c8418..98664294691 100644 --- a/cf/formatters/bools.go +++ b/cf/formatters/bools.go @@ -1,7 +1,7 @@ package formatters import ( - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) func Allowed(allowed bool) string { diff --git a/cf/formatters/bools_test.go b/cf/formatters/bools_test.go index 040017ad548..183b468b8ba 100644 --- a/cf/formatters/bools_test.go +++ b/cf/formatters/bools_test.go @@ -1,8 +1,8 @@ package formatters_test import ( - . "code.cloudfoundry.org/cli/cf/formatters" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/formatters" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/formatters/bytes.go b/cf/formatters/bytes.go index bdd76a65c28..50a360564cb 100644 --- a/cf/formatters/bytes.go +++ b/cf/formatters/bytes.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) const ( diff --git a/cf/formatters/bytes_test.go b/cf/formatters/bytes_test.go index 015986f2e9c..45c34645eeb 100644 --- a/cf/formatters/bytes_test.go +++ b/cf/formatters/bytes_test.go @@ -1,8 +1,8 @@ package formatters_test import ( - . "code.cloudfoundry.org/cli/cf/formatters" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/formatters" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/formatters/formatters_suite_test.go b/cf/formatters/formatters_suite_test.go index 9d2236b2726..79753b0e765 100644 --- a/cf/formatters/formatters_suite_test.go +++ b/cf/formatters/formatters_suite_test.go @@ -1,9 +1,9 @@ package formatters_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/formatters/memoryLimit_test.go b/cf/formatters/memoryLimit_test.go index ee981c8f500..5a1cb3233ed 100644 --- a/cf/formatters/memoryLimit_test.go +++ b/cf/formatters/memoryLimit_test.go @@ -1,8 +1,8 @@ package formatters_test import ( - . "code.cloudfoundry.org/cli/cf/formatters" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/formatters" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/help/help.go b/cf/help/help.go index bb992977d66..7f243e49638 100644 --- a/cf/help/help.go +++ b/cf/help/help.go @@ -11,13 +11,13 @@ import ( "path/filepath" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/version" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/version" ) type appPresenter struct { @@ -64,7 +64,7 @@ func newAppPresenter() appPresenter { pluginConfig := pluginconfig.NewPluginConfig( func(err error) { - //fail silently when running help + // fail silently when running help }, configuration.NewDiskPersistor(filepath.Join(pluginPath, "config.json")), pluginPath, diff --git a/cf/help/help_suite_test.go b/cf/help/help_suite_test.go index 0ed0de93fad..c05359e640a 100644 --- a/cf/help/help_suite_test.go +++ b/cf/help/help_suite_test.go @@ -1,8 +1,8 @@ package help_test import ( - "code.cloudfoundry.org/cli/cf/commandsloader" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandsloader" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/help/help_test.go b/cf/help/help_test.go index 8a5b5de1bdd..407f5ab3801 100644 --- a/cf/help/help_test.go +++ b/cf/help/help_test.go @@ -4,15 +4,15 @@ import ( "path/filepath" "strings" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/confighelpers" - "code.cloudfoundry.org/cli/cf/help" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/confighelpers" + "code.cloudfoundry.org/cli/v8/cf/help" - "code.cloudfoundry.org/cli/cf/util/testhelpers/io" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/io" "os" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cf/help/template.go b/cf/help/template.go index 850480fd584..f4b57044ecc 100644 --- a/cf/help/template.go +++ b/cf/help/template.go @@ -1,6 +1,6 @@ package help -import . "code.cloudfoundry.org/cli/cf/i18n" +import . "code.cloudfoundry.org/cli/v8/cf/i18n" func GetHelpTemplate() string { return `{{.Title "` + T("NAME:") + `"}} diff --git a/cf/i18n/README-i18n.md b/cf/i18n/README-i18n.md index 6b4e1d5a9d2..097e568d823 100644 --- a/cf/i18n/README-i18n.md +++ b/cf/i18n/README-i18n.md @@ -8,7 +8,7 @@ If you are interested in submitting translations for a currently unsupported lan ## How can you contribute? -If you see typos, errors in grammar, ambiguous strings or English after setting your locale, please find the appropriate entry in the corresponding `i18n/resources/_.all.json` file and submit a [pull request](https://help.github.com/articles/creating-a-pull-request/) with the fix(es). It is much better to submit small pull requests as you complete translations, rather than submitting a large one. This makes it much easier to rapidly merge your changes in. You can also report translations needing fixes as an issue in Github. +If you see typos, errors in grammar, ambiguous strings or English after setting your locale, please find the appropriate entry in the corresponding `i18n/resources/_.all.json` file and submit a [pull request](https://help.github.com/articles/creating-a-pull-request/) with the fix(es). It is much better to submit small pull requests as you complete translations, rather than submitting a large one. This makes it much easier to rapidly merge your changes in. You can also report translations needing fixes as an issue in GitHub. Pull requests should only contain changes to "translation" values; the "id" value should not change as it is the key which is used to find the translations, and will always be English. For example: diff --git a/cf/i18n/i18n.go b/cf/i18n/i18n.go index 4084738e99c..7d680aa6a5b 100644 --- a/cf/i18n/i18n.go +++ b/cf/i18n/i18n.go @@ -1,6 +1,6 @@ package i18n -import "code.cloudfoundry.org/cli/util/ui" +import "code.cloudfoundry.org/cli/v8/util/ui" var T ui.TranslateFunc diff --git a/cf/i18n/i18n_suite_test.go b/cf/i18n/i18n_suite_test.go index d00c86c0f49..ae75e715081 100644 --- a/cf/i18n/i18n_suite_test.go +++ b/cf/i18n/i18n_suite_test.go @@ -1,7 +1,7 @@ package i18n_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/i18n/locale.go b/cf/i18n/locale.go index 3857d1e42d1..1db267f2b2d 100644 --- a/cf/i18n/locale.go +++ b/cf/i18n/locale.go @@ -4,8 +4,8 @@ import ( "path" "strings" - "code.cloudfoundry.org/cli/i18n/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/i18n/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) const resourceSuffix = ".all.json" diff --git a/cf/i18n/locale_test.go b/cf/i18n/locale_test.go index 418d79c91b0..9e1242bac07 100644 --- a/cf/i18n/locale_test.go +++ b/cf/i18n/locale_test.go @@ -1,9 +1,9 @@ package i18n_test import ( - "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/i18n" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/manifest/generate_manifest.go b/cf/manifest/generate_manifest.go index 6a8a9eb68c4..b222908715d 100644 --- a/cf/manifest/generate_manifest.go +++ b/cf/manifest/generate_manifest.go @@ -4,13 +4,13 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" "gopkg.in/yaml.v2" "io" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . App @@ -194,7 +194,7 @@ func (m *appManifest) Save(f io.Writer) error { for _, app := range m.contents { appMap, mapErr := generateAppMap(app) if mapErr != nil { - return fmt.Errorf(T("Error saving manifest: {{.Error}}", map[string]interface{}{ + return errors.New(T("Error saving manifest: {{.Error}}", map[string]interface{}{ "Error": mapErr.Error(), })) } diff --git a/cf/manifest/generate_manifest_test.go b/cf/manifest/generate_manifest_test.go index 2b6d9cfbb4d..609e37fdc03 100644 --- a/cf/manifest/generate_manifest_test.go +++ b/cf/manifest/generate_manifest_test.go @@ -5,8 +5,8 @@ import ( "bytes" - . "code.cloudfoundry.org/cli/cf/manifest" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/manifest" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/manifest/manifest.go b/cf/manifest/manifest.go index 4d959ae5a06..860a5bbc9ea 100644 --- a/cf/manifest/manifest.go +++ b/cf/manifest/manifest.go @@ -7,12 +7,12 @@ import ( "regexp" "strconv" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/util/generic" - "code.cloudfoundry.org/cli/util/randomword" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/util/generic" + "code.cloudfoundry.org/cli/v8/util/randomword" ) type Manifest struct { @@ -72,7 +72,7 @@ func (m Manifest) getAppMaps(data generic.Map) ([]generic.Map, error) { for _, appData := range appMaps { if !generic.IsMappable(appData) { - errs = append(errs, fmt.Errorf(T("Expected application to be a list of key/value pairs\nError occurred in manifest near:\n'{{.YmlSnippet}}'", + errs = append(errs, errors.New(T("Expected application to be a list of key/value pairs\nError occurred in manifest near:\n'{{.YmlSnippet}}'", map[string]interface{}{"YmlSnippet": appData}))) continue } @@ -214,7 +214,7 @@ func mapToAppParams(basePath string, yamlMap generic.Map) (models.AppParams, err } if len(appParams.Buildpacks) > 0 { - errs = append(errs, fmt.Errorf(T("The following manifest fields cannot be used with legacy push: {{.fields}}", + errs = append(errs, errors.New(T("The following manifest fields cannot be used with legacy push: {{.fields}}", map[string]interface{}{ "fields": "buildpacks", }))) @@ -258,7 +258,7 @@ func checkForNulls(yamlMap generic.Map) error { return } if value == nil { - errs = append(errs, fmt.Errorf(T("{{.PropertyName}} should not be null", map[string]interface{}{"PropertyName": key}))) + errs = append(errs, errors.New(T("{{.PropertyName}} should not be null", map[string]interface{}{"PropertyName": key}))) } }) @@ -280,7 +280,7 @@ func stringVal(yamlMap generic.Map, key string, errs *[]error) *string { } result, ok := val.(string) if !ok { - *errs = append(*errs, fmt.Errorf(T("{{.PropertyName}} must be a string value", map[string]interface{}{"PropertyName": key}))) + *errs = append(*errs, errors.New(T("{{.PropertyName}} must be a string value", map[string]interface{}{"PropertyName": key}))) return nil } return &result @@ -300,7 +300,7 @@ func stringValOrDefault(yamlMap generic.Map, key string, errs *[]error) *string case nil: return &empty default: - *errs = append(*errs, fmt.Errorf(T("{{.PropertyName}} must be a string or null value", map[string]interface{}{"PropertyName": key}))) + *errs = append(*errs, errors.New(T("{{.PropertyName}} must be a string or null value", map[string]interface{}{"PropertyName": key}))) return nil } } @@ -314,7 +314,7 @@ func bytesVal(yamlMap generic.Map, key string, errs *[]error) *int64 { stringVal := coerceToString(yamlVal) value, err := formatters.ToMegabytes(stringVal) if err != nil { - *errs = append(*errs, fmt.Errorf(T("Invalid value for '{{.PropertyName}}': {{.StringVal}}\n{{.Error}}", + *errs = append(*errs, errors.New(T("Invalid value for '{{.PropertyName}}': {{.StringVal}}\n{{.Error}}", map[string]interface{}{ "PropertyName": key, "Error": err.Error(), @@ -341,7 +341,7 @@ func intVal(yamlMap generic.Map, key string, errs *[]error) *int { case nil: return nil default: - err = fmt.Errorf(T("Expected {{.PropertyName}} to be a number, but it was a {{.PropertyType}}.", + err = errors.New(T("Expected {{.PropertyName}} to be a number, but it was a {{.PropertyType}}.", map[string]interface{}{"PropertyName": key, "PropertyType": val})) } @@ -366,7 +366,7 @@ func boolVal(yamlMap generic.Map, key string, errs *[]error) bool { case string: return val == "true" default: - *errs = append(*errs, fmt.Errorf(T("Expected {{.PropertyName}} to be a boolean.", map[string]interface{}{"PropertyName": key}))) + *errs = append(*errs, errors.New(T("Expected {{.PropertyName}} to be a boolean.", map[string]interface{}{"PropertyName": key}))) return false } } @@ -382,7 +382,7 @@ func boolOrNil(yamlMap generic.Map, key string, errs *[]error) *bool { result = val == "true" return &result default: - *errs = append(*errs, fmt.Errorf(T("Expected {{.PropertyName}} to be a boolean.", map[string]interface{}{"PropertyName": key}))) + *errs = append(*errs, errors.New(T("Expected {{.PropertyName}} to be a boolean.", map[string]interface{}{"PropertyName": key}))) return &result } } @@ -394,7 +394,7 @@ func sliceOrNil(yamlMap generic.Map, key string, errs *[]error) []string { var err error stringSlice := []string{} - sliceErr := fmt.Errorf(T("Expected {{.PropertyName}} to be a list of strings.", map[string]interface{}{"PropertyName": key})) + sliceErr := errors.New(T("Expected {{.PropertyName}} to be a list of strings.", map[string]interface{}{"PropertyName": key})) switch input := yamlMap.Get(key).(type) { case []interface{}: @@ -444,7 +444,7 @@ func envVarOrEmptyMap(yamlMap generic.Map, errs *[]error) *map[string]interface{ return &result default: - *errs = append(*errs, fmt.Errorf(T("Expected {{.Name}} to be a set of key => value, but it was a {{.Type}}.", + *errs = append(*errs, errors.New(T("Expected {{.Name}} to be a set of key => value, but it was a {{.Type}}.", map[string]interface{}{"Name": key, "Type": envVars}))) return nil } @@ -453,7 +453,7 @@ func envVarOrEmptyMap(yamlMap generic.Map, errs *[]error) *map[string]interface{ func validateEnvVars(input generic.Map) (errs []error) { generic.Each(input, func(key, value interface{}) { if value == nil { - errs = append(errs, fmt.Errorf(T("env var '{{.PropertyName}}' should not be null", + errs = append(errs, errors.New(T("env var '{{.PropertyName}}' should not be null", map[string]interface{}{"PropertyName": key}))) } }) @@ -475,7 +475,7 @@ func parseRoutes(input generic.Map, errs *[]error) []models.ManifestRoute { genericRoutes, ok := input.Get("routes").([]interface{}) if !ok { - *errs = append(*errs, fmt.Errorf(T("'routes' should be a list"))) + *errs = append(*errs, errors.New(T("'routes' should be a list"))) return nil } @@ -483,7 +483,7 @@ func parseRoutes(input generic.Map, errs *[]error) []models.ManifestRoute { for _, genericRoute := range genericRoutes { route, ok := genericRoute.(map[interface{}]interface{}) if !ok { - *errs = append(*errs, fmt.Errorf(T("each route in 'routes' must have a 'route' property"))) + *errs = append(*errs, errors.New(T("each route in 'routes' must have a 'route' property"))) continue } @@ -492,7 +492,7 @@ func parseRoutes(input generic.Map, errs *[]error) []models.ManifestRoute { Route: routeVal.(string), }) } else { - *errs = append(*errs, fmt.Errorf(T("each route in 'routes' must have a 'route' property"))) + *errs = append(*errs, errors.New(T("each route in 'routes' must have a 'route' property"))) } } @@ -511,7 +511,7 @@ func parseDocker(input generic.Map, errs *[]error) models.ManifestDocker { var ok bool imageValue, ok = dockerMap.Get("image").(string) if !ok { - *errs = append(*errs, fmt.Errorf(T("'docker.image' must be a string"))) + *errs = append(*errs, errors.New(T("'docker.image' must be a string"))) return models.ManifestDocker{} } } @@ -521,7 +521,7 @@ func parseDocker(input generic.Map, errs *[]error) models.ManifestDocker { var ok bool usernameValue, ok = dockerMap.Get("username").(string) if !ok { - *errs = append(*errs, fmt.Errorf(T("'docker.username' must be a string"))) + *errs = append(*errs, errors.New(T("'docker.username' must be a string"))) return models.ManifestDocker{} } } diff --git a/cf/manifest/manifest_disk_repository.go b/cf/manifest/manifest_disk_repository.go index 166e3202bd1..711e13ad18c 100644 --- a/cf/manifest/manifest_disk_repository.go +++ b/cf/manifest/manifest_disk_repository.go @@ -7,9 +7,9 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/util/generic" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/util/generic" "gopkg.in/yaml.v2" ) diff --git a/cf/manifest/manifest_disk_repository_test.go b/cf/manifest/manifest_disk_repository_test.go index 9ae516f1a7b..f1a5cc95cdd 100644 --- a/cf/manifest/manifest_disk_repository_test.go +++ b/cf/manifest/manifest_disk_repository_test.go @@ -3,8 +3,8 @@ package manifest_test import ( "path/filepath" - . "code.cloudfoundry.org/cli/cf/manifest" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/manifest" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/manifest/manifest_suite_test.go b/cf/manifest/manifest_suite_test.go index b5a7e3185c3..65682171978 100644 --- a/cf/manifest/manifest_suite_test.go +++ b/cf/manifest/manifest_suite_test.go @@ -1,9 +1,9 @@ package manifest_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/manifest/manifest_test.go b/cf/manifest/manifest_test.go index 8ea93170e16..24111d6023c 100644 --- a/cf/manifest/manifest_test.go +++ b/cf/manifest/manifest_test.go @@ -4,12 +4,12 @@ import ( "runtime" "strings" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" ) func NewManifest(path string, data generic.Map) (m *manifest.Manifest) { diff --git a/cf/manifest/manifestfakes/fake_app.go b/cf/manifest/manifestfakes/fake_app.go index 54860590aa5..f50a9f7e124 100644 --- a/cf/manifest/manifestfakes/fake_app.go +++ b/cf/manifest/manifestfakes/fake_app.go @@ -5,8 +5,8 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/cf/manifest" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/models" ) type FakeApp struct { @@ -117,9 +117,10 @@ func (fake *FakeApp) BuildpackURL(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.BuildpackURLStub fake.recordInvocation("BuildpackURL", []interface{}{arg1, arg2}) fake.buildpackURLMutex.Unlock() - if fake.BuildpackURLStub != nil { + if stub != nil { fake.BuildpackURLStub(arg1, arg2) } } @@ -149,9 +150,10 @@ func (fake *FakeApp) DiskQuota(arg1 string, arg2 int64) { arg1 string arg2 int64 }{arg1, arg2}) + stub := fake.DiskQuotaStub fake.recordInvocation("DiskQuota", []interface{}{arg1, arg2}) fake.diskQuotaMutex.Unlock() - if fake.DiskQuotaStub != nil { + if stub != nil { fake.DiskQuotaStub(arg1, arg2) } } @@ -182,9 +184,10 @@ func (fake *FakeApp) EnvironmentVars(arg1 string, arg2 string, arg3 string) { arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.EnvironmentVarsStub fake.recordInvocation("EnvironmentVars", []interface{}{arg1, arg2, arg3}) fake.environmentVarsMutex.Unlock() - if fake.EnvironmentVarsStub != nil { + if stub != nil { fake.EnvironmentVarsStub(arg1, arg2, arg3) } } @@ -213,15 +216,16 @@ func (fake *FakeApp) GetContents() []models.Application { ret, specificReturn := fake.getContentsReturnsOnCall[len(fake.getContentsArgsForCall)] fake.getContentsArgsForCall = append(fake.getContentsArgsForCall, struct { }{}) + stub := fake.GetContentsStub + fakeReturns := fake.getContentsReturns fake.recordInvocation("GetContents", []interface{}{}) fake.getContentsMutex.Unlock() - if fake.GetContentsStub != nil { - return fake.GetContentsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getContentsReturns return fakeReturns.result1 } @@ -266,9 +270,10 @@ func (fake *FakeApp) HealthCheckHTTPEndpoint(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.HealthCheckHTTPEndpointStub fake.recordInvocation("HealthCheckHTTPEndpoint", []interface{}{arg1, arg2}) fake.healthCheckHTTPEndpointMutex.Unlock() - if fake.HealthCheckHTTPEndpointStub != nil { + if stub != nil { fake.HealthCheckHTTPEndpointStub(arg1, arg2) } } @@ -298,9 +303,10 @@ func (fake *FakeApp) HealthCheckTimeout(arg1 string, arg2 int) { arg1 string arg2 int }{arg1, arg2}) + stub := fake.HealthCheckTimeoutStub fake.recordInvocation("HealthCheckTimeout", []interface{}{arg1, arg2}) fake.healthCheckTimeoutMutex.Unlock() - if fake.HealthCheckTimeoutStub != nil { + if stub != nil { fake.HealthCheckTimeoutStub(arg1, arg2) } } @@ -330,9 +336,10 @@ func (fake *FakeApp) HealthCheckType(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.HealthCheckTypeStub fake.recordInvocation("HealthCheckType", []interface{}{arg1, arg2}) fake.healthCheckTypeMutex.Unlock() - if fake.HealthCheckTypeStub != nil { + if stub != nil { fake.HealthCheckTypeStub(arg1, arg2) } } @@ -362,9 +369,10 @@ func (fake *FakeApp) Instances(arg1 string, arg2 int) { arg1 string arg2 int }{arg1, arg2}) + stub := fake.InstancesStub fake.recordInvocation("Instances", []interface{}{arg1, arg2}) fake.instancesMutex.Unlock() - if fake.InstancesStub != nil { + if stub != nil { fake.InstancesStub(arg1, arg2) } } @@ -394,9 +402,10 @@ func (fake *FakeApp) Memory(arg1 string, arg2 int64) { arg1 string arg2 int64 }{arg1, arg2}) + stub := fake.MemoryStub fake.recordInvocation("Memory", []interface{}{arg1, arg2}) fake.memoryMutex.Unlock() - if fake.MemoryStub != nil { + if stub != nil { fake.MemoryStub(arg1, arg2) } } @@ -429,9 +438,10 @@ func (fake *FakeApp) Route(arg1 string, arg2 string, arg3 string, arg4 string, a arg4 string arg5 int }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.RouteStub fake.recordInvocation("Route", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.routeMutex.Unlock() - if fake.RouteStub != nil { + if stub != nil { fake.RouteStub(arg1, arg2, arg3, arg4, arg5) } } @@ -461,15 +471,16 @@ func (fake *FakeApp) Save(arg1 io.Writer) error { fake.saveArgsForCall = append(fake.saveArgsForCall, struct { arg1 io.Writer }{arg1}) + stub := fake.SaveStub + fakeReturns := fake.saveReturns fake.recordInvocation("Save", []interface{}{arg1}) fake.saveMutex.Unlock() - if fake.SaveStub != nil { - return fake.SaveStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.saveReturns return fakeReturns.result1 } @@ -521,9 +532,10 @@ func (fake *FakeApp) Service(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.ServiceStub fake.recordInvocation("Service", []interface{}{arg1, arg2}) fake.serviceMutex.Unlock() - if fake.ServiceStub != nil { + if stub != nil { fake.ServiceStub(arg1, arg2) } } @@ -553,9 +565,10 @@ func (fake *FakeApp) Stack(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.StackStub fake.recordInvocation("Stack", []interface{}{arg1, arg2}) fake.stackMutex.Unlock() - if fake.StackStub != nil { + if stub != nil { fake.StackStub(arg1, arg2) } } @@ -585,9 +598,10 @@ func (fake *FakeApp) StartCommand(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.StartCommandStub fake.recordInvocation("StartCommand", []interface{}{arg1, arg2}) fake.startCommandMutex.Unlock() - if fake.StartCommandStub != nil { + if stub != nil { fake.StartCommandStub(arg1, arg2) } } diff --git a/cf/manifest/manifestfakes/fake_repository.go b/cf/manifest/manifestfakes/fake_repository.go index a87be0e2861..0906cc877d4 100644 --- a/cf/manifest/manifestfakes/fake_repository.go +++ b/cf/manifest/manifestfakes/fake_repository.go @@ -4,7 +4,7 @@ package manifestfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/manifest" + "code.cloudfoundry.org/cli/v8/cf/manifest" ) type FakeRepository struct { @@ -31,15 +31,16 @@ func (fake *FakeRepository) ReadManifest(arg1 string) (*manifest.Manifest, error fake.readManifestArgsForCall = append(fake.readManifestArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ReadManifestStub + fakeReturns := fake.readManifestReturns fake.recordInvocation("ReadManifest", []interface{}{arg1}) fake.readManifestMutex.Unlock() - if fake.ReadManifestStub != nil { - return fake.ReadManifestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.readManifestReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/models/application_test.go b/cf/models/application_test.go index d0fdb9efb82..4fe59542b66 100644 --- a/cf/models/application_test.go +++ b/cf/models/application_test.go @@ -3,8 +3,8 @@ package models_test import ( "os" - . "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/domain_test.go b/cf/models/domain_test.go index da359bb2af9..e270b3bff18 100644 --- a/cf/models/domain_test.go +++ b/cf/models/domain_test.go @@ -1,8 +1,8 @@ package models_test import ( - . "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/models_suite_test.go b/cf/models/models_suite_test.go index 2d4c6ded196..71cd775e549 100644 --- a/cf/models/models_suite_test.go +++ b/cf/models/models_suite_test.go @@ -1,7 +1,7 @@ package models_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/models/route_summary_test.go b/cf/models/route_summary_test.go index 4b9bd3ce4df..33ae0c7451c 100644 --- a/cf/models/route_summary_test.go +++ b/cf/models/route_summary_test.go @@ -1,9 +1,9 @@ package models_test import ( - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/route_test.go b/cf/models/route_test.go index 9bd6b291777..a93e1d27ea0 100644 --- a/cf/models/route_test.go +++ b/cf/models/route_test.go @@ -1,9 +1,9 @@ package models_test import ( - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/models" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/service_instance_test.go b/cf/models/service_instance_test.go index a46217b8007..ed211b871d5 100644 --- a/cf/models/service_instance_test.go +++ b/cf/models/service_instance_test.go @@ -1,8 +1,8 @@ package models_test import ( - . "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/service_plan_test.go b/cf/models/service_plan_test.go index e446e93cff0..c6664833400 100644 --- a/cf/models/service_plan_test.go +++ b/cf/models/service_plan_test.go @@ -1,8 +1,8 @@ package models_test import ( - . "code.cloudfoundry.org/cli/cf/models" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/models" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/models/space_quota.go b/cf/models/space_quota.go index 4edf2992ee1..8b2adcc0637 100644 --- a/cf/models/space_quota.go +++ b/cf/models/space_quota.go @@ -4,8 +4,8 @@ import ( "encoding/json" "strconv" - "code.cloudfoundry.org/cli/cf/formatters" - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/formatters" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type SpaceQuota struct { @@ -36,7 +36,7 @@ func (q SpaceQuota) FormattedInstanceMemoryLimit() string { func (q SpaceQuota) FormattedAppInstanceLimit() string { appInstanceLimit := T(UnlimitedDisplay) - if q.AppInstanceLimit != -1 { //TODO - figure out how to use resources.UnlimitedAppInstances + if q.AppInstanceLimit != -1 { // TODO - figure out how to use resources.UnlimitedAppInstances appInstanceLimit = strconv.Itoa(q.AppInstanceLimit) } diff --git a/cf/net/cloud_controller_gateway.go b/cf/net/cloud_controller_gateway.go index 449ccbf972e..6ca8581d8b5 100644 --- a/cf/net/cloud_controller_gateway.go +++ b/cf/net/cloud_controller_gateway.go @@ -5,10 +5,10 @@ import ( "strconv" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type ccErrorResponse struct { diff --git a/cf/net/cloud_controller_gateway_test.go b/cf/net/cloud_controller_gateway_test.go index d61ff7b6c26..a43863ea520 100644 --- a/cf/net/cloud_controller_gateway_test.go +++ b/cf/net/cloud_controller_gateway_test.go @@ -8,14 +8,14 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/net/gateway.go b/cf/net/gateway.go index 9a7ee4f701f..4f2f5f2f726 100644 --- a/cf/net/gateway.go +++ b/cf/net/gateway.go @@ -17,13 +17,13 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/util" - "code.cloudfoundry.org/cli/version" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/util" + "code.cloudfoundry.org/cli/v8/version" ) const ( diff --git a/cf/net/gateway_test.go b/cf/net/gateway_test.go index bdc15877344..7f97978e2dc 100644 --- a/cf/net/gateway_test.go +++ b/cf/net/gateway_test.go @@ -15,17 +15,17 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/cf/api/authentication" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/net/netfakes" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" - "code.cloudfoundry.org/cli/version" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/authentication" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/net/netfakes" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testnet "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/version" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) @@ -528,7 +528,13 @@ var _ = Describe("Gateway", func() { }) Context("when SSL validation is enabled", func() { + BeforeEach(func() { + if runtime.GOOS == "darwin" { + Skip("ssl verification is different on darwin") + } + }) It("returns an invalid cert error if the server's CA is unknown (e.g. cert is self-signed)", func() { + apiServer.TLS.Certificates = []tls.Certificate{testnet.MakeSelfSignedTLSCert()} _, apiErr := ccGateway.PerformRequest(request) diff --git a/cf/net/http_client.go b/cf/net/http_client.go index f2d26a34806..3201f9a14db 100644 --- a/cf/net/http_client.go +++ b/cf/net/http_client.go @@ -3,14 +3,15 @@ package net import ( _ "crypto/sha512" // #82254112: http://bridge.grumpy-troll.org/2014/05/golang-tls-comodo/ "crypto/x509" + asErrors "errors" "fmt" "net" "net/http" "net/url" "strings" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/i18n" "golang.org/x/net/websocket" ) @@ -83,14 +84,17 @@ func WrapNetworkErrors(host string, err error) error { } if innerErr != nil { - switch typedInnerErr := innerErr.(type) { - case x509.UnknownAuthorityError: + if asErrors.As(innerErr, &x509.UnknownAuthorityError{}) { return errors.NewInvalidSSLCert(host, T("unknown authority")) - case x509.HostnameError: + } + if asErrors.As(innerErr, &x509.HostnameError{}) { return errors.NewInvalidSSLCert(host, T("not valid for the requested host")) - case x509.CertificateInvalidError: + } + if asErrors.As(innerErr, &x509.CertificateInvalidError{}) { return errors.NewInvalidSSLCert(host, "") - case *net.OpError: + } + typedInnerErr := new(net.OpError) + if asErrors.As(innerErr, &typedInnerErr) { if typedInnerErr.Op == "dial" { return fmt.Errorf("%s: %s\n%s", T("Error performing request"), err.Error(), T("TIP: If you are behind a firewall and require an HTTP proxy, verify the https_proxy environment variable is correctly set. Else, check your network connection.")) } diff --git a/cf/net/http_client_test.go b/cf/net/http_client_test.go index 63cb0c7c6cb..9379ebfea0d 100644 --- a/cf/net/http_client_test.go +++ b/cf/net/http_client_test.go @@ -7,10 +7,10 @@ import ( "net/url" "syscall" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "golang.org/x/net/websocket" ) diff --git a/cf/net/net_suite_test.go b/cf/net/net_suite_test.go index 6c7da8e1cfa..90ad9b50df8 100644 --- a/cf/net/net_suite_test.go +++ b/cf/net/net_suite_test.go @@ -1,9 +1,9 @@ package net_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/net/netfakes/fake_httpclient_interface.go b/cf/net/netfakes/fake_httpclient_interface.go index 9040eef181c..ac66593af0b 100644 --- a/cf/net/netfakes/fake_httpclient_interface.go +++ b/cf/net/netfakes/fake_httpclient_interface.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/net" ) type FakeHTTPClientInterface struct { @@ -54,15 +54,16 @@ func (fake *FakeHTTPClientInterface) Do(arg1 *http.Request) (*http.Response, err fake.doArgsForCall = append(fake.doArgsForCall, struct { arg1 *http.Request }{arg1}) + stub := fake.DoStub + fakeReturns := fake.doReturns fake.recordInvocation("Do", []interface{}{arg1}) fake.doMutex.Unlock() - if fake.DoStub != nil { - return fake.DoStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.doReturns return fakeReturns.result1, fakeReturns.result2 } @@ -116,9 +117,10 @@ func (fake *FakeHTTPClientInterface) DumpRequest(arg1 *http.Request) { fake.dumpRequestArgsForCall = append(fake.dumpRequestArgsForCall, struct { arg1 *http.Request }{arg1}) + stub := fake.DumpRequestStub fake.recordInvocation("DumpRequest", []interface{}{arg1}) fake.dumpRequestMutex.Unlock() - if fake.DumpRequestStub != nil { + if stub != nil { fake.DumpRequestStub(arg1) } } @@ -147,9 +149,10 @@ func (fake *FakeHTTPClientInterface) DumpResponse(arg1 *http.Response) { fake.dumpResponseArgsForCall = append(fake.dumpResponseArgsForCall, struct { arg1 *http.Response }{arg1}) + stub := fake.DumpResponseStub fake.recordInvocation("DumpResponse", []interface{}{arg1}) fake.dumpResponseMutex.Unlock() - if fake.DumpResponseStub != nil { + if stub != nil { fake.DumpResponseStub(arg1) } } @@ -185,15 +188,16 @@ func (fake *FakeHTTPClientInterface) ExecuteCheckRedirect(arg1 *http.Request, ar arg1 *http.Request arg2 []*http.Request }{arg1, arg2Copy}) + stub := fake.ExecuteCheckRedirectStub + fakeReturns := fake.executeCheckRedirectReturns fake.recordInvocation("ExecuteCheckRedirect", []interface{}{arg1, arg2Copy}) fake.executeCheckRedirectMutex.Unlock() - if fake.ExecuteCheckRedirectStub != nil { - return fake.ExecuteCheckRedirectStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeCheckRedirectReturns return fakeReturns.result1 } diff --git a/cf/net/netfakes/fake_request_dumper_interface.go b/cf/net/netfakes/fake_request_dumper_interface.go index 19350408b1a..56ee5f7582c 100644 --- a/cf/net/netfakes/fake_request_dumper_interface.go +++ b/cf/net/netfakes/fake_request_dumper_interface.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/net" ) type FakeRequestDumperInterface struct { @@ -28,9 +28,10 @@ func (fake *FakeRequestDumperInterface) DumpRequest(arg1 *http.Request) { fake.dumpRequestArgsForCall = append(fake.dumpRequestArgsForCall, struct { arg1 *http.Request }{arg1}) + stub := fake.DumpRequestStub fake.recordInvocation("DumpRequest", []interface{}{arg1}) fake.dumpRequestMutex.Unlock() - if fake.DumpRequestStub != nil { + if stub != nil { fake.DumpRequestStub(arg1) } } @@ -59,9 +60,10 @@ func (fake *FakeRequestDumperInterface) DumpResponse(arg1 *http.Response) { fake.dumpResponseArgsForCall = append(fake.dumpResponseArgsForCall, struct { arg1 *http.Response }{arg1}) + stub := fake.DumpResponseStub fake.recordInvocation("DumpResponse", []interface{}{arg1}) fake.dumpResponseMutex.Unlock() - if fake.DumpResponseStub != nil { + if stub != nil { fake.DumpResponseStub(arg1) } } diff --git a/cf/net/netfakes/fake_warning_producer.go b/cf/net/netfakes/fake_warning_producer.go index d21e5364852..528f8eacefa 100644 --- a/cf/net/netfakes/fake_warning_producer.go +++ b/cf/net/netfakes/fake_warning_producer.go @@ -4,7 +4,7 @@ package netfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/net" + "code.cloudfoundry.org/cli/v8/cf/net" ) type FakeWarningProducer struct { @@ -27,15 +27,16 @@ func (fake *FakeWarningProducer) Warnings() []string { ret, specificReturn := fake.warningsReturnsOnCall[len(fake.warningsArgsForCall)] fake.warningsArgsForCall = append(fake.warningsArgsForCall, struct { }{}) + stub := fake.WarningsStub + fakeReturns := fake.warningsReturns fake.recordInvocation("Warnings", []interface{}{}) fake.warningsMutex.Unlock() - if fake.WarningsStub != nil { - return fake.WarningsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.warningsReturns return fakeReturns.result1 } diff --git a/cf/net/progress_reader.go b/cf/net/progress_reader.go index 8716cafd980..61d20f5dcf9 100644 --- a/cf/net/progress_reader.go +++ b/cf/net/progress_reader.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/cf/formatters" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/formatters" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type ProgressReader struct { @@ -67,8 +67,8 @@ func (progressReader *ProgressReader) printProgress(quit chan bool) { for { select { case <-quit: - //The spaces are there to ensure we overwrite the entire line - //before using the terminal printer to output Done Uploading + // The spaces are there to ensure we overwrite the entire line + // before using the terminal printer to output Done Uploading progressReader.ui.PrintCapturingNoOutput("\r ") progressReader.ui.Say("\rDone uploading") return diff --git a/cf/net/progress_reader_test.go b/cf/net/progress_reader_test.go index 9e220268991..f34e5898dc1 100644 --- a/cf/net/progress_reader_test.go +++ b/cf/net/progress_reader_test.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package net_test @@ -6,9 +7,9 @@ import ( "os" "time" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/net/request_dumper.go b/cf/net/request_dumper.go index 18670114846..ba8a77b2445 100644 --- a/cf/net/request_dumper.go +++ b/cf/net/request_dumper.go @@ -11,10 +11,10 @@ import ( "strings" "time" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/util/ui" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/util/ui" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RequestDumperInterface diff --git a/cf/net/request_dumper_test.go b/cf/net/request_dumper_test.go index 465f61e732d..43db9036be5 100644 --- a/cf/net/request_dumper_test.go +++ b/cf/net/request_dumper_test.go @@ -5,9 +5,9 @@ import ( "net/http" "strings" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/trace" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/trace" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/net/routing_api_gateway.go b/cf/net/routing_api_gateway.go index c186a87c1d8..d07e97c8b32 100644 --- a/cf/net/routing_api_gateway.go +++ b/cf/net/routing_api_gateway.go @@ -5,10 +5,10 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type errorResponse struct { diff --git a/cf/net/routing_api_gateway_test.go b/cf/net/routing_api_gateway_test.go index 92e77ea2f5c..94d4dcb5a2e 100644 --- a/cf/net/routing_api_gateway_test.go +++ b/cf/net/routing_api_gateway_test.go @@ -6,13 +6,13 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/net/uaa_gateway.go b/cf/net/uaa_gateway.go index 29d9105062c..ee2b3294b17 100644 --- a/cf/net/uaa_gateway.go +++ b/cf/net/uaa_gateway.go @@ -4,10 +4,10 @@ import ( "encoding/json" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type uaaErrorResponse struct { diff --git a/cf/net/uaa_gateway_test.go b/cf/net/uaa_gateway_test.go index 306007f2d72..16bc93d9c6c 100644 --- a/cf/net/uaa_gateway_test.go +++ b/cf/net/uaa_gateway_test.go @@ -6,13 +6,13 @@ import ( "net/http/httptest" "time" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - . "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + . "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/net/warnings_collector.go b/cf/net/warnings_collector.go index 0ae16613dcd..600ef8ad4a7 100644 --- a/cf/net/warnings_collector.go +++ b/cf/net/warnings_collector.go @@ -1,11 +1,12 @@ package net import ( - "fmt" "os" "strings" - "code.cloudfoundry.org/cli/cf/terminal" + "errors" + + "code.cloudfoundry.org/cli/v8/cf/terminal" ) const DeprecatedEndpointWarning = "Endpoint deprecated" @@ -41,7 +42,7 @@ func (warningsCollector WarningsCollector) PrintWarnings() error { if os.Getenv("CF_RAISE_ERROR_ON_WARNINGS") != "" { if len(warnings) > 0 { - return fmt.Errorf(strings.Join(warnings, "\n")) + return errors.New(strings.Join(warnings, "\n")) } } diff --git a/cf/net/warnings_collector_test.go b/cf/net/warnings_collector_test.go index 8e62bc1de7b..ac6e5527eb2 100644 --- a/cf/net/warnings_collector_test.go +++ b/cf/net/warnings_collector_test.go @@ -3,10 +3,10 @@ package net_test import ( "os" - "code.cloudfoundry.org/cli/cf/net" - "code.cloudfoundry.org/cli/cf/net/netfakes" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/net" + "code.cloudfoundry.org/cli/v8/cf/net/netfakes" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/api_endpoint.go b/cf/requirements/api_endpoint.go index 6208289630d..a27d0a68c79 100644 --- a/cf/requirements/api_endpoint.go +++ b/cf/requirements/api_endpoint.go @@ -5,10 +5,10 @@ import ( "errors" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type APIEndpointRequirement struct { diff --git a/cf/requirements/api_endpoint_test.go b/cf/requirements/api_endpoint_test.go index 32ff9d12d10..c4d6a702a2b 100644 --- a/cf/requirements/api_endpoint_test.go +++ b/cf/requirements/api_endpoint_test.go @@ -1,10 +1,10 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/requirements" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/application.go b/cf/requirements/application.go index 3ce04a99cbc..8159a5d00fb 100644 --- a/cf/requirements/application.go +++ b/cf/requirements/application.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ApplicationRequirement diff --git a/cf/requirements/application_test.go b/cf/requirements/application_test.go index 7287bcda01a..79168699b6e 100644 --- a/cf/requirements/application_test.go +++ b/cf/requirements/application_test.go @@ -1,11 +1,11 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/buildpack.go b/cf/requirements/buildpack.go index 0f8981e3da3..5958260a6dc 100644 --- a/cf/requirements/buildpack.go +++ b/cf/requirements/buildpack.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . BuildpackRequirement diff --git a/cf/requirements/buildpack_test.go b/cf/requirements/buildpack_test.go index f9128a0a1f7..d6c4957460a 100644 --- a/cf/requirements/buildpack_test.go +++ b/cf/requirements/buildpack_test.go @@ -1,10 +1,10 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/config_refreshing_requirement.go b/cf/requirements/config_refreshing_requirement.go index a6f46179b7b..c14a57f99d2 100644 --- a/cf/requirements/config_refreshing_requirement.go +++ b/cf/requirements/config_refreshing_requirement.go @@ -1,6 +1,6 @@ package requirements -import "code.cloudfoundry.org/cli/cf/configuration/coreconfig" +import "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" type configRefreshingRequirement struct { requirement Requirement diff --git a/cf/requirements/config_refreshing_requirement_test.go b/cf/requirements/config_refreshing_requirement_test.go index 4bb706a6a35..5624a212c66 100644 --- a/cf/requirements/config_refreshing_requirement_test.go +++ b/cf/requirements/config_refreshing_requirement_test.go @@ -1,12 +1,12 @@ package requirements_test import ( - . "code.cloudfoundry.org/cli/cf/requirements" + . "code.cloudfoundry.org/cli/v8/cf/requirements" "errors" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/dea_application.go b/cf/requirements/dea_application.go index 747c9d42e4d..07cd2d1b280 100644 --- a/cf/requirements/dea_application.go +++ b/cf/requirements/dea_application.go @@ -1,10 +1,10 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api/applications" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/api/applications" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . DEAApplicationRequirement diff --git a/cf/requirements/dea_application_test.go b/cf/requirements/dea_application_test.go index b3feee872d2..3770ad37538 100644 --- a/cf/requirements/dea_application_test.go +++ b/cf/requirements/dea_application_test.go @@ -3,12 +3,12 @@ package requirements_test import ( "errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" - "code.cloudfoundry.org/cli/cf/api/applications/applicationsfakes" + "code.cloudfoundry.org/cli/v8/cf/api/applications/applicationsfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/domain.go b/cf/requirements/domain.go index 72d9d01d212..bbd1746a65d 100644 --- a/cf/requirements/domain.go +++ b/cf/requirements/domain.go @@ -1,9 +1,9 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . DomainRequirement diff --git a/cf/requirements/domain_test.go b/cf/requirements/domain_test.go index c855b44dca8..ae63f62e153 100644 --- a/cf/requirements/domain_test.go +++ b/cf/requirements/domain_test.go @@ -1,13 +1,13 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/factory.go b/cf/requirements/factory.go index 39429fad48c..cba1dfaccba 100644 --- a/cf/requirements/factory.go +++ b/cf/requirements/factory.go @@ -1,9 +1,9 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "github.com/blang/semver/v4" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Factory diff --git a/cf/requirements/login.go b/cf/requirements/login.go index 05e54315a79..d7f1f724d1c 100644 --- a/cf/requirements/login.go +++ b/cf/requirements/login.go @@ -3,8 +3,8 @@ package requirements import ( "errors" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type LoginRequirement struct { diff --git a/cf/requirements/login_test.go b/cf/requirements/login_test.go index 0a8b19f6df6..883113afc6f 100644 --- a/cf/requirements/login_test.go +++ b/cf/requirements/login_test.go @@ -1,12 +1,12 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" ) var _ = Describe("LoginRequirement", func() { diff --git a/cf/requirements/max_api_version.go b/cf/requirements/max_api_version.go index 8cebdb293cf..9639145c27d 100644 --- a/cf/requirements/max_api_version.go +++ b/cf/requirements/max_api_version.go @@ -3,10 +3,10 @@ package requirements import ( "errors" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "github.com/blang/semver/v4" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type MaxAPIVersionRequirement struct { diff --git a/cf/requirements/max_api_version_test.go b/cf/requirements/max_api_version_test.go index b25fd23bb19..32f0b7d9b9c 100644 --- a/cf/requirements/max_api_version_test.go +++ b/cf/requirements/max_api_version_test.go @@ -1,13 +1,13 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "github.com/blang/semver/v4" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/min_api_version.go b/cf/requirements/min_api_version.go index 30b1902a4cb..48c60259654 100644 --- a/cf/requirements/min_api_version.go +++ b/cf/requirements/min_api_version.go @@ -3,10 +3,10 @@ package requirements import ( "errors" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "github.com/blang/semver/v4" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type MinAPIVersionRequirement struct { diff --git a/cf/requirements/min_api_version_test.go b/cf/requirements/min_api_version_test.go index ec960648a60..aa1c58b5076 100644 --- a/cf/requirements/min_api_version_test.go +++ b/cf/requirements/min_api_version_test.go @@ -1,13 +1,13 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "github.com/blang/semver/v4" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/number_arguments.go b/cf/requirements/number_arguments.go index 36672dabf66..fe21784c1a0 100644 --- a/cf/requirements/number_arguments.go +++ b/cf/requirements/number_arguments.go @@ -3,7 +3,7 @@ package requirements import ( "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type NumberArguments struct { diff --git a/cf/requirements/number_arguments_test.go b/cf/requirements/number_arguments_test.go index 8725a373c0a..06564365f1f 100644 --- a/cf/requirements/number_arguments_test.go +++ b/cf/requirements/number_arguments_test.go @@ -1,9 +1,9 @@ package requirements_test import ( - . "code.cloudfoundry.org/cli/cf/requirements" + . "code.cloudfoundry.org/cli/v8/cf/requirements" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/organization.go b/cf/requirements/organization.go index 96d1c8d8007..54dbd02d3fd 100644 --- a/cf/requirements/organization.go +++ b/cf/requirements/organization.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api/organizations" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/organizations" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . OrganizationRequirement diff --git a/cf/requirements/organization_test.go b/cf/requirements/organization_test.go index 22a0580200f..052e50e14ff 100644 --- a/cf/requirements/organization_test.go +++ b/cf/requirements/organization_test.go @@ -3,10 +3,10 @@ package requirements_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/organizations/organizationsfakes" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/organizations/organizationsfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/requirements_suite_test.go b/cf/requirements/requirements_suite_test.go index 7d694ce9fff..7e89ce08294 100644 --- a/cf/requirements/requirements_suite_test.go +++ b/cf/requirements/requirements_suite_test.go @@ -1,9 +1,9 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/requirements/requirements_test.go b/cf/requirements/requirements_test.go index 727da97f6fe..30cf87780a9 100644 --- a/cf/requirements/requirements_test.go +++ b/cf/requirements/requirements_test.go @@ -1,11 +1,11 @@ package requirements_test import ( - . "code.cloudfoundry.org/cli/cf/requirements" + . "code.cloudfoundry.org/cli/v8/cf/requirements" - "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" + "code.cloudfoundry.org/cli/v8/cf/requirements/requirementsfakes" "errors" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/requirementsfakes/fake_application_requirement.go b/cf/requirements/requirementsfakes/fake_application_requirement.go index b165f5a7c20..04e08ea004a 100644 --- a/cf/requirements/requirementsfakes/fake_application_requirement.go +++ b/cf/requirements/requirementsfakes/fake_application_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeApplicationRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeApplicationRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeApplicationRequirement) GetApplication() models.Application { ret, specificReturn := fake.getApplicationReturnsOnCall[len(fake.getApplicationArgsForCall)] fake.getApplicationArgsForCall = append(fake.getApplicationArgsForCall, struct { }{}) + stub := fake.GetApplicationStub + fakeReturns := fake.getApplicationReturns fake.recordInvocation("GetApplication", []interface{}{}) fake.getApplicationMutex.Unlock() - if fake.GetApplicationStub != nil { - return fake.GetApplicationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getApplicationReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_buildpack_requirement.go b/cf/requirements/requirementsfakes/fake_buildpack_requirement.go index 531ae8e0591..2db82f479d3 100644 --- a/cf/requirements/requirementsfakes/fake_buildpack_requirement.go +++ b/cf/requirements/requirementsfakes/fake_buildpack_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeBuildpackRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeBuildpackRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeBuildpackRequirement) GetBuildpack() models.Buildpack { ret, specificReturn := fake.getBuildpackReturnsOnCall[len(fake.getBuildpackArgsForCall)] fake.getBuildpackArgsForCall = append(fake.getBuildpackArgsForCall, struct { }{}) + stub := fake.GetBuildpackStub + fakeReturns := fake.getBuildpackReturns fake.recordInvocation("GetBuildpack", []interface{}{}) fake.getBuildpackMutex.Unlock() - if fake.GetBuildpackStub != nil { - return fake.GetBuildpackStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getBuildpackReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_config_refresher.go b/cf/requirements/requirementsfakes/fake_config_refresher.go index 2a602ba115d..fb5edc8eb22 100644 --- a/cf/requirements/requirementsfakes/fake_config_refresher.go +++ b/cf/requirements/requirementsfakes/fake_config_refresher.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeConfigRefresher struct { @@ -30,15 +30,16 @@ func (fake *FakeConfigRefresher) Refresh() (coreconfig.Warning, error) { ret, specificReturn := fake.refreshReturnsOnCall[len(fake.refreshArgsForCall)] fake.refreshArgsForCall = append(fake.refreshArgsForCall, struct { }{}) + stub := fake.RefreshStub + fakeReturns := fake.refreshReturns fake.recordInvocation("Refresh", []interface{}{}) fake.refreshMutex.Unlock() - if fake.RefreshStub != nil { - return fake.RefreshStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/requirements/requirementsfakes/fake_deaapplication_requirement.go b/cf/requirements/requirementsfakes/fake_deaapplication_requirement.go index 282f0047e0d..cd3e7b9c6dd 100644 --- a/cf/requirements/requirementsfakes/fake_deaapplication_requirement.go +++ b/cf/requirements/requirementsfakes/fake_deaapplication_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeDEAApplicationRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeDEAApplicationRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeDEAApplicationRequirement) GetApplication() models.Application { ret, specificReturn := fake.getApplicationReturnsOnCall[len(fake.getApplicationArgsForCall)] fake.getApplicationArgsForCall = append(fake.getApplicationArgsForCall, struct { }{}) + stub := fake.GetApplicationStub + fakeReturns := fake.getApplicationReturns fake.recordInvocation("GetApplication", []interface{}{}) fake.getApplicationMutex.Unlock() - if fake.GetApplicationStub != nil { - return fake.GetApplicationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getApplicationReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_domain_requirement.go b/cf/requirements/requirementsfakes/fake_domain_requirement.go index 0e1bdca81d3..dbd356225c7 100644 --- a/cf/requirements/requirementsfakes/fake_domain_requirement.go +++ b/cf/requirements/requirementsfakes/fake_domain_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeDomainRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeDomainRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeDomainRequirement) GetDomain() models.DomainFields { ret, specificReturn := fake.getDomainReturnsOnCall[len(fake.getDomainArgsForCall)] fake.getDomainArgsForCall = append(fake.getDomainArgsForCall, struct { }{}) + stub := fake.GetDomainStub + fakeReturns := fake.getDomainReturns fake.recordInvocation("GetDomain", []interface{}{}) fake.getDomainMutex.Unlock() - if fake.GetDomainStub != nil { - return fake.GetDomainStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getDomainReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_factory.go b/cf/requirements/requirementsfakes/fake_factory.go index c6351e2ecdf..49fb668c180 100644 --- a/cf/requirements/requirementsfakes/fake_factory.go +++ b/cf/requirements/requirementsfakes/fake_factory.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/requirements" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/cf/requirements" + semver "github.com/blang/semver/v4" ) type FakeFactory struct { @@ -219,15 +219,16 @@ func (fake *FakeFactory) NewAPIEndpointRequirement() requirements.Requirement { ret, specificReturn := fake.newAPIEndpointRequirementReturnsOnCall[len(fake.newAPIEndpointRequirementArgsForCall)] fake.newAPIEndpointRequirementArgsForCall = append(fake.newAPIEndpointRequirementArgsForCall, struct { }{}) + stub := fake.NewAPIEndpointRequirementStub + fakeReturns := fake.newAPIEndpointRequirementReturns fake.recordInvocation("NewAPIEndpointRequirement", []interface{}{}) fake.newAPIEndpointRequirementMutex.Unlock() - if fake.NewAPIEndpointRequirementStub != nil { - return fake.NewAPIEndpointRequirementStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.newAPIEndpointRequirementReturns return fakeReturns.result1 } @@ -272,15 +273,16 @@ func (fake *FakeFactory) NewApplicationRequirement(arg1 string) requirements.App fake.newApplicationRequirementArgsForCall = append(fake.newApplicationRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewApplicationRequirementStub + fakeReturns := fake.newApplicationRequirementReturns fake.recordInvocation("NewApplicationRequirement", []interface{}{arg1}) fake.newApplicationRequirementMutex.Unlock() - if fake.NewApplicationRequirementStub != nil { - return fake.NewApplicationRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newApplicationRequirementReturns return fakeReturns.result1 } @@ -333,15 +335,16 @@ func (fake *FakeFactory) NewBuildpackRequirement(arg1 string, arg2 string) requi arg1 string arg2 string }{arg1, arg2}) + stub := fake.NewBuildpackRequirementStub + fakeReturns := fake.newBuildpackRequirementReturns fake.recordInvocation("NewBuildpackRequirement", []interface{}{arg1, arg2}) fake.newBuildpackRequirementMutex.Unlock() - if fake.NewBuildpackRequirementStub != nil { - return fake.NewBuildpackRequirementStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newBuildpackRequirementReturns return fakeReturns.result1 } @@ -393,15 +396,16 @@ func (fake *FakeFactory) NewClientRequirement(arg1 string) requirements.UserRequ fake.newClientRequirementArgsForCall = append(fake.newClientRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewClientRequirementStub + fakeReturns := fake.newClientRequirementReturns fake.recordInvocation("NewClientRequirement", []interface{}{arg1}) fake.newClientRequirementMutex.Unlock() - if fake.NewClientRequirementStub != nil { - return fake.NewClientRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newClientRequirementReturns return fakeReturns.result1 } @@ -453,15 +457,16 @@ func (fake *FakeFactory) NewDEAApplicationRequirement(arg1 string) requirements. fake.newDEAApplicationRequirementArgsForCall = append(fake.newDEAApplicationRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewDEAApplicationRequirementStub + fakeReturns := fake.newDEAApplicationRequirementReturns fake.recordInvocation("NewDEAApplicationRequirement", []interface{}{arg1}) fake.newDEAApplicationRequirementMutex.Unlock() - if fake.NewDEAApplicationRequirementStub != nil { - return fake.NewDEAApplicationRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newDEAApplicationRequirementReturns return fakeReturns.result1 } @@ -513,15 +518,16 @@ func (fake *FakeFactory) NewDomainRequirement(arg1 string) requirements.DomainRe fake.newDomainRequirementArgsForCall = append(fake.newDomainRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewDomainRequirementStub + fakeReturns := fake.newDomainRequirementReturns fake.recordInvocation("NewDomainRequirement", []interface{}{arg1}) fake.newDomainRequirementMutex.Unlock() - if fake.NewDomainRequirementStub != nil { - return fake.NewDomainRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newDomainRequirementReturns return fakeReturns.result1 } @@ -572,15 +578,16 @@ func (fake *FakeFactory) NewLoginRequirement() requirements.Requirement { ret, specificReturn := fake.newLoginRequirementReturnsOnCall[len(fake.newLoginRequirementArgsForCall)] fake.newLoginRequirementArgsForCall = append(fake.newLoginRequirementArgsForCall, struct { }{}) + stub := fake.NewLoginRequirementStub + fakeReturns := fake.newLoginRequirementReturns fake.recordInvocation("NewLoginRequirement", []interface{}{}) fake.newLoginRequirementMutex.Unlock() - if fake.NewLoginRequirementStub != nil { - return fake.NewLoginRequirementStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.newLoginRequirementReturns return fakeReturns.result1 } @@ -626,15 +633,16 @@ func (fake *FakeFactory) NewMaxAPIVersionRequirement(arg1 string, arg2 semver.Ve arg1 string arg2 semver.Version }{arg1, arg2}) + stub := fake.NewMaxAPIVersionRequirementStub + fakeReturns := fake.newMaxAPIVersionRequirementReturns fake.recordInvocation("NewMaxAPIVersionRequirement", []interface{}{arg1, arg2}) fake.newMaxAPIVersionRequirementMutex.Unlock() - if fake.NewMaxAPIVersionRequirementStub != nil { - return fake.NewMaxAPIVersionRequirementStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newMaxAPIVersionRequirementReturns return fakeReturns.result1 } @@ -687,15 +695,16 @@ func (fake *FakeFactory) NewMinAPIVersionRequirement(arg1 string, arg2 semver.Ve arg1 string arg2 semver.Version }{arg1, arg2}) + stub := fake.NewMinAPIVersionRequirementStub + fakeReturns := fake.newMinAPIVersionRequirementReturns fake.recordInvocation("NewMinAPIVersionRequirement", []interface{}{arg1, arg2}) fake.newMinAPIVersionRequirementMutex.Unlock() - if fake.NewMinAPIVersionRequirementStub != nil { - return fake.NewMinAPIVersionRequirementStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newMinAPIVersionRequirementReturns return fakeReturns.result1 } @@ -753,15 +762,16 @@ func (fake *FakeFactory) NewNumberArguments(arg1 []string, arg2 ...string) requi arg1 []string arg2 []string }{arg1Copy, arg2}) + stub := fake.NewNumberArgumentsStub + fakeReturns := fake.newNumberArgumentsReturns fake.recordInvocation("NewNumberArguments", []interface{}{arg1Copy, arg2}) fake.newNumberArgumentsMutex.Unlock() - if fake.NewNumberArgumentsStub != nil { - return fake.NewNumberArgumentsStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1 } - fakeReturns := fake.newNumberArgumentsReturns return fakeReturns.result1 } @@ -813,15 +823,16 @@ func (fake *FakeFactory) NewOrganizationRequirement(arg1 string) requirements.Or fake.newOrganizationRequirementArgsForCall = append(fake.newOrganizationRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewOrganizationRequirementStub + fakeReturns := fake.newOrganizationRequirementReturns fake.recordInvocation("NewOrganizationRequirement", []interface{}{arg1}) fake.newOrganizationRequirementMutex.Unlock() - if fake.NewOrganizationRequirementStub != nil { - return fake.NewOrganizationRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newOrganizationRequirementReturns return fakeReturns.result1 } @@ -873,15 +884,16 @@ func (fake *FakeFactory) NewServiceInstanceRequirement(arg1 string) requirements fake.newServiceInstanceRequirementArgsForCall = append(fake.newServiceInstanceRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewServiceInstanceRequirementStub + fakeReturns := fake.newServiceInstanceRequirementReturns fake.recordInvocation("NewServiceInstanceRequirement", []interface{}{arg1}) fake.newServiceInstanceRequirementMutex.Unlock() - if fake.NewServiceInstanceRequirementStub != nil { - return fake.NewServiceInstanceRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newServiceInstanceRequirementReturns return fakeReturns.result1 } @@ -933,15 +945,16 @@ func (fake *FakeFactory) NewSpaceRequirement(arg1 string) requirements.SpaceRequ fake.newSpaceRequirementArgsForCall = append(fake.newSpaceRequirementArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NewSpaceRequirementStub + fakeReturns := fake.newSpaceRequirementReturns fake.recordInvocation("NewSpaceRequirement", []interface{}{arg1}) fake.newSpaceRequirementMutex.Unlock() - if fake.NewSpaceRequirementStub != nil { - return fake.NewSpaceRequirementStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newSpaceRequirementReturns return fakeReturns.result1 } @@ -992,15 +1005,16 @@ func (fake *FakeFactory) NewTargetedOrgRequirement() requirements.TargetedOrgReq ret, specificReturn := fake.newTargetedOrgRequirementReturnsOnCall[len(fake.newTargetedOrgRequirementArgsForCall)] fake.newTargetedOrgRequirementArgsForCall = append(fake.newTargetedOrgRequirementArgsForCall, struct { }{}) + stub := fake.NewTargetedOrgRequirementStub + fakeReturns := fake.newTargetedOrgRequirementReturns fake.recordInvocation("NewTargetedOrgRequirement", []interface{}{}) fake.newTargetedOrgRequirementMutex.Unlock() - if fake.NewTargetedOrgRequirementStub != nil { - return fake.NewTargetedOrgRequirementStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.newTargetedOrgRequirementReturns return fakeReturns.result1 } @@ -1044,15 +1058,16 @@ func (fake *FakeFactory) NewTargetedSpaceRequirement() requirements.Requirement ret, specificReturn := fake.newTargetedSpaceRequirementReturnsOnCall[len(fake.newTargetedSpaceRequirementArgsForCall)] fake.newTargetedSpaceRequirementArgsForCall = append(fake.newTargetedSpaceRequirementArgsForCall, struct { }{}) + stub := fake.NewTargetedSpaceRequirementStub + fakeReturns := fake.newTargetedSpaceRequirementReturns fake.recordInvocation("NewTargetedSpaceRequirement", []interface{}{}) fake.newTargetedSpaceRequirementMutex.Unlock() - if fake.NewTargetedSpaceRequirementStub != nil { - return fake.NewTargetedSpaceRequirementStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.newTargetedSpaceRequirementReturns return fakeReturns.result1 } @@ -1097,15 +1112,16 @@ func (fake *FakeFactory) NewUnsupportedLegacyFlagRequirement(arg1 ...string) req fake.newUnsupportedLegacyFlagRequirementArgsForCall = append(fake.newUnsupportedLegacyFlagRequirementArgsForCall, struct { arg1 []string }{arg1}) + stub := fake.NewUnsupportedLegacyFlagRequirementStub + fakeReturns := fake.newUnsupportedLegacyFlagRequirementReturns fake.recordInvocation("NewUnsupportedLegacyFlagRequirement", []interface{}{arg1}) fake.newUnsupportedLegacyFlagRequirementMutex.Unlock() - if fake.NewUnsupportedLegacyFlagRequirementStub != nil { - return fake.NewUnsupportedLegacyFlagRequirementStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1 } - fakeReturns := fake.newUnsupportedLegacyFlagRequirementReturns return fakeReturns.result1 } @@ -1159,15 +1175,16 @@ func (fake *FakeFactory) NewUsageRequirement(arg1 requirements.Usable, arg2 stri arg2 string arg3 func() bool }{arg1, arg2, arg3}) + stub := fake.NewUsageRequirementStub + fakeReturns := fake.newUsageRequirementReturns fake.recordInvocation("NewUsageRequirement", []interface{}{arg1, arg2, arg3}) fake.newUsageRequirementMutex.Unlock() - if fake.NewUsageRequirementStub != nil { - return fake.NewUsageRequirementStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.newUsageRequirementReturns return fakeReturns.result1 } @@ -1220,15 +1237,16 @@ func (fake *FakeFactory) NewUserRequirement(arg1 string, arg2 bool) requirements arg1 string arg2 bool }{arg1, arg2}) + stub := fake.NewUserRequirementStub + fakeReturns := fake.newUserRequirementReturns fake.recordInvocation("NewUserRequirement", []interface{}{arg1, arg2}) fake.newUserRequirementMutex.Unlock() - if fake.NewUserRequirementStub != nil { - return fake.NewUserRequirementStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newUserRequirementReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_organization_requirement.go b/cf/requirements/requirementsfakes/fake_organization_requirement.go index c9b1752a1ec..2d8f4ba59a0 100644 --- a/cf/requirements/requirementsfakes/fake_organization_requirement.go +++ b/cf/requirements/requirementsfakes/fake_organization_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeOrganizationRequirement struct { @@ -43,15 +43,16 @@ func (fake *FakeOrganizationRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -95,15 +96,16 @@ func (fake *FakeOrganizationRequirement) GetOrganization() models.Organization { ret, specificReturn := fake.getOrganizationReturnsOnCall[len(fake.getOrganizationArgsForCall)] fake.getOrganizationArgsForCall = append(fake.getOrganizationArgsForCall, struct { }{}) + stub := fake.GetOrganizationStub + fakeReturns := fake.getOrganizationReturns fake.recordInvocation("GetOrganization", []interface{}{}) fake.getOrganizationMutex.Unlock() - if fake.GetOrganizationStub != nil { - return fake.GetOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getOrganizationReturns return fakeReturns.result1 } @@ -147,9 +149,10 @@ func (fake *FakeOrganizationRequirement) SetOrganizationName(arg1 string) { fake.setOrganizationNameArgsForCall = append(fake.setOrganizationNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetOrganizationNameStub fake.recordInvocation("SetOrganizationName", []interface{}{arg1}) fake.setOrganizationNameMutex.Unlock() - if fake.SetOrganizationNameStub != nil { + if stub != nil { fake.SetOrganizationNameStub(arg1) } } diff --git a/cf/requirements/requirementsfakes/fake_requirement.go b/cf/requirements/requirementsfakes/fake_requirement.go index 0ebc0b1a938..5a9ccfa8a3b 100644 --- a/cf/requirements/requirementsfakes/fake_requirement.go +++ b/cf/requirements/requirementsfakes/fake_requirement.go @@ -4,7 +4,7 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeRequirement struct { @@ -27,15 +27,16 @@ func (fake *FakeRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_service_instance_requirement.go b/cf/requirements/requirementsfakes/fake_service_instance_requirement.go index 52a9c81065a..fde73c93af5 100644 --- a/cf/requirements/requirementsfakes/fake_service_instance_requirement.go +++ b/cf/requirements/requirementsfakes/fake_service_instance_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeServiceInstanceRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeServiceInstanceRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeServiceInstanceRequirement) GetServiceInstance() models.ServiceI ret, specificReturn := fake.getServiceInstanceReturnsOnCall[len(fake.getServiceInstanceArgsForCall)] fake.getServiceInstanceArgsForCall = append(fake.getServiceInstanceArgsForCall, struct { }{}) + stub := fake.GetServiceInstanceStub + fakeReturns := fake.getServiceInstanceReturns fake.recordInvocation("GetServiceInstance", []interface{}{}) fake.getServiceInstanceMutex.Unlock() - if fake.GetServiceInstanceStub != nil { - return fake.GetServiceInstanceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getServiceInstanceReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_space_requirement.go b/cf/requirements/requirementsfakes/fake_space_requirement.go index 12758455c70..0b233d6354c 100644 --- a/cf/requirements/requirementsfakes/fake_space_requirement.go +++ b/cf/requirements/requirementsfakes/fake_space_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeSpaceRequirement struct { @@ -43,15 +43,16 @@ func (fake *FakeSpaceRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -95,15 +96,16 @@ func (fake *FakeSpaceRequirement) GetSpace() models.Space { ret, specificReturn := fake.getSpaceReturnsOnCall[len(fake.getSpaceArgsForCall)] fake.getSpaceArgsForCall = append(fake.getSpaceArgsForCall, struct { }{}) + stub := fake.GetSpaceStub + fakeReturns := fake.getSpaceReturns fake.recordInvocation("GetSpace", []interface{}{}) fake.getSpaceMutex.Unlock() - if fake.GetSpaceStub != nil { - return fake.GetSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getSpaceReturns return fakeReturns.result1 } @@ -147,9 +149,10 @@ func (fake *FakeSpaceRequirement) SetSpaceName(arg1 string) { fake.setSpaceNameArgsForCall = append(fake.setSpaceNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetSpaceNameStub fake.recordInvocation("SetSpaceName", []interface{}{arg1}) fake.setSpaceNameMutex.Unlock() - if fake.SetSpaceNameStub != nil { + if stub != nil { fake.SetSpaceNameStub(arg1) } } diff --git a/cf/requirements/requirementsfakes/fake_targeted_org_requirement.go b/cf/requirements/requirementsfakes/fake_targeted_org_requirement.go index f4faa3ddb50..2ce78e5f2cd 100644 --- a/cf/requirements/requirementsfakes/fake_targeted_org_requirement.go +++ b/cf/requirements/requirementsfakes/fake_targeted_org_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeTargetedOrgRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeTargetedOrgRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeTargetedOrgRequirement) GetOrganizationFields() models.Organizat ret, specificReturn := fake.getOrganizationFieldsReturnsOnCall[len(fake.getOrganizationFieldsArgsForCall)] fake.getOrganizationFieldsArgsForCall = append(fake.getOrganizationFieldsArgsForCall, struct { }{}) + stub := fake.GetOrganizationFieldsStub + fakeReturns := fake.getOrganizationFieldsReturns fake.recordInvocation("GetOrganizationFields", []interface{}{}) fake.getOrganizationFieldsMutex.Unlock() - if fake.GetOrganizationFieldsStub != nil { - return fake.GetOrganizationFieldsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getOrganizationFieldsReturns return fakeReturns.result1 } diff --git a/cf/requirements/requirementsfakes/fake_user_requirement.go b/cf/requirements/requirementsfakes/fake_user_requirement.go index a8df8330825..714a57ee0fa 100644 --- a/cf/requirements/requirementsfakes/fake_user_requirement.go +++ b/cf/requirements/requirementsfakes/fake_user_requirement.go @@ -4,8 +4,8 @@ package requirementsfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeUserRequirement struct { @@ -38,15 +38,16 @@ func (fake *FakeUserRequirement) Execute() error { ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { }{}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } @@ -90,15 +91,16 @@ func (fake *FakeUserRequirement) GetUser() models.UserFields { ret, specificReturn := fake.getUserReturnsOnCall[len(fake.getUserArgsForCall)] fake.getUserArgsForCall = append(fake.getUserArgsForCall, struct { }{}) + stub := fake.GetUserStub + fakeReturns := fake.getUserReturns fake.recordInvocation("GetUser", []interface{}{}) fake.getUserMutex.Unlock() - if fake.GetUserStub != nil { - return fake.GetUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.getUserReturns return fakeReturns.result1 } diff --git a/cf/requirements/service_instance.go b/cf/requirements/service_instance.go index 7c4616934d5..9df3ddde74e 100644 --- a/cf/requirements/service_instance.go +++ b/cf/requirements/service_instance.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ServiceInstanceRequirement diff --git a/cf/requirements/service_instance_test.go b/cf/requirements/service_instance_test.go index 59cad62514a..8be9c424599 100644 --- a/cf/requirements/service_instance_test.go +++ b/cf/requirements/service_instance_test.go @@ -1,11 +1,11 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/space.go b/cf/requirements/space.go index 7f56ba5aed9..5fd82d1170c 100644 --- a/cf/requirements/space.go +++ b/cf/requirements/space.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api/spaces" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api/spaces" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SpaceRequirement diff --git a/cf/requirements/space_test.go b/cf/requirements/space_test.go index 59f8b37bc9a..63550063895 100644 --- a/cf/requirements/space_test.go +++ b/cf/requirements/space_test.go @@ -3,10 +3,10 @@ package requirements_test import ( "errors" - "code.cloudfoundry.org/cli/cf/api/spaces/spacesfakes" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api/spaces/spacesfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/targeted_organization.go b/cf/requirements/targeted_organization.go index adf4469ecf6..c1e050d0d08 100644 --- a/cf/requirements/targeted_organization.go +++ b/cf/requirements/targeted_organization.go @@ -2,13 +2,12 @@ package requirements import ( "errors" - "fmt" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . TargetedOrgRequirement @@ -28,7 +27,7 @@ func NewTargetedOrgRequirement(config coreconfig.Reader) TargetedOrgRequirement func (req targetedOrgAPIRequirement) Execute() error { if !req.config.HasOrganization() { - message := fmt.Sprintf(T("No org targeted, use '{{.Command}}' to target an org.", map[string]interface{}{"Command": terminal.CommandColor(cf.Name + " target -o ORG")})) + message := T("No org targeted, use '{{.Command}}' to target an org.", map[string]interface{}{"Command": terminal.CommandColor(cf.Name + " target -o ORG")}) return errors.New(message) } diff --git a/cf/requirements/targeted_organization_test.go b/cf/requirements/targeted_organization_test.go index a441477e9fd..27cfbb47456 100644 --- a/cf/requirements/targeted_organization_test.go +++ b/cf/requirements/targeted_organization_test.go @@ -1,13 +1,13 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/targeted_space.go b/cf/requirements/targeted_space.go index 7f0bc55bba1..2ccd269d441 100644 --- a/cf/requirements/targeted_space.go +++ b/cf/requirements/targeted_space.go @@ -1,14 +1,12 @@ package requirements import ( - "fmt" - "errors" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - . "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + . "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type TargetedSpaceRequirement struct { @@ -21,12 +19,12 @@ func NewTargetedSpaceRequirement(config coreconfig.Reader) TargetedSpaceRequirem func (req TargetedSpaceRequirement) Execute() error { if !req.config.HasOrganization() { - message := fmt.Sprintf(T("No org and space targeted, use '{{.Command}}' to target an org and space", map[string]interface{}{"Command": terminal.CommandColor(cf.Name + " target -o ORG -s SPACE")})) + message := T("No org and space targeted, use '{{.Command}}' to target an org and space", map[string]interface{}{"Command": terminal.CommandColor(cf.Name + " target -o ORG -s SPACE")}) return errors.New(message) } if !req.config.HasSpace() { - message := fmt.Sprintf(T("No space targeted, use '{{.Command}}' to target a space.", map[string]interface{}{"Command": terminal.CommandColor("cf target -s")})) + message := T("No space targeted, use '{{.Command}}' to target a space.", map[string]interface{}{"Command": terminal.CommandColor("cf target -s")}) return errors.New(message) } diff --git a/cf/requirements/targeted_space_test.go b/cf/requirements/targeted_space_test.go index 97826b03fd3..fbdaa4d13e5 100644 --- a/cf/requirements/targeted_space_test.go +++ b/cf/requirements/targeted_space_test.go @@ -1,11 +1,11 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - . "code.cloudfoundry.org/cli/cf/requirements" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/unsupported_legacy_flag.go b/cf/requirements/unsupported_legacy_flag.go index 3b67eacd83a..e944a34b4e6 100644 --- a/cf/requirements/unsupported_legacy_flag.go +++ b/cf/requirements/unsupported_legacy_flag.go @@ -4,7 +4,7 @@ import ( "errors" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type UnsupportedLegacyFlagRequirement struct { diff --git a/cf/requirements/unsupported_legacy_flag_test.go b/cf/requirements/unsupported_legacy_flag_test.go index 072ae4a8ddd..9ff70d23961 100644 --- a/cf/requirements/unsupported_legacy_flag_test.go +++ b/cf/requirements/unsupported_legacy_flag_test.go @@ -1,9 +1,9 @@ package requirements_test import ( - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/requirements" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/usage_requirement.go b/cf/requirements/usage_requirement.go index ac2f2197d8b..37ec7e108b9 100644 --- a/cf/requirements/usage_requirement.go +++ b/cf/requirements/usage_requirement.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) type RequirementFunction func() error diff --git a/cf/requirements/usage_requirement_test.go b/cf/requirements/usage_requirement_test.go index 44300021683..5955a82c709 100644 --- a/cf/requirements/usage_requirement_test.go +++ b/cf/requirements/usage_requirement_test.go @@ -1,8 +1,8 @@ package requirements_test import ( - . "code.cloudfoundry.org/cli/cf/requirements" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/requirements" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/requirements/user.go b/cf/requirements/user.go index 298231fea07..adf1525dbd0 100644 --- a/cf/requirements/user.go +++ b/cf/requirements/user.go @@ -1,8 +1,8 @@ package requirements import ( - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UserRequirement diff --git a/cf/requirements/user_test.go b/cf/requirements/user_test.go index cacd18a2a0e..5e1b2b6e325 100644 --- a/cf/requirements/user_test.go +++ b/cf/requirements/user_test.go @@ -3,12 +3,12 @@ package requirements_test import ( "errors" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/requirements" - "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/v8/cf/api/apifakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/ssh/options/options_suite_test.go b/cf/ssh/options/options_suite_test.go index a928cbe1095..890967e4ea1 100644 --- a/cf/ssh/options/options_suite_test.go +++ b/cf/ssh/options/options_suite_test.go @@ -1,7 +1,7 @@ package options_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/ssh/options/ssh_options.go b/cf/ssh/options/ssh_options.go index a4976a538cd..c1b2550fc28 100644 --- a/cf/ssh/options/ssh_options.go +++ b/cf/ssh/options/ssh_options.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/flags" ) type TTYRequest int diff --git a/cf/ssh/options/ssh_options_test.go b/cf/ssh/options/ssh_options_test.go index b4fe1f8d25d..29a46fd504d 100644 --- a/cf/ssh/options/ssh_options_test.go +++ b/cf/ssh/options/ssh_options_test.go @@ -1,10 +1,10 @@ package options_test import ( - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/ssh/options" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/ssh/options" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -121,7 +121,7 @@ var _ = Describe("SSHOptions", func() { BeforeEach(func() { args = append(args, "app-name", "-tt") }) - It("foces tty allocation", func() { + It("forces tty allocation", func() { Expect(opts.TerminalRequest).To(Equal(options.RequestTTYForce)) }) }) @@ -190,7 +190,7 @@ var _ = Describe("SSHOptions", func() { }) }) - Context("with an explit bind address", func() { + Context("with an explicit bind address", func() { BeforeEach(func() { args = append(args, "-L", "explicit:9999:remote:8888") }) diff --git a/cf/ssh/sigwinch/sigwinch.go b/cf/ssh/sigwinch/sigwinch.go index ace01f9a2a2..6eab1ee5e72 100644 --- a/cf/ssh/sigwinch/sigwinch.go +++ b/cf/ssh/sigwinch/sigwinch.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package sigwinch diff --git a/cf/ssh/sigwinch/sigwinch_win.go b/cf/ssh/sigwinch/sigwinch_win.go index eac5f1ec141..045da2d6721 100644 --- a/cf/ssh/sigwinch/sigwinch_win.go +++ b/cf/ssh/sigwinch/sigwinch_win.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package sigwinch diff --git a/cf/ssh/ssh.go b/cf/ssh/ssh.go index b1bf62f12b0..ef4c51b28d3 100644 --- a/cf/ssh/ssh.go +++ b/cf/ssh/ssh.go @@ -19,11 +19,11 @@ import ( "golang.org/x/crypto/ssh" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/ssh/options" - "code.cloudfoundry.org/cli/cf/ssh/sigwinch" - "code.cloudfoundry.org/cli/cf/ssh/terminal" - "github.com/moby/moby/pkg/term" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/ssh/options" + "code.cloudfoundry.org/cli/v8/cf/ssh/sigwinch" + "code.cloudfoundry.org/cli/v8/cf/ssh/terminal" + "github.com/moby/term" ) const ( diff --git a/cf/ssh/ssh_suite_test.go b/cf/ssh/ssh_suite_test.go index d1e7ac87141..89e007eb471 100644 --- a/cf/ssh/ssh_suite_test.go +++ b/cf/ssh/ssh_suite_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "path/filepath" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "golang.org/x/crypto/ssh" diff --git a/cf/ssh/ssh_test.go b/cf/ssh/ssh_test.go index 263a17a3530..ff4094f848f 100644 --- a/cf/ssh/ssh_test.go +++ b/cf/ssh/ssh_test.go @@ -1,3 +1,4 @@ +//go:build !windows && !386 // +build !windows,!386 // skipping 386 because lager uses UInt64 in Session() @@ -15,24 +16,24 @@ import ( "syscall" "time" - "code.cloudfoundry.org/cli/cf/models" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" - "code.cloudfoundry.org/cli/cf/ssh/options" - "code.cloudfoundry.org/cli/cf/ssh/sshfakes" - "code.cloudfoundry.org/cli/cf/ssh/terminal" - "code.cloudfoundry.org/cli/cf/ssh/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/models" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" + "code.cloudfoundry.org/cli/v8/cf/ssh/options" + "code.cloudfoundry.org/cli/v8/cf/ssh/sshfakes" + "code.cloudfoundry.org/cli/v8/cf/ssh/terminal" + "code.cloudfoundry.org/cli/v8/cf/ssh/terminal/terminalfakes" "code.cloudfoundry.org/diego-ssh/server" fake_server "code.cloudfoundry.org/diego-ssh/server/fakes" "code.cloudfoundry.org/diego-ssh/test_helpers" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_io" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_net" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_ssh" - "code.cloudfoundry.org/lager/lagertest" - "github.com/kr/pty" - "github.com/moby/moby/pkg/term" + "code.cloudfoundry.org/lager/v3/lagertest" + "github.com/creack/pty" + "github.com/moby/term" "golang.org/x/crypto/ssh" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -480,7 +481,7 @@ var _ = Describe("SSH", func() { Expect(fakeSecureSession.ShellCallCount()).To(Equal(1)) }) - It("does not not restore the terminal", func() { + It("does not restore the terminal", func() { Expect(fakeSecureSession.ShellCallCount()).To(Equal(1)) Expect(fakeTerminalHelper.SetRawTerminalCallCount()).To(Equal(1)) Expect(fakeTerminalHelper.RestoreTerminalCallCount()).To(Equal(0)) @@ -580,7 +581,7 @@ var _ = Describe("SSH", func() { }) }) - Context("when a command is specifed", func() { + Context("when a command is specified", func() { BeforeEach(func() { opts.Command = []string{"echo", "-n", "hello"} }) @@ -888,7 +889,7 @@ var _ = Describe("SSH", func() { fakeLocalListener = &fake_net.FakeListener{} fakeLocalListener.AcceptReturns(nil, errors.New("Not Accepting Connections")) - echoServer = server.NewServer(logger.Session("echo"), "", echoHandler) + echoServer = server.NewServer(logger.Session("echo"), "", echoHandler, 500*time.Millisecond) echoServer.SetListener(echoListener) go echoServer.Serve() diff --git a/cf/ssh/sshfakes/fake_listener_factory.go b/cf/ssh/sshfakes/fake_listener_factory.go index 2f378cdbf81..8541bc05501 100644 --- a/cf/ssh/sshfakes/fake_listener_factory.go +++ b/cf/ssh/sshfakes/fake_listener_factory.go @@ -5,7 +5,7 @@ import ( "net" "sync" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" ) type FakeListenerFactory struct { @@ -34,15 +34,16 @@ func (fake *FakeListenerFactory) Listen(arg1 string, arg2 string) (net.Listener, arg1 string arg2 string }{arg1, arg2}) + stub := fake.ListenStub + fakeReturns := fake.listenReturns fake.recordInvocation("Listen", []interface{}{arg1, arg2}) fake.listenMutex.Unlock() - if fake.ListenStub != nil { - return fake.ListenStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/ssh/sshfakes/fake_secure_client.go b/cf/ssh/sshfakes/fake_secure_client.go index d2df9c7d0a8..1c50caf278a 100644 --- a/cf/ssh/sshfakes/fake_secure_client.go +++ b/cf/ssh/sshfakes/fake_secure_client.go @@ -5,7 +5,7 @@ import ( "net" "sync" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" "golang.org/x/crypto/ssh" ) @@ -75,15 +75,16 @@ func (fake *FakeSecureClient) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -127,15 +128,16 @@ func (fake *FakeSecureClient) Conn() ssh.Conn { ret, specificReturn := fake.connReturnsOnCall[len(fake.connArgsForCall)] fake.connArgsForCall = append(fake.connArgsForCall, struct { }{}) + stub := fake.ConnStub + fakeReturns := fake.connReturns fake.recordInvocation("Conn", []interface{}{}) fake.connMutex.Unlock() - if fake.ConnStub != nil { - return fake.ConnStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.connReturns return fakeReturns.result1 } @@ -181,15 +183,16 @@ func (fake *FakeSecureClient) Dial(arg1 string, arg2 string) (net.Conn, error) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.DialStub + fakeReturns := fake.dialReturns fake.recordInvocation("Dial", []interface{}{arg1, arg2}) fake.dialMutex.Unlock() - if fake.DialStub != nil { - return fake.DialStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.dialReturns return fakeReturns.result1, fakeReturns.result2 } @@ -243,15 +246,16 @@ func (fake *FakeSecureClient) NewSession() (sshCmd.SecureSession, error) { ret, specificReturn := fake.newSessionReturnsOnCall[len(fake.newSessionArgsForCall)] fake.newSessionArgsForCall = append(fake.newSessionArgsForCall, struct { }{}) + stub := fake.NewSessionStub + fakeReturns := fake.newSessionReturns fake.recordInvocation("NewSession", []interface{}{}) fake.newSessionMutex.Unlock() - if fake.NewSessionStub != nil { - return fake.NewSessionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.newSessionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -298,15 +302,16 @@ func (fake *FakeSecureClient) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/cf/ssh/sshfakes/fake_secure_dialer.go b/cf/ssh/sshfakes/fake_secure_dialer.go index d7fdc1d40db..9a598e65e58 100644 --- a/cf/ssh/sshfakes/fake_secure_dialer.go +++ b/cf/ssh/sshfakes/fake_secure_dialer.go @@ -4,7 +4,7 @@ package sshfakes import ( "sync" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" "golang.org/x/crypto/ssh" ) @@ -36,15 +36,16 @@ func (fake *FakeSecureDialer) Dial(arg1 string, arg2 string, arg3 *ssh.ClientCon arg2 string arg3 *ssh.ClientConfig }{arg1, arg2, arg3}) + stub := fake.DialStub + fakeReturns := fake.dialReturns fake.recordInvocation("Dial", []interface{}{arg1, arg2, arg3}) fake.dialMutex.Unlock() - if fake.DialStub != nil { - return fake.DialStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.dialReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/cf/ssh/sshfakes/fake_secure_session.go b/cf/ssh/sshfakes/fake_secure_session.go index 16a44a39442..cb09f49b657 100644 --- a/cf/ssh/sshfakes/fake_secure_session.go +++ b/cf/ssh/sshfakes/fake_secure_session.go @@ -5,7 +5,7 @@ import ( "io" "sync" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" "golang.org/x/crypto/ssh" ) @@ -125,15 +125,16 @@ func (fake *FakeSecureSession) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -181,15 +182,16 @@ func (fake *FakeSecureSession) RequestPty(arg1 string, arg2 int, arg3 int, arg4 arg3 int arg4 ssh.TerminalModes }{arg1, arg2, arg3, arg4}) + stub := fake.RequestPtyStub + fakeReturns := fake.requestPtyReturns fake.recordInvocation("RequestPty", []interface{}{arg1, arg2, arg3, arg4}) fake.requestPtyMutex.Unlock() - if fake.RequestPtyStub != nil { - return fake.RequestPtyStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.requestPtyReturns return fakeReturns.result1 } @@ -248,15 +250,16 @@ func (fake *FakeSecureSession) SendRequest(arg1 string, arg2 bool, arg3 []byte) arg2 bool arg3 []byte }{arg1, arg2, arg3Copy}) + stub := fake.SendRequestStub + fakeReturns := fake.sendRequestReturns fake.recordInvocation("SendRequest", []interface{}{arg1, arg2, arg3Copy}) fake.sendRequestMutex.Unlock() - if fake.SendRequestStub != nil { - return fake.SendRequestStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.sendRequestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -310,15 +313,16 @@ func (fake *FakeSecureSession) Shell() error { ret, specificReturn := fake.shellReturnsOnCall[len(fake.shellArgsForCall)] fake.shellArgsForCall = append(fake.shellArgsForCall, struct { }{}) + stub := fake.ShellStub + fakeReturns := fake.shellReturns fake.recordInvocation("Shell", []interface{}{}) fake.shellMutex.Unlock() - if fake.ShellStub != nil { - return fake.ShellStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.shellReturns return fakeReturns.result1 } @@ -363,15 +367,16 @@ func (fake *FakeSecureSession) Start(arg1 string) error { fake.startArgsForCall = append(fake.startArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{arg1}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -422,15 +427,16 @@ func (fake *FakeSecureSession) StderrPipe() (io.Reader, error) { ret, specificReturn := fake.stderrPipeReturnsOnCall[len(fake.stderrPipeArgsForCall)] fake.stderrPipeArgsForCall = append(fake.stderrPipeArgsForCall, struct { }{}) + stub := fake.StderrPipeStub + fakeReturns := fake.stderrPipeReturns fake.recordInvocation("StderrPipe", []interface{}{}) fake.stderrPipeMutex.Unlock() - if fake.StderrPipeStub != nil { - return fake.StderrPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stderrPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -477,15 +483,16 @@ func (fake *FakeSecureSession) StdinPipe() (io.WriteCloser, error) { ret, specificReturn := fake.stdinPipeReturnsOnCall[len(fake.stdinPipeArgsForCall)] fake.stdinPipeArgsForCall = append(fake.stdinPipeArgsForCall, struct { }{}) + stub := fake.StdinPipeStub + fakeReturns := fake.stdinPipeReturns fake.recordInvocation("StdinPipe", []interface{}{}) fake.stdinPipeMutex.Unlock() - if fake.StdinPipeStub != nil { - return fake.StdinPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stdinPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -532,15 +539,16 @@ func (fake *FakeSecureSession) StdoutPipe() (io.Reader, error) { ret, specificReturn := fake.stdoutPipeReturnsOnCall[len(fake.stdoutPipeArgsForCall)] fake.stdoutPipeArgsForCall = append(fake.stdoutPipeArgsForCall, struct { }{}) + stub := fake.StdoutPipeStub + fakeReturns := fake.stdoutPipeReturns fake.recordInvocation("StdoutPipe", []interface{}{}) fake.stdoutPipeMutex.Unlock() - if fake.StdoutPipeStub != nil { - return fake.StdoutPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stdoutPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -587,15 +595,16 @@ func (fake *FakeSecureSession) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/cf/ssh/sshfakes/fake_secure_shell.go b/cf/ssh/sshfakes/fake_secure_shell.go index 35dfa9f51f0..80bb4863f13 100644 --- a/cf/ssh/sshfakes/fake_secure_shell.go +++ b/cf/ssh/sshfakes/fake_secure_shell.go @@ -4,8 +4,8 @@ package sshfakes import ( "sync" - sshCmd "code.cloudfoundry.org/cli/cf/ssh" - "code.cloudfoundry.org/cli/cf/ssh/options" + sshCmd "code.cloudfoundry.org/cli/v8/cf/ssh" + "code.cloudfoundry.org/cli/v8/cf/ssh/options" ) type FakeSecureShell struct { @@ -69,15 +69,16 @@ func (fake *FakeSecureShell) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -122,15 +123,16 @@ func (fake *FakeSecureShell) Connect(arg1 *options.SSHOptions) error { fake.connectArgsForCall = append(fake.connectArgsForCall, struct { arg1 *options.SSHOptions }{arg1}) + stub := fake.ConnectStub + fakeReturns := fake.connectReturns fake.recordInvocation("Connect", []interface{}{arg1}) fake.connectMutex.Unlock() - if fake.ConnectStub != nil { - return fake.ConnectStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.connectReturns return fakeReturns.result1 } @@ -181,15 +183,16 @@ func (fake *FakeSecureShell) InteractiveSession() error { ret, specificReturn := fake.interactiveSessionReturnsOnCall[len(fake.interactiveSessionArgsForCall)] fake.interactiveSessionArgsForCall = append(fake.interactiveSessionArgsForCall, struct { }{}) + stub := fake.InteractiveSessionStub + fakeReturns := fake.interactiveSessionReturns fake.recordInvocation("InteractiveSession", []interface{}{}) fake.interactiveSessionMutex.Unlock() - if fake.InteractiveSessionStub != nil { - return fake.InteractiveSessionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.interactiveSessionReturns return fakeReturns.result1 } @@ -233,15 +236,16 @@ func (fake *FakeSecureShell) LocalPortForward() error { ret, specificReturn := fake.localPortForwardReturnsOnCall[len(fake.localPortForwardArgsForCall)] fake.localPortForwardArgsForCall = append(fake.localPortForwardArgsForCall, struct { }{}) + stub := fake.LocalPortForwardStub + fakeReturns := fake.localPortForwardReturns fake.recordInvocation("LocalPortForward", []interface{}{}) fake.localPortForwardMutex.Unlock() - if fake.LocalPortForwardStub != nil { - return fake.LocalPortForwardStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.localPortForwardReturns return fakeReturns.result1 } @@ -285,15 +289,16 @@ func (fake *FakeSecureShell) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/cf/ssh/terminal/helper.go b/cf/ssh/terminal/helper.go index b755b3ea988..b4d52a84421 100644 --- a/cf/ssh/terminal/helper.go +++ b/cf/ssh/terminal/helper.go @@ -3,7 +3,7 @@ package terminal import ( "io" - "github.com/moby/moby/pkg/term" + "github.com/moby/term" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . TerminalHelper diff --git a/cf/ssh/terminal/helper_test.go b/cf/ssh/terminal/helper_test.go index 758962b1a2e..2fa91f14abe 100644 --- a/cf/ssh/terminal/helper_test.go +++ b/cf/ssh/terminal/helper_test.go @@ -1,9 +1,9 @@ package terminal_test import ( - "code.cloudfoundry.org/cli/cf/ssh/terminal" + "code.cloudfoundry.org/cli/v8/cf/ssh/terminal" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/ssh/terminal/terminal_suite_test.go b/cf/ssh/terminal/terminal_suite_test.go index 7ae041f713c..6707582b58a 100644 --- a/cf/ssh/terminal/terminal_suite_test.go +++ b/cf/ssh/terminal/terminal_suite_test.go @@ -1,7 +1,7 @@ package terminal_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/ssh/terminal/terminalfakes/fake_terminal_helper.go b/cf/ssh/terminal/terminalfakes/fake_terminal_helper.go index 8a7ed1a2e2e..02e965e2f12 100644 --- a/cf/ssh/terminal/terminalfakes/fake_terminal_helper.go +++ b/cf/ssh/terminal/terminalfakes/fake_terminal_helper.go @@ -5,8 +5,8 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/cf/ssh/terminal" - "github.com/moby/moby/pkg/term" + "code.cloudfoundry.org/cli/v8/cf/ssh/terminal" + "github.com/moby/term" ) type FakeTerminalHelper struct { @@ -96,15 +96,16 @@ func (fake *FakeTerminalHelper) GetFdInfo(arg1 interface{}) (uintptr, bool) { fake.getFdInfoArgsForCall = append(fake.getFdInfoArgsForCall, struct { arg1 interface{} }{arg1}) + stub := fake.GetFdInfoStub + fakeReturns := fake.getFdInfoReturns fake.recordInvocation("GetFdInfo", []interface{}{arg1}) fake.getFdInfoMutex.Unlock() - if fake.GetFdInfoStub != nil { - return fake.GetFdInfoStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getFdInfoReturns return fakeReturns.result1, fakeReturns.result2 } @@ -159,15 +160,16 @@ func (fake *FakeTerminalHelper) GetWinsize(arg1 uintptr) (*term.Winsize, error) fake.getWinsizeArgsForCall = append(fake.getWinsizeArgsForCall, struct { arg1 uintptr }{arg1}) + stub := fake.GetWinsizeStub + fakeReturns := fake.getWinsizeReturns fake.recordInvocation("GetWinsize", []interface{}{arg1}) fake.getWinsizeMutex.Unlock() - if fake.GetWinsizeStub != nil { - return fake.GetWinsizeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getWinsizeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -222,15 +224,16 @@ func (fake *FakeTerminalHelper) IsTerminal(arg1 uintptr) bool { fake.isTerminalArgsForCall = append(fake.isTerminalArgsForCall, struct { arg1 uintptr }{arg1}) + stub := fake.IsTerminalStub + fakeReturns := fake.isTerminalReturns fake.recordInvocation("IsTerminal", []interface{}{arg1}) fake.isTerminalMutex.Unlock() - if fake.IsTerminalStub != nil { - return fake.IsTerminalStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.isTerminalReturns return fakeReturns.result1 } @@ -283,15 +286,16 @@ func (fake *FakeTerminalHelper) RestoreTerminal(arg1 uintptr, arg2 *term.State) arg1 uintptr arg2 *term.State }{arg1, arg2}) + stub := fake.RestoreTerminalStub + fakeReturns := fake.restoreTerminalReturns fake.recordInvocation("RestoreTerminal", []interface{}{arg1, arg2}) fake.restoreTerminalMutex.Unlock() - if fake.RestoreTerminalStub != nil { - return fake.RestoreTerminalStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.restoreTerminalReturns return fakeReturns.result1 } @@ -343,15 +347,16 @@ func (fake *FakeTerminalHelper) SetRawTerminal(arg1 uintptr) (*term.State, error fake.setRawTerminalArgsForCall = append(fake.setRawTerminalArgsForCall, struct { arg1 uintptr }{arg1}) + stub := fake.SetRawTerminalStub + fakeReturns := fake.setRawTerminalReturns fake.recordInvocation("SetRawTerminal", []interface{}{arg1}) fake.setRawTerminalMutex.Unlock() - if fake.SetRawTerminalStub != nil { - return fake.SetRawTerminalStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setRawTerminalReturns return fakeReturns.result1, fakeReturns.result2 } @@ -405,15 +410,16 @@ func (fake *FakeTerminalHelper) StdStreams() (io.ReadCloser, io.Writer, io.Write ret, specificReturn := fake.stdStreamsReturnsOnCall[len(fake.stdStreamsArgsForCall)] fake.stdStreamsArgsForCall = append(fake.stdStreamsArgsForCall, struct { }{}) + stub := fake.StdStreamsStub + fakeReturns := fake.stdStreamsReturns fake.recordInvocation("StdStreams", []interface{}{}) fake.stdStreamsMutex.Unlock() - if fake.StdStreamsStub != nil { - return fake.StdStreamsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.stdStreamsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/cf/terminal/color_test.go b/cf/terminal/color_test.go index 8e6aadc86af..717b30ae1f3 100644 --- a/cf/terminal/color_test.go +++ b/cf/terminal/color_test.go @@ -3,9 +3,9 @@ package terminal_test import ( "os" - . "code.cloudfoundry.org/cli/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/terminal" "github.com/fatih/color" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/terminal/table.go b/cf/terminal/table.go index a123e3ff310..debd10d19a5 100644 --- a/cf/terminal/table.go +++ b/cf/terminal/table.go @@ -174,7 +174,7 @@ func (t *Table) calculateMaxSize(transformer rowTransformer, rowIndex int, row [ return nil } -// printRow is responsible for the layouting, transforming and +// printRow is responsible for the laying-out, transforming and // printing of the string in a single row func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error { @@ -255,7 +255,7 @@ func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex } // printCellValue pads the specified string to the width of the given -// column, adds the spacing bewtween columns, and returns the result. +// column, adds the spacing between columns, and returns the result. func (t *Table) printCellValue(result io.Writer, transformer rowTransformer, col, last int, value string) error { value = trim(transformer.Transform(col, trim(value))) fmt.Fprint(result, value) diff --git a/cf/terminal/table_test.go b/cf/terminal/table_test.go index d893d7a3b4d..0263a591edf 100644 --- a/cf/terminal/table_test.go +++ b/cf/terminal/table_test.go @@ -4,9 +4,9 @@ import ( "bytes" "strings" - . "code.cloudfoundry.org/cli/cf/terminal" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/terminal/tee_printer_test.go b/cf/terminal/tee_printer_test.go index 17e1dca58ed..c31d7076d1d 100644 --- a/cf/terminal/tee_printer_test.go +++ b/cf/terminal/tee_printer_test.go @@ -3,10 +3,10 @@ package terminal_test import ( "os" - . "code.cloudfoundry.org/cli/cf/terminal" + . "code.cloudfoundry.org/cli/v8/cf/terminal" - io_helpers "code.cloudfoundry.org/cli/cf/util/testhelpers/io" - . "github.com/onsi/ginkgo" + io_helpers "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/io" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cf/terminal/terminal_suite_test.go b/cf/terminal/terminal_suite_test.go index 056b2718c86..9d70dd83c17 100644 --- a/cf/terminal/terminal_suite_test.go +++ b/cf/terminal/terminal_suite_test.go @@ -1,9 +1,9 @@ package terminal_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/terminal/terminalfakes/fake_ui.go b/cf/terminal/terminalfakes/fake_ui.go index dda18707b17..2739e023770 100644 --- a/cf/terminal/terminalfakes/fake_ui.go +++ b/cf/terminal/terminalfakes/fake_ui.go @@ -5,8 +5,8 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type FakeUI struct { @@ -152,15 +152,16 @@ func (fake *FakeUI) Ask(arg1 string) string { fake.askArgsForCall = append(fake.askArgsForCall, struct { arg1 string }{arg1}) + stub := fake.AskStub + fakeReturns := fake.askReturns fake.recordInvocation("Ask", []interface{}{arg1}) fake.askMutex.Unlock() - if fake.AskStub != nil { - return fake.AskStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.askReturns return fakeReturns.result1 } @@ -212,15 +213,16 @@ func (fake *FakeUI) AskForPassword(arg1 string) string { fake.askForPasswordArgsForCall = append(fake.askForPasswordArgsForCall, struct { arg1 string }{arg1}) + stub := fake.AskForPasswordStub + fakeReturns := fake.askForPasswordReturns fake.recordInvocation("AskForPassword", []interface{}{arg1}) fake.askForPasswordMutex.Unlock() - if fake.AskForPasswordStub != nil { - return fake.AskForPasswordStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.askForPasswordReturns return fakeReturns.result1 } @@ -272,15 +274,16 @@ func (fake *FakeUI) Confirm(arg1 string) bool { fake.confirmArgsForCall = append(fake.confirmArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ConfirmStub + fakeReturns := fake.confirmReturns fake.recordInvocation("Confirm", []interface{}{arg1}) fake.confirmMutex.Unlock() - if fake.ConfirmStub != nil { - return fake.ConfirmStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.confirmReturns return fakeReturns.result1 } @@ -333,15 +336,16 @@ func (fake *FakeUI) ConfirmDelete(arg1 string, arg2 string) bool { arg1 string arg2 string }{arg1, arg2}) + stub := fake.ConfirmDeleteStub + fakeReturns := fake.confirmDeleteReturns fake.recordInvocation("ConfirmDelete", []interface{}{arg1, arg2}) fake.confirmDeleteMutex.Unlock() - if fake.ConfirmDeleteStub != nil { - return fake.ConfirmDeleteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.confirmDeleteReturns return fakeReturns.result1 } @@ -394,15 +398,16 @@ func (fake *FakeUI) ConfirmDeleteWithAssociations(arg1 string, arg2 string) bool arg1 string arg2 string }{arg1, arg2}) + stub := fake.ConfirmDeleteWithAssociationsStub + fakeReturns := fake.confirmDeleteWithAssociationsReturns fake.recordInvocation("ConfirmDeleteWithAssociations", []interface{}{arg1, arg2}) fake.confirmDeleteWithAssociationsMutex.Unlock() - if fake.ConfirmDeleteWithAssociationsStub != nil { - return fake.ConfirmDeleteWithAssociationsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.confirmDeleteWithAssociationsReturns return fakeReturns.result1 } @@ -454,9 +459,10 @@ func (fake *FakeUI) Failed(arg1 string, arg2 ...interface{}) { arg1 string arg2 []interface{} }{arg1, arg2}) + stub := fake.FailedStub fake.recordInvocation("Failed", []interface{}{arg1, arg2}) fake.failedMutex.Unlock() - if fake.FailedStub != nil { + if stub != nil { fake.FailedStub(arg1, arg2...) } } @@ -484,9 +490,10 @@ func (fake *FakeUI) LoadingIndication() { fake.loadingIndicationMutex.Lock() fake.loadingIndicationArgsForCall = append(fake.loadingIndicationArgsForCall, struct { }{}) + stub := fake.LoadingIndicationStub fake.recordInvocation("LoadingIndication", []interface{}{}) fake.loadingIndicationMutex.Unlock() - if fake.LoadingIndicationStub != nil { + if stub != nil { fake.LoadingIndicationStub() } } @@ -508,9 +515,10 @@ func (fake *FakeUI) NotifyUpdateIfNeeded(arg1 coreconfig.Reader) { fake.notifyUpdateIfNeededArgsForCall = append(fake.notifyUpdateIfNeededArgsForCall, struct { arg1 coreconfig.Reader }{arg1}) + stub := fake.NotifyUpdateIfNeededStub fake.recordInvocation("NotifyUpdateIfNeeded", []interface{}{arg1}) fake.notifyUpdateIfNeededMutex.Unlock() - if fake.NotifyUpdateIfNeededStub != nil { + if stub != nil { fake.NotifyUpdateIfNeededStub(arg1) } } @@ -538,9 +546,10 @@ func (fake *FakeUI) Ok() { fake.okMutex.Lock() fake.okArgsForCall = append(fake.okArgsForCall, struct { }{}) + stub := fake.OkStub fake.recordInvocation("Ok", []interface{}{}) fake.okMutex.Unlock() - if fake.OkStub != nil { + if stub != nil { fake.OkStub() } } @@ -563,9 +572,10 @@ func (fake *FakeUI) PrintCapturingNoOutput(arg1 string, arg2 ...interface{}) { arg1 string arg2 []interface{} }{arg1, arg2}) + stub := fake.PrintCapturingNoOutputStub fake.recordInvocation("PrintCapturingNoOutput", []interface{}{arg1, arg2}) fake.printCapturingNoOutputMutex.Unlock() - if fake.PrintCapturingNoOutputStub != nil { + if stub != nil { fake.PrintCapturingNoOutputStub(arg1, arg2...) } } @@ -600,9 +610,10 @@ func (fake *FakeUI) PrintPaginator(arg1 []string, arg2 error) { arg1 []string arg2 error }{arg1Copy, arg2}) + stub := fake.PrintPaginatorStub fake.recordInvocation("PrintPaginator", []interface{}{arg1Copy, arg2}) fake.printPaginatorMutex.Unlock() - if fake.PrintPaginatorStub != nil { + if stub != nil { fake.PrintPaginatorStub(arg1, arg2) } } @@ -632,9 +643,10 @@ func (fake *FakeUI) Say(arg1 string, arg2 ...interface{}) { arg1 string arg2 []interface{} }{arg1, arg2}) + stub := fake.SayStub fake.recordInvocation("Say", []interface{}{arg1, arg2}) fake.sayMutex.Unlock() - if fake.SayStub != nil { + if stub != nil { fake.SayStub(arg1, arg2...) } } @@ -664,15 +676,16 @@ func (fake *FakeUI) ShowConfiguration(arg1 coreconfig.Reader) error { fake.showConfigurationArgsForCall = append(fake.showConfigurationArgsForCall, struct { arg1 coreconfig.Reader }{arg1}) + stub := fake.ShowConfigurationStub + fakeReturns := fake.showConfigurationReturns fake.recordInvocation("ShowConfiguration", []interface{}{arg1}) fake.showConfigurationMutex.Unlock() - if fake.ShowConfigurationStub != nil { - return fake.ShowConfigurationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.showConfigurationReturns return fakeReturns.result1 } @@ -729,15 +742,16 @@ func (fake *FakeUI) Table(arg1 []string) *terminal.UITable { fake.tableArgsForCall = append(fake.tableArgsForCall, struct { arg1 []string }{arg1Copy}) + stub := fake.TableStub + fakeReturns := fake.tableReturns fake.recordInvocation("Table", []interface{}{arg1Copy}) fake.tableMutex.Unlock() - if fake.TableStub != nil { - return fake.TableStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.tableReturns return fakeReturns.result1 } @@ -789,9 +803,10 @@ func (fake *FakeUI) Warn(arg1 string, arg2 ...interface{}) { arg1 string arg2 []interface{} }{arg1, arg2}) + stub := fake.WarnStub fake.recordInvocation("Warn", []interface{}{arg1, arg2}) fake.warnMutex.Unlock() - if fake.WarnStub != nil { + if stub != nil { fake.WarnStub(arg1, arg2...) } } @@ -820,15 +835,16 @@ func (fake *FakeUI) Writer() io.Writer { ret, specificReturn := fake.writerReturnsOnCall[len(fake.writerArgsForCall)] fake.writerArgsForCall = append(fake.writerArgsForCall, struct { }{}) + stub := fake.WriterStub + fakeReturns := fake.writerReturns fake.recordInvocation("Writer", []interface{}{}) fake.writerMutex.Unlock() - if fake.WriterStub != nil { - return fake.WriterStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.writerReturns return fakeReturns.result1 } diff --git a/cf/terminal/ui.go b/cf/terminal/ui.go index 18df1937bd6..5c30ee3d852 100644 --- a/cf/terminal/ui.go +++ b/cf/terminal/ui.go @@ -5,22 +5,22 @@ import ( "io" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" "bytes" "bufio" - "code.cloudfoundry.org/cli/cf" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type ColoringFunction func(value string, row int, col int) string func NotLoggedInText() string { - return fmt.Sprintf(T("Not logged in. Use '{{.CFLoginCommand}}' or '{{.CFLoginCommandSSO}}' to log in.", map[string]interface{}{"CFLoginCommand": CommandColor(cf.Name + " " + "login"), - "CFLoginCommandSSO": CommandColor(cf.Name + " " + "login --sso")})) + return T("Not logged in. Use '{{.CFLoginCommand}}' or '{{.CFLoginCommandSSO}}' to log in.", map[string]interface{}{"CFLoginCommand": CommandColor(cf.Name + " " + "login"), + "CFLoginCommandSSO": CommandColor(cf.Name + " " + "login --sso")}) } //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UI diff --git a/cf/terminal/ui_test.go b/cf/terminal/ui_test.go index e3bfea5ebf3..4b37f701650 100644 --- a/cf/terminal/ui_test.go +++ b/cf/terminal/ui_test.go @@ -6,19 +6,19 @@ import ( "os" "strings" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - io_helpers "code.cloudfoundry.org/cli/cf/util/testhelpers/io" - newUI "code.cloudfoundry.org/cli/util/ui" - - . "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/cf/trace" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + io_helpers "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/io" + newUI "code.cloudfoundry.org/cli/v8/util/ui" + + . "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/trace" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cf/terminal/ui_unix.go b/cf/terminal/ui_unix.go index e62891cbc89..200ea612e12 100644 --- a/cf/terminal/ui_unix.go +++ b/cf/terminal/ui_unix.go @@ -1,18 +1,20 @@ // Copied from https://code.google.com/p/gopass/ +//go:build !windows // +build !windows package terminal import ( "bufio" + "errors" "fmt" "os" "os/signal" "strings" "syscall" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) const ( @@ -72,7 +74,7 @@ func echoOff(fd []uintptr) (int, error) { pid, err := syscall.ForkExec(sttyArg0, sttyArgvEOff, &syscall.ProcAttr{Dir: execCWDir, Files: fd}) if err != nil { - return 0, fmt.Errorf(T("failed turning off console echo for password entry:\n{{.ErrorDescription}}", map[string]interface{}{"ErrorDescription": err})) + return 0, errors.New(T("failed turning off console echo for password entry:\n{{.ErrorDescription}}", map[string]interface{}{"ErrorDescription": err})) } return pid, nil diff --git a/cf/terminal/ui_windows.go b/cf/terminal/ui_windows.go index d964e5c00da..1dbe9574a6b 100644 --- a/cf/terminal/ui_windows.go +++ b/cf/terminal/ui_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package terminal diff --git a/cf/trace/combined_printer_test.go b/cf/trace/combined_printer_test.go index 0fea6714a42..f23f0f2a6a6 100644 --- a/cf/trace/combined_printer_test.go +++ b/cf/trace/combined_printer_test.go @@ -1,11 +1,11 @@ package trace_test import ( - . "code.cloudfoundry.org/cli/cf/trace" + . "code.cloudfoundry.org/cli/v8/cf/trace" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/trace/logger_provider.go b/cf/trace/logger_provider.go index 6337b0dbd5d..61a0da76b0f 100644 --- a/cf/trace/logger_provider.go +++ b/cf/trace/logger_provider.go @@ -6,7 +6,7 @@ import ( "path/filepath" "strconv" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) func NewLogger(writer io.Writer, verbose bool, boolsOrPaths ...string) Printer { diff --git a/cf/trace/logger_provider_test.go b/cf/trace/logger_provider_test.go index 9a3271446ff..3850af06235 100644 --- a/cf/trace/logger_provider_test.go +++ b/cf/trace/logger_provider_test.go @@ -5,12 +5,12 @@ import ( "path" "runtime" - . "code.cloudfoundry.org/cli/cf/trace" + . "code.cloudfoundry.org/cli/v8/cf/trace" "code.cloudfoundry.org/gofileutils/fileutils" "os" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" ) diff --git a/cf/trace/trace.go b/cf/trace/trace.go index 25addf1c26e..701ea4c023e 100644 --- a/cf/trace/trace.go +++ b/cf/trace/trace.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" ) var LoggingToStdout bool diff --git a/cf/trace/trace_suite_test.go b/cf/trace/trace_suite_test.go index a874d42e876..528b61ef609 100644 --- a/cf/trace/trace_suite_test.go +++ b/cf/trace/trace_suite_test.go @@ -1,9 +1,9 @@ package trace_test import ( - "code.cloudfoundry.org/cli/cf/i18n" - "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/trace/trace_test.go b/cf/trace/trace_test.go index 5b7f38f74d5..5994272e1a5 100644 --- a/cf/trace/trace_test.go +++ b/cf/trace/trace_test.go @@ -1,8 +1,8 @@ package trace_test import ( - . "code.cloudfoundry.org/cli/cf/trace" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/trace" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/trace/tracefakes/fake_printer.go b/cf/trace/tracefakes/fake_printer.go index af366fefc72..10e82bcd7a6 100644 --- a/cf/trace/tracefakes/fake_printer.go +++ b/cf/trace/tracefakes/fake_printer.go @@ -4,7 +4,7 @@ package tracefakes import ( "sync" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/trace" ) type FakePrinter struct { @@ -43,9 +43,10 @@ func (fake *FakePrinter) Print(arg1 ...interface{}) { fake.printArgsForCall = append(fake.printArgsForCall, struct { arg1 []interface{} }{arg1}) + stub := fake.PrintStub fake.recordInvocation("Print", []interface{}{arg1}) fake.printMutex.Unlock() - if fake.PrintStub != nil { + if stub != nil { fake.PrintStub(arg1...) } } @@ -75,9 +76,10 @@ func (fake *FakePrinter) Printf(arg1 string, arg2 ...interface{}) { arg1 string arg2 []interface{} }{arg1, arg2}) + stub := fake.PrintfStub fake.recordInvocation("Printf", []interface{}{arg1, arg2}) fake.printfMutex.Unlock() - if fake.PrintfStub != nil { + if stub != nil { fake.PrintfStub(arg1, arg2...) } } @@ -106,9 +108,10 @@ func (fake *FakePrinter) Println(arg1 ...interface{}) { fake.printlnArgsForCall = append(fake.printlnArgsForCall, struct { arg1 []interface{} }{arg1}) + stub := fake.PrintlnStub fake.recordInvocation("Println", []interface{}{arg1}) fake.printlnMutex.Unlock() - if fake.PrintlnStub != nil { + if stub != nil { fake.PrintlnStub(arg1...) } } @@ -137,15 +140,16 @@ func (fake *FakePrinter) WritesToConsole() bool { ret, specificReturn := fake.writesToConsoleReturnsOnCall[len(fake.writesToConsoleArgsForCall)] fake.writesToConsoleArgsForCall = append(fake.writesToConsoleArgsForCall, struct { }{}) + stub := fake.WritesToConsoleStub + fakeReturns := fake.writesToConsoleReturns fake.recordInvocation("WritesToConsole", []interface{}{}) fake.writesToConsoleMutex.Unlock() - if fake.WritesToConsoleStub != nil { - return fake.WritesToConsoleStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.writesToConsoleReturns return fakeReturns.result1 } diff --git a/cf/uihelpers/tags_parser_test.go b/cf/uihelpers/tags_parser_test.go index 5c11de8822a..1660a041118 100644 --- a/cf/uihelpers/tags_parser_test.go +++ b/cf/uihelpers/tags_parser_test.go @@ -1,8 +1,8 @@ package uihelpers_test import ( - . "code.cloudfoundry.org/cli/cf/uihelpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/uihelpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/uihelpers/ui.go b/cf/uihelpers/ui.go index ca43771236f..4aa24bf89eb 100644 --- a/cf/uihelpers/ui.go +++ b/cf/uihelpers/ui.go @@ -4,10 +4,10 @@ import ( "fmt" "strings" - . "code.cloudfoundry.org/cli/cf/i18n" + . "code.cloudfoundry.org/cli/v8/cf/i18n" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) func ColoredAppState(app models.ApplicationFields) string { diff --git a/cf/uihelpers/ui_helpers_suite_test.go b/cf/uihelpers/ui_helpers_suite_test.go index d2c3d75d4c8..5c35f8774e7 100644 --- a/cf/uihelpers/ui_helpers_suite_test.go +++ b/cf/uihelpers/ui_helpers_suite_test.go @@ -1,7 +1,7 @@ package uihelpers_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/downloader/file_download.go b/cf/util/downloader/file_download.go index 567a9c9d664..a6a71f80f40 100644 --- a/cf/util/downloader/file_download.go +++ b/cf/util/downloader/file_download.go @@ -1,7 +1,7 @@ package downloader import ( - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/util" "fmt" "io" "net/http" @@ -29,7 +29,7 @@ func NewDownloader(saveDir string) Downloader { } } -//this func returns byte written, filename and error +// this func returns byte written, filename and error func (d *downloader) DownloadFile(url string) (int64, string, error) { c := http.Client{ Transport: &http.Transport{ @@ -38,7 +38,7 @@ func (d *downloader) DownloadFile(url string) (int64, string, error) { CheckRedirect: func(r *http.Request, via []*http.Request) error { r.URL.Opaque = r.URL.Path - //some redirect return '/' as url + // some redirect return '/' as url if strings.Trim(r.URL.Opaque, "/") != "" { url = r.URL.Opaque } diff --git a/cf/util/downloader/file_download_test.go b/cf/util/downloader/file_download_test.go index 2665771ddaf..19efd72b96b 100644 --- a/cf/util/downloader/file_download_test.go +++ b/cf/util/downloader/file_download_test.go @@ -6,11 +6,11 @@ import ( "os" "path" - "code.cloudfoundry.org/cli/cf/util/downloader" + "code.cloudfoundry.org/cli/v8/cf/util/downloader" "github.com/onsi/gomega/ghttp" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -154,7 +154,7 @@ var _ = Describe("Downloader", func() { Context("when the URL is invalid", func() { It("returns an error", func() { - _, _, err := d.DownloadFile("http://going.nowwhere/abc.zip") + _, _, err := d.DownloadFile("http://going.nowhere/abc.zip") Expect(err).To(HaveOccurred()) }) }) diff --git a/cf/util/downloader/fileutils_suite_test.go b/cf/util/downloader/fileutils_suite_test.go index 4bcde26ee9b..e554aa37a84 100644 --- a/cf/util/downloader/fileutils_suite_test.go +++ b/cf/util/downloader/fileutils_suite_test.go @@ -1,7 +1,7 @@ package downloader_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/glob/glob.go b/cf/util/glob/glob.go index 860ac68718a..e30edd0be85 100644 --- a/cf/util/glob/glob.go +++ b/cf/util/glob/glob.go @@ -9,10 +9,10 @@ import ( // matching against paths. // // Glob notation: -// - `?` matches a single char in a single path component -// - `*` matches zero or more chars in a single path component -// - `**` matches zero or more chars in zero or more components -// - any other sequence matches itself +// - `?` matches a single char in a single path component +// - `*` matches zero or more chars in a single path component +// - `**` matches zero or more chars in zero or more components +// - any other sequence matches itself type Glob struct { pattern string // original glob pattern regexp *regexp.Regexp // compiled regexp @@ -27,9 +27,9 @@ func mustBuildRe(p string) *regexp.Regexp { var globRe = mustBuildRe(`(` + charPat + `|[\*\?])`) // Supports unix/ruby-style glob patterns: -// - `?` matches a single char in a single path component -// - `*` matches zero or more chars in a single path component -// - `**` matches zero or more chars in zero or more components +// - `?` matches a single char in a single path component +// - `*` matches zero or more chars in a single path component +// - `**` matches zero or more chars in zero or more components func translateGlob(pat string) (string, error) { if !globRe.MatchString(pat) { return "", Error(pat) diff --git a/cf/util/glob/glob_test.go b/cf/util/glob/glob_test.go index 41e54b33b90..d80a31a9002 100644 --- a/cf/util/glob/glob_test.go +++ b/cf/util/glob/glob_test.go @@ -3,7 +3,7 @@ package glob import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/json/json_parser_test.go b/cf/util/json/json_parser_test.go index d77d12ef657..29c9f618544 100644 --- a/cf/util/json/json_parser_test.go +++ b/cf/util/json/json_parser_test.go @@ -4,8 +4,8 @@ import ( "io/ioutil" "os" - "code.cloudfoundry.org/cli/cf/util/json" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/util/json" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/json/json_suite_test.go b/cf/util/json/json_suite_test.go index 9ea25dd8a26..03b6108b0b2 100644 --- a/cf/util/json/json_suite_test.go +++ b/cf/util/json/json_suite_test.go @@ -1,7 +1,7 @@ package json_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/spellcheck/spellcheck_suite_test.go b/cf/util/spellcheck/spellcheck_suite_test.go index d3441a7c1f0..b1a60fd89c5 100644 --- a/cf/util/spellcheck/spellcheck_suite_test.go +++ b/cf/util/spellcheck/spellcheck_suite_test.go @@ -1,7 +1,7 @@ package spellcheck_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/spellcheck/spellcheck_test.go b/cf/util/spellcheck/spellcheck_test.go index f8c1abfbe5b..970ac563f3c 100644 --- a/cf/util/spellcheck/spellcheck_test.go +++ b/cf/util/spellcheck/spellcheck_test.go @@ -1,9 +1,9 @@ package spellcheck_test import ( - . "code.cloudfoundry.org/cli/cf/util/spellcheck" + . "code.cloudfoundry.org/cli/v8/cf/util/spellcheck" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/commands/requirements.go b/cf/util/testhelpers/commands/requirements.go index d000c04096e..46cb966792a 100644 --- a/cf/util/testhelpers/commands/requirements.go +++ b/cf/util/testhelpers/commands/requirements.go @@ -1,6 +1,6 @@ package commands -import "code.cloudfoundry.org/cli/cf/requirements" +import "code.cloudfoundry.org/cli/v8/cf/requirements" func RunRequirements(reqs []requirements.Requirement) error { var retErr error diff --git a/cf/util/testhelpers/commands/runner.go b/cf/util/testhelpers/commands/runner.go index 627ccd1fb63..56b30d0765e 100644 --- a/cf/util/testhelpers/commands/runner.go +++ b/cf/util/testhelpers/commands/runner.go @@ -4,10 +4,10 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + testterm "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/terminal" ) type RunCommandResult int diff --git a/cf/util/testhelpers/configuration/access_token.go b/cf/util/testhelpers/configuration/access_token.go index 40819751fd6..e57de6ff6f8 100644 --- a/cf/util/testhelpers/configuration/access_token.go +++ b/cf/util/testhelpers/configuration/access_token.go @@ -9,7 +9,7 @@ import ( "github.com/SermoDigital/jose/crypto" "github.com/SermoDigital/jose/jws" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" ) func EncodeAccessToken(tokenInfo coreconfig.TokenInfo) (accessToken string, err error) { diff --git a/cf/util/testhelpers/configuration/fake_config_persistance.go b/cf/util/testhelpers/configuration/fake_config_persistance.go index 358217b660b..e9222e60ce5 100644 --- a/cf/util/testhelpers/configuration/fake_config_persistance.go +++ b/cf/util/testhelpers/configuration/fake_config_persistance.go @@ -1,8 +1,8 @@ package configuration import ( - "code.cloudfoundry.org/cli/cf/configuration" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" ) type FakePersistor struct { diff --git a/cf/util/testhelpers/configuration/test_config.go b/cf/util/testhelpers/configuration/test_config.go index 0c7f0341bc6..3b3b8994f19 100644 --- a/cf/util/testhelpers/configuration/test_config.go +++ b/cf/util/testhelpers/configuration/test_config.go @@ -1,8 +1,8 @@ package configuration import ( - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" ) func NewRepository() coreconfig.Repository { diff --git a/cf/util/testhelpers/io/io.go b/cf/util/testhelpers/io/io.go index df710d856f8..6a66f439ae9 100644 --- a/cf/util/testhelpers/io/io.go +++ b/cf/util/testhelpers/io/io.go @@ -50,7 +50,7 @@ func CaptureOutput(block func()) []string { doneWriting := make(chan bool) result := make(chan []string) - go captureOutputAsyncronously(doneWriting, result, r) + go captureOutputAsynchronously(doneWriting, result, r) block() w.Close() @@ -59,12 +59,12 @@ func CaptureOutput(block func()) []string { } /* - The reason we're doing is that you can't write an infinite amount of bytes into a pipe. - On some platforms, the limit is fairly high; on other platforms, the limit is infuriatingly small - (looking at you, Windows). To counteract this, we need to read in a goroutine from one end of - the pipe and return the result across a channel. +The reason we're doing is that you can't write an infinite amount of bytes into a pipe. +On some platforms, the limit is fairly high; on other platforms, the limit is infuriatingly small +(looking at you, Windows). To counteract this, we need to read in a goroutine from one end of +the pipe and return the result across a channel. */ -func captureOutputAsyncronously(doneWriting <-chan bool, result chan<- []string, reader io.Reader) { +func captureOutputAsynchronously(doneWriting <-chan bool, result chan<- []string, reader io.Reader) { var readingString string for { diff --git a/cf/util/testhelpers/io/io_test.go b/cf/util/testhelpers/io/io_test.go index da4c78b6e6f..9fe0772c746 100644 --- a/cf/util/testhelpers/io/io_test.go +++ b/cf/util/testhelpers/io/io_test.go @@ -4,8 +4,8 @@ import ( "os" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/io" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/io" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/io/suite_test.go b/cf/util/testhelpers/io/suite_test.go index e7f78b3be80..9c6d911db62 100644 --- a/cf/util/testhelpers/io/suite_test.go +++ b/cf/util/testhelpers/io/suite_test.go @@ -1,7 +1,7 @@ package io_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/testhelpers/matchers/all_requests_called_matcher.go b/cf/util/testhelpers/matchers/all_requests_called_matcher.go index fe425529a58..e98bb9c7b6e 100644 --- a/cf/util/testhelpers/matchers/all_requests_called_matcher.go +++ b/cf/util/testhelpers/matchers/all_requests_called_matcher.go @@ -3,7 +3,7 @@ package matchers import ( "fmt" - "code.cloudfoundry.org/cli/cf/util/testhelpers/net" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/net" "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/be_in_display_order.go b/cf/util/testhelpers/matchers/be_in_display_order.go index ed52746c5d2..d58bb99f464 100644 --- a/cf/util/testhelpers/matchers/be_in_display_order.go +++ b/cf/util/testhelpers/matchers/be_in_display_order.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/terminal" "github.com/onsi/gomega" ) @@ -25,11 +25,11 @@ func (matcher *OrderMatcher) Match(actualStr interface{}) (success bool, err err return false, nil } - //loop and match, stop at last actual[0] line + // loop and match, stop at last actual[0] line for len(actual) > 1 { if matched, msg := matchSingleLine(actual[0], matcher.expected[0]); matched { if len(matcher.expected) == 1 { - return true, nil //no more expected to match, all passed + return true, nil // no more expected to match, all passed } matcher.expected = matcher.expected[1:] } else if msg != "" { @@ -39,7 +39,7 @@ func (matcher *OrderMatcher) Match(actualStr interface{}) (success bool, err err actual = actual[1:] } - //match the last actual line with the rest of expected + // match the last actual line with the rest of expected matched, msg := matchSingleLine(actual[0], matcher.expected[0]) if matched && len(matcher.expected) == 1 { return true, nil diff --git a/cf/util/testhelpers/matchers/be_in_display_order_test.go b/cf/util/testhelpers/matchers/be_in_display_order_test.go index 0a4e65e4a12..abf20f4c68a 100644 --- a/cf/util/testhelpers/matchers/be_in_display_order_test.go +++ b/cf/util/testhelpers/matchers/be_in_display_order_test.go @@ -3,9 +3,9 @@ package matchers_test import ( "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/contain_element_times_test.go b/cf/util/testhelpers/matchers/contain_element_times_test.go index d862f0c73ab..606ad12196c 100644 --- a/cf/util/testhelpers/matchers/contain_element_times_test.go +++ b/cf/util/testhelpers/matchers/contain_element_times_test.go @@ -1,8 +1,8 @@ package matchers_test import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/contain_elements_in_order_test.go b/cf/util/testhelpers/matchers/contain_elements_in_order_test.go index 9cba9e8ad8a..0500ff628ab 100644 --- a/cf/util/testhelpers/matchers/contain_elements_in_order_test.go +++ b/cf/util/testhelpers/matchers/contain_elements_in_order_test.go @@ -1,8 +1,8 @@ package matchers_test import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/contain_substrings.go b/cf/util/testhelpers/matchers/contain_substrings.go index bc31c2149bd..c1209d9362a 100644 --- a/cf/util/testhelpers/matchers/contain_substrings.go +++ b/cf/util/testhelpers/matchers/contain_substrings.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/terminal" "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/have_succeeded.go b/cf/util/testhelpers/matchers/have_succeeded.go index 1537fb7c486..917944400f9 100644 --- a/cf/util/testhelpers/matchers/have_succeeded.go +++ b/cf/util/testhelpers/matchers/have_succeeded.go @@ -3,7 +3,7 @@ package matchers import ( "fmt" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/have_type_of_test.go b/cf/util/testhelpers/matchers/have_type_of_test.go index e9e34765738..127612e9cc1 100644 --- a/cf/util/testhelpers/matchers/have_type_of_test.go +++ b/cf/util/testhelpers/matchers/have_type_of_test.go @@ -1,8 +1,8 @@ package matchers_test import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/matchers/match_func_name_test.go b/cf/util/testhelpers/matchers/match_func_name_test.go index 604b740d90b..2a06e9f1897 100644 --- a/cf/util/testhelpers/matchers/match_func_name_test.go +++ b/cf/util/testhelpers/matchers/match_func_name_test.go @@ -3,8 +3,8 @@ package matchers_test import ( "errors" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" . "github.com/onsi/gomega" ) @@ -99,7 +99,7 @@ var _ = Describe("MatchChangeAppFuncsByName", func() { }) }) - Describe("NegatedFaileureMessage", func() { + Describe("NegatedFailureMessage", func() { It("shows expected and actual", func() { matcher = MatchFuncsByName(dummyFunc) matcher.Match([]func(){dummyNotMatchFunc}) diff --git a/cf/util/testhelpers/matchers/match_path_test.go b/cf/util/testhelpers/matchers/match_path_test.go index 03146318811..a7f2dcdbc2d 100644 --- a/cf/util/testhelpers/matchers/match_path_test.go +++ b/cf/util/testhelpers/matchers/match_path_test.go @@ -1,9 +1,9 @@ package matchers_test import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" "errors" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" . "github.com/onsi/gomega" "io/ioutil" diff --git a/cf/util/testhelpers/matchers/matchers_suite_test.go b/cf/util/testhelpers/matchers/matchers_suite_test.go index 4d11b6a2147..e85892796fa 100644 --- a/cf/util/testhelpers/matchers/matchers_suite_test.go +++ b/cf/util/testhelpers/matchers/matchers_suite_test.go @@ -1,7 +1,7 @@ package matchers_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/cf/util/testhelpers/matchers/passed_requirements.go b/cf/util/testhelpers/matchers/passed_requirements.go index 0fce7829962..1756c375bdf 100644 --- a/cf/util/testhelpers/matchers/passed_requirements.go +++ b/cf/util/testhelpers/matchers/passed_requirements.go @@ -3,7 +3,7 @@ package matchers import ( "fmt" - testcmd "code.cloudfoundry.org/cli/cf/util/testhelpers/commands" + testcmd "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/commands" "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/net/make_tls_cert.go b/cf/util/testhelpers/net/make_tls_cert.go index ab55003fb0d..d681898d6e2 100644 --- a/cf/util/testhelpers/net/make_tls_cert.go +++ b/cf/util/testhelpers/net/make_tls_cert.go @@ -30,7 +30,7 @@ func MakeUnauthorizedTLSCert() tls.Certificate { } func generateCert(hosts []string, notAfter time.Time, isAuthorizedToSign bool) tls.Certificate { - priv, err := rsa.GenerateKey(rand.Reader, 1024) + priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { panic(err) } diff --git a/cf/util/testhelpers/net/request_matcher.go b/cf/util/testhelpers/net/request_matcher.go index 84950c2570e..e4d5b1ad5e4 100644 --- a/cf/util/testhelpers/net/request_matcher.go +++ b/cf/util/testhelpers/net/request_matcher.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cf/util/testhelpers/net/server.go b/cf/util/testhelpers/net/server.go index 79be4b70c83..7f31eeeabc6 100644 --- a/cf/util/testhelpers/net/server.go +++ b/cf/util/testhelpers/net/server.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" ) type TestRequest struct { @@ -41,7 +41,7 @@ func urlQueryContains(container, containee url.Values) bool { //Example: "foo:bar;baz:qux" is semantically the same as "baz:qux;foo:bar". CC doesn't care about order. - //Therefore, we crack apart "q" params on their seperator (a colon) and compare the resulting + //Therefore, we crack apart "q" params on their separator (a colon) and compare the resulting //substrings. No other params seem to use semicolon separators AND are order-dependent, so we just //run all params through the same process. for key := range containee { diff --git a/cf/util/testhelpers/rpcserver/rpcserverfakes/fake_handlers.go b/cf/util/testhelpers/rpcserver/rpcserverfakes/fake_handlers.go index b234743de44..461f7247501 100644 --- a/cf/util/testhelpers/rpcserver/rpcserverfakes/fake_handlers.go +++ b/cf/util/testhelpers/rpcserver/rpcserverfakes/fake_handlers.go @@ -4,9 +4,9 @@ package rpcserverfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/util/testhelpers/rpcserver" - "code.cloudfoundry.org/cli/plugin" - plugin_models "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/rpcserver" + "code.cloudfoundry.org/cli/v8/plugin" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" ) type FakeHandlers struct { @@ -381,15 +381,16 @@ func (fake *FakeHandlers) AccessToken(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{arg1, arg2}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -442,15 +443,16 @@ func (fake *FakeHandlers) ApiEndpoint(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.ApiEndpointStub + fakeReturns := fake.apiEndpointReturns fake.recordInvocation("ApiEndpoint", []interface{}{arg1, arg2}) fake.apiEndpointMutex.Unlock() - if fake.ApiEndpointStub != nil { - return fake.ApiEndpointStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.apiEndpointReturns return fakeReturns.result1 } @@ -503,15 +505,16 @@ func (fake *FakeHandlers) ApiVersion(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.ApiVersionStub + fakeReturns := fake.apiVersionReturns fake.recordInvocation("ApiVersion", []interface{}{arg1, arg2}) fake.apiVersionMutex.Unlock() - if fake.ApiVersionStub != nil { - return fake.ApiVersionStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.apiVersionReturns return fakeReturns.result1 } @@ -569,15 +572,16 @@ func (fake *FakeHandlers) CallCoreCommand(arg1 []string, arg2 *bool) error { arg1 []string arg2 *bool }{arg1Copy, arg2}) + stub := fake.CallCoreCommandStub + fakeReturns := fake.callCoreCommandReturns fake.recordInvocation("CallCoreCommand", []interface{}{arg1Copy, arg2}) fake.callCoreCommandMutex.Unlock() - if fake.CallCoreCommandStub != nil { - return fake.CallCoreCommandStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.callCoreCommandReturns return fakeReturns.result1 } @@ -630,15 +634,16 @@ func (fake *FakeHandlers) DisableTerminalOutput(arg1 bool, arg2 *bool) error { arg1 bool arg2 *bool }{arg1, arg2}) + stub := fake.DisableTerminalOutputStub + fakeReturns := fake.disableTerminalOutputReturns fake.recordInvocation("DisableTerminalOutput", []interface{}{arg1, arg2}) fake.disableTerminalOutputMutex.Unlock() - if fake.DisableTerminalOutputStub != nil { - return fake.DisableTerminalOutputStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.disableTerminalOutputReturns return fakeReturns.result1 } @@ -691,15 +696,16 @@ func (fake *FakeHandlers) DopplerEndpoint(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.DopplerEndpointStub + fakeReturns := fake.dopplerEndpointReturns fake.recordInvocation("DopplerEndpoint", []interface{}{arg1, arg2}) fake.dopplerEndpointMutex.Unlock() - if fake.DopplerEndpointStub != nil { - return fake.DopplerEndpointStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.dopplerEndpointReturns return fakeReturns.result1 } @@ -752,15 +758,16 @@ func (fake *FakeHandlers) GetApp(arg1 string, arg2 *plugin_models.GetAppModel) e arg1 string arg2 *plugin_models.GetAppModel }{arg1, arg2}) + stub := fake.GetAppStub + fakeReturns := fake.getAppReturns fake.recordInvocation("GetApp", []interface{}{arg1, arg2}) fake.getAppMutex.Unlock() - if fake.GetAppStub != nil { - return fake.GetAppStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getAppReturns return fakeReturns.result1 } @@ -813,15 +820,16 @@ func (fake *FakeHandlers) GetApps(arg1 string, arg2 *[]plugin_models.GetAppsMode arg1 string arg2 *[]plugin_models.GetAppsModel }{arg1, arg2}) + stub := fake.GetAppsStub + fakeReturns := fake.getAppsReturns fake.recordInvocation("GetApps", []interface{}{arg1, arg2}) fake.getAppsMutex.Unlock() - if fake.GetAppsStub != nil { - return fake.GetAppsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getAppsReturns return fakeReturns.result1 } @@ -874,15 +882,16 @@ func (fake *FakeHandlers) GetCurrentOrg(arg1 string, arg2 *plugin_models.Organiz arg1 string arg2 *plugin_models.Organization }{arg1, arg2}) + stub := fake.GetCurrentOrgStub + fakeReturns := fake.getCurrentOrgReturns fake.recordInvocation("GetCurrentOrg", []interface{}{arg1, arg2}) fake.getCurrentOrgMutex.Unlock() - if fake.GetCurrentOrgStub != nil { - return fake.GetCurrentOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getCurrentOrgReturns return fakeReturns.result1 } @@ -935,15 +944,16 @@ func (fake *FakeHandlers) GetCurrentSpace(arg1 string, arg2 *plugin_models.Space arg1 string arg2 *plugin_models.Space }{arg1, arg2}) + stub := fake.GetCurrentSpaceStub + fakeReturns := fake.getCurrentSpaceReturns fake.recordInvocation("GetCurrentSpace", []interface{}{arg1, arg2}) fake.getCurrentSpaceMutex.Unlock() - if fake.GetCurrentSpaceStub != nil { - return fake.GetCurrentSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getCurrentSpaceReturns return fakeReturns.result1 } @@ -996,15 +1006,16 @@ func (fake *FakeHandlers) GetOrg(arg1 string, arg2 *plugin_models.GetOrg_Model) arg1 string arg2 *plugin_models.GetOrg_Model }{arg1, arg2}) + stub := fake.GetOrgStub + fakeReturns := fake.getOrgReturns fake.recordInvocation("GetOrg", []interface{}{arg1, arg2}) fake.getOrgMutex.Unlock() - if fake.GetOrgStub != nil { - return fake.GetOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getOrgReturns return fakeReturns.result1 } @@ -1062,15 +1073,16 @@ func (fake *FakeHandlers) GetOrgUsers(arg1 []string, arg2 *[]plugin_models.GetOr arg1 []string arg2 *[]plugin_models.GetOrgUsers_Model }{arg1Copy, arg2}) + stub := fake.GetOrgUsersStub + fakeReturns := fake.getOrgUsersReturns fake.recordInvocation("GetOrgUsers", []interface{}{arg1Copy, arg2}) fake.getOrgUsersMutex.Unlock() - if fake.GetOrgUsersStub != nil { - return fake.GetOrgUsersStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getOrgUsersReturns return fakeReturns.result1 } @@ -1123,15 +1135,16 @@ func (fake *FakeHandlers) GetOrgs(arg1 string, arg2 *[]plugin_models.GetOrgs_Mod arg1 string arg2 *[]plugin_models.GetOrgs_Model }{arg1, arg2}) + stub := fake.GetOrgsStub + fakeReturns := fake.getOrgsReturns fake.recordInvocation("GetOrgs", []interface{}{arg1, arg2}) fake.getOrgsMutex.Unlock() - if fake.GetOrgsStub != nil { - return fake.GetOrgsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getOrgsReturns return fakeReturns.result1 } @@ -1184,15 +1197,16 @@ func (fake *FakeHandlers) GetOutputAndReset(arg1 bool, arg2 *[]string) error { arg1 bool arg2 *[]string }{arg1, arg2}) + stub := fake.GetOutputAndResetStub + fakeReturns := fake.getOutputAndResetReturns fake.recordInvocation("GetOutputAndReset", []interface{}{arg1, arg2}) fake.getOutputAndResetMutex.Unlock() - if fake.GetOutputAndResetStub != nil { - return fake.GetOutputAndResetStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getOutputAndResetReturns return fakeReturns.result1 } @@ -1245,15 +1259,16 @@ func (fake *FakeHandlers) GetService(arg1 string, arg2 *plugin_models.GetService arg1 string arg2 *plugin_models.GetService_Model }{arg1, arg2}) + stub := fake.GetServiceStub + fakeReturns := fake.getServiceReturns fake.recordInvocation("GetService", []interface{}{arg1, arg2}) fake.getServiceMutex.Unlock() - if fake.GetServiceStub != nil { - return fake.GetServiceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getServiceReturns return fakeReturns.result1 } @@ -1306,15 +1321,16 @@ func (fake *FakeHandlers) GetServices(arg1 string, arg2 *[]plugin_models.GetServ arg1 string arg2 *[]plugin_models.GetServices_Model }{arg1, arg2}) + stub := fake.GetServicesStub + fakeReturns := fake.getServicesReturns fake.recordInvocation("GetServices", []interface{}{arg1, arg2}) fake.getServicesMutex.Unlock() - if fake.GetServicesStub != nil { - return fake.GetServicesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getServicesReturns return fakeReturns.result1 } @@ -1367,15 +1383,16 @@ func (fake *FakeHandlers) GetSpace(arg1 string, arg2 *plugin_models.GetSpace_Mod arg1 string arg2 *plugin_models.GetSpace_Model }{arg1, arg2}) + stub := fake.GetSpaceStub + fakeReturns := fake.getSpaceReturns fake.recordInvocation("GetSpace", []interface{}{arg1, arg2}) fake.getSpaceMutex.Unlock() - if fake.GetSpaceStub != nil { - return fake.GetSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getSpaceReturns return fakeReturns.result1 } @@ -1433,15 +1450,16 @@ func (fake *FakeHandlers) GetSpaceUsers(arg1 []string, arg2 *[]plugin_models.Get arg1 []string arg2 *[]plugin_models.GetSpaceUsers_Model }{arg1Copy, arg2}) + stub := fake.GetSpaceUsersStub + fakeReturns := fake.getSpaceUsersReturns fake.recordInvocation("GetSpaceUsers", []interface{}{arg1Copy, arg2}) fake.getSpaceUsersMutex.Unlock() - if fake.GetSpaceUsersStub != nil { - return fake.GetSpaceUsersStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getSpaceUsersReturns return fakeReturns.result1 } @@ -1494,15 +1512,16 @@ func (fake *FakeHandlers) GetSpaces(arg1 string, arg2 *[]plugin_models.GetSpaces arg1 string arg2 *[]plugin_models.GetSpaces_Model }{arg1, arg2}) + stub := fake.GetSpacesStub + fakeReturns := fake.getSpacesReturns fake.recordInvocation("GetSpaces", []interface{}{arg1, arg2}) fake.getSpacesMutex.Unlock() - if fake.GetSpacesStub != nil { - return fake.GetSpacesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getSpacesReturns return fakeReturns.result1 } @@ -1555,15 +1574,16 @@ func (fake *FakeHandlers) HasAPIEndpoint(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.HasAPIEndpointStub + fakeReturns := fake.hasAPIEndpointReturns fake.recordInvocation("HasAPIEndpoint", []interface{}{arg1, arg2}) fake.hasAPIEndpointMutex.Unlock() - if fake.HasAPIEndpointStub != nil { - return fake.HasAPIEndpointStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.hasAPIEndpointReturns return fakeReturns.result1 } @@ -1616,15 +1636,16 @@ func (fake *FakeHandlers) HasOrganization(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.HasOrganizationStub + fakeReturns := fake.hasOrganizationReturns fake.recordInvocation("HasOrganization", []interface{}{arg1, arg2}) fake.hasOrganizationMutex.Unlock() - if fake.HasOrganizationStub != nil { - return fake.HasOrganizationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.hasOrganizationReturns return fakeReturns.result1 } @@ -1677,15 +1698,16 @@ func (fake *FakeHandlers) HasSpace(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.HasSpaceStub + fakeReturns := fake.hasSpaceReturns fake.recordInvocation("HasSpace", []interface{}{arg1, arg2}) fake.hasSpaceMutex.Unlock() - if fake.HasSpaceStub != nil { - return fake.HasSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.hasSpaceReturns return fakeReturns.result1 } @@ -1738,15 +1760,16 @@ func (fake *FakeHandlers) IsLoggedIn(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.IsLoggedInStub + fakeReturns := fake.isLoggedInReturns fake.recordInvocation("IsLoggedIn", []interface{}{arg1, arg2}) fake.isLoggedInMutex.Unlock() - if fake.IsLoggedInStub != nil { - return fake.IsLoggedInStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.isLoggedInReturns return fakeReturns.result1 } @@ -1799,15 +1822,16 @@ func (fake *FakeHandlers) IsMinCliVersion(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.IsMinCliVersionStub + fakeReturns := fake.isMinCliVersionReturns fake.recordInvocation("IsMinCliVersion", []interface{}{arg1, arg2}) fake.isMinCliVersionMutex.Unlock() - if fake.IsMinCliVersionStub != nil { - return fake.IsMinCliVersionStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.isMinCliVersionReturns return fakeReturns.result1 } @@ -1860,15 +1884,16 @@ func (fake *FakeHandlers) IsSSLDisabled(arg1 string, arg2 *bool) error { arg1 string arg2 *bool }{arg1, arg2}) + stub := fake.IsSSLDisabledStub + fakeReturns := fake.isSSLDisabledReturns fake.recordInvocation("IsSSLDisabled", []interface{}{arg1, arg2}) fake.isSSLDisabledMutex.Unlock() - if fake.IsSSLDisabledStub != nil { - return fake.IsSSLDisabledStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.isSSLDisabledReturns return fakeReturns.result1 } @@ -1921,15 +1946,16 @@ func (fake *FakeHandlers) LoggregatorEndpoint(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.LoggregatorEndpointStub + fakeReturns := fake.loggregatorEndpointReturns fake.recordInvocation("LoggregatorEndpoint", []interface{}{arg1, arg2}) fake.loggregatorEndpointMutex.Unlock() - if fake.LoggregatorEndpointStub != nil { - return fake.LoggregatorEndpointStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.loggregatorEndpointReturns return fakeReturns.result1 } @@ -1982,15 +2008,16 @@ func (fake *FakeHandlers) SetPluginMetadata(arg1 plugin.PluginMetadata, arg2 *bo arg1 plugin.PluginMetadata arg2 *bool }{arg1, arg2}) + stub := fake.SetPluginMetadataStub + fakeReturns := fake.setPluginMetadataReturns fake.recordInvocation("SetPluginMetadata", []interface{}{arg1, arg2}) fake.setPluginMetadataMutex.Unlock() - if fake.SetPluginMetadataStub != nil { - return fake.SetPluginMetadataStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.setPluginMetadataReturns return fakeReturns.result1 } @@ -2043,15 +2070,16 @@ func (fake *FakeHandlers) UserEmail(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.UserEmailStub + fakeReturns := fake.userEmailReturns fake.recordInvocation("UserEmail", []interface{}{arg1, arg2}) fake.userEmailMutex.Unlock() - if fake.UserEmailStub != nil { - return fake.UserEmailStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.userEmailReturns return fakeReturns.result1 } @@ -2104,15 +2132,16 @@ func (fake *FakeHandlers) UserGuid(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.UserGuidStub + fakeReturns := fake.userGuidReturns fake.recordInvocation("UserGuid", []interface{}{arg1, arg2}) fake.userGuidMutex.Unlock() - if fake.UserGuidStub != nil { - return fake.UserGuidStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.userGuidReturns return fakeReturns.result1 } @@ -2165,15 +2194,16 @@ func (fake *FakeHandlers) Username(arg1 string, arg2 *string) error { arg1 string arg2 *string }{arg1, arg2}) + stub := fake.UsernameStub + fakeReturns := fake.usernameReturns fake.recordInvocation("Username", []interface{}{arg1, arg2}) fake.usernameMutex.Unlock() - if fake.UsernameStub != nil { - return fake.UsernameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.usernameReturns return fakeReturns.result1 } diff --git a/cf/util/testhelpers/rpcserver/server.go b/cf/util/testhelpers/rpcserver/server.go index 8933195911c..72eba1f6455 100644 --- a/cf/util/testhelpers/rpcserver/server.go +++ b/cf/util/testhelpers/rpcserver/server.go @@ -9,8 +9,8 @@ import ( "os" "strconv" - "code.cloudfoundry.org/cli/plugin" - "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/plugin" + "code.cloudfoundry.org/cli/v8/plugin/models" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Handlers diff --git a/cf/util/testhelpers/terminal/ui.go b/cf/util/testhelpers/terminal/ui.go index ec8a0cbd9cd..2ac3ed5765d 100644 --- a/cf/util/testhelpers/terminal/ui.go +++ b/cf/util/testhelpers/terminal/ui.go @@ -9,8 +9,8 @@ import ( "os" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - term "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + term "code.cloudfoundry.org/cli/v8/cf/terminal" ) type FakeUI struct { diff --git a/cf/util/utilfakes/fake_sha1checksum.go b/cf/util/utilfakes/fake_sha1checksum.go index 977e7cc7d47..1d9d0653000 100644 --- a/cf/util/utilfakes/fake_sha1checksum.go +++ b/cf/util/utilfakes/fake_sha1checksum.go @@ -4,7 +4,7 @@ package utilfakes import ( "sync" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/util" ) type FakeSha1Checksum struct { diff --git a/command/api_version_warning.go b/command/api_version_warning.go index db206edcda0..e53946fdf57 100644 --- a/command/api_version_warning.go +++ b/command/api_version_warning.go @@ -1,9 +1,9 @@ package command import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - "code.cloudfoundry.org/cli/version" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/version" + "github.com/blang/semver/v4" ) type APIVersionTooHighError struct{} diff --git a/command/api_version_warning_test.go b/command/api_version_warning_test.go index 1e07989e00b..6282e44f314 100644 --- a/command/api_version_warning_test.go +++ b/command/api_version_warning_test.go @@ -4,13 +4,13 @@ import ( "fmt" "regexp" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - . "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/util/ui" - "code.cloudfoundry.org/cli/version" - "github.com/blang/semver" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/util/ui" + "code.cloudfoundry.org/cli/v8/version" + "github.com/blang/semver/v4" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/command_suite_test.go b/command/command_suite_test.go index 33fb4da90fb..af257e39a12 100644 --- a/command/command_suite_test.go +++ b/command/command_suite_test.go @@ -1,7 +1,7 @@ package command_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/command/commandfakes/fake_config.go b/command/commandfakes/fake_config.go index 4e94d9f543c..54c5de6ca7d 100644 --- a/command/commandfakes/fake_config.go +++ b/command/commandfakes/fake_config.go @@ -5,8 +5,8 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeConfig struct { @@ -51,6 +51,26 @@ type FakeConfig struct { authorizationEndpointReturnsOnCall map[int]struct { result1 string } + B3SpanIDStub func() string + b3SpanIDMutex sync.RWMutex + b3SpanIDArgsForCall []struct { + } + b3SpanIDReturns struct { + result1 string + } + b3SpanIDReturnsOnCall map[int]struct { + result1 string + } + B3TraceIDStub func() string + b3TraceIDMutex sync.RWMutex + b3TraceIDArgsForCall []struct { + } + b3TraceIDReturns struct { + result1 string + } + b3TraceIDReturnsOnCall map[int]struct { + result1 string + } BinaryNameStub func() string binaryNameMutex sync.RWMutex binaryNameArgsForCall []struct { @@ -91,6 +111,18 @@ type FakeConfig struct { cFUsernameReturnsOnCall map[int]struct { result1 string } + CNBCredentialsStub func() (map[string]interface{}, error) + cNBCredentialsMutex sync.RWMutex + cNBCredentialsArgsForCall []struct { + } + cNBCredentialsReturns struct { + result1 map[string]interface{} + result2 error + } + cNBCredentialsReturnsOnCall map[int]struct { + result1 map[string]interface{} + result2 error + } ColorEnabledStub func() configv3.ColorSetting colorEnabledMutex sync.RWMutex colorEnabledArgsForCall []struct { @@ -636,15 +668,16 @@ func (fake *FakeConfig) APIVersion() string { ret, specificReturn := fake.aPIVersionReturnsOnCall[len(fake.aPIVersionArgsForCall)] fake.aPIVersionArgsForCall = append(fake.aPIVersionArgsForCall, struct { }{}) + stub := fake.APIVersionStub + fakeReturns := fake.aPIVersionReturns fake.recordInvocation("APIVersion", []interface{}{}) fake.aPIVersionMutex.Unlock() - if fake.APIVersionStub != nil { - return fake.APIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.aPIVersionReturns return fakeReturns.result1 } @@ -688,15 +721,16 @@ func (fake *FakeConfig) AccessToken() string { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1 } @@ -740,9 +774,10 @@ func (fake *FakeConfig) AddPlugin(arg1 configv3.Plugin) { fake.addPluginArgsForCall = append(fake.addPluginArgsForCall, struct { arg1 configv3.Plugin }{arg1}) + stub := fake.AddPluginStub fake.recordInvocation("AddPlugin", []interface{}{arg1}) fake.addPluginMutex.Unlock() - if fake.AddPluginStub != nil { + if stub != nil { fake.AddPluginStub(arg1) } } @@ -772,9 +807,10 @@ func (fake *FakeConfig) AddPluginRepository(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.AddPluginRepositoryStub fake.recordInvocation("AddPluginRepository", []interface{}{arg1, arg2}) fake.addPluginRepositoryMutex.Unlock() - if fake.AddPluginRepositoryStub != nil { + if stub != nil { fake.AddPluginRepositoryStub(arg1, arg2) } } @@ -803,15 +839,16 @@ func (fake *FakeConfig) AuthorizationEndpoint() string { ret, specificReturn := fake.authorizationEndpointReturnsOnCall[len(fake.authorizationEndpointArgsForCall)] fake.authorizationEndpointArgsForCall = append(fake.authorizationEndpointArgsForCall, struct { }{}) + stub := fake.AuthorizationEndpointStub + fakeReturns := fake.authorizationEndpointReturns fake.recordInvocation("AuthorizationEndpoint", []interface{}{}) fake.authorizationEndpointMutex.Unlock() - if fake.AuthorizationEndpointStub != nil { - return fake.AuthorizationEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.authorizationEndpointReturns return fakeReturns.result1 } @@ -850,20 +887,127 @@ func (fake *FakeConfig) AuthorizationEndpointReturnsOnCall(i int, result1 string }{result1} } +func (fake *FakeConfig) B3SpanID() string { + fake.b3SpanIDMutex.Lock() + ret, specificReturn := fake.b3SpanIDReturnsOnCall[len(fake.b3SpanIDArgsForCall)] + fake.b3SpanIDArgsForCall = append(fake.b3SpanIDArgsForCall, struct { + }{}) + stub := fake.B3SpanIDStub + fakeReturns := fake.b3SpanIDReturns + fake.recordInvocation("B3SpanID", []interface{}{}) + fake.b3SpanIDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeConfig) B3SpanIDCallCount() int { + fake.b3SpanIDMutex.RLock() + defer fake.b3SpanIDMutex.RUnlock() + return len(fake.b3SpanIDArgsForCall) +} + +func (fake *FakeConfig) B3SpanIDCalls(stub func() string) { + fake.b3SpanIDMutex.Lock() + defer fake.b3SpanIDMutex.Unlock() + fake.B3SpanIDStub = stub +} + +func (fake *FakeConfig) B3SpanIDReturns(result1 string) { + fake.b3SpanIDMutex.Lock() + defer fake.b3SpanIDMutex.Unlock() + fake.B3SpanIDStub = nil + fake.b3SpanIDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeConfig) B3SpanIDReturnsOnCall(i int, result1 string) { + fake.b3SpanIDMutex.Lock() + defer fake.b3SpanIDMutex.Unlock() + fake.B3SpanIDStub = nil + if fake.b3SpanIDReturnsOnCall == nil { + fake.b3SpanIDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.b3SpanIDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeConfig) B3TraceID() string { + fake.b3TraceIDMutex.Lock() + ret, specificReturn := fake.b3TraceIDReturnsOnCall[len(fake.b3TraceIDArgsForCall)] + fake.b3TraceIDArgsForCall = append(fake.b3TraceIDArgsForCall, struct { + }{}) + stub := fake.B3TraceIDStub + fakeReturns := fake.b3TraceIDReturns + fake.recordInvocation("B3TraceID", []interface{}{}) + fake.b3TraceIDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeConfig) B3TraceIDCallCount() int { + fake.b3TraceIDMutex.RLock() + defer fake.b3TraceIDMutex.RUnlock() + return len(fake.b3TraceIDArgsForCall) +} + +func (fake *FakeConfig) B3TraceIDCalls(stub func() string) { + fake.b3TraceIDMutex.Lock() + defer fake.b3TraceIDMutex.Unlock() + fake.B3TraceIDStub = stub +} + +func (fake *FakeConfig) B3TraceIDReturns(result1 string) { + fake.b3TraceIDMutex.Lock() + defer fake.b3TraceIDMutex.Unlock() + fake.B3TraceIDStub = nil + fake.b3TraceIDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeConfig) B3TraceIDReturnsOnCall(i int, result1 string) { + fake.b3TraceIDMutex.Lock() + defer fake.b3TraceIDMutex.Unlock() + fake.B3TraceIDStub = nil + if fake.b3TraceIDReturnsOnCall == nil { + fake.b3TraceIDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.b3TraceIDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + func (fake *FakeConfig) BinaryName() string { fake.binaryNameMutex.Lock() ret, specificReturn := fake.binaryNameReturnsOnCall[len(fake.binaryNameArgsForCall)] fake.binaryNameArgsForCall = append(fake.binaryNameArgsForCall, struct { }{}) + stub := fake.BinaryNameStub + fakeReturns := fake.binaryNameReturns fake.recordInvocation("BinaryName", []interface{}{}) fake.binaryNameMutex.Unlock() - if fake.BinaryNameStub != nil { - return fake.BinaryNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryNameReturns return fakeReturns.result1 } @@ -907,15 +1051,16 @@ func (fake *FakeConfig) BinaryVersion() string { ret, specificReturn := fake.binaryVersionReturnsOnCall[len(fake.binaryVersionArgsForCall)] fake.binaryVersionArgsForCall = append(fake.binaryVersionArgsForCall, struct { }{}) + stub := fake.BinaryVersionStub + fakeReturns := fake.binaryVersionReturns fake.recordInvocation("BinaryVersion", []interface{}{}) fake.binaryVersionMutex.Unlock() - if fake.BinaryVersionStub != nil { - return fake.BinaryVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.binaryVersionReturns return fakeReturns.result1 } @@ -959,15 +1104,16 @@ func (fake *FakeConfig) CFPassword() string { ret, specificReturn := fake.cFPasswordReturnsOnCall[len(fake.cFPasswordArgsForCall)] fake.cFPasswordArgsForCall = append(fake.cFPasswordArgsForCall, struct { }{}) + stub := fake.CFPasswordStub + fakeReturns := fake.cFPasswordReturns fake.recordInvocation("CFPassword", []interface{}{}) fake.cFPasswordMutex.Unlock() - if fake.CFPasswordStub != nil { - return fake.CFPasswordStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.cFPasswordReturns return fakeReturns.result1 } @@ -1011,15 +1157,16 @@ func (fake *FakeConfig) CFUsername() string { ret, specificReturn := fake.cFUsernameReturnsOnCall[len(fake.cFUsernameArgsForCall)] fake.cFUsernameArgsForCall = append(fake.cFUsernameArgsForCall, struct { }{}) + stub := fake.CFUsernameStub + fakeReturns := fake.cFUsernameReturns fake.recordInvocation("CFUsername", []interface{}{}) fake.cFUsernameMutex.Unlock() - if fake.CFUsernameStub != nil { - return fake.CFUsernameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.cFUsernameReturns return fakeReturns.result1 } @@ -1058,20 +1205,77 @@ func (fake *FakeConfig) CFUsernameReturnsOnCall(i int, result1 string) { }{result1} } +func (fake *FakeConfig) CNBCredentials() (map[string]interface{}, error) { + fake.cNBCredentialsMutex.Lock() + ret, specificReturn := fake.cNBCredentialsReturnsOnCall[len(fake.cNBCredentialsArgsForCall)] + fake.cNBCredentialsArgsForCall = append(fake.cNBCredentialsArgsForCall, struct { + }{}) + stub := fake.CNBCredentialsStub + fakeReturns := fake.cNBCredentialsReturns + fake.recordInvocation("CNBCredentials", []interface{}{}) + fake.cNBCredentialsMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeConfig) CNBCredentialsCallCount() int { + fake.cNBCredentialsMutex.RLock() + defer fake.cNBCredentialsMutex.RUnlock() + return len(fake.cNBCredentialsArgsForCall) +} + +func (fake *FakeConfig) CNBCredentialsCalls(stub func() (map[string]interface{}, error)) { + fake.cNBCredentialsMutex.Lock() + defer fake.cNBCredentialsMutex.Unlock() + fake.CNBCredentialsStub = stub +} + +func (fake *FakeConfig) CNBCredentialsReturns(result1 map[string]interface{}, result2 error) { + fake.cNBCredentialsMutex.Lock() + defer fake.cNBCredentialsMutex.Unlock() + fake.CNBCredentialsStub = nil + fake.cNBCredentialsReturns = struct { + result1 map[string]interface{} + result2 error + }{result1, result2} +} + +func (fake *FakeConfig) CNBCredentialsReturnsOnCall(i int, result1 map[string]interface{}, result2 error) { + fake.cNBCredentialsMutex.Lock() + defer fake.cNBCredentialsMutex.Unlock() + fake.CNBCredentialsStub = nil + if fake.cNBCredentialsReturnsOnCall == nil { + fake.cNBCredentialsReturnsOnCall = make(map[int]struct { + result1 map[string]interface{} + result2 error + }) + } + fake.cNBCredentialsReturnsOnCall[i] = struct { + result1 map[string]interface{} + result2 error + }{result1, result2} +} + func (fake *FakeConfig) ColorEnabled() configv3.ColorSetting { fake.colorEnabledMutex.Lock() ret, specificReturn := fake.colorEnabledReturnsOnCall[len(fake.colorEnabledArgsForCall)] fake.colorEnabledArgsForCall = append(fake.colorEnabledArgsForCall, struct { }{}) + stub := fake.ColorEnabledStub + fakeReturns := fake.colorEnabledReturns fake.recordInvocation("ColorEnabled", []interface{}{}) fake.colorEnabledMutex.Unlock() - if fake.ColorEnabledStub != nil { - return fake.ColorEnabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.colorEnabledReturns return fakeReturns.result1 } @@ -1115,15 +1319,16 @@ func (fake *FakeConfig) CurrentUser() (configv3.User, error) { ret, specificReturn := fake.currentUserReturnsOnCall[len(fake.currentUserArgsForCall)] fake.currentUserArgsForCall = append(fake.currentUserArgsForCall, struct { }{}) + stub := fake.CurrentUserStub + fakeReturns := fake.currentUserReturns fake.recordInvocation("CurrentUser", []interface{}{}) fake.currentUserMutex.Unlock() - if fake.CurrentUserStub != nil { - return fake.CurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1170,15 +1375,16 @@ func (fake *FakeConfig) CurrentUserName() (string, error) { ret, specificReturn := fake.currentUserNameReturnsOnCall[len(fake.currentUserNameArgsForCall)] fake.currentUserNameArgsForCall = append(fake.currentUserNameArgsForCall, struct { }{}) + stub := fake.CurrentUserNameStub + fakeReturns := fake.currentUserNameReturns fake.recordInvocation("CurrentUserName", []interface{}{}) fake.currentUserNameMutex.Unlock() - if fake.CurrentUserNameStub != nil { - return fake.CurrentUserNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1225,15 +1431,16 @@ func (fake *FakeConfig) DialTimeout() time.Duration { ret, specificReturn := fake.dialTimeoutReturnsOnCall[len(fake.dialTimeoutArgsForCall)] fake.dialTimeoutArgsForCall = append(fake.dialTimeoutArgsForCall, struct { }{}) + stub := fake.DialTimeoutStub + fakeReturns := fake.dialTimeoutReturns fake.recordInvocation("DialTimeout", []interface{}{}) fake.dialTimeoutMutex.Unlock() - if fake.DialTimeoutStub != nil { - return fake.DialTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dialTimeoutReturns return fakeReturns.result1 } @@ -1277,15 +1484,16 @@ func (fake *FakeConfig) DockerPassword() string { ret, specificReturn := fake.dockerPasswordReturnsOnCall[len(fake.dockerPasswordArgsForCall)] fake.dockerPasswordArgsForCall = append(fake.dockerPasswordArgsForCall, struct { }{}) + stub := fake.DockerPasswordStub + fakeReturns := fake.dockerPasswordReturns fake.recordInvocation("DockerPassword", []interface{}{}) fake.dockerPasswordMutex.Unlock() - if fake.DockerPasswordStub != nil { - return fake.DockerPasswordStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.dockerPasswordReturns return fakeReturns.result1 } @@ -1329,15 +1537,16 @@ func (fake *FakeConfig) Experimental() bool { ret, specificReturn := fake.experimentalReturnsOnCall[len(fake.experimentalArgsForCall)] fake.experimentalArgsForCall = append(fake.experimentalArgsForCall, struct { }{}) + stub := fake.ExperimentalStub + fakeReturns := fake.experimentalReturns fake.recordInvocation("Experimental", []interface{}{}) fake.experimentalMutex.Unlock() - if fake.ExperimentalStub != nil { - return fake.ExperimentalStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.experimentalReturns return fakeReturns.result1 } @@ -1382,15 +1591,16 @@ func (fake *FakeConfig) GetPlugin(arg1 string) (configv3.Plugin, bool) { fake.getPluginArgsForCall = append(fake.getPluginArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPluginStub + fakeReturns := fake.getPluginReturns fake.recordInvocation("GetPlugin", []interface{}{arg1}) fake.getPluginMutex.Unlock() - if fake.GetPluginStub != nil { - return fake.GetPluginStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1445,15 +1655,16 @@ func (fake *FakeConfig) GetPluginCaseInsensitive(arg1 string) (configv3.Plugin, fake.getPluginCaseInsensitiveArgsForCall = append(fake.getPluginCaseInsensitiveArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPluginCaseInsensitiveStub + fakeReturns := fake.getPluginCaseInsensitiveReturns fake.recordInvocation("GetPluginCaseInsensitive", []interface{}{arg1}) fake.getPluginCaseInsensitiveMutex.Unlock() - if fake.GetPluginCaseInsensitiveStub != nil { - return fake.GetPluginCaseInsensitiveStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginCaseInsensitiveReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1507,15 +1718,16 @@ func (fake *FakeConfig) HasTargetedOrganization() bool { ret, specificReturn := fake.hasTargetedOrganizationReturnsOnCall[len(fake.hasTargetedOrganizationArgsForCall)] fake.hasTargetedOrganizationArgsForCall = append(fake.hasTargetedOrganizationArgsForCall, struct { }{}) + stub := fake.HasTargetedOrganizationStub + fakeReturns := fake.hasTargetedOrganizationReturns fake.recordInvocation("HasTargetedOrganization", []interface{}{}) fake.hasTargetedOrganizationMutex.Unlock() - if fake.HasTargetedOrganizationStub != nil { - return fake.HasTargetedOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasTargetedOrganizationReturns return fakeReturns.result1 } @@ -1559,15 +1771,16 @@ func (fake *FakeConfig) HasTargetedSpace() bool { ret, specificReturn := fake.hasTargetedSpaceReturnsOnCall[len(fake.hasTargetedSpaceArgsForCall)] fake.hasTargetedSpaceArgsForCall = append(fake.hasTargetedSpaceArgsForCall, struct { }{}) + stub := fake.HasTargetedSpaceStub + fakeReturns := fake.hasTargetedSpaceReturns fake.recordInvocation("HasTargetedSpace", []interface{}{}) fake.hasTargetedSpaceMutex.Unlock() - if fake.HasTargetedSpaceStub != nil { - return fake.HasTargetedSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.hasTargetedSpaceReturns return fakeReturns.result1 } @@ -1611,15 +1824,16 @@ func (fake *FakeConfig) IsCFOnK8s() bool { ret, specificReturn := fake.isCFOnK8sReturnsOnCall[len(fake.isCFOnK8sArgsForCall)] fake.isCFOnK8sArgsForCall = append(fake.isCFOnK8sArgsForCall, struct { }{}) + stub := fake.IsCFOnK8sStub + fakeReturns := fake.isCFOnK8sReturns fake.recordInvocation("IsCFOnK8s", []interface{}{}) fake.isCFOnK8sMutex.Unlock() - if fake.IsCFOnK8sStub != nil { - return fake.IsCFOnK8sStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isCFOnK8sReturns return fakeReturns.result1 } @@ -1663,15 +1877,16 @@ func (fake *FakeConfig) IsTTY() bool { ret, specificReturn := fake.isTTYReturnsOnCall[len(fake.isTTYArgsForCall)] fake.isTTYArgsForCall = append(fake.isTTYArgsForCall, struct { }{}) + stub := fake.IsTTYStub + fakeReturns := fake.isTTYReturns fake.recordInvocation("IsTTY", []interface{}{}) fake.isTTYMutex.Unlock() - if fake.IsTTYStub != nil { - return fake.IsTTYStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isTTYReturns return fakeReturns.result1 } @@ -1715,15 +1930,16 @@ func (fake *FakeConfig) Locale() string { ret, specificReturn := fake.localeReturnsOnCall[len(fake.localeArgsForCall)] fake.localeArgsForCall = append(fake.localeArgsForCall, struct { }{}) + stub := fake.LocaleStub + fakeReturns := fake.localeReturns fake.recordInvocation("Locale", []interface{}{}) fake.localeMutex.Unlock() - if fake.LocaleStub != nil { - return fake.LocaleStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.localeReturns return fakeReturns.result1 } @@ -1767,15 +1983,16 @@ func (fake *FakeConfig) LogCacheEndpoint() string { ret, specificReturn := fake.logCacheEndpointReturnsOnCall[len(fake.logCacheEndpointArgsForCall)] fake.logCacheEndpointArgsForCall = append(fake.logCacheEndpointArgsForCall, struct { }{}) + stub := fake.LogCacheEndpointStub + fakeReturns := fake.logCacheEndpointReturns fake.recordInvocation("LogCacheEndpoint", []interface{}{}) fake.logCacheEndpointMutex.Unlock() - if fake.LogCacheEndpointStub != nil { - return fake.LogCacheEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.logCacheEndpointReturns return fakeReturns.result1 } @@ -1819,15 +2036,16 @@ func (fake *FakeConfig) MinCLIVersion() string { ret, specificReturn := fake.minCLIVersionReturnsOnCall[len(fake.minCLIVersionArgsForCall)] fake.minCLIVersionArgsForCall = append(fake.minCLIVersionArgsForCall, struct { }{}) + stub := fake.MinCLIVersionStub + fakeReturns := fake.minCLIVersionReturns fake.recordInvocation("MinCLIVersion", []interface{}{}) fake.minCLIVersionMutex.Unlock() - if fake.MinCLIVersionStub != nil { - return fake.MinCLIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.minCLIVersionReturns return fakeReturns.result1 } @@ -1871,15 +2089,16 @@ func (fake *FakeConfig) NOAARequestRetryCount() int { ret, specificReturn := fake.nOAARequestRetryCountReturnsOnCall[len(fake.nOAARequestRetryCountArgsForCall)] fake.nOAARequestRetryCountArgsForCall = append(fake.nOAARequestRetryCountArgsForCall, struct { }{}) + stub := fake.NOAARequestRetryCountStub + fakeReturns := fake.nOAARequestRetryCountReturns fake.recordInvocation("NOAARequestRetryCount", []interface{}{}) fake.nOAARequestRetryCountMutex.Unlock() - if fake.NOAARequestRetryCountStub != nil { - return fake.NOAARequestRetryCountStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.nOAARequestRetryCountReturns return fakeReturns.result1 } @@ -1923,15 +2142,16 @@ func (fake *FakeConfig) NetworkPolicyV1Endpoint() string { ret, specificReturn := fake.networkPolicyV1EndpointReturnsOnCall[len(fake.networkPolicyV1EndpointArgsForCall)] fake.networkPolicyV1EndpointArgsForCall = append(fake.networkPolicyV1EndpointArgsForCall, struct { }{}) + stub := fake.NetworkPolicyV1EndpointStub + fakeReturns := fake.networkPolicyV1EndpointReturns fake.recordInvocation("NetworkPolicyV1Endpoint", []interface{}{}) fake.networkPolicyV1EndpointMutex.Unlock() - if fake.NetworkPolicyV1EndpointStub != nil { - return fake.NetworkPolicyV1EndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.networkPolicyV1EndpointReturns return fakeReturns.result1 } @@ -1975,15 +2195,16 @@ func (fake *FakeConfig) OverallPollingTimeout() time.Duration { ret, specificReturn := fake.overallPollingTimeoutReturnsOnCall[len(fake.overallPollingTimeoutArgsForCall)] fake.overallPollingTimeoutArgsForCall = append(fake.overallPollingTimeoutArgsForCall, struct { }{}) + stub := fake.OverallPollingTimeoutStub + fakeReturns := fake.overallPollingTimeoutReturns fake.recordInvocation("OverallPollingTimeout", []interface{}{}) fake.overallPollingTimeoutMutex.Unlock() - if fake.OverallPollingTimeoutStub != nil { - return fake.OverallPollingTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.overallPollingTimeoutReturns return fakeReturns.result1 } @@ -2027,15 +2248,16 @@ func (fake *FakeConfig) PluginHome() string { ret, specificReturn := fake.pluginHomeReturnsOnCall[len(fake.pluginHomeArgsForCall)] fake.pluginHomeArgsForCall = append(fake.pluginHomeArgsForCall, struct { }{}) + stub := fake.PluginHomeStub + fakeReturns := fake.pluginHomeReturns fake.recordInvocation("PluginHome", []interface{}{}) fake.pluginHomeMutex.Unlock() - if fake.PluginHomeStub != nil { - return fake.PluginHomeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginHomeReturns return fakeReturns.result1 } @@ -2079,15 +2301,16 @@ func (fake *FakeConfig) PluginRepositories() []configv3.PluginRepository { ret, specificReturn := fake.pluginRepositoriesReturnsOnCall[len(fake.pluginRepositoriesArgsForCall)] fake.pluginRepositoriesArgsForCall = append(fake.pluginRepositoriesArgsForCall, struct { }{}) + stub := fake.PluginRepositoriesStub + fakeReturns := fake.pluginRepositoriesReturns fake.recordInvocation("PluginRepositories", []interface{}{}) fake.pluginRepositoriesMutex.Unlock() - if fake.PluginRepositoriesStub != nil { - return fake.PluginRepositoriesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginRepositoriesReturns return fakeReturns.result1 } @@ -2131,15 +2354,16 @@ func (fake *FakeConfig) Plugins() []configv3.Plugin { ret, specificReturn := fake.pluginsReturnsOnCall[len(fake.pluginsArgsForCall)] fake.pluginsArgsForCall = append(fake.pluginsArgsForCall, struct { }{}) + stub := fake.PluginsStub + fakeReturns := fake.pluginsReturns fake.recordInvocation("Plugins", []interface{}{}) fake.pluginsMutex.Unlock() - if fake.PluginsStub != nil { - return fake.PluginsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pluginsReturns return fakeReturns.result1 } @@ -2183,15 +2407,16 @@ func (fake *FakeConfig) PollingInterval() time.Duration { ret, specificReturn := fake.pollingIntervalReturnsOnCall[len(fake.pollingIntervalArgsForCall)] fake.pollingIntervalArgsForCall = append(fake.pollingIntervalArgsForCall, struct { }{}) + stub := fake.PollingIntervalStub + fakeReturns := fake.pollingIntervalReturns fake.recordInvocation("PollingInterval", []interface{}{}) fake.pollingIntervalMutex.Unlock() - if fake.PollingIntervalStub != nil { - return fake.PollingIntervalStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.pollingIntervalReturns return fakeReturns.result1 } @@ -2235,15 +2460,16 @@ func (fake *FakeConfig) RefreshToken() string { ret, specificReturn := fake.refreshTokenReturnsOnCall[len(fake.refreshTokenArgsForCall)] fake.refreshTokenArgsForCall = append(fake.refreshTokenArgsForCall, struct { }{}) + stub := fake.RefreshTokenStub + fakeReturns := fake.refreshTokenReturns fake.recordInvocation("RefreshToken", []interface{}{}) fake.refreshTokenMutex.Unlock() - if fake.RefreshTokenStub != nil { - return fake.RefreshTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.refreshTokenReturns return fakeReturns.result1 } @@ -2287,9 +2513,10 @@ func (fake *FakeConfig) RemovePlugin(arg1 string) { fake.removePluginArgsForCall = append(fake.removePluginArgsForCall, struct { arg1 string }{arg1}) + stub := fake.RemovePluginStub fake.recordInvocation("RemovePlugin", []interface{}{arg1}) fake.removePluginMutex.Unlock() - if fake.RemovePluginStub != nil { + if stub != nil { fake.RemovePluginStub(arg1) } } @@ -2318,15 +2545,16 @@ func (fake *FakeConfig) RequestRetryCount() int { ret, specificReturn := fake.requestRetryCountReturnsOnCall[len(fake.requestRetryCountArgsForCall)] fake.requestRetryCountArgsForCall = append(fake.requestRetryCountArgsForCall, struct { }{}) + stub := fake.RequestRetryCountStub + fakeReturns := fake.requestRetryCountReturns fake.recordInvocation("RequestRetryCount", []interface{}{}) fake.requestRetryCountMutex.Unlock() - if fake.RequestRetryCountStub != nil { - return fake.RequestRetryCountStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.requestRetryCountReturns return fakeReturns.result1 } @@ -2370,15 +2598,16 @@ func (fake *FakeConfig) RoutingEndpoint() string { ret, specificReturn := fake.routingEndpointReturnsOnCall[len(fake.routingEndpointArgsForCall)] fake.routingEndpointArgsForCall = append(fake.routingEndpointArgsForCall, struct { }{}) + stub := fake.RoutingEndpointStub + fakeReturns := fake.routingEndpointReturns fake.recordInvocation("RoutingEndpoint", []interface{}{}) fake.routingEndpointMutex.Unlock() - if fake.RoutingEndpointStub != nil { - return fake.RoutingEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.routingEndpointReturns return fakeReturns.result1 } @@ -2422,15 +2651,16 @@ func (fake *FakeConfig) SSHOAuthClient() string { ret, specificReturn := fake.sSHOAuthClientReturnsOnCall[len(fake.sSHOAuthClientArgsForCall)] fake.sSHOAuthClientArgsForCall = append(fake.sSHOAuthClientArgsForCall, struct { }{}) + stub := fake.SSHOAuthClientStub + fakeReturns := fake.sSHOAuthClientReturns fake.recordInvocation("SSHOAuthClient", []interface{}{}) fake.sSHOAuthClientMutex.Unlock() - if fake.SSHOAuthClientStub != nil { - return fake.SSHOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.sSHOAuthClientReturns return fakeReturns.result1 } @@ -2474,9 +2704,10 @@ func (fake *FakeConfig) SetAccessToken(arg1 string) { fake.setAccessTokenArgsForCall = append(fake.setAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetAccessTokenStub fake.recordInvocation("SetAccessToken", []interface{}{arg1}) fake.setAccessTokenMutex.Unlock() - if fake.SetAccessTokenStub != nil { + if stub != nil { fake.SetAccessTokenStub(arg1) } } @@ -2505,9 +2736,10 @@ func (fake *FakeConfig) SetAsyncTimeout(arg1 int) { fake.setAsyncTimeoutArgsForCall = append(fake.setAsyncTimeoutArgsForCall, struct { arg1 int }{arg1}) + stub := fake.SetAsyncTimeoutStub fake.recordInvocation("SetAsyncTimeout", []interface{}{arg1}) fake.setAsyncTimeoutMutex.Unlock() - if fake.SetAsyncTimeoutStub != nil { + if stub != nil { fake.SetAsyncTimeoutStub(arg1) } } @@ -2536,9 +2768,10 @@ func (fake *FakeConfig) SetColorEnabled(arg1 string) { fake.setColorEnabledArgsForCall = append(fake.setColorEnabledArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetColorEnabledStub fake.recordInvocation("SetColorEnabled", []interface{}{arg1}) fake.setColorEnabledMutex.Unlock() - if fake.SetColorEnabledStub != nil { + if stub != nil { fake.SetColorEnabledStub(arg1) } } @@ -2567,9 +2800,10 @@ func (fake *FakeConfig) SetKubernetesAuthInfo(arg1 string) { fake.setKubernetesAuthInfoArgsForCall = append(fake.setKubernetesAuthInfoArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetKubernetesAuthInfoStub fake.recordInvocation("SetKubernetesAuthInfo", []interface{}{arg1}) fake.setKubernetesAuthInfoMutex.Unlock() - if fake.SetKubernetesAuthInfoStub != nil { + if stub != nil { fake.SetKubernetesAuthInfoStub(arg1) } } @@ -2598,9 +2832,10 @@ func (fake *FakeConfig) SetLocale(arg1 string) { fake.setLocaleArgsForCall = append(fake.setLocaleArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetLocaleStub fake.recordInvocation("SetLocale", []interface{}{arg1}) fake.setLocaleMutex.Unlock() - if fake.SetLocaleStub != nil { + if stub != nil { fake.SetLocaleStub(arg1) } } @@ -2629,9 +2864,10 @@ func (fake *FakeConfig) SetMinCLIVersion(arg1 string) { fake.setMinCLIVersionArgsForCall = append(fake.setMinCLIVersionArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetMinCLIVersionStub fake.recordInvocation("SetMinCLIVersion", []interface{}{arg1}) fake.setMinCLIVersionMutex.Unlock() - if fake.SetMinCLIVersionStub != nil { + if stub != nil { fake.SetMinCLIVersionStub(arg1) } } @@ -2661,9 +2897,10 @@ func (fake *FakeConfig) SetOrganizationInformation(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetOrganizationInformationStub fake.recordInvocation("SetOrganizationInformation", []interface{}{arg1, arg2}) fake.setOrganizationInformationMutex.Unlock() - if fake.SetOrganizationInformationStub != nil { + if stub != nil { fake.SetOrganizationInformationStub(arg1, arg2) } } @@ -2692,9 +2929,10 @@ func (fake *FakeConfig) SetRefreshToken(arg1 string) { fake.setRefreshTokenArgsForCall = append(fake.setRefreshTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetRefreshTokenStub fake.recordInvocation("SetRefreshToken", []interface{}{arg1}) fake.setRefreshTokenMutex.Unlock() - if fake.SetRefreshTokenStub != nil { + if stub != nil { fake.SetRefreshTokenStub(arg1) } } @@ -2725,9 +2963,10 @@ func (fake *FakeConfig) SetSpaceInformation(arg1 string, arg2 string, arg3 bool) arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.SetSpaceInformationStub fake.recordInvocation("SetSpaceInformation", []interface{}{arg1, arg2, arg3}) fake.setSpaceInformationMutex.Unlock() - if fake.SetSpaceInformationStub != nil { + if stub != nil { fake.SetSpaceInformationStub(arg1, arg2, arg3) } } @@ -2756,9 +2995,10 @@ func (fake *FakeConfig) SetTargetInformation(arg1 configv3.TargetInformationArgs fake.setTargetInformationArgsForCall = append(fake.setTargetInformationArgsForCall, struct { arg1 configv3.TargetInformationArgs }{arg1}) + stub := fake.SetTargetInformationStub fake.recordInvocation("SetTargetInformation", []interface{}{arg1}) fake.setTargetInformationMutex.Unlock() - if fake.SetTargetInformationStub != nil { + if stub != nil { fake.SetTargetInformationStub(arg1) } } @@ -2789,9 +3029,10 @@ func (fake *FakeConfig) SetTokenInformation(arg1 string, arg2 string, arg3 strin arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.SetTokenInformationStub fake.recordInvocation("SetTokenInformation", []interface{}{arg1, arg2, arg3}) fake.setTokenInformationMutex.Unlock() - if fake.SetTokenInformationStub != nil { + if stub != nil { fake.SetTokenInformationStub(arg1, arg2, arg3) } } @@ -2820,9 +3061,10 @@ func (fake *FakeConfig) SetTrace(arg1 string) { fake.setTraceArgsForCall = append(fake.setTraceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetTraceStub fake.recordInvocation("SetTrace", []interface{}{arg1}) fake.setTraceMutex.Unlock() - if fake.SetTraceStub != nil { + if stub != nil { fake.SetTraceStub(arg1) } } @@ -2852,9 +3094,10 @@ func (fake *FakeConfig) SetUAAClientCredentials(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetUAAClientCredentialsStub fake.recordInvocation("SetUAAClientCredentials", []interface{}{arg1, arg2}) fake.setUAAClientCredentialsMutex.Unlock() - if fake.SetUAAClientCredentialsStub != nil { + if stub != nil { fake.SetUAAClientCredentialsStub(arg1, arg2) } } @@ -2883,9 +3126,10 @@ func (fake *FakeConfig) SetUAAEndpoint(arg1 string) { fake.setUAAEndpointArgsForCall = append(fake.setUAAEndpointArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAEndpointStub fake.recordInvocation("SetUAAEndpoint", []interface{}{arg1}) fake.setUAAEndpointMutex.Unlock() - if fake.SetUAAEndpointStub != nil { + if stub != nil { fake.SetUAAEndpointStub(arg1) } } @@ -2914,9 +3158,10 @@ func (fake *FakeConfig) SetUAAGrantType(arg1 string) { fake.setUAAGrantTypeArgsForCall = append(fake.setUAAGrantTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.SetUAAGrantTypeStub fake.recordInvocation("SetUAAGrantType", []interface{}{arg1}) fake.setUAAGrantTypeMutex.Unlock() - if fake.SetUAAGrantTypeStub != nil { + if stub != nil { fake.SetUAAGrantTypeStub(arg1) } } @@ -2945,15 +3190,16 @@ func (fake *FakeConfig) SkipSSLValidation() bool { ret, specificReturn := fake.skipSSLValidationReturnsOnCall[len(fake.skipSSLValidationArgsForCall)] fake.skipSSLValidationArgsForCall = append(fake.skipSSLValidationArgsForCall, struct { }{}) + stub := fake.SkipSSLValidationStub + fakeReturns := fake.skipSSLValidationReturns fake.recordInvocation("SkipSSLValidation", []interface{}{}) fake.skipSSLValidationMutex.Unlock() - if fake.SkipSSLValidationStub != nil { - return fake.SkipSSLValidationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.skipSSLValidationReturns return fakeReturns.result1 } @@ -2997,15 +3243,16 @@ func (fake *FakeConfig) StagingTimeout() time.Duration { ret, specificReturn := fake.stagingTimeoutReturnsOnCall[len(fake.stagingTimeoutArgsForCall)] fake.stagingTimeoutArgsForCall = append(fake.stagingTimeoutArgsForCall, struct { }{}) + stub := fake.StagingTimeoutStub + fakeReturns := fake.stagingTimeoutReturns fake.recordInvocation("StagingTimeout", []interface{}{}) fake.stagingTimeoutMutex.Unlock() - if fake.StagingTimeoutStub != nil { - return fake.StagingTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.stagingTimeoutReturns return fakeReturns.result1 } @@ -3049,15 +3296,16 @@ func (fake *FakeConfig) StartupTimeout() time.Duration { ret, specificReturn := fake.startupTimeoutReturnsOnCall[len(fake.startupTimeoutArgsForCall)] fake.startupTimeoutArgsForCall = append(fake.startupTimeoutArgsForCall, struct { }{}) + stub := fake.StartupTimeoutStub + fakeReturns := fake.startupTimeoutReturns fake.recordInvocation("StartupTimeout", []interface{}{}) fake.startupTimeoutMutex.Unlock() - if fake.StartupTimeoutStub != nil { - return fake.StartupTimeoutStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startupTimeoutReturns return fakeReturns.result1 } @@ -3101,15 +3349,16 @@ func (fake *FakeConfig) Target() string { ret, specificReturn := fake.targetReturnsOnCall[len(fake.targetArgsForCall)] fake.targetArgsForCall = append(fake.targetArgsForCall, struct { }{}) + stub := fake.TargetStub + fakeReturns := fake.targetReturns fake.recordInvocation("Target", []interface{}{}) fake.targetMutex.Unlock() - if fake.TargetStub != nil { - return fake.TargetStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetReturns return fakeReturns.result1 } @@ -3153,15 +3402,16 @@ func (fake *FakeConfig) TargetedOrganization() configv3.Organization { ret, specificReturn := fake.targetedOrganizationReturnsOnCall[len(fake.targetedOrganizationArgsForCall)] fake.targetedOrganizationArgsForCall = append(fake.targetedOrganizationArgsForCall, struct { }{}) + stub := fake.TargetedOrganizationStub + fakeReturns := fake.targetedOrganizationReturns fake.recordInvocation("TargetedOrganization", []interface{}{}) fake.targetedOrganizationMutex.Unlock() - if fake.TargetedOrganizationStub != nil { - return fake.TargetedOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetedOrganizationReturns return fakeReturns.result1 } @@ -3205,15 +3455,16 @@ func (fake *FakeConfig) TargetedOrganizationName() string { ret, specificReturn := fake.targetedOrganizationNameReturnsOnCall[len(fake.targetedOrganizationNameArgsForCall)] fake.targetedOrganizationNameArgsForCall = append(fake.targetedOrganizationNameArgsForCall, struct { }{}) + stub := fake.TargetedOrganizationNameStub + fakeReturns := fake.targetedOrganizationNameReturns fake.recordInvocation("TargetedOrganizationName", []interface{}{}) fake.targetedOrganizationNameMutex.Unlock() - if fake.TargetedOrganizationNameStub != nil { - return fake.TargetedOrganizationNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetedOrganizationNameReturns return fakeReturns.result1 } @@ -3257,15 +3508,16 @@ func (fake *FakeConfig) TargetedSpace() configv3.Space { ret, specificReturn := fake.targetedSpaceReturnsOnCall[len(fake.targetedSpaceArgsForCall)] fake.targetedSpaceArgsForCall = append(fake.targetedSpaceArgsForCall, struct { }{}) + stub := fake.TargetedSpaceStub + fakeReturns := fake.targetedSpaceReturns fake.recordInvocation("TargetedSpace", []interface{}{}) fake.targetedSpaceMutex.Unlock() - if fake.TargetedSpaceStub != nil { - return fake.TargetedSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.targetedSpaceReturns return fakeReturns.result1 } @@ -3309,15 +3561,16 @@ func (fake *FakeConfig) TerminalWidth() int { ret, specificReturn := fake.terminalWidthReturnsOnCall[len(fake.terminalWidthArgsForCall)] fake.terminalWidthArgsForCall = append(fake.terminalWidthArgsForCall, struct { }{}) + stub := fake.TerminalWidthStub + fakeReturns := fake.terminalWidthReturns fake.recordInvocation("TerminalWidth", []interface{}{}) fake.terminalWidthMutex.Unlock() - if fake.TerminalWidthStub != nil { - return fake.TerminalWidthStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.terminalWidthReturns return fakeReturns.result1 } @@ -3361,15 +3614,16 @@ func (fake *FakeConfig) UAADisableKeepAlives() bool { ret, specificReturn := fake.uAADisableKeepAlivesReturnsOnCall[len(fake.uAADisableKeepAlivesArgsForCall)] fake.uAADisableKeepAlivesArgsForCall = append(fake.uAADisableKeepAlivesArgsForCall, struct { }{}) + stub := fake.UAADisableKeepAlivesStub + fakeReturns := fake.uAADisableKeepAlivesReturns fake.recordInvocation("UAADisableKeepAlives", []interface{}{}) fake.uAADisableKeepAlivesMutex.Unlock() - if fake.UAADisableKeepAlivesStub != nil { - return fake.UAADisableKeepAlivesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAADisableKeepAlivesReturns return fakeReturns.result1 } @@ -3413,15 +3667,16 @@ func (fake *FakeConfig) UAAEndpoint() string { ret, specificReturn := fake.uAAEndpointReturnsOnCall[len(fake.uAAEndpointArgsForCall)] fake.uAAEndpointArgsForCall = append(fake.uAAEndpointArgsForCall, struct { }{}) + stub := fake.UAAEndpointStub + fakeReturns := fake.uAAEndpointReturns fake.recordInvocation("UAAEndpoint", []interface{}{}) fake.uAAEndpointMutex.Unlock() - if fake.UAAEndpointStub != nil { - return fake.UAAEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAEndpointReturns return fakeReturns.result1 } @@ -3465,15 +3720,16 @@ func (fake *FakeConfig) UAAGrantType() string { ret, specificReturn := fake.uAAGrantTypeReturnsOnCall[len(fake.uAAGrantTypeArgsForCall)] fake.uAAGrantTypeArgsForCall = append(fake.uAAGrantTypeArgsForCall, struct { }{}) + stub := fake.UAAGrantTypeStub + fakeReturns := fake.uAAGrantTypeReturns fake.recordInvocation("UAAGrantType", []interface{}{}) fake.uAAGrantTypeMutex.Unlock() - if fake.UAAGrantTypeStub != nil { - return fake.UAAGrantTypeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAGrantTypeReturns return fakeReturns.result1 } @@ -3517,15 +3773,16 @@ func (fake *FakeConfig) UAAOAuthClient() string { ret, specificReturn := fake.uAAOAuthClientReturnsOnCall[len(fake.uAAOAuthClientArgsForCall)] fake.uAAOAuthClientArgsForCall = append(fake.uAAOAuthClientArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientStub + fakeReturns := fake.uAAOAuthClientReturns fake.recordInvocation("UAAOAuthClient", []interface{}{}) fake.uAAOAuthClientMutex.Unlock() - if fake.UAAOAuthClientStub != nil { - return fake.UAAOAuthClientStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientReturns return fakeReturns.result1 } @@ -3569,15 +3826,16 @@ func (fake *FakeConfig) UAAOAuthClientSecret() string { ret, specificReturn := fake.uAAOAuthClientSecretReturnsOnCall[len(fake.uAAOAuthClientSecretArgsForCall)] fake.uAAOAuthClientSecretArgsForCall = append(fake.uAAOAuthClientSecretArgsForCall, struct { }{}) + stub := fake.UAAOAuthClientSecretStub + fakeReturns := fake.uAAOAuthClientSecretReturns fake.recordInvocation("UAAOAuthClientSecret", []interface{}{}) fake.uAAOAuthClientSecretMutex.Unlock() - if fake.UAAOAuthClientSecretStub != nil { - return fake.UAAOAuthClientSecretStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.uAAOAuthClientSecretReturns return fakeReturns.result1 } @@ -3620,9 +3878,10 @@ func (fake *FakeConfig) UnsetOrganizationAndSpaceInformation() { fake.unsetOrganizationAndSpaceInformationMutex.Lock() fake.unsetOrganizationAndSpaceInformationArgsForCall = append(fake.unsetOrganizationAndSpaceInformationArgsForCall, struct { }{}) + stub := fake.UnsetOrganizationAndSpaceInformationStub fake.recordInvocation("UnsetOrganizationAndSpaceInformation", []interface{}{}) fake.unsetOrganizationAndSpaceInformationMutex.Unlock() - if fake.UnsetOrganizationAndSpaceInformationStub != nil { + if stub != nil { fake.UnsetOrganizationAndSpaceInformationStub() } } @@ -3643,9 +3902,10 @@ func (fake *FakeConfig) UnsetSpaceInformation() { fake.unsetSpaceInformationMutex.Lock() fake.unsetSpaceInformationArgsForCall = append(fake.unsetSpaceInformationArgsForCall, struct { }{}) + stub := fake.UnsetSpaceInformationStub fake.recordInvocation("UnsetSpaceInformation", []interface{}{}) fake.unsetSpaceInformationMutex.Unlock() - if fake.UnsetSpaceInformationStub != nil { + if stub != nil { fake.UnsetSpaceInformationStub() } } @@ -3666,9 +3926,10 @@ func (fake *FakeConfig) UnsetUserInformation() { fake.unsetUserInformationMutex.Lock() fake.unsetUserInformationArgsForCall = append(fake.unsetUserInformationArgsForCall, struct { }{}) + stub := fake.UnsetUserInformationStub fake.recordInvocation("UnsetUserInformation", []interface{}{}) fake.unsetUserInformationMutex.Unlock() - if fake.UnsetUserInformationStub != nil { + if stub != nil { fake.UnsetUserInformationStub() } } @@ -3691,9 +3952,10 @@ func (fake *FakeConfig) V7SetSpaceInformation(arg1 string, arg2 string) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.V7SetSpaceInformationStub fake.recordInvocation("V7SetSpaceInformation", []interface{}{arg1, arg2}) fake.v7SetSpaceInformationMutex.Unlock() - if fake.V7SetSpaceInformationStub != nil { + if stub != nil { fake.V7SetSpaceInformationStub(arg1, arg2) } } @@ -3722,15 +3984,16 @@ func (fake *FakeConfig) Verbose() (bool, []string) { ret, specificReturn := fake.verboseReturnsOnCall[len(fake.verboseArgsForCall)] fake.verboseArgsForCall = append(fake.verboseArgsForCall, struct { }{}) + stub := fake.VerboseStub + fakeReturns := fake.verboseReturns fake.recordInvocation("Verbose", []interface{}{}) fake.verboseMutex.Unlock() - if fake.VerboseStub != nil { - return fake.VerboseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.verboseReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3777,15 +4040,16 @@ func (fake *FakeConfig) WriteConfig() error { ret, specificReturn := fake.writeConfigReturnsOnCall[len(fake.writeConfigArgsForCall)] fake.writeConfigArgsForCall = append(fake.writeConfigArgsForCall, struct { }{}) + stub := fake.WriteConfigStub + fakeReturns := fake.writeConfigReturns fake.recordInvocation("WriteConfig", []interface{}{}) fake.writeConfigMutex.Unlock() - if fake.WriteConfigStub != nil { - return fake.WriteConfigStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.writeConfigReturns return fakeReturns.result1 } @@ -3829,15 +4093,16 @@ func (fake *FakeConfig) WritePluginConfig() error { ret, specificReturn := fake.writePluginConfigReturnsOnCall[len(fake.writePluginConfigArgsForCall)] fake.writePluginConfigArgsForCall = append(fake.writePluginConfigArgsForCall, struct { }{}) + stub := fake.WritePluginConfigStub + fakeReturns := fake.writePluginConfigReturns fake.recordInvocation("WritePluginConfig", []interface{}{}) fake.writePluginConfigMutex.Unlock() - if fake.WritePluginConfigStub != nil { - return fake.WritePluginConfigStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.writePluginConfigReturns return fakeReturns.result1 } @@ -3889,6 +4154,10 @@ func (fake *FakeConfig) Invocations() map[string][][]interface{} { defer fake.addPluginRepositoryMutex.RUnlock() fake.authorizationEndpointMutex.RLock() defer fake.authorizationEndpointMutex.RUnlock() + fake.b3SpanIDMutex.RLock() + defer fake.b3SpanIDMutex.RUnlock() + fake.b3TraceIDMutex.RLock() + defer fake.b3TraceIDMutex.RUnlock() fake.binaryNameMutex.RLock() defer fake.binaryNameMutex.RUnlock() fake.binaryVersionMutex.RLock() @@ -3897,6 +4166,8 @@ func (fake *FakeConfig) Invocations() map[string][][]interface{} { defer fake.cFPasswordMutex.RUnlock() fake.cFUsernameMutex.RLock() defer fake.cFUsernameMutex.RUnlock() + fake.cNBCredentialsMutex.RLock() + defer fake.cNBCredentialsMutex.RUnlock() fake.colorEnabledMutex.RLock() defer fake.colorEnabledMutex.RUnlock() fake.currentUserMutex.RLock() diff --git a/command/commandfakes/fake_shared_actor.go b/command/commandfakes/fake_shared_actor.go index fec3b1b77d3..06dafc6c3a5 100644 --- a/command/commandfakes/fake_shared_actor.go +++ b/command/commandfakes/fake_shared_actor.go @@ -4,7 +4,7 @@ package commandfakes import ( "sync" - "code.cloudfoundry.org/cli/command" + "code.cloudfoundry.org/cli/v8/command" ) type FakeSharedActor struct { @@ -85,15 +85,16 @@ func (fake *FakeSharedActor) CheckTarget(arg1 bool, arg2 bool) error { arg1 bool arg2 bool }{arg1, arg2}) + stub := fake.CheckTargetStub + fakeReturns := fake.checkTargetReturns fake.recordInvocation("CheckTarget", []interface{}{arg1, arg2}) fake.checkTargetMutex.Unlock() - if fake.CheckTargetStub != nil { - return fake.CheckTargetStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.checkTargetReturns return fakeReturns.result1 } @@ -144,15 +145,16 @@ func (fake *FakeSharedActor) IsLoggedIn() bool { ret, specificReturn := fake.isLoggedInReturnsOnCall[len(fake.isLoggedInArgsForCall)] fake.isLoggedInArgsForCall = append(fake.isLoggedInArgsForCall, struct { }{}) + stub := fake.IsLoggedInStub + fakeReturns := fake.isLoggedInReturns fake.recordInvocation("IsLoggedIn", []interface{}{}) fake.isLoggedInMutex.Unlock() - if fake.IsLoggedInStub != nil { - return fake.IsLoggedInStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isLoggedInReturns return fakeReturns.result1 } @@ -196,15 +198,16 @@ func (fake *FakeSharedActor) IsOrgTargeted() bool { ret, specificReturn := fake.isOrgTargetedReturnsOnCall[len(fake.isOrgTargetedArgsForCall)] fake.isOrgTargetedArgsForCall = append(fake.isOrgTargetedArgsForCall, struct { }{}) + stub := fake.IsOrgTargetedStub + fakeReturns := fake.isOrgTargetedReturns fake.recordInvocation("IsOrgTargeted", []interface{}{}) fake.isOrgTargetedMutex.Unlock() - if fake.IsOrgTargetedStub != nil { - return fake.IsOrgTargetedStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isOrgTargetedReturns return fakeReturns.result1 } @@ -248,15 +251,16 @@ func (fake *FakeSharedActor) IsSpaceTargeted() bool { ret, specificReturn := fake.isSpaceTargetedReturnsOnCall[len(fake.isSpaceTargetedArgsForCall)] fake.isSpaceTargetedArgsForCall = append(fake.isSpaceTargetedArgsForCall, struct { }{}) + stub := fake.IsSpaceTargetedStub + fakeReturns := fake.isSpaceTargetedReturns fake.recordInvocation("IsSpaceTargeted", []interface{}{}) fake.isSpaceTargetedMutex.Unlock() - if fake.IsSpaceTargetedStub != nil { - return fake.IsSpaceTargetedStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.isSpaceTargetedReturns return fakeReturns.result1 } @@ -300,15 +304,16 @@ func (fake *FakeSharedActor) RequireCurrentUser() (string, error) { ret, specificReturn := fake.requireCurrentUserReturnsOnCall[len(fake.requireCurrentUserArgsForCall)] fake.requireCurrentUserArgsForCall = append(fake.requireCurrentUserArgsForCall, struct { }{}) + stub := fake.RequireCurrentUserStub + fakeReturns := fake.requireCurrentUserReturns fake.recordInvocation("RequireCurrentUser", []interface{}{}) fake.requireCurrentUserMutex.Unlock() - if fake.RequireCurrentUserStub != nil { - return fake.RequireCurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requireCurrentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -355,15 +360,16 @@ func (fake *FakeSharedActor) RequireTargetedOrg() (string, error) { ret, specificReturn := fake.requireTargetedOrgReturnsOnCall[len(fake.requireTargetedOrgArgsForCall)] fake.requireTargetedOrgArgsForCall = append(fake.requireTargetedOrgArgsForCall, struct { }{}) + stub := fake.RequireTargetedOrgStub + fakeReturns := fake.requireTargetedOrgReturns fake.recordInvocation("RequireTargetedOrg", []interface{}{}) fake.requireTargetedOrgMutex.Unlock() - if fake.RequireTargetedOrgStub != nil { - return fake.RequireTargetedOrgStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.requireTargetedOrgReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/commandfakes/fake_ui.go b/command/commandfakes/fake_ui.go index c160f6d0be2..9b6ced857d6 100644 --- a/command/commandfakes/fake_ui.go +++ b/command/commandfakes/fake_ui.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/util/ui" ) type FakeUI struct { @@ -174,6 +174,11 @@ type FakeUI struct { arg1 string arg2 []map[string]interface{} } + DisplayTextLiteralStub func(string) + displayTextLiteralMutex sync.RWMutex + displayTextLiteralArgsForCall []struct { + arg1 string + } DisplayTextMenuStub func([]string, string, ...map[string]interface{}) (string, error) displayTextMenuMutex sync.RWMutex displayTextMenuArgsForCall []struct { @@ -737,15 +742,16 @@ func (fake *FakeUI) DisplayJSON(arg1 string, arg2 interface{}) error { arg1 string arg2 interface{} }{arg1, arg2}) + stub := fake.DisplayJSONStub + fakeReturns := fake.displayJSONReturns fake.recordInvocation("DisplayJSON", []interface{}{arg1, arg2}) fake.displayJSONMutex.Unlock() - if fake.DisplayJSONStub != nil { - return fake.DisplayJSONStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayJSONReturns return fakeReturns.result1 } @@ -1190,6 +1196,38 @@ func (fake *FakeUI) DisplayTextArgsForCall(i int) (string, []map[string]interfac return argsForCall.arg1, argsForCall.arg2 } +func (fake *FakeUI) DisplayTextLiteral(arg1 string) { + fake.displayTextLiteralMutex.Lock() + fake.displayTextLiteralArgsForCall = append(fake.displayTextLiteralArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.DisplayTextLiteralStub + fake.recordInvocation("DisplayTextLiteral", []interface{}{arg1}) + fake.displayTextLiteralMutex.Unlock() + if stub != nil { + fake.DisplayTextLiteralStub(arg1) + } +} + +func (fake *FakeUI) DisplayTextLiteralCallCount() int { + fake.displayTextLiteralMutex.RLock() + defer fake.displayTextLiteralMutex.RUnlock() + return len(fake.displayTextLiteralArgsForCall) +} + +func (fake *FakeUI) DisplayTextLiteralCalls(stub func(string)) { + fake.displayTextLiteralMutex.Lock() + defer fake.displayTextLiteralMutex.Unlock() + fake.DisplayTextLiteralStub = stub +} + +func (fake *FakeUI) DisplayTextLiteralArgsForCall(i int) string { + fake.displayTextLiteralMutex.RLock() + defer fake.displayTextLiteralMutex.RUnlock() + argsForCall := fake.displayTextLiteralArgsForCall[i] + return argsForCall.arg1 +} + func (fake *FakeUI) DisplayTextMenu(arg1 []string, arg2 string, arg3 ...map[string]interface{}) (string, error) { var arg1Copy []string if arg1 != nil { @@ -1963,6 +2001,8 @@ func (fake *FakeUI) Invocations() map[string][][]interface{} { defer fake.displayTableWithHeaderMutex.RUnlock() fake.displayTextMutex.RLock() defer fake.displayTextMutex.RUnlock() + fake.displayTextLiteralMutex.RLock() + defer fake.displayTextLiteralMutex.RUnlock() fake.displayTextMenuMutex.RLock() defer fake.displayTextMenuMutex.RUnlock() fake.displayTextPromptMutex.RLock() diff --git a/command/common/command_list_v7.go b/command/common/command_list_v7.go index 6cb264ed745..4940e11cf75 100644 --- a/command/common/command_list_v7.go +++ b/command/common/command_list_v7.go @@ -3,8 +3,8 @@ package common import ( "reflect" - "code.cloudfoundry.org/cli/command/plugin" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/command/plugin" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) var Commands commandList @@ -32,6 +32,7 @@ type commandList struct { CancelDeployment v7.CancelDeploymentCommand `command:"cancel-deployment" description:"Cancel the most recent deployment for an app. Resets the current droplet to the previous deployment's droplet."` CheckRoute v7.CheckRouteCommand `command:"check-route" description:"Perform a check to determine whether a route currently exists or not"` Config v7.ConfigCommand `command:"config" description:"Write default values to the config"` + ContinueDeployment v7.ContinueDeploymentCommand `command:"continue-deployment" description:"Continue the most recent deployment for an app."` CopySource v7.CopySourceCommand `command:"copy-source" description:"Copies the source code of an application to another existing application and restages that application"` CreateApp v7.CreateAppCommand `command:"create-app" description:"Create an Application in the target space"` CreateAppManifest v7.CreateAppManifestCommand `command:"create-app-manifest" description:"Create an app manifest for an app that has been pushed successfully"` @@ -42,6 +43,7 @@ type commandList struct { CreateOrgQuota v7.CreateOrgQuotaCommand `command:"create-org-quota" alias:"create-quota" description:"Define a new quota for an organization"` CreatePrivateDomain v7.CreatePrivateDomainCommand `command:"create-private-domain" alias:"create-domain" description:"Create a private domain for a specific org"` CreateRoute v7.CreateRouteCommand `command:"create-route" description:"Create a route for later use"` + UpdateRoute v7.UpdateRouteCommand `command:"update-route" description:"Update a route by route specific options, e.g. load balancing algorithm"` CreateSecurityGroup v7.CreateSecurityGroupCommand `command:"create-security-group" description:"Create a security group"` CreateService v7.CreateServiceCommand `command:"create-service" alias:"cs" description:"Create a service instance"` CreateServiceBroker v7.CreateServiceBrokerCommand `command:"create-service-broker" alias:"csb" description:"Create a service broker"` @@ -85,6 +87,7 @@ type commandList struct { FeatureFlag v7.FeatureFlagCommand `command:"feature-flag" description:"Retrieve an individual feature flag with status"` FeatureFlags v7.FeatureFlagsCommand `command:"feature-flags" description:"Retrieve list of feature flags with status"` GetHealthCheck v7.GetHealthCheckCommand `command:"get-health-check" description:"Show the type of health check performed on an app"` + GetReadinessHealthCheck v7.GetReadinessHealthCheckCommand `command:"get-readiness-health-check" description:"Show the type of readiness health check performed on an app"` Help HelpCommand `command:"help" alias:"h" description:"Show help"` InstallPlugin InstallPluginCommand `command:"install-plugin" description:"Install CLI plugin"` IsolationSegments v7.IsolationSegmentsCommand `command:"isolation-segments" description:"List all isolation segments"` @@ -124,7 +127,7 @@ type commandList struct { Rollback v7.RollbackCommand `command:"rollback" description:"Rollback to the specified revision of an app"` StagePackage v7.StagePackageCommand `command:"stage-package" alias:"stage" description:"Stage a package into a droplet"` Restart v7.RestartCommand `command:"restart" alias:"rs" description:"Stop all instances of the app, then start them again."` - RestartAppInstance v7.RestartAppInstanceCommand `command:"restart-app-instance" description:"Terminate, then instantiate an app instance"` + RestartAppInstance v7.RestartAppInstanceCommand `command:"restart-app-instance" description:"Stop, then start application instance without updating application environment"` RouterGroups v7.RouterGroupsCommand `command:"router-groups" description:"List router groups"` Route v7.RouteCommand `command:"route" alias:"ro" description:"Display route details and mapped destinations"` Routes v7.RoutesCommand `command:"routes" alias:"r" description:"List all routes in the current space or the current organization"` @@ -134,7 +137,7 @@ type commandList struct { SSH v7.SSHCommand `command:"ssh" description:"SSH to an application container instance"` SSHCode v7.SSHCodeCommand `command:"ssh-code" description:"Get a one time password for ssh clients"` SSHEnabled v7.SSHEnabledCommand `command:"ssh-enabled" description:"Reports whether SSH is enabled on an application container instance"` - Scale v7.ScaleCommand `command:"scale" description:"Change or view the instance count, disk space limit, and memory limit for an app"` + Scale v7.ScaleCommand `command:"scale" description:"Change or view the instance count, disk space limit, memory limit, and log rate limit for an app"` SecurityGroup v7.SecurityGroupCommand `command:"security-group" description:"Show a single security group"` SecurityGroups v7.SecurityGroupsCommand `command:"security-groups" description:"List all security groups"` Service v7.ServiceCommand `command:"service" description:"Show service instance info"` @@ -157,6 +160,7 @@ type commandList struct { SetStagingEnvironmentVariableGroup v7.SetStagingEnvironmentVariableGroupCommand `command:"set-staging-environment-variable-group" alias:"ssevg" description:"Pass parameters as JSON to create a staging environment variable group"` SharePrivateDomain v7.SharePrivateDomainCommand `command:"share-private-domain" description:"Share a private domain with a specific org"` ShareService v7.ShareServiceCommand `command:"share-service" description:"Share a service instance with another space"` + ShareRoute v7.ShareRouteCommand `command:"share-route" description:"Share a route in between spaces"` Space v7.SpaceCommand `command:"space" description:"Show space info"` SpaceQuota v7.SpaceQuotaCommand `command:"space-quota" description:"Show space quota info"` SpaceQuotas v7.SpaceQuotasCommand `command:"space-quotas" description:"List available space quotas"` @@ -170,8 +174,10 @@ type commandList struct { Start v7.StartCommand `command:"start" alias:"st" description:"Start an app"` Stop v7.StopCommand `command:"stop" alias:"sp" description:"Stop an app"` Target v7.TargetCommand `command:"target" alias:"t" description:"Set or view the targeted org or space"` + Task v7.TaskCommand `command:"task" description:"Display a task of an app"` Tasks v7.TasksCommand `command:"tasks" description:"List tasks of an app"` TerminateTask v7.TerminateTaskCommand `command:"terminate-task" description:"Terminate a running task of an app"` + MoveRoute v7.MoveRouteCommand `command:"move-route" description:"Assign a route to a different space"` UnbindRouteService v7.UnbindRouteServiceCommand `command:"unbind-route-service" alias:"urs" description:"Unbind a service instance from an HTTP route"` UnbindRunningSecurityGroup v7.UnbindRunningSecurityGroupCommand `command:"unbind-running-security-group" description:"Unbind a security group from the set of security groups for running applications globally"` UnbindSecurityGroup v7.UnbindSecurityGroupCommand `command:"unbind-security-group" description:"Unbind a security group from a space"` @@ -185,8 +191,10 @@ type commandList struct { UnsetSpaceQuota v7.UnsetSpaceQuotaCommand `command:"unset-space-quota" description:"Unassign a quota from a space"` UnsetSpaceRole v7.UnsetSpaceRoleCommand `command:"unset-space-role" description:"Remove a space role from a user"` UnsharePrivateDomain v7.UnsharePrivateDomainCommand `command:"unshare-private-domain" description:"Unshare a private domain with a specific org"` + UnshareRoute v7.UnshareRouteCommand `command:"unshare-route" description:"Unshare an existing route from a space"` UnshareService v7.UnshareServiceCommand `command:"unshare-service" description:"Unshare a shared service instance from a space"` UpdateBuildpack v7.UpdateBuildpackCommand `command:"update-buildpack" description:"Update a buildpack"` + UpdateDestination v7.UpdateDestinationCommand `command:"update-destination" description:"Updates the destination protocol for a route"` UpdateOrgQuota v7.UpdateOrgQuotaCommand `command:"update-org-quota" alias:"update-quota" description:"Update an existing organization quota"` UpdateSecurityGroup v7.UpdateSecurityGroupCommand `command:"update-security-group" description:"Update a security group"` UpdateService v7.UpdateServiceCommand `command:"update-service" description:"Update a service instance"` diff --git a/command/common/command_list_v7_test.go b/command/common/command_list_v7_test.go index 50acdce0ec4..92fffb0f377 100644 --- a/command/common/command_list_v7_test.go +++ b/command/common/command_list_v7_test.go @@ -1,8 +1,8 @@ package common_test import ( - . "code.cloudfoundry.org/cli/command/common" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/common/common_suite_test.go b/command/common/common_suite_test.go index 32e4b98071d..4f17bfab8ae 100644 --- a/command/common/common_suite_test.go +++ b/command/common/common_suite_test.go @@ -1,7 +1,7 @@ package common_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" diff --git a/command/common/commonfakes/fake_help_actor.go b/command/common/commonfakes/fake_help_actor.go index ac130fb2f4c..f03e620155e 100644 --- a/command/common/commonfakes/fake_help_actor.go +++ b/command/common/commonfakes/fake_help_actor.go @@ -4,8 +4,8 @@ package commonfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/command/common" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/command/common" ) type FakeHelpActor struct { @@ -45,15 +45,16 @@ func (fake *FakeHelpActor) CommandInfoByName(arg1 interface{}, arg2 string) (sha arg1 interface{} arg2 string }{arg1, arg2}) + stub := fake.CommandInfoByNameStub + fakeReturns := fake.commandInfoByNameReturns fake.recordInvocation("CommandInfoByName", []interface{}{arg1, arg2}) fake.commandInfoByNameMutex.Unlock() - if fake.CommandInfoByNameStub != nil { - return fake.CommandInfoByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.commandInfoByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -108,15 +109,16 @@ func (fake *FakeHelpActor) CommandInfos(arg1 interface{}) map[string]sharedactio fake.commandInfosArgsForCall = append(fake.commandInfosArgsForCall, struct { arg1 interface{} }{arg1}) + stub := fake.CommandInfosStub + fakeReturns := fake.commandInfosReturns fake.recordInvocation("CommandInfos", []interface{}{arg1}) fake.commandInfosMutex.Unlock() - if fake.CommandInfosStub != nil { - return fake.CommandInfosStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.commandInfosReturns return fakeReturns.result1 } diff --git a/command/common/commonfakes/fake_install_plugin_actor.go b/command/common/commonfakes/fake_install_plugin_actor.go index 3f6de0cf1d0..8cc30868063 100644 --- a/command/common/commonfakes/fake_install_plugin_actor.go +++ b/command/common/commonfakes/fake_install_plugin_actor.go @@ -4,10 +4,10 @@ package commonfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeInstallPluginActor struct { @@ -155,15 +155,16 @@ func (fake *FakeInstallPluginActor) CreateExecutableCopy(arg1 string, arg2 strin arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateExecutableCopyStub + fakeReturns := fake.createExecutableCopyReturns fake.recordInvocation("CreateExecutableCopy", []interface{}{arg1, arg2}) fake.createExecutableCopyMutex.Unlock() - if fake.CreateExecutableCopyStub != nil { - return fake.CreateExecutableCopyStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createExecutableCopyReturns return fakeReturns.result1, fakeReturns.result2 } @@ -220,15 +221,16 @@ func (fake *FakeInstallPluginActor) DownloadExecutableBinaryFromURL(arg1 string, arg2 string arg3 plugin.ProxyReader }{arg1, arg2, arg3}) + stub := fake.DownloadExecutableBinaryFromURLStub + fakeReturns := fake.downloadExecutableBinaryFromURLReturns fake.recordInvocation("DownloadExecutableBinaryFromURL", []interface{}{arg1, arg2, arg3}) fake.downloadExecutableBinaryFromURLMutex.Unlock() - if fake.DownloadExecutableBinaryFromURLStub != nil { - return fake.DownloadExecutableBinaryFromURLStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.downloadExecutableBinaryFromURLReturns return fakeReturns.result1, fakeReturns.result2 } @@ -283,15 +285,16 @@ func (fake *FakeInstallPluginActor) FileExists(arg1 string) bool { fake.fileExistsArgsForCall = append(fake.fileExistsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.FileExistsStub + fakeReturns := fake.fileExistsReturns fake.recordInvocation("FileExists", []interface{}{arg1}) fake.fileExistsMutex.Unlock() - if fake.FileExistsStub != nil { - return fake.FileExistsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.fileExistsReturns return fakeReturns.result1 } @@ -345,15 +348,16 @@ func (fake *FakeInstallPluginActor) GetAndValidatePlugin(arg1 pluginaction.Plugi arg2 pluginaction.CommandList arg3 string }{arg1, arg2, arg3}) + stub := fake.GetAndValidatePluginStub + fakeReturns := fake.getAndValidatePluginReturns fake.recordInvocation("GetAndValidatePlugin", []interface{}{arg1, arg2, arg3}) fake.getAndValidatePluginMutex.Unlock() - if fake.GetAndValidatePluginStub != nil { - return fake.GetAndValidatePluginStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAndValidatePluginReturns return fakeReturns.result1, fakeReturns.result2 } @@ -409,15 +413,16 @@ func (fake *FakeInstallPluginActor) GetPlatformString(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetPlatformStringStub + fakeReturns := fake.getPlatformStringReturns fake.recordInvocation("GetPlatformString", []interface{}{arg1, arg2}) fake.getPlatformStringMutex.Unlock() - if fake.GetPlatformStringStub != nil { - return fake.GetPlatformStringStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.getPlatformStringReturns return fakeReturns.result1 } @@ -476,15 +481,16 @@ func (fake *FakeInstallPluginActor) GetPluginInfoFromRepositoriesForPlatform(arg arg2 []configv3.PluginRepository arg3 string }{arg1, arg2Copy, arg3}) + stub := fake.GetPluginInfoFromRepositoriesForPlatformStub + fakeReturns := fake.getPluginInfoFromRepositoriesForPlatformReturns fake.recordInvocation("GetPluginInfoFromRepositoriesForPlatform", []interface{}{arg1, arg2Copy, arg3}) fake.getPluginInfoFromRepositoriesForPlatformMutex.Unlock() - if fake.GetPluginInfoFromRepositoriesForPlatformStub != nil { - return fake.GetPluginInfoFromRepositoriesForPlatformStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getPluginInfoFromRepositoriesForPlatformReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -542,15 +548,16 @@ func (fake *FakeInstallPluginActor) GetPluginRepository(arg1 string) (configv3.P fake.getPluginRepositoryArgsForCall = append(fake.getPluginRepositoryArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetPluginRepositoryStub + fakeReturns := fake.getPluginRepositoryReturns fake.recordInvocation("GetPluginRepository", []interface{}{arg1}) fake.getPluginRepositoryMutex.Unlock() - if fake.GetPluginRepositoryStub != nil { - return fake.GetPluginRepositoryStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getPluginRepositoryReturns return fakeReturns.result1, fakeReturns.result2 } @@ -606,15 +613,16 @@ func (fake *FakeInstallPluginActor) InstallPluginFromPath(arg1 string, arg2 conf arg1 string arg2 configv3.Plugin }{arg1, arg2}) + stub := fake.InstallPluginFromPathStub + fakeReturns := fake.installPluginFromPathReturns fake.recordInvocation("InstallPluginFromPath", []interface{}{arg1, arg2}) fake.installPluginFromPathMutex.Unlock() - if fake.InstallPluginFromPathStub != nil { - return fake.InstallPluginFromPathStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.installPluginFromPathReturns return fakeReturns.result1 } @@ -667,15 +675,16 @@ func (fake *FakeInstallPluginActor) UninstallPlugin(arg1 pluginaction.PluginUnin arg1 pluginaction.PluginUninstaller arg2 string }{arg1, arg2}) + stub := fake.UninstallPluginStub + fakeReturns := fake.uninstallPluginReturns fake.recordInvocation("UninstallPlugin", []interface{}{arg1, arg2}) fake.uninstallPluginMutex.Unlock() - if fake.UninstallPluginStub != nil { - return fake.UninstallPluginStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.uninstallPluginReturns return fakeReturns.result1 } @@ -728,15 +737,16 @@ func (fake *FakeInstallPluginActor) ValidateFileChecksum(arg1 string, arg2 strin arg1 string arg2 string }{arg1, arg2}) + stub := fake.ValidateFileChecksumStub + fakeReturns := fake.validateFileChecksumReturns fake.recordInvocation("ValidateFileChecksum", []interface{}{arg1, arg2}) fake.validateFileChecksumMutex.Unlock() - if fake.ValidateFileChecksumStub != nil { - return fake.ValidateFileChecksumStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.validateFileChecksumReturns return fakeReturns.result1 } diff --git a/command/common/help_command.go b/command/common/help_command.go index 23e9b429e0d..7b79b62bb32 100644 --- a/command/common/help_command.go +++ b/command/common/help_command.go @@ -5,12 +5,12 @@ import ( "math" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/common/internal" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/common/internal" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/configv3" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . HelpActor @@ -136,8 +136,6 @@ func (cmd HelpCommand) displayHelpFooter(cmdInfo map[string]sharedaction.Command cmd.UI.DisplayNonWrappingTable(sharedaction.AllCommandsIndent, cmd.globalOptionsTableData(), 25) cmd.UI.DisplayNewline() - - cmd.displayCommandGroups(internal.ExperimentalHelpCategoryList, cmdInfo, 34) } func (cmd HelpCommand) displayCommonCommands() { @@ -214,10 +212,10 @@ func (cmd HelpCommand) displayCommonCommands() { func (cmd HelpCommand) displayCommand() error { cmdInfo, err := cmd.Actor.CommandInfoByName(Commands, cmd.OptionalArgs.CommandName) if err != nil { - if err, ok := err.(actionerror.InvalidCommandError); ok { + if err1, ok := err.(actionerror.InvalidCommandError); ok { var found bool if cmdInfo, found = cmd.findPlugin(); !found { - return err + return err1 } } else { return err diff --git a/command/common/install_plugin_command.go b/command/common/install_plugin_command.go index e38fa3864e2..d176b56f9d9 100644 --- a/command/common/install_plugin_command.go +++ b/command/common/install_plugin_command.go @@ -1,22 +1,21 @@ package common import ( - "io/ioutil" "os" "runtime" "strings" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/plugin/shared" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/plugin/shared" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util" + "code.cloudfoundry.org/cli/v8/util/configv3" log "github.com/sirupsen/logrus" ) @@ -79,7 +78,7 @@ func (cmd InstallPluginCommand) Execute([]string) (err error) { log.WithField("PluginHome", cmd.Config.PluginHome()).Info("making plugin dir") var tempPluginDir string - tempPluginDir, err = ioutil.TempDir(cmd.Config.PluginHome(), "temp") + tempPluginDir, err = os.MkdirTemp(cmd.Config.PluginHome(), "temp") log.WithField("tempPluginDir", tempPluginDir).Debug("making tempPluginDir dir") defer func() { @@ -407,7 +406,7 @@ func (cmd InstallPluginCommand) installPluginPrompt(template string, templateVal } if !really { - log.Debug("plugin confirmation - 'no' inputed") + log.Debug("plugin confirmation - 'no' inputted") return cancelInstall{} } diff --git a/command/common/install_plugin_command_test.go b/command/common/install_plugin_command_test.go index 9e29befb9e6..dd8f75504e1 100644 --- a/command/common/install_plugin_command_test.go +++ b/command/common/install_plugin_command_test.go @@ -2,19 +2,18 @@ package common_test import ( "errors" - "io/ioutil" "os" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/command/common/commonfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/command/common/commonfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -47,7 +46,7 @@ var _ = Describe("install-plugin command", func() { } var err error - pluginHome, err = ioutil.TempDir("", "some-pluginhome") + pluginHome, err = os.MkdirTemp("", "some-pluginhome") Expect(err).NotTo(HaveOccurred()) fakeConfig.PluginHomeReturns(pluginHome) diff --git a/command/common/install_plugin_from_repo_command_test.go b/command/common/install_plugin_from_repo_command_test.go index a92a4de9f9e..d7227281c2f 100644 --- a/command/common/install_plugin_from_repo_command_test.go +++ b/command/common/install_plugin_from_repo_command_test.go @@ -4,25 +4,24 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "math/rand" "os" "runtime" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/plugin/pluginfakes" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/command/common/commonfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/command/common/commonfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -56,7 +55,7 @@ var _ = Describe("install-plugin command", func() { } var err error - pluginHome, err = ioutil.TempDir("", "some-pluginhome") + pluginHome, err = os.MkdirTemp("", "some-pluginhome") Expect(err).ToNot(HaveOccurred()) fakeConfig.PluginHomeReturns(pluginHome) binaryName = helpers.PrefixedRandomName("bin") @@ -307,7 +306,7 @@ var _ = Describe("install-plugin command", func() { }) }) - When("creating an exectuable copy succeeds", func() { + When("creating an executable copy succeeds", func() { BeforeEach(func() { fakeActor.CreateExecutableCopyReturns("copy-path", nil) }) diff --git a/command/common/internal/help_all_display.go b/command/common/internal/help_all_display.go index 3dac8169748..9bbd28714a6 100644 --- a/command/common/internal/help_all_display.go +++ b/command/common/internal/help_all_display.go @@ -13,16 +13,18 @@ var HelpCategoryList = []HelpCategory{ CommandList: [][]string{ {"apps", "app", "create-app"}, {"push", "scale", "delete", "rename"}, - {"cancel-deployment"}, + {"cancel-deployment", "continue-deployment"}, {"start", "stop", "restart", "stage-package", "restage", "restart-app-instance"}, - {"run-task", "tasks", "terminate-task"}, + {"run-task", "task", "tasks", "terminate-task"}, {"packages", "create-package"}, + {"revision", "revisions", "rollback"}, {"droplets", "set-droplet", "download-droplet"}, {"events", "logs"}, {"env", "set-env", "unset-env"}, {"stacks", "stack"}, {"copy-source", "create-app-manifest"}, - {"get-health-check", "set-health-check", "enable-ssh", "disable-ssh", "ssh-enabled", "ssh"}, + {"get-health-check", "set-health-check", "get-readiness-health-check"}, + {"enable-ssh", "disable-ssh", "ssh-enabled", "ssh"}, }, }, { @@ -65,8 +67,11 @@ var HelpCategoryList = []HelpCategory{ CategoryName: "ROUTES:", CommandList: [][]string{ {"routes", "route"}, - {"create-route", "check-route", "map-route", "unmap-route", "delete-route"}, + {"create-route", "update-route", "check-route", "map-route", "unmap-route", "delete-route"}, {"delete-orphaned-routes"}, + {"update-destination"}, + {"share-route", "unshare-route"}, + {"move-route"}, }, }, { @@ -164,12 +169,3 @@ var HelpCategoryList = []HelpCategory{ }, }, } - -var ExperimentalHelpCategoryList = []HelpCategory{ - { - CategoryName: "EXPERIMENTAL COMMANDS:", - CommandList: [][]string{ - {"revisions", "revision", "rollback"}, - }, - }, -} diff --git a/command/common/internal/help_all_display_test.go b/command/common/internal/help_all_display_test.go index ee812d6d1cf..60647a8fb8f 100644 --- a/command/common/internal/help_all_display_test.go +++ b/command/common/internal/help_all_display_test.go @@ -4,9 +4,9 @@ import ( "reflect" "strings" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/command/common/internal" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/command/common/internal" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -34,16 +34,6 @@ var _ = Describe("test help all display", func() { } } } - - for _, category := range internal.ExperimentalHelpCategoryList { - for _, row := range category.CommandList { - for _, command := range row { - if command != "" { - fromHelpAllDisplay = append(fromHelpAllDisplay, command) - } - } - } - } }) It("lists all commands from command list in at least one category", func() { diff --git a/command/common/internal/help_display.go b/command/common/internal/help_display.go index 55eb2c87480..d2b309a83e0 100644 --- a/command/common/internal/help_display.go +++ b/command/common/internal/help_display.go @@ -5,9 +5,9 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/sorting" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/sorting" ) type HelpCategory struct { diff --git a/command/common/internal/internal_suite_test.go b/command/common/internal/internal_suite_test.go index 86d6b32f524..b38fb2bd915 100644 --- a/command/common/internal/internal_suite_test.go +++ b/command/common/internal/internal_suite_test.go @@ -3,7 +3,7 @@ package internal_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/common/version_command.go b/command/common/version_command.go index 2b1e2ba8676..9d5fe25a357 100644 --- a/command/common/version_command.go +++ b/command/common/version_command.go @@ -1,6 +1,6 @@ package common -import "code.cloudfoundry.org/cli/command" +import "code.cloudfoundry.org/cli/v8/command" type VersionCommand struct { usage interface{} `usage:"CF_NAME version\n\n 'cf -v' and 'cf --version' are also accepted."` diff --git a/command/common/version_command_test.go b/command/common/version_command_test.go index a6f3b6d8b34..52c7a6295c3 100644 --- a/command/common/version_command_test.go +++ b/command/common/version_command_test.go @@ -1,11 +1,11 @@ package common_test import ( - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/util/ui" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/config.go b/command/config.go index 44b30e5ba99..8d89f062ed1 100644 --- a/command/config.go +++ b/command/config.go @@ -3,7 +3,7 @@ package command import ( "time" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Config @@ -15,6 +15,7 @@ type Config interface { AddPluginRepository(name string, url string) AuthorizationEndpoint() string APIVersion() string + B3TraceID() string BinaryName() string BinaryVersion() string CFPassword() string @@ -24,6 +25,7 @@ type Config interface { CurrentUserName() (string, error) DialTimeout() time.Duration DockerPassword() string + CNBCredentials() (map[string]interface{}, error) Experimental() bool GetPlugin(pluginName string) (configv3.Plugin, bool) GetPluginCaseInsensitive(pluginName string) (configv3.Plugin, bool) diff --git a/command/flag/app_type.go b/command/flag/app_type.go index 5b5fdfd4587..6a4eb3e9788 100644 --- a/command/flag/app_type.go +++ b/command/flag/app_type.go @@ -5,5 +5,5 @@ import flags "github.com/jessevdk/go-flags" type AppType string func (AppType) Complete(prefix string) []flags.Completion { - return completions([]string{"buildpack", "docker"}, prefix, false) + return completions([]string{"buildpack", "docker", "cnb"}, prefix, false) } diff --git a/command/flag/app_type_test.go b/command/flag/app_type_test.go index cfd3a36b904..cd1636e7fd2 100644 --- a/command/flag/app_type_test.go +++ b/command/flag/app_type_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,14 +19,16 @@ var _ = Describe("AppType", func() { Entry("completes to 'buildpack' when passed 'b'", "b", []flags.Completion{{Item: "buildpack"}}), + Entry("completes to 'cnb' when passed 'c'", "c", + []flags.Completion{{Item: "cnb"}}), Entry("completes to 'docker' when passed 'd'", "d", []flags.Completion{{Item: "docker"}}), Entry("completes to 'buildpack' when passed 'bU'", "bU", []flags.Completion{{Item: "buildpack"}}), Entry("completes to 'docker' when passed 'Do'", "Do", []flags.Completion{{Item: "docker"}}), - Entry("returns 'buildpack' and 'docker' when passed nothing", "", - []flags.Completion{{Item: "buildpack"}, {Item: "docker"}}), + Entry("returns 'buildpack', 'cnb', and 'docker' when passed nothing", "", + []flags.Completion{{Item: "buildpack"}, {Item: "docker"}, {Item: "cnb"}}), Entry("completes to nothing when passed 'wut'", "wut", []flags.Completion{}), ) diff --git a/command/flag/arguments.go b/command/flag/arguments.go index f4141c58085..9e3d60263f8 100644 --- a/command/flag/arguments.go +++ b/command/flag/arguments.go @@ -324,8 +324,8 @@ type ServiceBroker struct { type ServiceBrokerArgs struct { ServiceBroker string `positional-arg-name:"SERVICE_BROKER" required:"true" description:"The service broker name"` Username string `positional-arg-name:"USERNAME" required:"true" description:"The username"` - Password string `positional-arg-name:"PASSWORD" required:"true" description:"The password"` - URL string `positional-arg-name:"URL" required:"true" description:"The URL of the service broker"` + PasswordOrURL string `positional-arg-name:"URL" required:"true" description:"The URL of the service broker"` + URL string `positional-arg-name:"URL" description:"The URL of the service broker"` } type RenameServiceBrokerArgs struct { @@ -408,3 +408,8 @@ type RemoveNetworkPolicyArgsV7 struct { SourceApp string `positional-arg-name:"SOURCE_APP" required:"true" description:"The source app"` DestApp string `positional-arg-name:"DESTINATION_APP" required:"true" description:"The destination app"` } + +type TaskArgs struct { + AppName string `positional-arg-name:"APP_NAME" required:"true" description:"The application name"` + TaskID int `positional-arg-name:"TASK_ID" required:"true" description:"The Task ID for the application"` +} diff --git a/command/flag/binding_name_test.go b/command/flag/binding_name_test.go index 0a01d0b95a6..a0bc0596dad 100644 --- a/command/flag/binding_name_test.go +++ b/command/flag/binding_name_test.go @@ -1,9 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/buildpack.go b/command/flag/buildpack.go index 4dd9d9330b5..2426791ad08 100644 --- a/command/flag/buildpack.go +++ b/command/flag/buildpack.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) type Buildpack struct { diff --git a/command/flag/buildpack_test.go b/command/flag/buildpack_test.go index 11ab0374d78..7fad2d7ab85 100644 --- a/command/flag/buildpack_test.go +++ b/command/flag/buildpack_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/bytes_with_unlimited.go b/command/flag/bytes_with_unlimited.go new file mode 100644 index 00000000000..30d14b39366 --- /dev/null +++ b/command/flag/bytes_with_unlimited.go @@ -0,0 +1,59 @@ +package flag + +import ( + "regexp" + "strings" + + "code.cloudfoundry.org/bytefmt" + "code.cloudfoundry.org/cli/v8/types" + flags "github.com/jessevdk/go-flags" +) + +type BytesWithUnlimited types.NullInt + +var zeroBytes *regexp.Regexp = regexp.MustCompile(`^0[KMGT]?B?$`) +var negativeOneBytes *regexp.Regexp = regexp.MustCompile(`^-1[KMGT]?B?$`) + +func (m *BytesWithUnlimited) UnmarshalFlag(val string) error { + if val == "" { + return nil + } + + if negativeOneBytes.MatchString(val) { + m.Value = -1 + m.IsSet = true + return nil + } + + if zeroBytes.MatchString(val) { + m.Value = 0 + m.IsSet = true + return nil + } + + size, err := ConvertToBytes(val) + if err != nil { + return err + } + + m.Value = int(size) + m.IsSet = true + + return nil +} + +func (m *BytesWithUnlimited) IsValidValue(val string) error { + return m.UnmarshalFlag(val) +} + +func ConvertToBytes(val string) (uint64, error) { + size, err := bytefmt.ToBytes(val) + + if err != nil || strings.Contains(strings.ToLower(val), ".") { + return size, &flags.Error{ + Type: flags.ErrRequired, + Message: `Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB`, + } + } + return size, nil +} diff --git a/command/flag/bytes_with_unlimited_test.go b/command/flag/bytes_with_unlimited_test.go new file mode 100644 index 00000000000..a47608e5774 --- /dev/null +++ b/command/flag/bytes_with_unlimited_test.go @@ -0,0 +1,148 @@ +package flag_test + +import ( + . "code.cloudfoundry.org/cli/v8/command/flag" + flags "github.com/jessevdk/go-flags" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("BytesWithUnlimited", func() { + var bytesWithUnlimited BytesWithUnlimited + + Describe("UnmarshalFlag", func() { + BeforeEach(func() { + bytesWithUnlimited = BytesWithUnlimited{} + }) + + When("the suffix is B", func() { + It("interprets the number as bytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("17B") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(17)) + }) + }) + + When("the suffix is K", func() { + It("interprets the number as kilobytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("64K") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(64 * 1024)) + }) + }) + + When("the suffix is KB", func() { + It("interprets the number as kilobytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("64KB") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(64 * 1024)) + }) + }) + + When("the suffix is M", func() { + It("interprets the number as megabytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("17M") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(17 * 1024 * 1024)) + }) + }) + + When("the suffix is MB", func() { + It("interprets the number as megabytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("19MB") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(19 * 1024 * 1024)) + }) + }) + + When("the suffix is G", func() { + It("interprets the number as gigabytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("2G") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(2 * 1024 * 1024 * 1024)) + }) + }) + + When("the suffix is GB", func() { + It("interprets the number as gigabytes", func() { + err := bytesWithUnlimited.UnmarshalFlag("3GB") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(3 * 1024 * 1024 * 1024)) + }) + }) + + When("the value is -1 (unlimited)", func() { + It("interprets the number as -1 (unlimited)", func() { + err := bytesWithUnlimited.UnmarshalFlag("-1") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(-1)) + }) + + It("accepts units", func() { + err := bytesWithUnlimited.UnmarshalFlag("-1T") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(-1)) + }) + }) + + When("the value is 0", func() { + It("set's the value to 0", func() { + err := bytesWithUnlimited.UnmarshalFlag("0") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(0)) + }) + + It("accepts units", func() { + err := bytesWithUnlimited.UnmarshalFlag("0TB") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(0)) + }) + }) + + When("the suffix is lowercase", func() { + It("is case insensitive", func() { + err := bytesWithUnlimited.UnmarshalFlag("7m") + Expect(err).ToNot(HaveOccurred()) + Expect(bytesWithUnlimited.Value).To(BeEquivalentTo(7 * 1024 * 1024)) + }) + }) + + When("the value is invalid", func() { + It("returns an error", func() { + err := bytesWithUnlimited.UnmarshalFlag("invalid") + Expect(err).To(MatchError(&flags.Error{ + Type: flags.ErrRequired, + Message: `Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB`, + })) + }) + }) + + When("a decimal is used", func() { + It("returns an error", func() { + err := bytesWithUnlimited.UnmarshalFlag("1.2M") + Expect(err).To(MatchError(&flags.Error{ + Type: flags.ErrRequired, + Message: `Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB`, + })) + }) + }) + + When("the units are missing", func() { + It("returns an error", func() { + err := bytesWithUnlimited.UnmarshalFlag("37") + Expect(err).To(MatchError(&flags.Error{ + Type: flags.ErrRequired, + Message: `Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB`, + })) + }) + }) + + When("value is empty", func() { + It("sets IsSet to false", func() { + err := bytesWithUnlimited.UnmarshalFlag("") + Expect(err).NotTo(HaveOccurred()) + Expect(bytesWithUnlimited.IsSet).To(BeFalse()) + }) + }) + }) +}) diff --git a/command/flag/color_test.go b/command/flag/color_test.go index 104975e5fa8..58517253843 100644 --- a/command/flag/color_test.go +++ b/command/flag/color_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/command.go b/command/flag/command.go index d041895392b..1556e7353a1 100644 --- a/command/flag/command.go +++ b/command/flag/command.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) type Command struct { diff --git a/command/flag/command_test.go b/command/flag/command_test.go index dd5a2f54971..fb5f9703291 100644 --- a/command/flag/command_test.go +++ b/command/flag/command_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/credentials_or_json.go b/command/flag/credentials_or_json.go index d4beca680c3..f4396cc60a0 100644 --- a/command/flag/credentials_or_json.go +++ b/command/flag/credentials_or_json.go @@ -3,10 +3,10 @@ package flag import ( "encoding/json" "fmt" - "io/ioutil" + "os" "strings" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) @@ -54,7 +54,7 @@ func canParseAsJSON(input string) (value map[string]interface{}, ok bool) { } func canParseFileAsJSON(input string) (value map[string]interface{}, ok bool, parseError error) { - contents, err := ioutil.ReadFile(input) + contents, err := os.ReadFile(input) if err != nil { return } diff --git a/command/flag/credentials_or_json_test.go b/command/flag/credentials_or_json_test.go index f962d8b1a97..6631521b4ec 100644 --- a/command/flag/credentials_or_json_test.go +++ b/command/flag/credentials_or_json_test.go @@ -4,10 +4,10 @@ import ( "fmt" "os" - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/deployment_strategy.go b/command/flag/deployment_strategy.go index 0c7a98bb5e4..0c034f8b371 100644 --- a/command/flag/deployment_strategy.go +++ b/command/flag/deployment_strategy.go @@ -3,7 +3,7 @@ package flag import ( "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" "github.com/jessevdk/go-flags" ) @@ -12,7 +12,7 @@ type DeploymentStrategy struct { } func (DeploymentStrategy) Complete(prefix string) []flags.Completion { - return completions([]string{string(constant.DeploymentStrategyRolling)}, prefix, false) + return completions([]string{string(constant.DeploymentStrategyRolling), string(constant.DeploymentStrategyCanary)}, prefix, false) } func (h *DeploymentStrategy) UnmarshalFlag(val string) error { @@ -23,13 +23,14 @@ func (h *DeploymentStrategy) UnmarshalFlag(val string) error { case string(constant.DeploymentStrategyDefault): // Do nothing, leave the default value - case string(constant.DeploymentStrategyRolling): + case string(constant.DeploymentStrategyRolling), + string(constant.DeploymentStrategyCanary): h.Name = constant.DeploymentStrategy(valLower) default: return &flags.Error{ Type: flags.ErrInvalidChoice, - Message: `STRATEGY must be "rolling" or not set`, + Message: `STRATEGY must be "canary", "rolling" or not set`, } } diff --git a/command/flag/deployment_strategy_test.go b/command/flag/deployment_strategy_test.go index 78846b11c59..2ee856181f3 100644 --- a/command/flag/deployment_strategy_test.go +++ b/command/flag/deployment_strategy_test.go @@ -1,11 +1,10 @@ package flag_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -35,7 +34,7 @@ var _ = Describe("DeploymentStrategy", func() { Expect(strategy.Name).To(Equal(expectedType)) }, Entry("sets 'rolling' when passed 'rolling'", "rolling", constant.DeploymentStrategyRolling), - Entry("sets 'rolling' when passed 'rOlliNg'", "rOlliNg", constant.DeploymentStrategyRolling), + Entry("sets 'rolling' when passed 'cAnaRy'", "cAnaRy", constant.DeploymentStrategyCanary), Entry("sets 'rolling' when passed 'ROLLING'", "ROLLING", constant.DeploymentStrategyRolling), ) @@ -44,7 +43,7 @@ var _ = Describe("DeploymentStrategy", func() { err := strategy.UnmarshalFlag("banana") Expect(err).To(MatchError(&flags.Error{ Type: flags.ErrInvalidChoice, - Message: `STRATEGY must be "rolling" or not set`, + Message: `STRATEGY must be "canary", "rolling" or not set`, })) Expect(strategy.Name).To(BeEmpty()) }) diff --git a/command/flag/docker.go b/command/flag/docker.go index 5bab908f3d2..c5d8ace34b3 100644 --- a/command/flag/docker.go +++ b/command/flag/docker.go @@ -3,7 +3,7 @@ package flag import ( "fmt" - "github.com/docker/distribution/reference" + "github.com/distribution/reference" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/docker_test.go b/command/flag/docker_test.go index 510071e0741..c9d9a59f066 100644 --- a/command/flag/docker_test.go +++ b/command/flag/docker_test.go @@ -1,9 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/droplet_test.go b/command/flag/droplet_test.go index 0fd86977c16..714f6f4346e 100644 --- a/command/flag/droplet_test.go +++ b/command/flag/droplet_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/environment_variable_test.go b/command/flag/environment_variable_test.go index a4568586ce4..377b15a3abd 100644 --- a/command/flag/environment_variable_test.go +++ b/command/flag/environment_variable_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package flag_test @@ -7,9 +8,9 @@ import ( "os" "strings" - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/flag_suite_test.go b/command/flag/flag_suite_test.go index 7254810be22..8f8a5ad234d 100644 --- a/command/flag/flag_suite_test.go +++ b/command/flag/flag_suite_test.go @@ -1,13 +1,11 @@ package flag_test import ( - "io/ioutil" "os" + "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) func TestFlag(t *testing.T) { @@ -19,7 +17,7 @@ var tempDir string var _ = BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "cf-cli-") + tempDir, err = os.MkdirTemp("", "cf-cli-") Expect(err).ToNot(HaveOccurred()) }) @@ -29,7 +27,7 @@ var _ = AfterEach(func() { }) func tempFile(data string) string { - tempFile, err := ioutil.TempFile(tempDir, "") + tempFile, err := os.CreateTemp(tempDir, "") Expect(err).ToNot(HaveOccurred()) _, err = tempFile.WriteString(data) Expect(err).ToNot(HaveOccurred()) diff --git a/command/flag/health_check_type.go b/command/flag/health_check_type.go index 203f36017c5..e80834dc5a8 100644 --- a/command/flag/health_check_type.go +++ b/command/flag/health_check_type.go @@ -3,7 +3,7 @@ package flag import ( "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/health_check_type_test.go b/command/flag/health_check_type_test.go index f96ab6c0e44..f01aa4eaa01 100644 --- a/command/flag/health_check_type_test.go +++ b/command/flag/health_check_type_test.go @@ -1,11 +1,10 @@ package flag_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/health_check_type_with_deprecated_value_test.go b/command/flag/health_check_type_with_deprecated_value_test.go index 7645fe0e424..eb18d882e9c 100644 --- a/command/flag/health_check_type_with_deprecated_value_test.go +++ b/command/flag/health_check_type_with_deprecated_value_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/instances.go b/command/flag/instances.go index 437042a9034..d7ea3226b97 100644 --- a/command/flag/instances.go +++ b/command/flag/instances.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/instances_test.go b/command/flag/instances_test.go index d93af82d32b..5d53994f2e9 100644 --- a/command/flag/instances_test.go +++ b/command/flag/instances_test.go @@ -1,10 +1,10 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + . "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/integer_limit.go b/command/flag/integer_limit.go index 1f5c9253414..91df9f39977 100644 --- a/command/flag/integer_limit.go +++ b/command/flag/integer_limit.go @@ -3,7 +3,7 @@ package flag import ( "strconv" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/integer_limit_test.go b/command/flag/integer_limit_test.go index 1b84afe5c15..1414e983a51 100644 --- a/command/flag/integer_limit_test.go +++ b/command/flag/integer_limit_test.go @@ -1,9 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/locale.go b/command/flag/locale.go index d2cf1871ff0..92b70ed2ee3 100644 --- a/command/flag/locale.go +++ b/command/flag/locale.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/cf/i18n" + "code.cloudfoundry.org/cli/v8/cf/i18n" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/locale_test.go b/command/flag/locale_test.go index 309ba7c98dd..775e4a0c4c3 100644 --- a/command/flag/locale_test.go +++ b/command/flag/locale_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/megabytes.go b/command/flag/megabytes.go index edb780c9b7d..68b338a6cbd 100644 --- a/command/flag/megabytes.go +++ b/command/flag/megabytes.go @@ -3,7 +3,7 @@ package flag import ( "strings" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/bytefmt" flags "github.com/jessevdk/go-flags" diff --git a/command/flag/megabytes_test.go b/command/flag/megabytes_test.go index 385efc921f4..117ee09a7cc 100644 --- a/command/flag/megabytes_test.go +++ b/command/flag/megabytes_test.go @@ -1,9 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/memory_with_unlimited.go b/command/flag/megabytes_with_unlimited.go similarity index 56% rename from command/flag/memory_with_unlimited.go rename to command/flag/megabytes_with_unlimited.go index 10fe06b32f6..f421a9df14a 100644 --- a/command/flag/memory_with_unlimited.go +++ b/command/flag/megabytes_with_unlimited.go @@ -1,12 +1,12 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) -type MemoryWithUnlimited types.NullInt +type MegabytesWithUnlimited types.NullInt -func (m *MemoryWithUnlimited) UnmarshalFlag(val string) error { +func (m *MegabytesWithUnlimited) UnmarshalFlag(val string) error { if val == "" { return nil } @@ -28,6 +28,6 @@ func (m *MemoryWithUnlimited) UnmarshalFlag(val string) error { return nil } -func (m *MemoryWithUnlimited) IsValidValue(val string) error { +func (m *MegabytesWithUnlimited) IsValidValue(val string) error { return m.UnmarshalFlag(val) } diff --git a/command/flag/memory_with_unlimited_test.go b/command/flag/megabytes_with_unlimited_test.go similarity index 56% rename from command/flag/memory_with_unlimited_test.go rename to command/flag/megabytes_with_unlimited_test.go index 65c4e92d939..580924cd9e6 100644 --- a/command/flag/memory_with_unlimited_test.go +++ b/command/flag/megabytes_with_unlimited_test.go @@ -1,71 +1,71 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) -var _ = Describe("MemoryWithUnlimited", func() { - var memoryWithUnlimited MemoryWithUnlimited +var _ = Describe("MegabytesWithUnlimited", func() { + var megabytesWithUnlimited MegabytesWithUnlimited Describe("UnmarshalFlag", func() { BeforeEach(func() { - memoryWithUnlimited = MemoryWithUnlimited{} + megabytesWithUnlimited = MegabytesWithUnlimited{} }) When("the suffix is M", func() { - It("interprets the number as memoryWithUnlimited", func() { - err := memoryWithUnlimited.UnmarshalFlag("17M") + It("interprets the number as megabytesWithUnlimited", func() { + err := megabytesWithUnlimited.UnmarshalFlag("17M") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(17)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(17)) }) }) When("the suffix is MB", func() { - It("interprets the number as memoryWithUnlimited", func() { - err := memoryWithUnlimited.UnmarshalFlag("19MB") + It("interprets the number as megabytesWithUnlimited", func() { + err := megabytesWithUnlimited.UnmarshalFlag("19MB") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(19)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(19)) }) }) When("the suffix is G", func() { It("interprets the number as gigabytes", func() { - err := memoryWithUnlimited.UnmarshalFlag("2G") + err := megabytesWithUnlimited.UnmarshalFlag("2G") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(2048)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(2048)) }) }) When("the suffix is GB", func() { It("interprets the number as gigabytes", func() { - err := memoryWithUnlimited.UnmarshalFlag("3GB") + err := megabytesWithUnlimited.UnmarshalFlag("3GB") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(3072)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(3072)) }) }) When("the value is -1 (unlimited)", func() { - It("interprets the number as memoryWithUnlimited", func() { - err := memoryWithUnlimited.UnmarshalFlag("-1") + It("interprets the number as megabytesWithUnlimited", func() { + err := megabytesWithUnlimited.UnmarshalFlag("-1") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(-1)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(-1)) }) }) When("the suffix is lowercase", func() { It("is case insensitive", func() { - err := memoryWithUnlimited.UnmarshalFlag("7m") + err := megabytesWithUnlimited.UnmarshalFlag("7m") Expect(err).ToNot(HaveOccurred()) - Expect(memoryWithUnlimited.Value).To(BeEquivalentTo(7)) + Expect(megabytesWithUnlimited.Value).To(BeEquivalentTo(7)) }) }) - When("the memoryWithUnlimited are invalid", func() { + When("the megabytesWithUnlimited are invalid", func() { It("returns an error", func() { - err := memoryWithUnlimited.UnmarshalFlag("invalid") + err := megabytesWithUnlimited.UnmarshalFlag("invalid") Expect(err).To(MatchError(&flags.Error{ Type: flags.ErrRequired, Message: `Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB`, @@ -75,7 +75,7 @@ var _ = Describe("MemoryWithUnlimited", func() { When("a decimal is used", func() { It("returns an error", func() { - err := memoryWithUnlimited.UnmarshalFlag("1.2M") + err := megabytesWithUnlimited.UnmarshalFlag("1.2M") Expect(err).To(MatchError(&flags.Error{ Type: flags.ErrRequired, Message: `Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB`, @@ -85,7 +85,7 @@ var _ = Describe("MemoryWithUnlimited", func() { When("the units are missing", func() { It("returns an error", func() { - err := memoryWithUnlimited.UnmarshalFlag("37") + err := megabytesWithUnlimited.UnmarshalFlag("37") Expect(err).To(MatchError(&flags.Error{ Type: flags.ErrRequired, Message: `Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB`, @@ -95,7 +95,7 @@ var _ = Describe("MemoryWithUnlimited", func() { When("the suffix is B", func() { It("returns an error", func() { - err := memoryWithUnlimited.UnmarshalFlag("10B") + err := megabytesWithUnlimited.UnmarshalFlag("10B") Expect(err).To(MatchError(&flags.Error{ Type: flags.ErrRequired, Message: `Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB`, @@ -105,9 +105,9 @@ var _ = Describe("MemoryWithUnlimited", func() { When("value is empty", func() { It("sets IsSet to false", func() { - err := memoryWithUnlimited.UnmarshalFlag("") + err := megabytesWithUnlimited.UnmarshalFlag("") Expect(err).NotTo(HaveOccurred()) - Expect(memoryWithUnlimited.IsSet).To(BeFalse()) + Expect(megabytesWithUnlimited.IsSet).To(BeFalse()) }) }) }) diff --git a/command/flag/network_port_test.go b/command/flag/network_port_test.go index 03454f2d8e8..0c055b60574 100644 --- a/command/flag/network_port_test.go +++ b/command/flag/network_port_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/network_protocol_test.go b/command/flag/network_protocol_test.go index 3d11aa4982b..a58f4177c2c 100644 --- a/command/flag/network_protocol_test.go +++ b/command/flag/network_protocol_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/optional_string.go b/command/flag/optional_string.go index 030abed6316..2ca8f7e4032 100644 --- a/command/flag/optional_string.go +++ b/command/flag/optional_string.go @@ -1,6 +1,6 @@ package flag -import "code.cloudfoundry.org/cli/types" +import "code.cloudfoundry.org/cli/v8/types" type OptionalString types.OptionalString diff --git a/command/flag/optional_string_test.go b/command/flag/optional_string_test.go index 528178ad2af..098ca5116c8 100644 --- a/command/flag/optional_string_test.go +++ b/command/flag/optional_string_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/org_role_test.go b/command/flag/org_role_test.go index 4c8402c824e..a06f3f2eaa5 100644 --- a/command/flag/org_role_test.go +++ b/command/flag/org_role_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/path.go b/command/flag/path.go index b23b8b433ab..9aa463a3901 100644 --- a/command/flag/path.go +++ b/command/flag/path.go @@ -3,13 +3,12 @@ package flag import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strings" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/manifestparser" "github.com/jessevdk/go-flags" ) @@ -106,7 +105,7 @@ func (p *JSONOrFileWithValidation) UnmarshalFlag(pathOrJSON string) error { _, err := os.Stat(pathOrJSON) if err == nil { - jsonBytes, err = ioutil.ReadFile(pathOrJSON) + jsonBytes, err = os.ReadFile(pathOrJSON) if err != nil { return errorToReturn } diff --git a/command/flag/path_test.go b/command/flag/path_test.go index 75ab2453b4a..e28c11e1a1d 100644 --- a/command/flag/path_test.go +++ b/command/flag/path_test.go @@ -2,14 +2,13 @@ package flag_test import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - . "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -94,12 +93,12 @@ var _ = Describe("path types", func() { ) BeforeEach(func() { - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) os.Setenv("HOME", tempDir) for _, filename := range []string{"abc", "def"} { - err = ioutil.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) + err = os.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) Expect(err).ToNot(HaveOccurred()) } @@ -144,12 +143,12 @@ var _ = Describe("path types", func() { ) BeforeEach(func() { - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) os.Setenv("HOME", tempDir) for _, filename := range []string{"abc", "def"} { - err = ioutil.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) + err = os.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) Expect(err).ToNot(HaveOccurred()) } @@ -181,14 +180,14 @@ var _ = Describe("path types", func() { currentDir, err = os.Getwd() Expect(err).ToNot(HaveOccurred()) - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) err = os.Chdir(tempDir) Expect(err).ToNot(HaveOccurred()) for _, filename := range []string{"abc", "abd", "~abd", "tfg", "ABCD"} { - err = ioutil.WriteFile(filename, []byte{}, 0400) + err = os.WriteFile(filename, []byte{}, 0400) Expect(err).ToNot(HaveOccurred()) } @@ -484,12 +483,12 @@ var _ = Describe("path types", func() { ) BeforeEach(func() { - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) os.Setenv("HOME", tempDir) for _, filename := range []string{"abc", "def"} { - err = ioutil.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) + err = os.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) Expect(err).ToNot(HaveOccurred()) } @@ -534,12 +533,12 @@ var _ = Describe("path types", func() { ) BeforeEach(func() { - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) os.Setenv("HOME", tempDir) for _, filename := range []string{"abc", "def"} { - err = ioutil.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) + err = os.WriteFile(filepath.Join(tempDir, filename), []byte{}, 0400) Expect(err).ToNot(HaveOccurred()) } diff --git a/command/flag/port.go b/command/flag/port.go index 17d430ed36f..e7bc7b63849 100644 --- a/command/flag/port.go +++ b/command/flag/port.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/port_test.go b/command/flag/port_test.go index c2921565359..a8d40839f38 100644 --- a/command/flag/port_test.go +++ b/command/flag/port_test.go @@ -1,10 +1,10 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + . "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/positive_integer_test.go b/command/flag/positive_integer_test.go index 256a4201bac..8fb27748296 100644 --- a/command/flag/positive_integer_test.go +++ b/command/flag/positive_integer_test.go @@ -2,10 +2,10 @@ package flag_test import ( flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" ) var _ = Describe("Positive Integer", func() { diff --git a/command/flag/revision.go b/command/flag/revision.go index f800f8f9552..ce4f15edcc6 100644 --- a/command/flag/revision.go +++ b/command/flag/revision.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/revision_test.go b/command/flag/revision_test.go index f6c1993ce88..60a97c789e5 100644 --- a/command/flag/revision_test.go +++ b/command/flag/revision_test.go @@ -1,10 +1,10 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + . "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/route_path_test.go b/command/flag/route_path_test.go index 60766c2fc0c..0982b368ab2 100644 --- a/command/flag/route_path_test.go +++ b/command/flag/route_path_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/security_group_lifecycle_test.go b/command/flag/security_group_lifecycle_test.go index 570396acd70..238ac210739 100644 --- a/command/flag/security_group_lifecycle_test.go +++ b/command/flag/security_group_lifecycle_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/service_binding_strategy.go b/command/flag/service_binding_strategy.go new file mode 100644 index 00000000000..1b78a9c7a2e --- /dev/null +++ b/command/flag/service_binding_strategy.go @@ -0,0 +1,32 @@ +package flag + +import ( + "strings" + + "code.cloudfoundry.org/cli/v8/resources" + flags "github.com/jessevdk/go-flags" +) + +type ServiceBindingStrategy struct { + Strategy resources.BindingStrategyType + IsSet bool +} + +func (ServiceBindingStrategy) Complete(prefix string) []flags.Completion { + return completions([]string{"single", "multiple"}, prefix, false) +} + +func (h *ServiceBindingStrategy) UnmarshalFlag(val string) error { + valLower := strings.ToLower(val) + switch valLower { + case "single", "multiple": + h.Strategy = resources.BindingStrategyType(valLower) + h.IsSet = true + default: + return &flags.Error{ + Type: flags.ErrRequired, + Message: `STRATEGY must be "single" or "multiple"`, + } + } + return nil +} diff --git a/command/flag/service_binding_strategy_test.go b/command/flag/service_binding_strategy_test.go new file mode 100644 index 00000000000..a37a4b8c5ef --- /dev/null +++ b/command/flag/service_binding_strategy_test.go @@ -0,0 +1,68 @@ +package flag_test + +import ( + . "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + flags "github.com/jessevdk/go-flags" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("ServiceBindingStrategy", func() { + var sbs ServiceBindingStrategy + + Describe("Complete", func() { + DescribeTable("returns list of completions", + func(prefix string, matches []flags.Completion) { + completions := sbs.Complete(prefix) + Expect(completions).To(Equal(matches)) + }, + Entry("returns 'single' when passed 's'", "s", + []flags.Completion{{Item: "single"}}), + Entry("returns 'single' when passed 'S'", "S", + []flags.Completion{{Item: "single"}}), + Entry("returns 'multiple' when passed 'm'", "m", + []flags.Completion{{Item: "multiple"}}), + Entry("returns 'multiple' when passed 'M'", "M", + []flags.Completion{{Item: "multiple"}}), + Entry("returns 'single' and 'multiple' when passed ''", "", + []flags.Completion{{Item: "single"}, {Item: "multiple"}}), + ) + }) + + Describe("UnmarshalFlag", func() { + BeforeEach(func() { + sbs = ServiceBindingStrategy{} + }) + + When("unmarshal has not been called", func() { + It("is marked as not set", func() { + Expect(sbs.IsSet).To(BeFalse()) + }) + }) + + DescribeTable("downcases and sets strategy", + func(input string, expected resources.BindingStrategyType) { + err := sbs.UnmarshalFlag(input) + Expect(err).ToNot(HaveOccurred()) + Expect(sbs.Strategy).To(Equal(expected)) + Expect(sbs.IsSet).To(BeTrue()) + }, + Entry("sets 'single' when passed 'single'", "single", resources.SingleBindingStrategy), + Entry("sets 'single' when passed 'sInGlE'", "sInGlE", resources.SingleBindingStrategy), + Entry("sets 'multiple' when passed 'multiple'", "multiple", resources.MultipleBindingStrategy), + Entry("sets 'multiple' when passed 'MuLtIpLe'", "MuLtIpLe", resources.MultipleBindingStrategy), + ) + + When("passed anything else", func() { + It("returns an error", func() { + err := sbs.UnmarshalFlag("banana") + Expect(err).To(MatchError(&flags.Error{ + Type: flags.ErrRequired, + Message: `STRATEGY must be "single" or "multiple"`, + })) + Expect(sbs.Strategy).To(BeEmpty()) + }) + }) + }) +}) diff --git a/command/flag/space_role.go b/command/flag/space_role.go index 85d9c063fcd..da104ec658a 100644 --- a/command/flag/space_role.go +++ b/command/flag/space_role.go @@ -11,7 +11,7 @@ type SpaceRole struct { } func (SpaceRole) Complete(prefix string) []flags.Completion { - return completions([]string{"SpaceManager", "SpaceDeveloper", "SpaceAuditor"}, prefix, false) + return completions([]string{"SpaceManager", "SpaceDeveloper", "SpaceAuditor", "SpaceSupporter"}, prefix, false) } func (s *SpaceRole) UnmarshalFlag(val string) error { diff --git a/command/flag/space_role_test.go b/command/flag/space_role_test.go index 97f0bea9a3b..045c8bcdcae 100644 --- a/command/flag/space_role_test.go +++ b/command/flag/space_role_test.go @@ -1,10 +1,9 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -17,10 +16,10 @@ var _ = Describe("SpaceRole", func() { completions := spaceRole.Complete(prefix) Expect(completions).To(Equal(matches)) }, - Entry("returns 'SpaceManager', 'SpaceDeveloper' and 'SpaceAuditor' when passed 'S'", "S", - []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}}), - Entry("returns 'SpaceManager', 'SpaceDeveloper' and 'SpaceAuditor' when passed 's'", "s", - []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}}), + Entry("returns 'SpaceManager', 'SpaceDeveloper', 'SpaceAuditor' and 'SpaceSupporter' when passed 'S'", "S", + []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}, {Item: "SpaceSupporter"}}), + Entry("returns 'SpaceManager', 'SpaceDeveloper', 'SpaceAuditor' and 'SpaceSupporter' when passed 's'", "s", + []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}, {Item: "SpaceSupporter"}}), Entry("completes to 'SpaceAuditor' when passed 'Spacea'", "Spacea", []flags.Completion{{Item: "SpaceAuditor"}}), Entry("completes to 'SpaceDeveloper' when passed 'Spaced'", "Spaced", @@ -29,8 +28,10 @@ var _ = Describe("SpaceRole", func() { []flags.Completion{{Item: "SpaceManager"}}), Entry("completes to 'SpaceManager' when passed 'spacEM'", "spacEM", []flags.Completion{{Item: "SpaceManager"}}), - Entry("returns 'SpaceManager', 'SpaceDeveloper' and 'SpaceAuditor' when passed nothing", "", - []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}}), + Entry("completes to 'SpaceSupporter' when passed 'Spaces'", "Spaces", + []flags.Completion{{Item: "SpaceSupporter"}}), + Entry("returns 'SpaceManager', 'SpaceDeveloper', 'SpaceAuditor' and 'SpaceSupporter' when passed nothing", "", + []flags.Completion{{Item: "SpaceManager"}, {Item: "SpaceDeveloper"}, {Item: "SpaceAuditor"}, {Item: "SpaceSupporter"}}), Entry("completes to nothing when passed 'wut'", "wut", []flags.Completion{}), ) diff --git a/command/flag/ssh_port_forwarding_test.go b/command/flag/ssh_port_forwarding_test.go index cac98d2a0e1..6070c603232 100644 --- a/command/flag/ssh_port_forwarding_test.go +++ b/command/flag/ssh_port_forwarding_test.go @@ -3,10 +3,10 @@ package flag_test import ( "fmt" - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/tags.go b/command/flag/tags.go index 961c94773ca..5208dbdfb13 100644 --- a/command/flag/tags.go +++ b/command/flag/tags.go @@ -3,7 +3,7 @@ package flag import ( "strings" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) type Tags types.OptionalStringSlice diff --git a/command/flag/tags_test.go b/command/flag/tags_test.go index 8d2f1120623..de055e8d37d 100644 --- a/command/flag/tags_test.go +++ b/command/flag/tags_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/flag/timeout.go b/command/flag/timeout.go index 42250a543de..36fdcdc9c5e 100644 --- a/command/flag/timeout.go +++ b/command/flag/timeout.go @@ -1,7 +1,7 @@ package flag import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" flags "github.com/jessevdk/go-flags" ) diff --git a/command/flag/timeout_test.go b/command/flag/timeout_test.go index a24caadb81e..1ba970fbd0d 100644 --- a/command/flag/timeout_test.go +++ b/command/flag/timeout_test.go @@ -2,10 +2,10 @@ package flag_test import ( flags "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/command/flag" + . "code.cloudfoundry.org/cli/v8/command/flag" ) var _ = Describe("Timeout", func() { diff --git a/command/flag/trimmed_string_test.go b/command/flag/trimmed_string_test.go index 376ff303b04..803d73646da 100644 --- a/command/flag/trimmed_string_test.go +++ b/command/flag/trimmed_string_test.go @@ -1,8 +1,8 @@ package flag_test import ( - . "code.cloudfoundry.org/cli/command/flag" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/flag" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/minimum_version_check.go b/command/minimum_version_check.go index 9fa7aebf7a2..9cfbcd5737d 100644 --- a/command/minimum_version_check.go +++ b/command/minimum_version_check.go @@ -1,7 +1,7 @@ package command import ( - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" log "github.com/sirupsen/logrus" ) diff --git a/command/minimum_version_check_test.go b/command/minimum_version_check_test.go index 8ae9fc914d2..4c06641ab5e 100644 --- a/command/minimum_version_check_test.go +++ b/command/minimum_version_check_test.go @@ -1,11 +1,11 @@ package command_test import ( - . "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/version" + . "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/version" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/plugin/add_plugin_repo_command.go b/command/plugin/add_plugin_repo_command.go index 8c699b03a2d..3f657778777 100644 --- a/command/plugin/add_plugin_repo_command.go +++ b/command/plugin/add_plugin_repo_command.go @@ -1,11 +1,11 @@ package plugin import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/plugin/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/plugin/shared" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . AddPluginRepoActor diff --git a/command/plugin/add_plugin_repo_command_test.go b/command/plugin/add_plugin_repo_command_test.go index 81851357b9a..f632d271a4c 100644 --- a/command/plugin/add_plugin_repo_command_test.go +++ b/command/plugin/add_plugin_repo_command_test.go @@ -1,12 +1,12 @@ package plugin_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/plugin" - "code.cloudfoundry.org/cli/command/plugin/pluginfakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/plugin" + "code.cloudfoundry.org/cli/v8/command/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/plugin/list_plugin_repos_command.go b/command/plugin/list_plugin_repos_command.go index a4f1288fd0a..090e58687b9 100644 --- a/command/plugin/list_plugin_repos_command.go +++ b/command/plugin/list_plugin_repos_command.go @@ -1,8 +1,8 @@ package plugin import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type ListPluginReposCommand struct { diff --git a/command/plugin/plugin_suite_test.go b/command/plugin/plugin_suite_test.go index ff9b49859d0..78b837b48ed 100644 --- a/command/plugin/plugin_suite_test.go +++ b/command/plugin/plugin_suite_test.go @@ -1,7 +1,7 @@ package plugin_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/command/plugin/pluginfakes/fake_add_plugin_repo_actor.go b/command/plugin/pluginfakes/fake_add_plugin_repo_actor.go index 30a8dac4fc0..ac8c5509ea3 100644 --- a/command/plugin/pluginfakes/fake_add_plugin_repo_actor.go +++ b/command/plugin/pluginfakes/fake_add_plugin_repo_actor.go @@ -4,7 +4,7 @@ package pluginfakes import ( "sync" - "code.cloudfoundry.org/cli/command/plugin" + "code.cloudfoundry.org/cli/v8/command/plugin" ) type FakeAddPluginRepoActor struct { @@ -31,15 +31,16 @@ func (fake *FakeAddPluginRepoActor) AddPluginRepository(arg1 string, arg2 string arg1 string arg2 string }{arg1, arg2}) + stub := fake.AddPluginRepositoryStub + fakeReturns := fake.addPluginRepositoryReturns fake.recordInvocation("AddPluginRepository", []interface{}{arg1, arg2}) fake.addPluginRepositoryMutex.Unlock() - if fake.AddPluginRepositoryStub != nil { - return fake.AddPluginRepositoryStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.addPluginRepositoryReturns return fakeReturns.result1 } diff --git a/command/plugin/pluginfakes/fake_plugins_actor.go b/command/plugin/pluginfakes/fake_plugins_actor.go index d16659bf10b..2b4e6358c67 100644 --- a/command/plugin/pluginfakes/fake_plugins_actor.go +++ b/command/plugin/pluginfakes/fake_plugins_actor.go @@ -4,8 +4,8 @@ package pluginfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command/plugin" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command/plugin" ) type FakePluginsActor struct { @@ -30,15 +30,16 @@ func (fake *FakePluginsActor) GetOutdatedPlugins() ([]pluginaction.OutdatedPlugi ret, specificReturn := fake.getOutdatedPluginsReturnsOnCall[len(fake.getOutdatedPluginsArgsForCall)] fake.getOutdatedPluginsArgsForCall = append(fake.getOutdatedPluginsArgsForCall, struct { }{}) + stub := fake.GetOutdatedPluginsStub + fakeReturns := fake.getOutdatedPluginsReturns fake.recordInvocation("GetOutdatedPlugins", []interface{}{}) fake.getOutdatedPluginsMutex.Unlock() - if fake.GetOutdatedPluginsStub != nil { - return fake.GetOutdatedPluginsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getOutdatedPluginsReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/plugin/pluginfakes/fake_uninstall_plugin_actor.go b/command/plugin/pluginfakes/fake_uninstall_plugin_actor.go index 45ea9092410..e11995cec9a 100644 --- a/command/plugin/pluginfakes/fake_uninstall_plugin_actor.go +++ b/command/plugin/pluginfakes/fake_uninstall_plugin_actor.go @@ -4,8 +4,8 @@ package pluginfakes import ( "sync" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command/plugin" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command/plugin" ) type FakeUninstallPluginActor struct { @@ -32,15 +32,16 @@ func (fake *FakeUninstallPluginActor) UninstallPlugin(arg1 pluginaction.PluginUn arg1 pluginaction.PluginUninstaller arg2 string }{arg1, arg2}) + stub := fake.UninstallPluginStub + fakeReturns := fake.uninstallPluginReturns fake.recordInvocation("UninstallPlugin", []interface{}{arg1, arg2}) fake.uninstallPluginMutex.Unlock() - if fake.UninstallPluginStub != nil { - return fake.UninstallPluginStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.uninstallPluginReturns return fakeReturns.result1 } diff --git a/command/plugin/plugins_command.go b/command/plugin/plugins_command.go index 7c1a626c263..5c62a5968c0 100644 --- a/command/plugin/plugins_command.go +++ b/command/plugin/plugins_command.go @@ -3,12 +3,12 @@ package plugin import ( "strings" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/plugin/shared" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/plugin/shared" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . PluginsActor diff --git a/command/plugin/plugins_command_test.go b/command/plugin/plugins_command_test.go index ac522ad244a..0505fe5a120 100644 --- a/command/plugin/plugins_command_test.go +++ b/command/plugin/plugins_command_test.go @@ -1,18 +1,17 @@ package plugin_test import ( - "io/ioutil" "os" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/plugin" - "code.cloudfoundry.org/cli/command/plugin/pluginfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/plugin" + "code.cloudfoundry.org/cli/v8/command/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -138,11 +137,11 @@ var _ = Describe("plugins Command", func() { cmd.Checksum = true var err error - file, err = ioutil.TempFile("", "") + file, err = os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) defer file.Close() - err = ioutil.WriteFile(file.Name(), []byte("some-text"), 0600) + err = os.WriteFile(file.Name(), []byte("some-text"), 0600) Expect(err).NotTo(HaveOccurred()) plugins[0].Location = file.Name() diff --git a/command/plugin/remove_plugin_repo_command.go b/command/plugin/remove_plugin_repo_command.go index db5c6d042c0..6cb1800f554 100644 --- a/command/plugin/remove_plugin_repo_command.go +++ b/command/plugin/remove_plugin_repo_command.go @@ -1,9 +1,9 @@ package plugin import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type RemovePluginRepoCommand struct { diff --git a/command/plugin/repo_plugins_command.go b/command/plugin/repo_plugins_command.go index bbc825bddce..52ea10ddcda 100644 --- a/command/plugin/repo_plugins_command.go +++ b/command/plugin/repo_plugins_command.go @@ -1,14 +1,14 @@ package plugin import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type RepoPluginsCommand struct { RegisteredRepository string `short:"r" description:"Name of a registered repository"` usage interface{} `usage:"CF_NAME repo-plugins [-r REPO_NAME]\n\nEXAMPLES:\n CF_NAME repo-plugins -r PrivateRepo"` - relatedCommands interface{} `related_commands:"add-plugin-repo, delete-plugin-repo, install-plugin"` + relatedCommands interface{} `related_commands:"add-plugin-repo, remove-plugin-repo, install-plugin"` } func (RepoPluginsCommand) Setup(config command.Config, ui command.UI) error { diff --git a/command/plugin/shared/new_client.go b/command/plugin/shared/new_client.go index 01db4719a85..95e753a2a65 100644 --- a/command/plugin/shared/new_client.go +++ b/command/plugin/shared/new_client.go @@ -1,9 +1,9 @@ package shared import ( - "code.cloudfoundry.org/cli/api/plugin" - "code.cloudfoundry.org/cli/api/plugin/wrapper" - "code.cloudfoundry.org/cli/command" + "code.cloudfoundry.org/cli/v8/api/plugin" + "code.cloudfoundry.org/cli/v8/api/plugin/wrapper" + "code.cloudfoundry.org/cli/v8/command" ) // NewClient creates a new V2 Cloud Controller client and UAA client using the diff --git a/command/plugin/shared/rpc.go b/command/plugin/shared/rpc.go index 0a9fa550607..aeb631af69c 100644 --- a/command/plugin/shared/rpc.go +++ b/command/plugin/shared/rpc.go @@ -3,16 +3,15 @@ package shared import ( "fmt" "io" + netrpc "net/rpc" "os" "os/exec" "time" - netrpc "net/rpc" - - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/trace" - "code.cloudfoundry.org/cli/plugin/rpc" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/trace" + "code.cloudfoundry.org/cli/v8/plugin/rpc" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type Config interface { diff --git a/command/plugin/uninstall_plugin_command.go b/command/plugin/uninstall_plugin_command.go index 05a32d962da..7a729f6ffa0 100644 --- a/command/plugin/uninstall_plugin_command.go +++ b/command/plugin/uninstall_plugin_command.go @@ -1,12 +1,12 @@ package plugin import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/pluginaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/plugin/shared" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/pluginaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/plugin/shared" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UninstallPluginActor diff --git a/command/plugin/uninstall_plugin_command_test.go b/command/plugin/uninstall_plugin_command_test.go index 3438c35b71d..e1506084e23 100644 --- a/command/plugin/uninstall_plugin_command_test.go +++ b/command/plugin/uninstall_plugin_command_test.go @@ -4,14 +4,14 @@ import ( "errors" "os" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/plugin" - "code.cloudfoundry.org/cli/command/plugin/pluginfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/plugin" + "code.cloudfoundry.org/cli/v8/command/plugin/pluginfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/translatableerror/buildpack_not_found_error.go b/command/translatableerror/buildpack_not_found_error.go index 1f6e666fb21..0b562847e6c 100644 --- a/command/translatableerror/buildpack_not_found_error.go +++ b/command/translatableerror/buildpack_not_found_error.go @@ -1,20 +1,28 @@ package translatableerror +import "fmt" + type BuildpackNotFoundError struct { BuildpackName string StackName string + Lifecycle string } func (e BuildpackNotFoundError) Error() string { - if len(e.StackName) == 0 { - return "Buildpack '{{.BuildpackName}}' not found" + message := fmt.Sprintf("Buildpack '%s'", e.BuildpackName) + if len(e.StackName) != 0 { + message = fmt.Sprintf("%s with stack '%s'", message, e.StackName) + } + if len(e.Lifecycle) != 0 { + message = fmt.Sprintf("%s with lifecycle '%s'", message, e.Lifecycle) } - return "Buildpack '{{.BuildpackName}}' with stack '{{.StackName}}' not found" + return message + " not found" } func (e BuildpackNotFoundError) Translate(translate func(string, ...interface{}) string) string { return translate(e.Error(), map[string]interface{}{ "BuildpackName": e.BuildpackName, "StackName": e.StackName, + "Lifecycle": e.Lifecycle, }) } diff --git a/command/translatableerror/convert_to_translatable_error.go b/command/translatableerror/convert_to_translatable_error.go index 4bcacac1e35..fdb85782891 100644 --- a/command/translatableerror/convert_to_translatable_error.go +++ b/command/translatableerror/convert_to_translatable_error.go @@ -5,13 +5,13 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/util/clissh/ssherror" - "code.cloudfoundry.org/cli/util/download" - "code.cloudfoundry.org/cli/util/manifest" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/util/clissh/ssherror" + "code.cloudfoundry.org/cli/v8/util/download" + "code.cloudfoundry.org/cli/v8/util/manifest" log "github.com/sirupsen/logrus" ) @@ -188,6 +188,13 @@ func ConvertToTranslatableError(err error) error { return RunTaskError{Message: "App is not staged."} } + if strings.Contains(e.Message, "Unknown field(s): 'options'") { + return MinimumCFAPIVersionNotMetError{ + Command: "'--max-in-flight' flag", + MinimumVersion: "3.173.0", + } + } + // JSON Errors case *json.SyntaxError: return JSONSyntaxError{Err: e} diff --git a/command/translatableerror/convert_to_translatable_error_test.go b/command/translatableerror/convert_to_translatable_error_test.go index a68c3cd9621..32dc4f96e2a 100644 --- a/command/translatableerror/convert_to_translatable_error_test.go +++ b/command/translatableerror/convert_to_translatable_error_test.go @@ -5,16 +5,16 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/plugin/pluginerror" - "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/clissh/ssherror" - "code.cloudfoundry.org/cli/util/download" - "code.cloudfoundry.org/cli/util/manifest" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/plugin/pluginerror" + "code.cloudfoundry.org/cli/v8/api/uaa" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/clissh/ssherror" + "code.cloudfoundry.org/cli/v8/util/download" + "code.cloudfoundry.org/cli/v8/util/manifest" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/minimum_cf_api_version_not_met_error_test.go b/command/translatableerror/minimum_cf_api_version_not_met_error_test.go index ff6ba6e431b..f5b2919c681 100644 --- a/command/translatableerror/minimum_cf_api_version_not_met_error_test.go +++ b/command/translatableerror/minimum_cf_api_version_not_met_error_test.go @@ -1,9 +1,9 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/minimum_cli_version_not_met_error_test.go b/command/translatableerror/minimum_cli_version_not_met_error_test.go index 03dd6b4e229..af91c41133a 100644 --- a/command/translatableerror/minimum_cli_version_not_met_error_test.go +++ b/command/translatableerror/minimum_cli_version_not_met_error_test.go @@ -1,9 +1,9 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/minimum_uaa_api_version_not_met_error_test.go b/command/translatableerror/minimum_uaa_api_version_not_met_error_test.go index 2190e74b05c..7a4aa7338cd 100644 --- a/command/translatableerror/minimum_uaa_api_version_not_met_error_test.go +++ b/command/translatableerror/minimum_uaa_api_version_not_met_error_test.go @@ -1,9 +1,9 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/missing_credential_error_test.go b/command/translatableerror/missing_credential_error_test.go index a3225d84150..91d41b9b9e9 100644 --- a/command/translatableerror/missing_credential_error_test.go +++ b/command/translatableerror/missing_credential_error_test.go @@ -1,9 +1,9 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/multiple_buildpacks_found_error.go b/command/translatableerror/multiple_buildpacks_found_error.go index 724b94543e7..c1785a6eb08 100644 --- a/command/translatableerror/multiple_buildpacks_found_error.go +++ b/command/translatableerror/multiple_buildpacks_found_error.go @@ -5,7 +5,7 @@ type MultipleBuildpacksFoundError struct { } func (MultipleBuildpacksFoundError) Error() string { - return "Multiple buildpacks named {{.BuildpackName}} found. Specify a stack name by using a '-s' flag." + return "Multiple buildpacks named {{.BuildpackName}} found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag." } func (e MultipleBuildpacksFoundError) Translate(translate func(string, ...interface{}) string) string { diff --git a/command/translatableerror/service_instance_not_shareable_error_test.go b/command/translatableerror/service_instance_not_shareable_error_test.go index cf0149f5473..666ff093c81 100644 --- a/command/translatableerror/service_instance_not_shareable_error_test.go +++ b/command/translatableerror/service_instance_not_shareable_error_test.go @@ -1,8 +1,8 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/service_plan_not_found_error_test.go b/command/translatableerror/service_plan_not_found_error_test.go index 15f11be6c2c..447f473e783 100644 --- a/command/translatableerror/service_plan_not_found_error_test.go +++ b/command/translatableerror/service_plan_not_found_error_test.go @@ -1,8 +1,8 @@ package translatableerror_test import ( - "code.cloudfoundry.org/cli/command/translatableerror" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/staging_timeout_error_test.go b/command/translatableerror/staging_timeout_error_test.go index dad11893237..6ae50a5ea1b 100644 --- a/command/translatableerror/staging_timeout_error_test.go +++ b/command/translatableerror/staging_timeout_error_test.go @@ -6,9 +6,9 @@ import ( "text/template" "time" - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/tip_decorator_error_test.go b/command/translatableerror/tip_decorator_error_test.go index 3663c30f91e..edb2dd42ff1 100644 --- a/command/translatableerror/tip_decorator_error_test.go +++ b/command/translatableerror/tip_decorator_error_test.go @@ -4,9 +4,9 @@ import ( "errors" "fmt" - . "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/translatableerror/translatableerrorfakes" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror/translatableerrorfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/translatableerror_suite_test.go b/command/translatableerror/translatableerror_suite_test.go index 545e994c716..0654435ad3b 100644 --- a/command/translatableerror/translatableerror_suite_test.go +++ b/command/translatableerror/translatableerror_suite_test.go @@ -1,7 +1,7 @@ package translatableerror_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/command/translatableerror/translatableerrorfakes/fake_translatable_error.go b/command/translatableerror/translatableerrorfakes/fake_translatable_error.go index f4a97e0aba8..641a2b274d5 100644 --- a/command/translatableerror/translatableerrorfakes/fake_translatable_error.go +++ b/command/translatableerror/translatableerrorfakes/fake_translatable_error.go @@ -4,7 +4,7 @@ package translatableerrorfakes import ( "sync" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type FakeTranslatableError struct { @@ -38,15 +38,16 @@ func (fake *FakeTranslatableError) Error() string { ret, specificReturn := fake.errorReturnsOnCall[len(fake.errorArgsForCall)] fake.errorArgsForCall = append(fake.errorArgsForCall, struct { }{}) + stub := fake.ErrorStub + fakeReturns := fake.errorReturns fake.recordInvocation("Error", []interface{}{}) fake.errorMutex.Unlock() - if fake.ErrorStub != nil { - return fake.ErrorStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.errorReturns return fakeReturns.result1 } @@ -91,15 +92,16 @@ func (fake *FakeTranslatableError) Translate(arg1 func(string, ...interface{}) s fake.translateArgsForCall = append(fake.translateArgsForCall, struct { arg1 func(string, ...interface{}) string }{arg1}) + stub := fake.TranslateStub + fakeReturns := fake.translateReturns fake.recordInvocation("Translate", []interface{}{arg1}) fake.translateMutex.Unlock() - if fake.TranslateStub != nil { - return fake.TranslateStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.translateReturns return fakeReturns.result1 } diff --git a/command/translatableerror/translate_test.go b/command/translatableerror/translate_test.go index a96aad4f4f5..6603c1dc294 100644 --- a/command/translatableerror/translate_test.go +++ b/command/translatableerror/translate_test.go @@ -5,10 +5,9 @@ import ( "errors" "text/template" - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/translatableerror/unauthorized_error_test.go b/command/translatableerror/unauthorized_error_test.go index d49828de127..c1cffe7eb85 100644 --- a/command/translatableerror/unauthorized_error_test.go +++ b/command/translatableerror/unauthorized_error_test.go @@ -1,10 +1,9 @@ package translatableerror_test import ( - . "code.cloudfoundry.org/cli/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/translatableerror" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/ui.go b/command/ui.go index aedbe168ed4..bf1ef342a57 100644 --- a/command/ui.go +++ b/command/ui.go @@ -4,10 +4,11 @@ import ( "io" "time" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" ) // UI is the interface to STDOUT, STDERR, and STDIN. +// //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UI type UI interface { DeferText(template string, data ...map[string]interface{}) @@ -32,6 +33,7 @@ type UI interface { DisplayPasswordPrompt(template string, templateValues ...map[string]interface{}) (string, error) DisplayTableWithHeader(prefix string, table [][]string, padding int) DisplayText(template string, data ...map[string]interface{}) + DisplayTextLiteral(text string) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) DisplayTextPrompt(template string, templateValues ...map[string]interface{}) (string, error) DisplayTextWithBold(text string, keys ...map[string]interface{}) diff --git a/command/v7/actor.go b/command/v7/actor.go index d8bc2a17dca..642ddcf706d 100644 --- a/command/v7/actor.go +++ b/command/v7/actor.go @@ -6,15 +6,15 @@ import ( "net/http" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - uaa "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + uaa "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" "github.com/SermoDigital/jose/jwt" ) @@ -27,6 +27,7 @@ type Actor interface { Authenticate(credentials map[string]string, origin string, grantType uaa.GrantType) error BindSecurityGroupToSpaces(securityGroupGUID string, spaces []resources.Space, lifecycle constant.SecurityGroupLifecycle) (v7action.Warnings, error) CancelDeployment(deploymentGUID string) (v7action.Warnings, error) + ContinueDeployment(deploymentGUID string) (v7action.Warnings, error) CheckRoute(domainName string, hostname string, path string, port int) (bool, v7action.Warnings, error) ClearTarget() CopyPackage(sourceApp resources.Application, targetApp resources.Application) (resources.Package, v7action.Warnings, error) @@ -35,8 +36,7 @@ type Actor interface { CreateApplicationInSpace(app resources.Application, spaceGUID string) (resources.Application, v7action.Warnings, error) CreateBitsPackageByApplication(appGUID string) (resources.Package, v7action.Warnings, error) CreateBuildpack(buildpack resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) - CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, v7action.Warnings, error) - CreateDeploymentByApplicationAndRevision(appGUID string, revisionGUID string) (string, v7action.Warnings, error) + CreateDeployment(dep resources.Deployment) (string, v7action.Warnings, error) CreateDockerPackageByApplication(appGUID string, dockerImageCredentials v7action.DockerImageCredentials) (resources.Package, v7action.Warnings, error) CreateDockerPackageByApplicationNameAndSpace(appName string, spaceGUID string, dockerImageCredentials v7action.DockerImageCredentials) (resources.Package, v7action.Warnings, error) CreateIsolationSegmentByName(isolationSegment resources.IsolationSegment) (v7action.Warnings, error) @@ -45,7 +45,7 @@ type Actor interface { CreateOrganization(orgName string) (resources.Organization, v7action.Warnings, error) CreateOrganizationQuota(name string, limits v7action.QuotaLimits) (v7action.Warnings, error) CreatePrivateDomain(domainName string, orgName string) (v7action.Warnings, error) - CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, v7action.Warnings, error) + CreateRoute(spaceGUID, domainName, hostname, path string, port int, options map[string]*string) (resources.Route, v7action.Warnings, error) CreateRouteBinding(params v7action.CreateRouteBindingParams) (chan v7action.PollJobEvent, v7action.Warnings, error) CreateSecurityGroup(name, filePath string) (v7action.Warnings, error) CreateServiceAppBinding(params v7action.CreateServiceAppBindingParams) (chan v7action.PollJobEvent, v7action.Warnings, error) @@ -58,7 +58,7 @@ type Actor interface { CreateUser(username string, password string, origin string) (resources.User, v7action.Warnings, error) CreateUserProvidedServiceInstance(instance resources.ServiceInstance) (v7action.Warnings, error) DeleteApplicationByNameAndSpace(name, spaceGUID string, deleteRoutes bool) (v7action.Warnings, error) - DeleteBuildpackByNameAndStack(buildpackName string, buildpackStack string) (v7action.Warnings, error) + DeleteBuildpackByNameAndStackAndLifecycle(buildpackName string, buildpackStack string, buildpackLifecycle string) (v7action.Warnings, error) DeleteDomain(domain resources.Domain) (v7action.Warnings, error) DeleteInstanceByApplicationNameSpaceProcessTypeAndIndex(appName string, spaceGUID string, processType string, instanceIndex int) (v7action.Warnings, error) DeleteOrgRole(roleType constant.RoleType, orgGUID string, userNameOrGUID string, userOrigin string, isClient bool) (v7action.Warnings, error) @@ -87,19 +87,21 @@ type Actor interface { EnableServiceAccess(offeringName, brokerName, orgName, planName string) (v7action.SkippedPlans, v7action.Warnings, error) EntitleIsolationSegmentToOrganizationByName(isolationSegmentName string, orgName string) (v7action.Warnings, error) GetAppFeature(appGUID string, featureName string) (resources.ApplicationFeature, v7action.Warnings, error) - GetAppSummariesForSpace(spaceGUID string, labels string) ([]v7action.ApplicationSummary, v7action.Warnings, error) + GetAppSummariesForSpace(spaceGUID string, labels string, omitStats bool) ([]v7action.ApplicationSummary, v7action.Warnings, error) GetApplicationByNameAndSpace(appName string, spaceGUID string) (resources.Application, v7action.Warnings, error) GetApplicationMapForRoute(route resources.Route) (map[string]resources.Application, v7action.Warnings, error) + GetApplicationsByGUIDs(appGUIDs []string) ([]resources.Application, v7action.Warnings, error) GetApplicationDroplets(appName string, spaceGUID string) ([]resources.Droplet, v7action.Warnings, error) GetApplicationLabels(appName string, spaceGUID string) (map[string]types.NullString, v7action.Warnings, error) GetApplicationPackages(appName string, spaceGUID string) ([]resources.Package, v7action.Warnings, error) GetApplicationProcessHealthChecksByNameAndSpace(appName string, spaceGUID string) ([]v7action.ProcessHealthCheck, v7action.Warnings, error) + GetApplicationProcessReadinessHealthChecksByNameAndSpace(appName string, spaceGUID string) ([]v7action.ProcessReadinessHealthCheck, v7action.Warnings, error) GetApplicationRevisionsDeployed(appGUID string) ([]resources.Revision, v7action.Warnings, error) GetApplicationRoutes(appGUID string) ([]resources.Route, v7action.Warnings, error) GetApplicationTasks(appName string, sortOrder v7action.SortOrder) ([]resources.Task, v7action.Warnings, error) GetApplicationsByNamesAndSpace(appNames []string, spaceGUID string) ([]resources.Application, v7action.Warnings, error) - GetBuildpackLabels(buildpackName string, buildpackStack string) (map[string]types.NullString, v7action.Warnings, error) - GetBuildpacks(labelSelector string) ([]resources.Buildpack, v7action.Warnings, error) + GetBuildpackLabels(buildpackName string, buildpackStack string, buildpackLifecycle string) (map[string]types.NullString, v7action.Warnings, error) + GetBuildpacks(labelSelector string, lifecycle string) ([]resources.Buildpack, v7action.Warnings, error) GetCurrentUser() (configv3.User, error) GetDefaultDomain(orgGUID string) (resources.Domain, v7action.Warnings, error) GetDetailedAppSummary(appName string, spaceGUID string, withObfuscatedValues bool) (v7action.DetailedApplicationSummary, v7action.Warnings, error) @@ -108,6 +110,7 @@ type Actor interface { GetDomainLabels(domainName string) (map[string]types.NullString, v7action.Warnings, error) GetEffectiveIsolationSegmentBySpace(spaceGUID string, orgDefaultIsolationSegmentGUID string) (resources.IsolationSegment, v7action.Warnings, error) GetEnvironmentVariableGroup(group constant.EnvironmentVariableGroupName) (v7action.EnvironmentVariableGroup, v7action.Warnings, error) + GetEnvironmentVariableGroupByRevision(revision resources.Revision) (v7action.EnvironmentVariableGroup, bool, v7action.Warnings, error) GetEnvironmentVariablesByApplicationNameAndSpace(appName string, spaceGUID string) (v7action.EnvironmentVariableGroups, v7action.Warnings, error) GetFeatureFlagByName(featureFlagName string) (resources.FeatureFlag, v7action.Warnings, error) GetFeatureFlags() ([]resources.FeatureFlag, v7action.Warnings, error) @@ -116,6 +119,7 @@ type Actor interface { GetIsolationSegmentsByOrganization(orgName string) ([]resources.IsolationSegment, v7action.Warnings, error) GetIsolationSegmentByName(isoSegmentName string) (resources.IsolationSegment, v7action.Warnings, error) GetIsolationSegmentSummaries() ([]v7action.IsolationSegmentSummary, v7action.Warnings, error) + GetInfoResponse() (v7action.Info, v7action.Warnings, error) GetLatestActiveDeploymentForApp(appGUID string) (resources.Deployment, v7action.Warnings, error) GetLoginPrompts() (map[string]coreconfig.AuthPrompt, error) GetNewestReadyPackageForApplication(app resources.Application) (resources.Package, v7action.Warnings, error) @@ -133,7 +137,7 @@ type Actor interface { GetRawApplicationManifestByNameAndSpace(appName string, spaceGUID string) ([]byte, v7action.Warnings, error) GetRecentEventsByApplicationNameAndSpace(appName string, spaceGUID string) ([]v7action.Event, v7action.Warnings, error) GetRecentLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client sharedaction.LogCacheClient) ([]sharedaction.LogMessage, v7action.Warnings, error) - GetRootResponse() (v7action.Info, v7action.Warnings, error) + GetRootResponse() (v7action.Root, v7action.Warnings, error) GetRevisionByApplicationAndVersion(appGUID string, revisionVersion int) (resources.Revision, v7action.Warnings, error) GetRevisionsByApplicationNameAndSpace(appName string, spaceGUID string) ([]resources.Revision, v7action.Warnings, error) GetRouteByAttributes(domain resources.Domain, hostname string, path string, port int) (resources.Route, v7action.Warnings, error) @@ -183,11 +187,13 @@ type Actor interface { MakeCurlRequest(httpMethod string, path string, customHeaders []string, httpData string, failOnHTTPError bool) ([]byte, *http.Response, error) MapRoute(routeGUID string, appGUID string, destinationProtocol string) (v7action.Warnings, error) Marketplace(filter v7action.MarketplaceFilter) ([]v7action.ServiceOfferingWithPlans, v7action.Warnings, error) + MoveRoute(routeGUID string, spaceGUID string) (v7action.Warnings, error) ParseAccessToken(accessToken string) (jwt.JWT, error) PollBuild(buildGUID string, appName string) (resources.Droplet, v7action.Warnings, error) PollPackage(pkg resources.Package) (resources.Package, v7action.Warnings, error) PollStart(app resources.Application, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) - PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) + PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) + PollTask(task resources.Task) (resources.Task, v7action.Warnings, error) PollUploadBuildpackJob(jobURL ccv3.JobURL) (v7action.Warnings, error) PrepareBuildpackBits(inputPath string, tmpDirPath string, downloader v7action.Downloader) (string, error) PurgeServiceInstance(serviceInstanceName, spaceGUID string) (v7action.Warnings, error) @@ -216,6 +222,7 @@ type Actor interface { SetTarget(settings v7action.TargetSettings) (v7action.Warnings, error) SharePrivateDomain(domainName string, orgName string) (v7action.Warnings, error) ShareServiceInstanceToSpaceAndOrg(serviceInstanceName, targetedSpaceGUID, targetedOrgGUID string, sharedToDetails v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) + ShareRoute(routeGUID string, spaceGUID string) (v7action.Warnings, error) StageApplicationPackage(pkgGUID string) (resources.Build, v7action.Warnings, error) StagePackage(packageGUID, appName, spaceGUID string) (<-chan resources.Droplet, <-chan v7action.Warnings, <-chan error) StartApplication(appGUID string) (v7action.Warnings, error) @@ -226,18 +233,21 @@ type Actor interface { UnsetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, EnvironmentVariableName string) (v7action.Warnings, error) UnsetSpaceQuota(spaceQuotaName, spaceName, orgGUID string) (v7action.Warnings, error) UnsharePrivateDomain(domainName string, orgName string) (v7action.Warnings, error) + UnshareRoute(routeGUID string, spaceGUID string) (v7action.Warnings, error) UnshareServiceInstanceFromSpaceAndOrg(serviceInstanceName, targetedSpaceGUID, targetedOrgGUID string, unshareFromDetails v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) UpdateAppFeature(app resources.Application, enabled bool, featureName string) (v7action.Warnings, error) UpdateApplication(app resources.Application) (resources.Application, v7action.Warnings, error) UpdateApplicationLabelsByApplicationName(string, string, map[string]types.NullString) (v7action.Warnings, error) - UpdateBuildpackByNameAndStack(buildpackName string, buildpackStack string, buildpack resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) - UpdateBuildpackLabelsByBuildpackNameAndStack(string, string, map[string]types.NullString) (v7action.Warnings, error) + UpdateBuildpackByNameAndStackAndLifecycle(buildpackName string, buildpackStack string, buildpackLifecycle string, buildpack resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) + UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(string, string, string, map[string]types.NullString) (v7action.Warnings, error) + UpdateDestination(string, string, string) (v7action.Warnings, error) UpdateDomainLabelsByDomainName(string, map[string]types.NullString) (v7action.Warnings, error) UpdateManagedServiceInstance(params v7action.UpdateManagedServiceInstanceParams) (chan v7action.PollJobEvent, v7action.Warnings, error) - UpgradeManagedServiceInstance(serviceInstanceName, spaceGUID string) (v7action.Warnings, error) + UpgradeManagedServiceInstance(serviceInstanceName, spaceGUID string) (chan v7action.PollJobEvent, v7action.Warnings, error) UpdateOrganizationLabelsByOrganizationName(string, map[string]types.NullString) (v7action.Warnings, error) UpdateOrganizationQuota(quotaName string, newName string, limits v7action.QuotaLimits) (v7action.Warnings, error) UpdateProcessByTypeAndApplication(processType string, appGUID string, updatedProcess resources.Process) (v7action.Warnings, error) + UpdateRoute(routeGUID string, options map[string]*string) (resources.Route, v7action.Warnings, error) UpdateRouteLabels(string, string, map[string]types.NullString) (v7action.Warnings, error) UpdateSecurityGroup(name, filePath string) (v7action.Warnings, error) UpdateSecurityGroupGloballyEnabled(securityGroupName string, lifecycle constant.SecurityGroupLifecycle, enabled bool) (v7action.Warnings, error) diff --git a/command/v7/add_network_policy_command.go b/command/v7/add_network_policy_command.go index b795bde454a..4d8c07b9e0c 100644 --- a/command/v7/add_network_policy_command.go +++ b/command/v7/add_network_policy_command.go @@ -1,13 +1,13 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . NetworkingActor diff --git a/command/v7/add_network_policy_command_test.go b/command/v7/add_network_policy_command_test.go index 998afb510c9..b6fb10ef3ae 100644 --- a/command/v7/add_network_policy_command_test.go +++ b/command/v7/add_network_policy_command_test.go @@ -1,18 +1,18 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -115,7 +115,7 @@ var _ = Describe("add-network-policy Command", func() { }) }) - When("both protocol and port are specificed", func() { + When("both protocol and port are specified", func() { BeforeEach(func() { cmd.Protocol = flag.NetworkProtocol{Protocol: protocol} cmd.Port = flag.NetworkPort{StartPort: 8080, EndPort: 8081} diff --git a/command/v7/allow_space_ssh_command.go b/command/v7/allow_space_ssh_command.go index 38e6f99e56b..6e368c892c4 100644 --- a/command/v7/allow_space_ssh_command.go +++ b/command/v7/allow_space_ssh_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type AllowSpaceSSHCommand struct { diff --git a/command/v7/allow_space_ssh_command_test.go b/command/v7/allow_space_ssh_command_test.go index b8697fa1d1c..122435e71ac 100644 --- a/command/v7/allow_space_ssh_command_test.go +++ b/command/v7/allow_space_ssh_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/api_command.go b/command/v7/api_command.go index 5127b33bbf5..bf57654f6c3 100644 --- a/command/v7/api_command.go +++ b/command/v7/api_command.go @@ -6,10 +6,10 @@ import ( "code.cloudfoundry.org/clock" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type APICommand struct { diff --git a/command/v7/api_command_test.go b/command/v7/api_command_test.go index a69afda6996..efe8167a146 100644 --- a/command/v7/api_command_test.go +++ b/command/v7/api_command_test.go @@ -3,13 +3,13 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/app_command.go b/command/v7/app_command.go index d431a71ff55..bd7e3f36593 100644 --- a/command/v7/app_command.go +++ b/command/v7/app_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type AppCommand struct { diff --git a/command/v7/app_command_test.go b/command/v7/app_command_test.go index 238376ba7b7..1c5b2b064c4 100644 --- a/command/v7/app_command_test.go +++ b/command/v7/app_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -203,7 +203,7 @@ var _ = Describe("app Command", func() { }, }, CurrentDroplet: resources.Droplet{ - Stack: "cflinuxfs2", + Stack: "cflinuxfs4", Buildpacks: []resources.DropletBuildpack{ { Name: "ruby_buildpack", diff --git a/command/v7/apply_manifest_command.go b/command/v7/apply_manifest_command.go index 5f959382f51..0c9a60fa2cf 100644 --- a/command/v7/apply_manifest_command.go +++ b/command/v7/apply_manifest_command.go @@ -3,13 +3,13 @@ package v7 import ( "os" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/util/manifestparser" "github.com/cloudfoundry/bosh-cli/director/template" "gopkg.in/yaml.v2" ) @@ -20,6 +20,7 @@ type ApplyManifestCommand struct { PathToManifest flag.ManifestPathWithExistenceCheck `short:"f" description:"Path to app manifest"` Vars []template.VarKV `long:"var" description:"Variable key value pair for variable substitution, (e.g., name=app1); can specify multiple times"` PathsToVarsFiles []flag.PathWithExistenceCheck `long:"vars-file" description:"Path to a variable substitution file for manifest; can specify multiple times"` + RedactEnv bool `long:"redact-env" description:"Do not print values for environment vars set in the application manifest"` usage interface{} `usage:"CF_NAME apply-manifest -f APP_MANIFEST_PATH"` relatedCommands interface{} `related_commands:"create-app, create-app-manifest, push"` @@ -33,7 +34,10 @@ type ApplyManifestCommand struct { func (cmd *ApplyManifestCommand) Setup(config command.Config, ui command.UI) error { cmd.ManifestLocator = manifestparser.NewLocator() cmd.ManifestParser = manifestparser.ManifestParser{} - cmd.DiffDisplayer = shared.NewManifestDiffDisplayer(ui) + cmd.DiffDisplayer = &shared.ManifestDiffDisplayer{ + UI: ui, + RedactEnv: cmd.RedactEnv, + } currentDir, err := os.Getwd() if err != nil { diff --git a/command/v7/apply_manifest_command_test.go b/command/v7/apply_manifest_command_test.go index bc29e3c54e1..7b78dcd4c33 100644 --- a/command/v7/apply_manifest_command_test.go +++ b/command/v7/apply_manifest_command_test.go @@ -6,20 +6,20 @@ import ( "gopkg.in/yaml.v2" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/manifestparser" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/ui" "github.com/cloudfoundry/bosh-cli/director/template" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/apps_command.go b/command/v7/apps_command.go index e25ad73f5be..e02fb68cf7e 100644 --- a/command/v7/apps_command.go +++ b/command/v7/apps_command.go @@ -3,8 +3,8 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type AppsCommand struct { @@ -13,7 +13,8 @@ type AppsCommand struct { usage interface{} `usage:"CF_NAME apps [--labels SELECTOR]\n\nEXAMPLES:\n CF_NAME apps\n CF_NAME apps --labels 'environment in (production,staging),tier in (backend)'\n CF_NAME apps --labels 'env=dev,!chargeback-code,tier in (backend,worker)'"` relatedCommands interface{} `related_commands:"events, logs, map-route, push, scale, start, stop, restart"` - Labels string `long:"labels" description:"Selector to filter apps by labels"` + Labels string `long:"labels" description:"Selector to filter apps by labels"` + OmitStats bool `long:"no-stats" description:"Do not retrieve process stats"` } func (cmd AppsCommand) Execute(args []string) error { @@ -34,7 +35,7 @@ func (cmd AppsCommand) Execute(args []string) error { }) cmd.UI.DisplayNewline() - summaries, warnings, err := cmd.Actor.GetAppSummariesForSpace(cmd.Config.TargetedSpace().GUID, cmd.Labels) + summaries, warnings, err := cmd.Actor.GetAppSummariesForSpace(cmd.Config.TargetedSpace().GUID, cmd.Labels, cmd.OmitStats) cmd.UI.DisplayWarnings(warnings) if err != nil { return err @@ -45,22 +46,29 @@ func (cmd AppsCommand) Execute(args []string) error { return nil } - table := [][]string{ - { - cmd.UI.TranslateText("name"), - cmd.UI.TranslateText("requested state"), - cmd.UI.TranslateText("processes"), - cmd.UI.TranslateText("routes"), - }, + fields := []string{ + cmd.UI.TranslateText("name"), + cmd.UI.TranslateText("requested state"), } + if !cmd.OmitStats { + fields = append(fields, cmd.UI.TranslateText("processes")) + } + + fields = append(fields, cmd.UI.TranslateText("routes")) + + table := [][]string{fields} + for _, summary := range summaries { - table = append(table, []string{ + tableRow := []string{ summary.Name, cmd.UI.TranslateText(strings.ToLower(string(summary.State))), - summary.ProcessSummaries.String(), - getURLs(summary.Routes), - }) + } + if !cmd.OmitStats { + tableRow = append(tableRow, summary.ProcessSummaries.String()) + } + tableRow = append(tableRow, getURLs(summary.Routes)) + table = append(table, tableRow) } cmd.UI.DisplayTableWithHeader("", table, ui.DefaultTableSpacePadding) diff --git a/command/v7/apps_command_test.go b/command/v7/apps_command_test.go index 4da0afec7da..f52c7c2d9c6 100644 --- a/command/v7/apps_command_test.go +++ b/command/v7/apps_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -144,6 +144,9 @@ var _ = Describe("apps Command", func() { When("the route actor does not return any errors", func() { Context("with existing apps", func() { BeforeEach(func() { + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + appSummaries := []v7action.ApplicationSummary{ { Application: resources.Application{ @@ -187,8 +190,9 @@ var _ = Describe("apps Command", func() { }, Routes: []resources.Route{ { - Host: "some-app-1", - URL: "some-app-1.some-other-domain", + Host: "some-app-1", + URL: "some-app-1.some-other-domain", + Options: map[string]*string{"loadbalancing": lbLeastConnections}, }, { Host: "some-app-1", @@ -237,15 +241,15 @@ var _ = Describe("apps Command", func() { Expect(testUI.Out).To(Say(`name\s+requested state\s+processes\s+routes`)) Expect(testUI.Out).To(Say(`some-app-1\s+started\s+web:2/2, console:0/0, worker:0/1\s+some-app-1.some-other-domain, some-app-1.some-domain`)) - Expect(testUI.Out).To(Say(`some-app-2\s+stopped\s+web:0/2\s+some-app-2.some-domain`)) Expect(testUI.Err).To(Say("warning-1")) Expect(testUI.Err).To(Say("warning-2")) Expect(fakeActor.GetAppSummariesForSpaceCallCount()).To(Equal(1)) - spaceGUID, labels := fakeActor.GetAppSummariesForSpaceArgsForCall(0) + spaceGUID, labels, omitStats := fakeActor.GetAppSummariesForSpaceArgsForCall(0) Expect(spaceGUID).To(Equal("some-space-guid")) Expect(labels).To(Equal("")) + Expect(omitStats).To(Equal(false)) }) }) @@ -274,9 +278,10 @@ var _ = Describe("apps Command", func() { Expect(testUI.Err).To(Say("warning")) Expect(fakeActor.GetAppSummariesForSpaceCallCount()).To(Equal(1)) - spaceGUID, labelSelector := fakeActor.GetAppSummariesForSpaceArgsForCall(0) + spaceGUID, labelSelector, omitStats := fakeActor.GetAppSummariesForSpaceArgsForCall(0) Expect(spaceGUID).To(Equal("some-space-guid")) Expect(labelSelector).To(Equal("")) + Expect(omitStats).To(Equal(false)) }) }) @@ -301,9 +306,46 @@ var _ = Describe("apps Command", func() { It("passes the flag to the API", func() { Expect(fakeActor.GetAppSummariesForSpaceCallCount()).To(Equal(1)) - _, labelSelector := fakeActor.GetAppSummariesForSpaceArgsForCall(0) + _, labelSelector, _ := fakeActor.GetAppSummariesForSpaceArgsForCall(0) Expect(labelSelector).To(Equal("fish=moose")) }) }) + Context("when '--skip-stats' flag is set", func() { + BeforeEach(func() { + cmd.OmitStats = true + + appSummaries := []v7action.ApplicationSummary{ + { + Application: resources.Application{ + GUID: "app-guid-1", + Name: "some-app-1", + State: constant.ApplicationStarted, + }, + ProcessSummaries: []v7action.ProcessSummary{}, + Routes: []resources.Route{ + { + Host: "some-app-1", + URL: "some-app-1.some-domain", + }, + }, + }, + } + fakeActor.GetAppSummariesForSpaceReturns(appSummaries, v7action.Warnings{}, nil) + + }) + + It("prints the application summary without process information", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say(`Getting apps in org some-org / space some-space as steve\.\.\.`)) + + Expect(testUI.Out).To(Say(`name\s+requested state\s+routes`)) + Expect(testUI.Out).To(Say(`some-app-1\s+started\s+some-app-1.some-domain`)) + Expect(fakeActor.GetAppSummariesForSpaceCallCount()).To(Equal(1)) + _, _, omitStats := fakeActor.GetAppSummariesForSpaceArgsForCall(0) + Expect(omitStats).To(Equal(true)) + }) + }) + }) diff --git a/command/v7/auth_command.go b/command/v7/auth_command.go index 0b03acd0a1e..8f657b72d51 100644 --- a/command/v7/auth_command.go +++ b/command/v7/auth_command.go @@ -3,12 +3,12 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/uaaversion" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/uaaversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type AuthCommand struct { @@ -17,7 +17,8 @@ type AuthCommand struct { RequiredArgs flag.Authentication `positional-args:"yes"` ClientCredentials bool `long:"client-credentials" description:"Use (non-user) service account (also called client credentials)"` Origin string `long:"origin" description:"Indicates the identity provider to be used for authentication"` - usage interface{} `usage:"CF_NAME auth USERNAME PASSWORD\n CF_NAME auth USERNAME PASSWORD --origin ORIGIN\n CF_NAME auth CLIENT_ID CLIENT_SECRET --client-credentials\n\nENVIRONMENT VARIABLES:\n CF_USERNAME=user Authenticating user. Overridden if USERNAME argument is provided.\n CF_PASSWORD=password Password associated with user. Overriden if PASSWORD argument is provided.\n\nWARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history\n Consider using the CF_PASSWORD environment variable instead\n\nEXAMPLES:\n CF_NAME auth name@example.com \"my password\" (use quotes for passwords with a space)\n CF_NAME auth name@example.com \"\\\"password\\\"\" (escape quotes if used in password)"` + Assertion string `long:"assertion" description:"Token based authentication with assertion (user) or in combination with client-credentials (non-user)"` + usage interface{} `usage:"CF_NAME auth USERNAME PASSWORD\n CF_NAME auth USERNAME PASSWORD --origin ORIGIN\n CF_NAME auth CLIENT_ID CLIENT_SECRET --client-credentials\n CF_NAME auth CLIENT_ID CLIENT_SECRET --assertion ID-TOKEN\n CF_NAME auth CLIENT_ID --client-credentials --assertion ACCESS-TOKEN\n\nENVIRONMENT VARIABLES:\n CF_USERNAME=user Authenticating user. Overridden if USERNAME argument is provided.\n CF_PASSWORD=password Password associated with user. Overridden if PASSWORD argument is provided.\n\nWARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history\n Consider using the CF_PASSWORD environment variable instead\n\nEXAMPLES:\n CF_NAME auth name@example.com \"my password\" (use quotes for passwords with a space)\n CF_NAME auth name@example.com \"\\\"password\\\"\" (escape quotes if used in password)"` relatedCommands interface{} `related_commands:"api, login, target"` } @@ -62,7 +63,7 @@ func (cmd AuthCommand) Execute(args []string) error { if !cmd.ClientCredentials { if cmd.Config.UAAGrantType() == string(constant.GrantTypeClientCredentials) { return translatableerror.PasswordGrantTypeLogoutRequiredError{} - } else if cmd.Config.UAAOAuthClient() != "cf" || cmd.Config.UAAOAuthClientSecret() != "" { + } else if (cmd.Assertion == "" && cmd.Config.UAAOAuthClient() != "cf") || cmd.Config.UAAOAuthClientSecret() != "" { return translatableerror.ManualClientCredentialsError{} } } @@ -75,12 +76,35 @@ func (cmd AuthCommand) Execute(args []string) error { grantType := constant.GrantTypePassword if cmd.ClientCredentials { grantType = constant.GrantTypeClientCredentials + if cmd.Assertion != "" { + if username == "" { + username = cmd.Config.UAAOAuthClient() + } + // use assertion as client_assertion - replacing client_secret - but stay with client credentials grant type + credentials["client_assertion"] = cmd.Assertion + credentials["client_assertion_type"] = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" + } else { + credentials["client_secret"] = password + } credentials["client_id"] = username - credentials["client_secret"] = password } else { - credentials = map[string]string{ - "username": username, - "password": password, + if cmd.Assertion != "" { + // use assertion as user authentication using JWT bearer grant type + grantType = constant.GrantTypeJwtBearer + credentials = map[string]string{ + "assertion": cmd.Assertion, + } + if username != "" { + credentials["client_id"] = username + } + if password != "" { + credentials["client_secret"] = password + } + } else { + credentials = map[string]string{ + "username": username, + "password": password, + } } } @@ -123,7 +147,14 @@ func (cmd AuthCommand) getUsernamePassword() (string, string, error) { } } - if userMissing || passwordMissing { + if cmd.Config.IsCFOnK8s() { + if !passwordMissing { + cmd.UI.DisplayWarning("Warning: password is ignored when authenticating against Kubernetes.") + } + passwordMissing = false + } + + if cmd.Assertion == "" && (userMissing || passwordMissing) { return "", "", translatableerror.MissingCredentialsError{ MissingUsername: userMissing, MissingPassword: passwordMissing, diff --git a/command/v7/auth_command_test.go b/command/v7/auth_command_test.go index 152c648a3c9..fb7d4af8772 100644 --- a/command/v7/auth_command_test.go +++ b/command/v7/auth_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/api/uaa/uaaversion" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/uaaversion" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -113,6 +113,34 @@ var _ = Describe("auth Command", func() { MissingPassword: true, })) }) + + When("authenticating against Korifi", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("succeeds", func() { + Expect(err).NotTo(HaveOccurred()) + }) + }) + }) + + When("the password is given", func() { + BeforeEach(func() { + cmd.RequiredArgs.Username = "myuser" + cmd.RequiredArgs.Password = "mypassword" + }) + + When("authenticating against korifi", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("succeeds but warns", func() { + Expect(err).NotTo(HaveOccurred()) + Expect(testUI.Err).To(Say("Warning: password is ignored when authenticating against Kubernetes.")) + }) + }) }) }) @@ -252,6 +280,65 @@ var _ = Describe("auth Command", func() { }) }) + When("--assertion is set", func() { + BeforeEach(func() { + cmd.ClientCredentials = false + cmd.Assertion = "jwt-token" + cmd.RequiredArgs.Username = testID + cmd.RequiredArgs.Password = testSecret + }) + + It("outputs API target information and clears the targeted org and space", func() { + Expect(err).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("API endpoint: %s", fakeConfig.Target())) + Expect(testUI.Out).To(Say(`Authenticating\.\.\.`)) + Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say("Use '%s target' to view or set your target org and space", binaryName)) + + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, origin, grantType := fakeActor.AuthenticateArgsForCall(0) + ID := credentials["client_id"] + secret := credentials["client_secret"] + Expect(ID).To(Equal(testID)) + Expect(secret).To(Equal(testSecret)) + Expect(origin).To(BeEmpty()) + Expect(grantType).To(Equal(constant.GrantTypeJwtBearer)) + }) + }) + + When("--assertion and --client-credentials is set", func() { + BeforeEach(func() { + cmd.ClientCredentials = true + cmd.Assertion = "client-jwt-token" + cmd.RequiredArgs.Username = testID + cmd.RequiredArgs.Password = testSecret + }) + + It("outputs API target information and clears the targeted org and space", func() { + Expect(err).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("API endpoint: %s", fakeConfig.Target())) + Expect(testUI.Out).To(Say(`Authenticating\.\.\.`)) + Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say("Use '%s target' to view or set your target org and space", binaryName)) + + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, origin, grantType := fakeActor.AuthenticateArgsForCall(0) + ID := credentials["client_id"] + secret := credentials["client_secret"] + clientAssertion := credentials["client_assertion"] + clientAssertionType := credentials["client_assertion_type"] + Expect(ID).To(Equal(testID)) + Expect(secret).To(BeEmpty()) + Expect(origin).To(BeEmpty()) + Expect(secret).To(Equal("")) + Expect(clientAssertion).To(Equal("client-jwt-token")) + Expect(clientAssertionType).To(Equal("urn:ietf:params:oauth:client-assertion-type:jwt-bearer")) + Expect(grantType).To(Equal(constant.GrantTypeClientCredentials)) + }) + }) + When("the username and password are provided in env variables", func() { var ( envUsername string @@ -298,6 +385,30 @@ var _ = Describe("auth Command", func() { }) }) }) + + When("authenticating against Korifi", func() { + BeforeEach(func() { + cmd.RequiredArgs.Username = "myuser" + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("attempts to authenticate with the correct username", func() { + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, _, _ := fakeActor.AuthenticateArgsForCall(0) + Expect(credentials).To(HaveKeyWithValue("username", "myuser")) + }) + + When("there is an error authenticating with the given username", func() { + BeforeEach(func() { + fakeActor.AuthenticateReturns(errors.New("stuff go boom")) + }) + + It("errors", func() { + Expect(err).To(MatchError("stuff go boom")) + }) + }) + + }) }) When("a user has manually added their client credentials to the config file", func() { diff --git a/command/v7/base_command.go b/command/v7/base_command.go index e40bcc26d65..bf6ace6580e 100644 --- a/command/v7/base_command.go +++ b/command/v7/base_command.go @@ -1,12 +1,12 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/v7/shared" "code.cloudfoundry.org/clock" ) diff --git a/command/v7/bind_route_service_command.go b/command/v7/bind_route_service_command.go index b6e0b2fa867..c793182e25f 100644 --- a/command/v7/bind_route_service_command.go +++ b/command/v7/bind_route_service_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/types" ) type BindRouteServiceCommand struct { diff --git a/command/v7/bind_route_service_command_test.go b/command/v7/bind_route_service_command_test.go index 537c529843a..4dce41620fd 100644 --- a/command/v7/bind_route_service_command_test.go +++ b/command/v7/bind_route_service_command_test.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/bind_running_security_group_command.go b/command/v7/bind_running_security_group_command.go index 82aca45eb39..cee69cd5032 100644 --- a/command/v7/bind_running_security_group_command.go +++ b/command/v7/bind_running_security_group_command.go @@ -1,15 +1,15 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" ) type BindRunningSecurityGroupCommand struct { BaseCommand SecurityGroup flag.SecurityGroup `positional-args:"yes"` - usage interface{} `usage:"CF_NAME bind-running-security-group SECURITY_GROUP\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME bind-running-security-group SECURITY_GROUP\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, bind-security-group, bind-staging-security-group, restart, running-security-groups, security-groups"` } @@ -38,7 +38,7 @@ func (cmd BindRunningSecurityGroupCommand) Execute(args []string) error { } cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/bind_running_security_group_command_test.go b/command/v7/bind_running_security_group_command_test.go index c993a862412..9d965d88cef 100644 --- a/command/v7/bind_running_security_group_command_test.go +++ b/command/v7/bind_running_security_group_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -104,7 +104,7 @@ var _ = Describe("bind-running-security-group Command", func() { It("signals that the security group is bound and provides a helpful tip", func() { Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("globally bind security group warning")) Expect(executeErr).NotTo(HaveOccurred()) }) diff --git a/command/v7/bind_security_group_command.go b/command/v7/bind_security_group_command.go index 712eedfd7ca..d0df0848992 100644 --- a/command/v7/bind_security_group_command.go +++ b/command/v7/bind_security_group_command.go @@ -3,10 +3,10 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type BindSecurityGroupCommand struct { @@ -15,7 +15,7 @@ type BindSecurityGroupCommand struct { RequiredArgs flag.BindSecurityGroupV7Args `positional-args:"yes"` Lifecycle flag.SecurityGroupLifecycle `long:"lifecycle" choice:"running" choice:"staging" default:"running" description:"Lifecycle phase the group applies to."` Space string `long:"space" description:"Space to bind the security group to. (Default: all existing spaces in org)"` - usage interface{} `usage:"CF_NAME bind-security-group SECURITY_GROUP ORG [--lifecycle (running | staging)] [--space SPACE]\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME bind-security-group SECURITY_GROUP ORG [--lifecycle (running | staging)] [--space SPACE]\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, bind-running-security-group, bind-staging-security-group, restart, security-groups"` } @@ -99,7 +99,7 @@ func (cmd BindSecurityGroupCommand) Execute(args []string) error { cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") } return nil diff --git a/command/v7/bind_security_group_command_test.go b/command/v7/bind_security_group_command_test.go index b90fa78d797..19f8f5d90cd 100644 --- a/command/v7/bind_security_group_command_test.go +++ b/command/v7/bind_security_group_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -211,7 +211,7 @@ var _ = Describe("bind-security-group Command", func() { // When space is provided, Assigning statement should only be printed once Expect(testUI.Out).NotTo(Say(`Assigning running security group some-security-group to space some-space in org some-org as some-user\.\.\.`)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) Expect(testUI.Err).To(Say("get org warning")) @@ -276,7 +276,7 @@ var _ = Describe("bind-security-group Command", func() { Expect(testUI.Out).To(Say("Assigning running security group %s to all spaces in org %s as some-user...", cmd.RequiredArgs.SecurityGroupName, cmd.RequiredArgs.OrganizationName)) Expect(testUI.Out).To(Say("No spaces in org %s.", cmd.RequiredArgs.OrganizationName)) Expect(testUI.Out).NotTo(Say("OK")) - Expect(testUI.Out).NotTo(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) //TODO Why? + Expect(testUI.Out).NotTo(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) // TODO Why? Expect(testUI.Err).To(Say("get security group warning")) Expect(testUI.Err).To(Say("get org warning")) @@ -313,7 +313,7 @@ var _ = Describe("bind-security-group Command", func() { Expect(testUI.Out).To(Say(`Assigning running security group some-security-group to spaces some-space-1, some-space-2 in org some-org as some-user\.\.\.`)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) Expect(testUI.Err).To(Say("get org warning")) @@ -410,7 +410,7 @@ var _ = Describe("bind-security-group Command", func() { Expect(testUI.Out).To(Say(`Assigning staging security group some-security-group to space some-space in org some-org as some-user\.\.\.`)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) Expect(testUI.Err).To(Say("get org warning")) @@ -484,7 +484,7 @@ var _ = Describe("bind-security-group Command", func() { Expect(testUI.Out).To(Say(`Assigning staging security group some-security-group to spaces some-space-1, some-space-2 in org some-org as some-user\.\.\.`)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) Expect(testUI.Err).To(Say("get org warning")) diff --git a/command/v7/bind_service_command.go b/command/v7/bind_service_command.go index 4f4f9e480a9..84db8e2c3d5 100644 --- a/command/v7/bind_service_command.go +++ b/command/v7/bind_service_command.go @@ -1,21 +1,24 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/types" ) type BindServiceCommand struct { BaseCommand - RequiredArgs flag.BindServiceArgs `positional-args:"yes"` - BindingName flag.BindingName `long:"binding-name" description:"Name to expose service instance to app process with (Default: service instance name)"` - ParametersAsJSON flag.JSONOrFileWithValidation `short:"c" description:"Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering."` - Wait bool `short:"w" long:"wait" description:"Wait for the operation to complete"` - relatedCommands interface{} `related_commands:"services"` + RequiredArgs flag.BindServiceArgs `positional-args:"yes"` + BindingName flag.BindingName `long:"binding-name" description:"Name to expose service instance to app process with (Default: service instance name)"` + ParametersAsJSON flag.JSONOrFileWithValidation `short:"c" description:"Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering."` + ServiceBindingStrategy flag.ServiceBindingStrategy `long:"strategy" description:"Service binding strategy. Valid values are 'single' (default) and 'multiple'."` + Wait bool `short:"w" long:"wait" description:"Wait for the operation to complete"` + relatedCommands interface{} `related_commands:"services"` } func (cmd BindServiceCommand) Execute(args []string) error { @@ -23,6 +26,13 @@ func (cmd BindServiceCommand) Execute(args []string) error { return err } + if cmd.ServiceBindingStrategy.IsSet { + err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionServiceBindingStrategy, "--strategy") + if err != nil { + return err + } + } + if err := cmd.displayIntro(); err != nil { return err } @@ -33,6 +43,7 @@ func (cmd BindServiceCommand) Execute(args []string) error { AppName: cmd.RequiredArgs.AppName, BindingName: cmd.BindingName.Value, Parameters: types.OptionalObject(cmd.ParametersAsJSON), + Strategy: cmd.ServiceBindingStrategy.Strategy, }) cmd.UI.DisplayWarnings(warnings) @@ -82,7 +93,12 @@ Example of valid JSON object: Optionally provide a binding name for the association between an app and a service instance: -CF_NAME bind-service APP_NAME SERVICE_INSTANCE --binding-name BINDING_NAME` +CF_NAME bind-service APP_NAME SERVICE_INSTANCE --binding-name BINDING_NAME + +Optionally provide the binding strategy type. Valid options are 'single' (default) and 'multiple'. The 'multiple' strategy allows multiple bindings between the same app and service instance. +This is useful for credential rotation scenarios. + +CF_NAME bind-service APP_NAME SERVICE_INSTANCE --strategy multiple` } func (cmd BindServiceCommand) Examples() string { diff --git a/command/v7/bind_service_command_test.go b/command/v7/bind_service_command_test.go index f38481905dc..43faf4e1140 100644 --- a/command/v7/bind_service_command_test.go +++ b/command/v7/bind_service_command_test.go @@ -3,15 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -39,6 +41,7 @@ var _ = Describe("bind-service Command", func() { BeforeEach(func() { testUI = ui.NewTestUI(NewBuffer(), NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns("3.205.0") fakeSharedActor = new(commandfakes.FakeSharedActor) fakeActor = new(v7fakes.FakeActor) @@ -110,6 +113,30 @@ var _ = Describe("bind-service Command", func() { }) }) + When("strategy flag is set", func() { + BeforeEach(func() { + setFlag(&cmd, "--strategy", "multiple") + }) + + It("passes the strategy to the actor", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(fakeActor.CreateServiceAppBindingCallCount()).To(Equal(1)) + Expect(fakeActor.CreateServiceAppBindingArgsForCall(0).Strategy). + To(Equal(resources.MultipleBindingStrategy)) + }) + + It("fails when the cc version is below the minimum", func() { + fakeConfig.APIVersionReturns("3.204.0") + executeErr = cmd.Execute(nil) + + Expect(executeErr).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--strategy", + CurrentVersion: "3.204.0", + MinimumVersion: "3.205.0", + })) + }) + }) + When("binding already exists", func() { BeforeEach(func() { fakeActor.CreateServiceAppBindingReturns( diff --git a/command/v7/bind_staging_security_group_command.go b/command/v7/bind_staging_security_group_command.go index 306c0548d0c..4dd0b48ccf5 100644 --- a/command/v7/bind_staging_security_group_command.go +++ b/command/v7/bind_staging_security_group_command.go @@ -1,15 +1,15 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" ) type BindStagingSecurityGroupCommand struct { BaseCommand SecurityGroup flag.SecurityGroup `positional-args:"yes"` - usage interface{} `usage:"CF_NAME bind-staging-security-group SECURITY_GROUP\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME bind-staging-security-group SECURITY_GROUP\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, bind-running-security-group, bind-security-group, restart, security-groups, staging-security-groups"` } @@ -38,7 +38,7 @@ func (cmd BindStagingSecurityGroupCommand) Execute(args []string) error { } cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/bind_staging_security_group_command_test.go b/command/v7/bind_staging_security_group_command_test.go index c7069f91b7a..43e57e2f556 100644 --- a/command/v7/bind_staging_security_group_command_test.go +++ b/command/v7/bind_staging_security_group_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -104,7 +104,7 @@ var _ = Describe("bind-staging-security-group Command", func() { It("signals that the security group is bound and provides a helpful tip", func() { Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("globally bind security group warning")) Expect(executeErr).NotTo(HaveOccurred()) }) diff --git a/command/v7/buildpacks_command.go b/command/v7/buildpacks_command.go index d0726abb496..6a046767dfc 100644 --- a/command/v7/buildpacks_command.go +++ b/command/v7/buildpacks_command.go @@ -1,18 +1,21 @@ package v7 import ( - "strconv" + "strconv" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type BuildpacksCommand struct { BaseCommand - usage interface{} `usage:"CF_NAME buildpacks [--labels SELECTOR]\n\nEXAMPLES:\n CF_NAME buildpacks\n CF_NAME buildpacks --labels 'environment in (production,staging),tier in (backend)'\n CF_NAME buildpacks --labels 'env=dev,!chargeback-code,tier in (backend,worker)'"` - relatedCommands interface{} `related_commands:"create-buildpack, delete-buildpack, rename-buildpack, update-buildpack"` + usage interface{} `usage:"CF_NAME buildpacks [--labels SELECTOR] [--lifecycle buildpack|cnb]\n\nEXAMPLES:\n CF_NAME buildpacks\n CF_NAME buildpacks --labels 'environment in (production,staging),tier in (backend)'\n CF_NAME buildpacks --labels 'env=dev,!chargeback-code,tier in (backend,worker)'\n CF_NAME buildpacks --lifecycle cnb"` + relatedCommands interface{} `related_commands:"create-buildpack, delete-buildpack, update-buildpack"` Labels string `long:"labels" description:"Selector to filter buildpacks by labels"` + Lifecycle string `long:"lifecycle" description:"Filter buildpacks by lifecycle ('buildpack' or 'cnb')"` } func (cmd BuildpacksCommand) Execute(args []string) error { @@ -26,12 +29,19 @@ func (cmd BuildpacksCommand) Execute(args []string) error { return err } + if cmd.Lifecycle != "" { + err = command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionBuildpackLifecycleQuery, "--lifecycle") + if err != nil { + return err + } + } + cmd.UI.DisplayTextWithFlavor("Getting buildpacks as {{.Username}}...", map[string]interface{}{ "Username": user.Name, }) cmd.UI.DisplayNewline() - buildpacks, warnings, err := cmd.Actor.GetBuildpacks(cmd.Labels) + buildpacks, warnings, err := cmd.Actor.GetBuildpacks(cmd.Labels, cmd.Lifecycle) cmd.UI.DisplayWarnings(warnings) if err != nil { return err @@ -48,8 +58,9 @@ func (cmd BuildpacksCommand) Execute(args []string) error { func (cmd BuildpacksCommand) displayTable(buildpacks []resources.Buildpack) { if len(buildpacks) > 0 { var keyValueTable = [][]string{ - {"position", "name", "stack", "enabled", "locked", "filename"}, + {"position", "name", "stack", "enabled", "locked", "state", "filename", "lifecycle"}, } + for _, buildpack := range buildpacks { keyValueTable = append(keyValueTable, []string{ strconv.Itoa(buildpack.Position.Value), @@ -57,7 +68,9 @@ func (cmd BuildpacksCommand) displayTable(buildpacks []resources.Buildpack) { buildpack.Stack, strconv.FormatBool(buildpack.Enabled.Value), strconv.FormatBool(buildpack.Locked.Value), + buildpack.State, buildpack.Filename, + buildpack.Lifecycle, }) } diff --git a/command/v7/buildpacks_command_test.go b/command/v7/buildpacks_command_test.go index 6dd304e0686..9d8fbd047aa 100644 --- a/command/v7/buildpacks_command_test.go +++ b/command/v7/buildpacks_command_test.go @@ -3,18 +3,20 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -34,6 +36,7 @@ var _ = Describe("buildpacks Command", func() { BeforeEach(func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns("4.0.0") fakeSharedActor = new(commandfakes.FakeSharedActor) fakeActor = new(v7fakes.FakeActor) args = nil @@ -75,7 +78,7 @@ var _ = Describe("buildpacks Command", func() { fakeActor.GetCurrentUserReturns(configv3.User{Name: "apple"}, nil) }) - It("should print text indicating its runnning", func() { + It("should print text indicating its running", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Out).To(Say(`Getting buildpacks as apple\.\.\.`)) }) @@ -86,11 +89,32 @@ var _ = Describe("buildpacks Command", func() { }) It("passes the label selector to the actor", func() { - labelSelector := fakeActor.GetBuildpacksArgsForCall(0) + labelSelector, _ := fakeActor.GetBuildpacksArgsForCall(0) Expect(labelSelector).To(Equal("some-label-selector")) }) }) + When("the --lifecycle flag is used", func() { + BeforeEach(func() { + cmd.Lifecycle = "cnb" + }) + + It("passes the lifecycle to the actor", func() { + _, lifecycle := fakeActor.GetBuildpacksArgsForCall(0) + Expect(lifecycle).To(Equal("cnb")) + }) + It("fails when the cc version is below the minimum", func() { + fakeConfig.APIVersionReturns("3.193.0") + executeErr = cmd.Execute(nil) + + Expect(executeErr).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--lifecycle", + CurrentVersion: "3.193.0", + MinimumVersion: "3.194.0", + })) + }) + }) + When("getting buildpacks fails", func() { BeforeEach(func() { fakeActor.GetBuildpacksReturns(nil, v7action.Warnings{"some-warning-1", "some-warning-2"}, @@ -110,21 +134,35 @@ var _ = Describe("buildpacks Command", func() { BeforeEach(func() { buildpacks := []resources.Buildpack{ { - Name: "buildpack-1", - Position: types.NullInt{Value: 1, IsSet: true}, - Enabled: types.NullBool{Value: true, IsSet: true}, - Locked: types.NullBool{Value: false, IsSet: true}, - Filename: "buildpack-1.file", - Stack: "buildpack-1-stack", + Name: "buildpack-1", + Position: types.NullInt{Value: 1, IsSet: true}, + Enabled: types.NullBool{Value: true, IsSet: true}, + Locked: types.NullBool{Value: false, IsSet: true}, + State: constant.BuildpackReady, + Filename: "buildpack-1.file", + Stack: "buildpack-1-stack", + Lifecycle: "buildpack", }, { - Name: "buildpack-2", - Position: types.NullInt{Value: 2, IsSet: true}, - Enabled: types.NullBool{Value: false, IsSet: true}, - Locked: types.NullBool{Value: true, IsSet: true}, - Filename: "buildpack-2.file", - Stack: "", + Name: "buildpack-2", + Position: types.NullInt{Value: 2, IsSet: true}, + Enabled: types.NullBool{Value: false, IsSet: true}, + Locked: types.NullBool{Value: true, IsSet: true}, + State: constant.BuildpackAwaitingUpload, + Filename: "buildpack-2.file", + Stack: "", + Lifecycle: "buildpack", + }, + { + Name: "cnb-1", + Position: types.NullInt{Value: 1, IsSet: true}, + Enabled: types.NullBool{Value: true, IsSet: true}, + Locked: types.NullBool{Value: false, IsSet: true}, + State: constant.BuildpackReady, + Filename: "cnb-1.cnb", + Stack: "cnb-1-stack", + Lifecycle: "cnb", }, } fakeActor.GetBuildpacksReturns(buildpacks, v7action.Warnings{"some-warning-1", "some-warning-2"}, nil) @@ -133,9 +171,10 @@ var _ = Describe("buildpacks Command", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Err).To(Say("some-warning-1")) Expect(testUI.Err).To(Say("some-warning-2")) - Expect(testUI.Out).To(Say(`position\s+name\s+stack\s+enabled\s+locked\s+filename`)) - Expect(testUI.Out).To(Say(`1\s+buildpack-1\s+buildpack-1-stack\s+true\s+false\s+buildpack-1.file`)) - Expect(testUI.Out).To(Say(`2\s+buildpack-2\s+false\s+true\s+buildpack-2.file`)) + Expect(testUI.Out).To(Say(`position\s+name\s+stack\s+enabled\s+locked\s+state\s+filename\s+lifecycle`)) + Expect(testUI.Out).To(Say(`1\s+buildpack-1\s+buildpack-1-stack\s+true\s+false\s+READY\s+buildpack-1.file\s+buildpack`)) + Expect(testUI.Out).To(Say(`2\s+buildpack-2\s+false\s+true\s+AWAITING_UPLOAD\s+buildpack-2.file\s+buildpack`)) + Expect(testUI.Out).To(Say(`1\s+cnb-1\s+cnb-1-stack\s+true\s+false\s+READY\s+cnb-1.cnb\s+cnb`)) }) }) When("there are no buildpacks", func() { diff --git a/command/v7/cancel_deployment_command.go b/command/v7/cancel_deployment_command.go index 55998b32a4c..2cfbaf6d302 100644 --- a/command/v7/cancel_deployment_command.go +++ b/command/v7/cancel_deployment_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CancelDeploymentCommand struct { diff --git a/command/v7/cancel_deployment_command_test.go b/command/v7/cancel_deployment_command_test.go index ce597a138b2..32ecb10ef68 100644 --- a/command/v7/cancel_deployment_command_test.go +++ b/command/v7/cancel_deployment_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/check_route_command.go b/command/v7/check_route_command.go index 444cd1f4d25..00b28c3dc2f 100644 --- a/command/v7/check_route_command.go +++ b/command/v7/check_route_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CheckRouteCommand struct { diff --git a/command/v7/check_route_command_test.go b/command/v7/check_route_command_test.go index 548dd7e28a3..251810ae29c 100644 --- a/command/v7/check_route_command_test.go +++ b/command/v7/check_route_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/config_command.go b/command/v7/config_command.go index ae306787c5f..76256b6fd5c 100644 --- a/command/v7/config_command.go +++ b/command/v7/config_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type ConfigCommand struct { diff --git a/command/v7/config_command_test.go b/command/v7/config_command_test.go index a3762f101d1..ec00aae9f59 100644 --- a/command/v7/config_command_test.go +++ b/command/v7/config_command_test.go @@ -1,14 +1,13 @@ package v7_test import ( - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -25,7 +24,7 @@ var _ = Describe("ConfigCommand", func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) - cmd = ConfigCommand{ + cmd = v7.ConfigCommand{ UI: testUI, Config: fakeConfig, } diff --git a/command/v7/continue_deployment_command.go b/command/v7/continue_deployment_command.go new file mode 100644 index 00000000000..f1e243cda16 --- /dev/null +++ b/command/v7/continue_deployment_command.go @@ -0,0 +1,80 @@ +package v7 + +import ( + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" +) + +type ContinueDeploymentCommand struct { + BaseCommand + + RequiredArgs flag.AppName `positional-args:"yes"` + NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` + usage interface{} `usage:"CF_NAME continue-deployment APP_NAME [--no-wait]\n\nEXAMPLES:\n cf continue-deployment my-app"` + relatedCommands interface{} `related_commands:"app, push"` +} + +func (cmd *ContinueDeploymentCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + cmd.UI.DisplayTextWithFlavor( + "Continuing deployment for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.UserName}}...\n", + map[string]interface{}{ + "AppName": cmd.RequiredArgs.AppName, + "OrgName": cmd.Config.TargetedOrganization().Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "UserName": user.Name, + }, + ) + + application, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + deployment, warnings, err := cmd.Actor.GetLatestActiveDeploymentForApp(application.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + warnings, err = cmd.Actor.ContinueDeployment(deployment.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + cmd.UI.DisplayText("Waiting for app to deploy...\n") + + handleInstanceDetails := func(instanceDetails string) { + cmd.UI.DisplayText(instanceDetails) + } + + warnings, err = cmd.Actor.PollStartForDeployment(application, deployment.GUID, cmd.NoWait, handleInstanceDetails) + cmd.UI.DisplayNewline() + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + summary, warnings, err := cmd.Actor.GetDetailedAppSummary(application.Name, application.SpaceGUID, false) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + appSummaryDisplayer := shared.NewAppSummaryDisplayer(cmd.UI) + appSummaryDisplayer.AppDisplay(summary, false) + + cmd.UI.DisplayText("\nTIP: Run 'cf app {{.AppName}}' to view app status.", map[string]interface{}{"AppName": cmd.RequiredArgs.AppName}) + return nil +} diff --git a/command/v7/continue_deployment_command_test.go b/command/v7/continue_deployment_command_test.go new file mode 100644 index 00000000000..8057aac4c73 --- /dev/null +++ b/command/v7/continue_deployment_command_test.go @@ -0,0 +1,275 @@ +package v7_test + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("Continue deployment command", func() { + var ( + cmd ContinueDeploymentCommand + testUI *ui.UI + input *Buffer + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + appName string + noWait bool + spaceGUID string + executeErr error + ) + + BeforeEach(func() { + input = NewBuffer() + testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "clodFoundry" + fakeConfig.BinaryNameReturns(binaryName) + + cmd = ContinueDeploymentCommand{ + RequiredArgs: flag.AppName{AppName: appName}, + NoWait: noWait, + BaseCommand: BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + } + + fakeConfig.TargetedOrganizationReturns(configv3.Organization{ + Name: "some-org", + GUID: "some-org-guid", + }) + + spaceGUID = "some-space-guid" + fakeConfig.TargetedSpaceReturns(configv3.Space{ + Name: "some-space", + GUID: spaceGUID, + }) + + fakeActor.GetCurrentUserReturns(configv3.User{Name: "timmyD"}, nil) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in", func() { + It("delegates to actor.GetApplicationByNameAndSpace", func() { + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + }) + + When("getting the app fails", func() { + BeforeEach(func() { + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{}, + v7action.Warnings{"get-app-warning"}, + errors.New("get-app-error"), + ) + }) + + It("returns the errors and outputs warnings", func() { + Expect(executeErr).To(MatchError("get-app-error")) + Expect(testUI.Err).To(Say("get-app-warning")) + + Expect(fakeActor.GetLatestActiveDeploymentForAppCallCount()).To(Equal(0)) + Expect(fakeActor.ContinueDeploymentCallCount()).To(Equal(0)) + }) + }) + + When("getting the app succeeds", func() { + var appGUID string + var returnedApplication resources.Application + + BeforeEach(func() { + appGUID = "some-app-guid" + returnedApplication = resources.Application{Name: appName, GUID: appGUID} + fakeActor.GetApplicationByNameAndSpaceReturns( + returnedApplication, + v7action.Warnings{"get-app-warning"}, + nil, + ) + }) + + It("delegates to actor.GetLatestDeployment", func() { + Expect(fakeActor.GetLatestActiveDeploymentForAppCallCount()).To(Equal(1)) + Expect(fakeActor.GetLatestActiveDeploymentForAppArgsForCall(0)).To(Equal(appGUID)) + }) + + When("getting the latest deployment fails", func() { + BeforeEach(func() { + fakeActor.GetLatestActiveDeploymentForAppReturns( + resources.Deployment{}, + v7action.Warnings{"get-deployment-warning"}, + errors.New("get-deployment-error"), + ) + }) + + It("returns the error and all warnings", func() { + Expect(executeErr).To(MatchError("get-deployment-error")) + Expect(testUI.Err).To(Say("get-app-warning")) + Expect(testUI.Err).To(Say("get-deployment-warning")) + + Expect(fakeActor.ContinueDeploymentCallCount()).To(Equal(0)) + }) + }) + + When("getting the latest deployment succeeds", func() { + var deploymentGUID string + BeforeEach(func() { + deploymentGUID = "some-deployment-guid" + fakeActor.GetLatestActiveDeploymentForAppReturns( + resources.Deployment{GUID: deploymentGUID}, + v7action.Warnings{"get-deployment-warning"}, + nil, + ) + }) + + It("delegates to actor.ContinueDeployment", func() { + Expect(fakeActor.ContinueDeploymentCallCount()).To(Equal(1)) + Expect(fakeActor.ContinueDeploymentArgsForCall(0)).To(Equal(deploymentGUID)) + }) + + When("continuing the deployment fails", func() { + BeforeEach(func() { + fakeActor.ContinueDeploymentReturns( + v7action.Warnings{"continue-deployment-warning"}, + errors.New("continue-deployment-error"), + ) + }) + + It("returns all warnings and errors", func() { + Expect(executeErr).To(MatchError("continue-deployment-error")) + Expect(testUI.Err).To(Say("get-app-warning")) + Expect(testUI.Err).To(Say("get-deployment-warning")) + Expect(testUI.Err).To(Say("continue-deployment-warning")) + }) + }) + + When("continuing the deployment succeeds", func() { + BeforeEach(func() { + fakeActor.ContinueDeploymentReturns( + nil, + nil, + ) + }) + + It("returns success", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + + When("the --no-wait flag is not provided", func() { + It("polls and waits", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) + Expect(invokedApplication).To(Equal(returnedApplication)) + Expect(invokedGuid).To(Equal(deploymentGUID)) + Expect(invokedNoWait).To(Equal(false)) + }) + }) + + When("the --no-wait flag is provided", func() { + BeforeEach(func() { + cmd.NoWait = true + }) + + It("polls without waiting", func() { + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) + + invokedApplication, invokedGuid, invokedNoWait, _ := fakeActor.PollStartForDeploymentArgsForCall(0) + Expect(invokedApplication).To(Equal(returnedApplication)) + Expect(invokedGuid).To(Equal(deploymentGUID)) + Expect(invokedNoWait).To(Equal(true)) + }) + }) + + When("polling the application fails", func() { + BeforeEach(func() { + fakeActor.PollStartForDeploymentReturns( + v7action.Warnings{"poll-app-warning"}, errors.New("poll-app-error")) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError("poll-app-error")) + }) + }) + + When("polling the application succeeds", func() { + BeforeEach(func() { + fakeActor.PollStartForDeploymentReturns(nil, nil) + }) + + When("getting the app summary fails", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = actionerror.ApplicationNotFoundError{Name: appName} + fakeActor.GetDetailedAppSummaryReturns(v7action.DetailedApplicationSummary{}, v7action.Warnings{"application-summary-warning-1", "application-summary-warning-2"}, expectedErr) + }) + + It("displays all warnings and returns an error", func() { + Expect(executeErr).To(Equal(actionerror.ApplicationNotFoundError{Name: appName})) + }) + }) + + When("getting the app summary succeeds", func() { + It("succeeds", func() { + Expect(executeErr).To(Not(HaveOccurred())) + }) + }) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/copy_source_command.go b/command/v7/copy_source_command.go index 42f869b2458..3f3dfc96c5a 100644 --- a/command/v7/copy_source_command.go +++ b/command/v7/copy_source_command.go @@ -1,12 +1,19 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/util/configv3" + "strconv" + "strings" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type CopySourceCommand struct { @@ -14,11 +21,13 @@ type CopySourceCommand struct { RequiredArgs flag.CopySourceArgs `positional-args:"yes"` usage interface{} `usage:"CF_NAME copy-source SOURCE_APP DESTINATION_APP [-s TARGET_SPACE [-o TARGET_ORG]] [--no-restart] [--strategy STRATEGY] [--no-wait]"` - Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy, either rolling or null"` + InstanceSteps string `long:"instance-steps" description:"An array of percentage steps to deploy when using deployment strategy canary. (e.g. 20,40,60)"` + MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively being started. Only applies when --strategy flag is specified."` NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` NoRestart bool `long:"no-restart" description:"Do not restage the destination application"` Organization string `short:"o" long:"organization" description:"Org that contains the destination application"` Space string `short:"s" long:"space" description:"Space that contains the destination application"` + Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary, rolling or null"` relatedCommands interface{} `related_commands:"apps, push, restage, restart, target"` envCFStagingTimeout interface{} `environmentName:"CF_STAGING_TIMEOUT" environmentDescription:"Max wait time for staging, in minutes" environmentDefault:"15"` envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` @@ -46,6 +55,26 @@ func (cmd *CopySourceCommand) ValidateFlags() error { } } + if cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil { + return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} + } + + if cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1 { + return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} + } + + if cmd.Strategy.Name != constant.DeploymentStrategyCanary && cmd.InstanceSteps != "" { + return translatableerror.RequiredFlagsError{Arg1: "--instance-steps", Arg2: "--strategy=canary"} + } + + if len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps) { + return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} + } + + if len(cmd.InstanceSteps) > 0 { + return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") + } + return nil } @@ -55,7 +84,11 @@ func (cmd *CopySourceCommand) Setup(config command.Config, ui command.UI) error return err } - logCacheClient := command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + logCacheClient, err := logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } + cmd.Stager = shared.NewAppStager(cmd.Actor, cmd.UI, cmd.Config, logCacheClient) return nil @@ -153,15 +186,29 @@ func (cmd CopySourceCommand) Execute(args []string) error { ) cmd.UI.DisplayNewline() - err = cmd.Stager.StageAndStart( - targetApp, - targetSpace, - targetOrg, - pkg.GUID, - cmd.Strategy.Name, - cmd.NoWait, - constant.ApplicationRestarting, - ) + opts := shared.AppStartOpts{ + AppAction: constant.ApplicationRestarting, + NoWait: cmd.NoWait, + Strategy: cmd.Strategy.Name, + } + + if cmd.MaxInFlight != nil { + opts.MaxInFlight = *cmd.MaxInFlight + } + + if cmd.InstanceSteps != "" { + if len(cmd.InstanceSteps) > 0 { + for _, v := range strings.Split(cmd.InstanceSteps, ",") { + parsedInt, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return err + } + opts.CanarySteps = append(opts.CanarySteps, resources.CanaryStep{InstanceWeight: parsedInt}) + } + } + } + + err = cmd.Stager.StageAndStart(targetApp, targetSpace, targetOrg, pkg.GUID, opts) if err != nil { return mapErr(cmd.Config, targetApp.Name, err) } diff --git a/command/v7/copy_source_command_test.go b/command/v7/copy_source_command_test.go index 3b8cedb9c04..7fa2433ca04 100644 --- a/command/v7/copy_source_command_test.go +++ b/command/v7/copy_source_command_test.go @@ -3,19 +3,19 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared/sharedfakes" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -125,49 +125,6 @@ var _ = Describe("copy-source Command", func() { }) }) - When("the target organization is specified but the targeted space isn't", func() { - BeforeEach(func() { - cmd.Organization = "some-other-organization" - }) - - It("returns an error", func() { - Expect(executeErr).To(MatchError(translatableerror.RequiredFlagsError{ - Arg1: "--organization, -o", - Arg2: "--space, -s", - })) - }) - }) - - When("the no restart and strategy flags are both provided", func() { - BeforeEach(func() { - cmd.NoRestart = true - cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} - }) - - It("returns an error", func() { - Expect(executeErr).To(MatchError(translatableerror.ArgumentCombinationError{ - Args: []string{ - "--no-restart", "--strategy", - }, - })) - }) - }) - - When("the no restart and no wait flags are both provided", func() { - BeforeEach(func() { - cmd.NoRestart = true - cmd.NoWait = true - }) - - It("returns an error", func() { - Expect(executeErr).To(MatchError(translatableerror.ArgumentCombinationError{ - Args: []string{ - "--no-restart", "--no-wait", - }, - })) - }) - }) - When("a target org and space is provided", func() { BeforeEach(func() { cmd.Organization = "destination-org" @@ -329,18 +286,66 @@ var _ = Describe("copy-source Command", func() { cmd.Strategy = flag.DeploymentStrategy{ Name: constant.DeploymentStrategyRolling, } + maxInFlight := 5 + cmd.MaxInFlight = &maxInFlight + }) + + It("stages and starts the app with the appropriate strategy", func() { + Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) + returnedApp, spaceForApp, orgForApp, pkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) + Expect(returnedApp).To(Equal(targetApp)) + Expect(spaceForApp).To(Equal(configv3.Space{Name: "some-space", GUID: "some-space-guid"})) + Expect(orgForApp).To(Equal(configv3.Organization{Name: "some-org"})) + Expect(pkgGUID).To(Equal("target-package-guid")) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.MaxInFlight).To(Equal(5)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyRolling)) + }) + }) + + When("the strategy flag is set to canary", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{ + Name: constant.DeploymentStrategyCanary, + } + maxInFlight := 1 + cmd.MaxInFlight = &maxInFlight }) It("stages and starts the app with the appropriate strategy", func() { Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - returnedApp, spaceForApp, orgForApp, pkgGUID, strategy, noWait, appAction := fakeAppStager.StageAndStartArgsForCall(0) + returnedApp, spaceForApp, orgForApp, pkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) Expect(returnedApp).To(Equal(targetApp)) Expect(spaceForApp).To(Equal(configv3.Space{Name: "some-space", GUID: "some-space-guid"})) Expect(orgForApp).To(Equal(configv3.Organization{Name: "some-org"})) Expect(pkgGUID).To(Equal("target-package-guid")) - Expect(strategy).To(Equal(constant.DeploymentStrategyRolling)) - Expect(noWait).To(Equal(false)) - Expect(appAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + }) + + When("instance steps is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "1,2,4" + + fakeConfig.APIVersionReturns("3.999.0") + }) + + It("starts the new app", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) + + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StageAndStartArgsForCall(0) + Expect(inputApp).To(Equal(targetApp)) + Expect(inputDropletGuid).To(Equal("target-package-guid")) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 4}})) + }) }) }) @@ -351,27 +356,27 @@ var _ = Describe("copy-source Command", func() { It("stages and starts the app with the appropriate strategy", func() { Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - returnedApp, spaceForApp, orgForApp, pkgGUID, strategy, noWait, appAction := fakeAppStager.StageAndStartArgsForCall(0) + returnedApp, spaceForApp, orgForApp, pkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) Expect(returnedApp).To(Equal(targetApp)) Expect(spaceForApp).To(Equal(configv3.Space{Name: "some-space", GUID: "some-space-guid"})) Expect(orgForApp).To(Equal(configv3.Organization{Name: "some-org"})) Expect(pkgGUID).To(Equal("target-package-guid")) - Expect(strategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(noWait).To(Equal(true)) - Expect(appAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + Expect(opts.NoWait).To(Equal(true)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) }) }) It("stages and starts the target app", func() { Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - returnedApp, spaceForApp, orgForApp, pkgGUID, strategy, noWait, appAction := fakeAppStager.StageAndStartArgsForCall(0) + returnedApp, spaceForApp, orgForApp, pkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) Expect(returnedApp).To(Equal(targetApp)) Expect(spaceForApp).To(Equal(configv3.Space{Name: "some-space", GUID: "some-space-guid"})) Expect(orgForApp).To(Equal(configv3.Organization{Name: "some-org"})) Expect(pkgGUID).To(Equal("target-package-guid")) - Expect(strategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(noWait).To(Equal(false)) - Expect(appAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) }) When("staging and starting the app fails", func() { @@ -397,4 +402,99 @@ var _ = Describe("copy-source Command", func() { It("succeeds", func() { Expect(executeErr).To(Not(HaveOccurred())) }) + + DescribeTable("ValidateFlags returns an error", + func(setup func(), expectedErr error) { + setup() + err := cmd.ValidateFlags() + if expectedErr == nil { + Expect(err).To(BeNil()) + } else { + Expect(err).To(MatchError(expectedErr)) + } + }, + Entry("the target organization is specified but the targeted space isn't", + func() { + cmd.Organization = "some-other-organization" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--organization, -o", + Arg2: "--space, -s", + }), + + Entry("the no restart and strategy flags are both provided", + func() { + cmd.NoRestart = true + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--no-restart", "--strategy", + }, + }), + + Entry("the no restart and no wait flags are both provided", + func() { + cmd.NoRestart = true + cmd.NoWait = true + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--no-restart", "--no-wait", + }, + }), + + Entry("max-in-flight is passed without strategy", + func() { + maxInFlight := 5 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.RequiredFlagsError{ + Arg1: "--max-in-flight", + Arg2: "--strategy", + }), + + Entry("max-in-flight is smaller than 1", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + maxInFlight := 0 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.IncorrectUsageError{ + Message: "--max-in-flight must be greater than or equal to 1", + }), + + Entry("instance-steps no strategy provided", + func() { + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps a valid list of ints", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "some,thing,not,right" + }, + translatableerror.ParseArgumentError{ + ArgumentName: "--instance-steps", + ExpectedType: "list of weights", + }), + + Entry("instance-steps used when CAPI does not support canary steps", + func() { + cmd.InstanceSteps = "1,2,3" + cmd.Strategy.Name = constant.DeploymentStrategyCanary + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("3.0.0") + cmd.Config = fakeConfig + }, + translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--instance-steps", + CurrentVersion: "3.0.0", + MinimumVersion: "3.189.0", + }), + ) }) diff --git a/command/v7/create_app_command.go b/command/v7/create_app_command.go index 938be0bcf73..a7a1c5aad3a 100644 --- a/command/v7/create_app_command.go +++ b/command/v7/create_app_command.go @@ -1,18 +1,24 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "errors" + "fmt" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type CreateAppCommand struct { BaseCommand RequiredArgs flag.AppName `positional-args:"yes"` - AppType flag.AppType `long:"app-type" choice:"buildpack" choice:"docker" description:"App lifecycle type to stage and run the app" default:"buildpack"` - usage interface{} `usage:"CF_NAME create-app APP_NAME [--app-type (buildpack | docker)]"` + AppType flag.AppType `long:"app-type" choice:"buildpack" choice:"docker" choice:"cnb" description:"App lifecycle type to stage and run the app" default:"buildpack"` + Buildpacks []string `long:"buildpack" short:"b" description:"Custom buildpack by name (e.g. my-buildpack), Docker image (e.g. docker://registry/image:tag), Git URL (e.g. 'https://github.com/cloudfoundry/java-buildpack.git') or Git URL with a branch or tag (e.g. 'https://github.com/cloudfoundry/java-buildpack.git#v3.3.0' for 'v3.3.0' tag). To use built-in buildpacks only, specify 'default' or 'null'"` + usage interface{} `usage:"CF_NAME create-app APP_NAME [--app-type (buildpack | docker | cnb)]"` relatedCommands interface{} `related_commands:"app, apps, push"` } @@ -34,11 +40,34 @@ func (cmd CreateAppCommand) Execute(args []string) error { "CurrentUser": user.Name, }) + cmd.UI.DisplayText(fmt.Sprintf("Using app type %q", constant.AppLifecycleType(cmd.AppType))) + + app := resources.Application{ + Name: cmd.RequiredArgs.AppName, + LifecycleType: constant.AppLifecycleType(cmd.AppType), + LifecycleBuildpacks: cmd.Buildpacks, + } + + if constant.AppLifecycleType(cmd.AppType) == constant.AppLifecycleTypeCNB { + err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCNB) + if err != nil { + return err + } + + if len(cmd.Buildpacks) == 0 { + return errors.New("buildpack(s) must be provided when using --app-type cnb") + } + + creds, err := cmd.Config.CNBCredentials() + if err != nil { + return err + } + + app.Credentials = creds + } + _, warnings, err := cmd.Actor.CreateApplicationInSpace( - resources.Application{ - Name: cmd.RequiredArgs.AppName, - LifecycleType: constant.AppLifecycleType(cmd.AppType), - }, + app, cmd.Config.TargetedSpace().GUID, ) cmd.UI.DisplayWarnings(warnings) diff --git a/command/v7/create_app_command_test.go b/command/v7/create_app_command_test.go index d4b416a7492..ff732346d5d 100644 --- a/command/v7/create_app_command_test.go +++ b/command/v7/create_app_command_test.go @@ -4,18 +4,19 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -124,6 +125,33 @@ var _ = Describe("create-app Command", func() { Expect(createSpaceGUID).To(Equal("some-space-guid")) }) }) + + When("app type is cnb", func() { + BeforeEach(func() { + cmd.AppType = "cnb" + cmd.Buildpacks = []string{"foo"} + fakeConfig.CNBCredentialsReturns(map[string]interface{}{ + "foo": "bar", + }, nil) + fakeConfig.APIVersionReturns(ccversion.MinVersionCNB) + }) + + It("creates an app with app type: cnb", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(fakeActor.CreateApplicationInSpaceCallCount()).To(Equal(1)) + createApp, createSpaceGUID := fakeActor.CreateApplicationInSpaceArgsForCall(0) + Expect(createApp).To(Equal(resources.Application{ + Name: app, + LifecycleType: constant.AppLifecycleTypeCNB, + LifecycleBuildpacks: []string{"foo"}, + Credentials: map[string]interface{}{ + "foo": "bar", + }, + })) + Expect(createSpaceGUID).To(Equal("some-space-guid")) + }) + }) }) When("the create is unsuccessful", func() { @@ -168,6 +196,19 @@ var _ = Describe("create-app Command", func() { Expect(testUI.Err).To(Say("I am also a warning")) }) }) + + Context("due to missing buildpacks when AppType is cnb", func() { + BeforeEach(func() { + cmd.AppType = "cnb" + fakeConfig.APIVersionReturns(ccversion.MinVersionCNB) + }) + + It("displays the header and error", func() { + Expect(executeErr).To(MatchError("buildpack(s) must be provided when using --app-type cnb")) + + Expect(testUI.Out).To(Say("Creating app some-app in org some-org / space some-space as banana...")) + }) + }) }) }) }) diff --git a/command/v7/create_app_manifest_command.go b/command/v7/create_app_manifest_command.go index 69d8652b50b..58d7085ce23 100644 --- a/command/v7/create_app_manifest_command.go +++ b/command/v7/create_app_manifest_command.go @@ -2,13 +2,12 @@ package v7 import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type CreateAppManifestCommand struct { @@ -66,7 +65,7 @@ func (cmd CreateAppManifestCommand) Execute(args []string) error { pathToYAMLFile = filepath.Join(cmd.PWD, fmt.Sprintf("%s_manifest.yml", appName)) } - err = ioutil.WriteFile(pathToYAMLFile, manifestBytes, 0666) + err = os.WriteFile(pathToYAMLFile, manifestBytes, 0666) if err != nil { return translatableerror.FileCreationError{Err: err} } diff --git a/command/v7/create_app_manifest_command_test.go b/command/v7/create_app_manifest_command_test.go index 23894166f13..c1b57ba05db 100644 --- a/command/v7/create_app_manifest_command_test.go +++ b/command/v7/create_app_manifest_command_test.go @@ -2,20 +2,19 @@ package v7_test import ( "errors" - "io/ioutil" "os" "path/filepath" "regexp" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -103,7 +102,7 @@ var _ = Describe("create-app-manifest Command", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "create-app-manifest-unit") + tempDir, err = os.MkdirTemp("", "create-app-manifest-unit") Expect(err).ToNot(HaveOccurred()) cmd.PWD = tempDir @@ -116,7 +115,7 @@ var _ = Describe("create-app-manifest Command", func() { Expect(os.RemoveAll(tempDir)).ToNot(HaveOccurred()) }) - It("creates application manifest in current directry as -manifest.yml", func() { + It("creates application manifest in current directory as -manifest.yml", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(fakeActor.GetRawApplicationManifestByNameAndSpaceCallCount()).To(Equal(1)) @@ -124,7 +123,7 @@ var _ = Describe("create-app-manifest Command", func() { Expect(appArg).To(Equal("some-app")) Expect(spaceArg).To(Equal("some-space-guid")) - fileContents, err := ioutil.ReadFile(pathToYAMLFile) + fileContents, err := os.ReadFile(pathToYAMLFile) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal(yamlContents)) }) @@ -157,7 +156,7 @@ var _ = Describe("create-app-manifest Command", func() { Expect(appArg).To(Equal("some-app")) Expect(spaceArg).To(Equal("some-space-guid")) - fileContents, err := ioutil.ReadFile(flagPath) + fileContents, err := os.ReadFile(flagPath) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal(yamlContents)) }) diff --git a/command/v7/create_buildpack_command.go b/command/v7/create_buildpack_command.go index 526fdc83474..640372609a4 100644 --- a/command/v7/create_buildpack_command.go +++ b/command/v7/create_buildpack_command.go @@ -1,27 +1,28 @@ package v7 import ( - "io/ioutil" "os" "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/download" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/download" ) type CreateBuildpackCommand struct { BaseCommand RequiredArgs flag.CreateBuildpackArgs `positional-args:"Yes"` - usage interface{} `usage:"CF_NAME create-buildpack BUILDPACK PATH POSITION [--disable]\n\nTIP:\n Path should be a zip file, a url to a zip file, or a local directory. Position is a positive integer, sets priority, and is sorted from lowest to highest."` + usage interface{} `usage:"CF_NAME create-buildpack BUILDPACK PATH POSITION [--disable] [--lifecycle buildpack|cnb]\n\nTIP:\n When using the 'buildpack' lifecycle type, Path should be a zip file, a url to a zip file, or a local directory. When using the 'cnb' lifecycle, Path should be a cnb file or gzipped oci image. Position is a positive integer, sets priority, and is sorted from lowest to highest."` relatedCommands interface{} `related_commands:"buildpacks, push"` Disable bool `long:"disable" description:"Disable the buildpack from being used for staging"` + Lifecycle string `long:"lifecycle" short:"l" description:"Lifecycle that the buildpack will use ('buildpack' or 'cnb')"` ProgressBar v7action.SimpleProgressBar } @@ -42,13 +43,20 @@ func (cmd CreateBuildpackCommand) Execute(args []string) error { return err } + if cmd.Lifecycle != "" { + err = command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionBuildpackLifecycleQuery, "--lifecycle") + if err != nil { + return err + } + } + cmd.UI.DisplayTextWithFlavor("Creating buildpack {{.BuildpackName}} as {{.Username}}...", map[string]interface{}{ "Username": user.Name, "BuildpackName": cmd.RequiredArgs.Buildpack, }) downloader := download.NewDownloader(time.Second * 30) - tmpDirPath, err := ioutil.TempDir("", "buildpack-dir-") + tmpDirPath, err := os.MkdirTemp("", "buildpack-dir-") if err != nil { return err } @@ -60,9 +68,10 @@ func (cmd CreateBuildpackCommand) Execute(args []string) error { } createdBuildpack, warnings, err := cmd.Actor.CreateBuildpack(resources.Buildpack{ - Name: cmd.RequiredArgs.Buildpack, - Position: types.NullInt{IsSet: true, Value: cmd.RequiredArgs.Position}, - Enabled: types.NullBool{IsSet: true, Value: !cmd.Disable}, + Name: cmd.RequiredArgs.Buildpack, + Position: types.NullInt{IsSet: true, Value: cmd.RequiredArgs.Position}, + Enabled: types.NullBool{IsSet: true, Value: !cmd.Disable}, + Lifecycle: cmd.Lifecycle, }) cmd.UI.DisplayWarnings(warnings) if err != nil { diff --git a/command/v7/create_buildpack_command_test.go b/command/v7/create_buildpack_command_test.go index 43b96f17a3f..13f30f975da 100644 --- a/command/v7/create_buildpack_command_test.go +++ b/command/v7/create_buildpack_command_test.go @@ -3,21 +3,21 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -39,6 +39,7 @@ var _ = Describe("create buildpack Command", func() { BeforeEach(func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns("4.0.0") fakeSharedActor = new(commandfakes.FakeSharedActor) fakeActor = new(v7fakes.FakeActor) args = nil @@ -82,6 +83,23 @@ var _ = Describe("create buildpack Command", func() { }) }) + When("--lifecyle is provided", func() { + JustBeforeEach(func() { + cmd.Lifecycle = "some-lifecycle" + fakeConfig.APIVersionReturns("3.193.0") + }) + It("fails when the cc version is below the minimum", func() { + executeErr = cmd.Execute(nil) + + Expect(executeErr).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--lifecycle", + CurrentVersion: "3.193.0", + MinimumVersion: "3.194.0", + })) + }) + + }) + When("the environment is setup correctly", func() { BeforeEach(func() { fakeActor.GetCurrentUserReturns(configv3.User{Name: "the-user"}, nil) @@ -92,6 +110,17 @@ var _ = Describe("create buildpack Command", func() { Expect(testUI.Out).To(Say(`Creating buildpack %s as the-user\.\.\.`, buildpackName)) }) + When("passing in buildpack lifecycle", func() { + BeforeEach(func() { + cmd.Lifecycle = "cnb" + }) + + It("sets the correct lifecycle in the buildpack resource", func() { + Expect(fakeActor.CreateBuildpackCallCount()).To(Equal(1)) + Expect(fakeActor.CreateBuildpackArgsForCall(0).Lifecycle).To(Equal("cnb")) + }) + }) + When("preparing the buildpack bits fails", func() { BeforeEach(func() { fakeActor.PrepareBuildpackBitsReturns("some/invalid/path", errors.New("some-prepare-bp-error")) diff --git a/command/v7/create_isolation_segment_command.go b/command/v7/create_isolation_segment_command.go index 04026ec5edf..f9cf1f33eea 100644 --- a/command/v7/create_isolation_segment_command.go +++ b/command/v7/create_isolation_segment_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type CreateIsolationSegmentCommand struct { diff --git a/command/v7/create_isolation_segment_command_test.go b/command/v7/create_isolation_segment_command_test.go index 1654035701d..bcd3385ddc4 100644 --- a/command/v7/create_isolation_segment_command_test.go +++ b/command/v7/create_isolation_segment_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_org_command.go b/command/v7/create_org_command.go index f28156bac8f..5f8e7a4d071 100644 --- a/command/v7/create_org_command.go +++ b/command/v7/create_org_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreateOrgCommand struct { diff --git a/command/v7/create_org_command_test.go b/command/v7/create_org_command_test.go index e710b03fe42..ca78330f4c8 100644 --- a/command/v7/create_org_command_test.go +++ b/command/v7/create_org_command_test.go @@ -4,18 +4,18 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_org_quota_command.go b/command/v7/create_org_quota_command.go index fe34a1de228..5de0fc31b8c 100644 --- a/command/v7/create_org_quota_command.go +++ b/command/v7/create_org_quota_command.go @@ -1,25 +1,27 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" ) type CreateOrgQuotaCommand struct { BaseCommand - RequiredArgs flag.OrganizationQuota `positional-args:"yes"` - NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. (Default: unlimited)."` - PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans. (Default: disallowed)."` - PerProcessMemory flag.MemoryWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). (Default: unlimited)."` - TotalMemory flag.MemoryWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount. (Default: 0)."` - TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount. (Default: 0)."` - TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount. (Default: 0)."` - TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount. (Default: 0)."` - usage interface{} `usage:"CF_NAME create-org-quota ORG_QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS]"` - relatedCommands interface{} `related_commands:"create-org, org-quotas, set-org-quota"` + RequiredArgs flag.OrganizationQuota `positional-args:"yes"` + NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. (Default: unlimited)."` + PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans. (Default: disallowed)."` + PerProcessMemory flag.MegabytesWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). (Default: unlimited)."` + TotalMemory flag.MegabytesWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount. (Default: 0)."` + TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount. (Default: 0)."` + TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount. (Default: 0)."` + TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount. (Default: 0)."` + TotalLogVolume flag.BytesWithUnlimited `short:"l" description:"Total log volume per second all processes can have, in bytes (e.g. 128B, 4K, 1M). -1 represents an unlimited amount. (Default: -1)."` + + usage interface{} `usage:"CF_NAME create-org-quota ORG_QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS] [-l LOG_VOLUME]"` + relatedCommands interface{} `related_commands:"create-org, org-quotas, set-org-quota"` } func (cmd CreateOrgQuotaCommand) Execute(args []string) error { @@ -49,6 +51,7 @@ func (cmd CreateOrgQuotaCommand) Execute(args []string) error { TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), + TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), }) cmd.UI.DisplayWarnings(warnings) @@ -66,7 +69,15 @@ func (cmd CreateOrgQuotaCommand) Execute(args []string) error { return nil } -func convertMegabytesFlagToNullInt(flag flag.MemoryWithUnlimited) *types.NullInt { +func convertBytesFlagToNullInt(flag flag.BytesWithUnlimited) *types.NullInt { + if !flag.IsSet { + return nil + } + + return &types.NullInt{IsSet: true, Value: flag.Value} +} + +func convertMegabytesFlagToNullInt(flag flag.MegabytesWithUnlimited) *types.NullInt { if !flag.IsSet { return nil } diff --git a/command/v7/create_org_quota_command_test.go b/command/v7/create_org_quota_command_test.go index d8f66f51fdd..9acd82fbd5a 100644 --- a/command/v7/create_org_quota_command_test.go +++ b/command/v7/create_org_quota_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -52,7 +52,6 @@ var _ = Describe("create-org-quota Command", func() { }) JustBeforeEach(func() { - executeErr = cmd.Execute(nil) }) @@ -105,11 +104,12 @@ var _ = Describe("create-org-quota Command", func() { BeforeEach(func() { cmd.PaidServicePlans = true cmd.NumAppInstances = flag.IntegerLimit{IsSet: true, Value: 10} - cmd.PerProcessMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 9} - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 2048} + cmd.PerProcessMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 9} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 2048} cmd.TotalRoutes = flag.IntegerLimit{IsSet: true, Value: 7} cmd.TotalReservedPorts = flag.IntegerLimit{IsSet: true, Value: 1} cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 2} + cmd.TotalLogVolume = flag.BytesWithUnlimited{IsSet: true, Value: 8} fakeActor.CreateOrganizationQuotaReturns( v7action.Warnings{"warning"}, nil) @@ -142,6 +142,9 @@ var _ = Describe("create-org-quota Command", func() { Expect(quotaLimits.TotalServiceInstances.IsSet).To(Equal(true)) Expect(quotaLimits.TotalServiceInstances.Value).To(Equal(2)) + Expect(quotaLimits.TotalLogVolume.IsSet).To(Equal(true)) + Expect(quotaLimits.TotalLogVolume.Value).To(Equal(8)) + Expect(testUI.Out).To(Say("Creating org quota %s as bob...", orgQuotaName)) Expect(testUI.Out).To(Say("OK")) }) diff --git a/command/v7/create_package_command.go b/command/v7/create_package_command.go index 47f6d2ff284..ff7736143a3 100644 --- a/command/v7/create_package_command.go +++ b/command/v7/create_package_command.go @@ -1,12 +1,12 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type CreatePackageCommand struct { diff --git a/command/v7/create_package_command_test.go b/command/v7/create_package_command_test.go index 24dabe17479..798b52a988f 100644 --- a/command/v7/create_package_command_test.go +++ b/command/v7/create_package_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_private_domain_command.go b/command/v7/create_private_domain_command.go index a0cbe7b4818..f648dd61a6c 100644 --- a/command/v7/create_private_domain_command.go +++ b/command/v7/create_private_domain_command.go @@ -1,7 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "fmt" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreatePrivateDomainCommand struct { @@ -34,8 +37,17 @@ func (cmd CreatePrivateDomainCommand) Execute(args []string) error { }) warnings, err := cmd.Actor.CreatePrivateDomain(domain, orgName) + cmd.UI.DisplayWarnings(warnings) if err != nil { + if e, ok := err.(ccerror.UnprocessableEntityError); ok { + inUse := fmt.Sprintf("The domain name \"%s\" is already in use", domain) + if e.Message == inUse { + cmd.UI.DisplayWarning(err.Error()) + cmd.UI.DisplayOK() + return nil + } + } return err } diff --git a/command/v7/create_private_domain_command_test.go b/command/v7/create_private_domain_command_test.go index 68f2fd6448d..405f6adc91a 100644 --- a/command/v7/create_private_domain_command_test.go +++ b/command/v7/create_private_domain_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_route_command.go b/command/v7/create_route_command.go index 7d6fc07e6bd..3baca71de9a 100644 --- a/command/v7/create_route_command.go +++ b/command/v7/create_route_command.go @@ -3,19 +3,42 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreateRouteCommand struct { BaseCommand RequiredArgs flag.Domain `positional-args:"yes"` - usage interface{} `usage:"Create an HTTP route:\n CF_NAME create-route DOMAIN [--hostname HOSTNAME] [--path PATH]\n\n Create a TCP route:\n CF_NAME create-route DOMAIN [--port PORT]\n\nEXAMPLES:\n CF_NAME create-route example.com # example.com\n CF_NAME create-route example.com --hostname myapp # myapp.example.com\n CF_NAME create-route example.com --hostname myapp --path foo # myapp.example.com/foo\n CF_NAME create-route example.com --port 5000 # example.com:5000"` Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` Port int `long:"port" description:"Port for the TCP route (default: random port)"` - relatedCommands interface{} `related_commands:"check-route, domains, map-route, routes, unmap-route"` + Options []string `long:"option" short:"o" description:"Set the value of a per-route option"` + relatedCommands interface{} `related_commands:"check-route, update-route, domains, map-route, routes, unmap-route"` +} + +func (cmd CreateRouteCommand) Usage() string { + return ` +Create an HTTP route: + CF_NAME create-route DOMAIN [--hostname HOSTNAME] [--path PATH] [--option OPTION=VALUE] + +Create a TCP route: + CF_NAME create-route DOMAIN [--port PORT] [--option OPTION=VALUE]` +} + +func (cmd CreateRouteCommand) Examples() string { + return ` +CF_NAME create-route example.com # example.com +CF_NAME create-route example.com --hostname myapp # myapp.example.com +CF_NAME create-route example.com --hostname myapp --path foo # myapp.example.com/foo +CF_NAME create-route example.com --port 5000 # example.com:5000 +CF_NAME create-route example.com --hostname myapp -o loadbalancing=least-connection # myapp.example.com with a per-route option +` } func (cmd CreateRouteCommand) Execute(args []string) error { @@ -46,7 +69,20 @@ func (cmd CreateRouteCommand) Execute(args []string) error { "Organization": orgName, }) - route, warnings, err := cmd.Actor.CreateRoute(spaceGUID, domain, hostname, pathName, port) + var routeOptions map[string]*string + if len(cmd.Options) > 0 && cmd.validateAPIVersionForPerRouteOptions() == nil { + var wrongOptSpec *string + routeOptions, wrongOptSpec = resources.CreateRouteOptions(cmd.Options) + if wrongOptSpec != nil { + return actionerror.RouteOptionError{ + Name: *wrongOptSpec, + DomainName: domain, + Path: pathName, + Host: hostname, + } + } + } + route, warnings, err := cmd.Actor.CreateRoute(spaceGUID, domain, hostname, pathName, port, routeOptions) cmd.UI.DisplayWarnings(warnings) if err != nil { @@ -86,3 +122,14 @@ func desiredURL(domain, hostname, path string, port int) string { return url } + +func (cmd CreateRouteCommand) validateAPIVersionForPerRouteOptions() error { + err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionPerRouteOpts) + if err != nil { + cmd.UI.DisplayWarning("Your CC API version ({{.APIVersion}}) does not support per-route options. Those will be ignored. Upgrade to a newer version of the API (minimum version {{.MinSupportedVersion}}).", map[string]interface{}{ + "APIVersion": cmd.Config.APIVersion(), + "MinSupportedVersion": ccversion.MinVersionPerRouteOpts, + }) + } + return err +} diff --git a/command/v7/create_route_command_test.go b/command/v7/create_route_command_test.go index b53f14758d9..db3cca6b3a7 100644 --- a/command/v7/create_route_command_test.go +++ b/command/v7/create_route_command_test.go @@ -3,18 +3,20 @@ package v7_test import ( "errors" "fmt" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "strconv" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -29,19 +31,23 @@ var _ = Describe("create-route Command", func() { executeErr error - binaryName string - domainName string - spaceName string - spaceGUID string - orgName string - hostname string - path string - port int + binaryName string + domainName string + spaceName string + spaceGUID string + orgName string + hostname string + path string + port int + cmdOptions []string + options map[string]*string + cCAPIOldVersion string ) BeforeEach(func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns(ccversion.MinVersionPerRouteOpts) fakeSharedActor = new(commandfakes.FakeSharedActor) fakeActor = new(v7fakes.FakeActor) @@ -53,6 +59,11 @@ var _ = Describe("create-route Command", func() { path = "" port = 0 + cmdOptions = []string{"loadbalancing=least-connection"} + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + options = map[string]*string{"loadbalancing": lbLeastConnections} + binaryName = "faceman" fakeConfig.BinaryNameReturns(binaryName) }) @@ -65,6 +76,7 @@ var _ = Describe("create-route Command", func() { Hostname: hostname, Path: flag.V7RoutePath{Path: path}, Port: port, + Options: cmdOptions, BaseCommand: BaseCommand{ UI: testUI, Config: fakeConfig, @@ -152,10 +164,36 @@ var _ = Describe("create-route Command", func() { }) }) + When("creating the route does not fail when the CC API version is too old for route options", func() { + BeforeEach(func() { + cCAPIOldVersion = strconv.Itoa(1) + fakeConfig.APIVersionReturns(cCAPIOldVersion) + }) + + It("does create a route and gives a warning message", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) + Expect(testUI.Err).To(Say("Your CC API")) + Expect(testUI.Err).To(Say("does not support per-route options")) + }) + }) + + When("creating the route fails when route options are specified incorrectly", func() { + BeforeEach(func() { + cmdOptions = []string{"loadbalancing"} + }) + + It("does not create a route and gives an error message", func() { + Expect(executeErr).To(MatchError(actionerror.RouteOptionError{Name: "loadbalancing", DomainName: domainName, Path: path, Host: hostname})) + Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) + }) + }) + When("creating the route is successful", func() { BeforeEach(func() { fakeActor.CreateRouteReturns(resources.Route{ - URL: domainName, + URL: domainName, + Options: options, }, v7action.Warnings{"warnings-1", "warnings-2"}, nil) }) @@ -167,12 +205,24 @@ var _ = Describe("create-route Command", func() { Expect(testUI.Out).To(Say("OK")) }) - It("creates the route", func() { - Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) - expectedSpaceGUID, expectedDomainName, expectedHostname, _, _ := fakeActor.CreateRouteArgsForCall(0) - Expect(expectedSpaceGUID).To(Equal(spaceGUID)) - Expect(expectedDomainName).To(Equal(domainName)) - Expect(expectedHostname).To(Equal(hostname)) + When("in a version of CAPI that does not support options", func() { + BeforeEach(func() { + fakeActor.CreateRouteReturns(resources.Route{ + URL: domainName, + }, v7action.Warnings{"warnings-1", "warnings-2"}, nil) + cmdOptions = []string{} + cCAPIOldVersion = strconv.Itoa(1) + fakeConfig.APIVersionReturns(cCAPIOldVersion) + }) + + It("creates the route when no options are provided", func() { + Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) + expectedSpaceGUID, expectedDomainName, expectedHostname, _, _, expectedOptions := fakeActor.CreateRouteArgsForCall(0) + Expect(expectedSpaceGUID).To(Equal(spaceGUID)) + Expect(expectedDomainName).To(Equal(domainName)) + Expect(expectedHostname).To(Equal(hostname)) + Expect(expectedOptions).To(BeNil()) + }) }) When("passing in a hostname", func() { @@ -194,7 +244,7 @@ var _ = Describe("create-route Command", func() { It("creates the route", func() { Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) - expectedSpaceGUID, expectedDomainName, expectedHostname, _, _ := fakeActor.CreateRouteArgsForCall(0) + expectedSpaceGUID, expectedDomainName, expectedHostname, _, _, _ := fakeActor.CreateRouteArgsForCall(0) Expect(expectedSpaceGUID).To(Equal(spaceGUID)) Expect(expectedDomainName).To(Equal(domainName)) Expect(expectedHostname).To(Equal(hostname)) @@ -220,11 +270,12 @@ var _ = Describe("create-route Command", func() { It("calls the actor with the correct arguments", func() { Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) - expectedSpaceGUID, expectedDomainName, expectedHostname, _, expectedPort := fakeActor.CreateRouteArgsForCall(0) + expectedSpaceGUID, expectedDomainName, expectedHostname, _, expectedPort, expectedOptions := fakeActor.CreateRouteArgsForCall(0) Expect(expectedSpaceGUID).To(Equal(spaceGUID)) Expect(expectedDomainName).To(Equal(domainName)) Expect(expectedHostname).To(Equal(hostname)) Expect(expectedPort).To(Equal(port)) + Expect(expectedOptions).To(Equal(options)) }) }) }) diff --git a/command/v7/create_security_group_command.go b/command/v7/create_security_group_command.go index 7c1f29c4b76..57764cce5e2 100644 --- a/command/v7/create_security_group_command.go +++ b/command/v7/create_security_group_command.go @@ -3,9 +3,9 @@ package v7 import ( "encoding/json" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreateSecurityGroupCommand struct { diff --git a/command/v7/create_security_group_command_test.go b/command/v7/create_security_group_command_test.go index 51b23f27e4b..ac08c731824 100644 --- a/command/v7/create_security_group_command_test.go +++ b/command/v7/create_security_group_command_test.go @@ -5,16 +5,16 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_service_broker_command.go b/command/v7/create_service_broker_command.go index 0fbd44c5f69..267794e611f 100644 --- a/command/v7/create_service_broker_command.go +++ b/command/v7/create_service_broker_command.go @@ -1,18 +1,26 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" + "os" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type CreateServiceBrokerCommand struct { BaseCommand - RequiredArgs flag.ServiceBrokerArgs `positional-args:"yes"` + PositionalArgs flag.ServiceBrokerArgs `positional-args:"yes"` SpaceScoped bool `long:"space-scoped" description:"Make the broker's service plans only visible within the targeted space"` - usage interface{} `usage:"CF_NAME create-service-broker SERVICE_BROKER USERNAME PASSWORD URL [--space-scoped]"` - relatedCommands interface{} `related_commands:"enable-service-access, service-brokers, target"` + UpdateIfExists bool `long:"update-if-exists" description:"If the broker already exists, update it rather than failing. Ignores --space-scoped."` + usage any `usage:"CF_NAME create-service-broker SERVICE_BROKER USERNAME PASSWORD URL [--space-scoped]\n CF_NAME create-service-broker SERVICE_BROKER USERNAME URL [--space-scoped] (omit password to specify interactively or via environment variable)\n\nWARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history"` + relatedCommands any `related_commands:"enable-service-access, service-brokers, target"` + + // This field is not used, it is only present to ensure we print the description as part of the usage of the command + envPassword any `environmentName:"CF_BROKER_PASSWORD" environmentDescription:"Password associated with user. Overridden if PASSWORD argument is provided" environmentDefault:"password"` //nolint:unused } func (cmd *CreateServiceBrokerCommand) Execute(args []string) error { @@ -21,19 +29,36 @@ func (cmd *CreateServiceBrokerCommand) Execute(args []string) error { return err } + brokerName, username, password, url, err := promptUserForBrokerPasswordIfRequired(cmd.PositionalArgs, cmd.UI) + if err != nil { + return err + } + user, err := cmd.Actor.GetCurrentUser() if err != nil { return err } + if cmd.UpdateIfExists { + serviceBroker, warnings, err := cmd.Actor.GetServiceBrokerByName(brokerName) + cmd.UI.DisplayWarnings(warnings) + switch err.(type) { + case nil: + return updateServiceBroker(cmd.UI, cmd.Actor, user.Name, serviceBroker.GUID, brokerName, username, password, url) + case actionerror.ServiceBrokerNotFoundError: // do nothing + default: + return err + } + } + var space configv3.Space if cmd.SpaceScoped { space = cmd.Config.TargetedSpace() cmd.UI.DisplayTextWithFlavor( "Creating service broker {{.ServiceBroker}} in org {{.Org}} / space {{.Space}} as {{.Username}}...", - map[string]interface{}{ + map[string]any{ "Username": user.Name, - "ServiceBroker": cmd.RequiredArgs.ServiceBroker, + "ServiceBroker": brokerName, "Org": cmd.Config.TargetedOrganizationName(), "Space": space.Name, }, @@ -41,19 +66,19 @@ func (cmd *CreateServiceBrokerCommand) Execute(args []string) error { } else { cmd.UI.DisplayTextWithFlavor( "Creating service broker {{.ServiceBroker}} as {{.Username}}...", - map[string]interface{}{ + map[string]any{ "Username": user.Name, - "ServiceBroker": cmd.RequiredArgs.ServiceBroker, + "ServiceBroker": brokerName, }, ) } warnings, err := cmd.Actor.CreateServiceBroker( resources.ServiceBroker{ - Name: cmd.RequiredArgs.ServiceBroker, - Username: cmd.RequiredArgs.Username, - Password: cmd.RequiredArgs.Password, - URL: cmd.RequiredArgs.URL, + Name: brokerName, + Username: username, + Password: password, + URL: url, SpaceGUID: space.GUID, }, ) @@ -65,3 +90,20 @@ func (cmd *CreateServiceBrokerCommand) Execute(args []string) error { cmd.UI.DisplayOK() return nil } + +func promptUserForBrokerPasswordIfRequired(args flag.ServiceBrokerArgs, ui command.UI) (string, string, string, string, error) { + if args.URL != "" { + return args.ServiceBroker, args.Username, args.PasswordOrURL, args.URL, nil + } + + if password, ok := os.LookupEnv("CF_BROKER_PASSWORD"); ok { + return args.ServiceBroker, args.Username, password, args.PasswordOrURL, nil + } + + password, err := ui.DisplayPasswordPrompt("Service Broker Password") + if err != nil { + return "", "", "", "", err + } + + return args.ServiceBroker, args.Username, password, args.PasswordOrURL, nil +} diff --git a/command/v7/create_service_broker_command_test.go b/command/v7/create_service_broker_command_test.go index f19175c3779..7673c620d31 100644 --- a/command/v7/create_service_broker_command_test.go +++ b/command/v7/create_service_broker_command_test.go @@ -2,19 +2,32 @@ package v7_test import ( "errors" + "fmt" + "os" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) var _ = Describe("create-service-broker Command", func() { + const ( + binaryName = "cf-command" + user = "steve" + serviceBrokerName = "fake-service-broker-name" + username = "fake-username" + password = "fake-password" + url = "fake-url" + ) + var ( cmd *v7.CreateServiceBrokerCommand testUI *ui.UI @@ -22,7 +35,6 @@ var _ = Describe("create-service-broker Command", func() { fakeSharedActor *commandfakes.FakeSharedActor fakeActor *v7fakes.FakeActor input *Buffer - binaryName string executeErr error ) @@ -34,7 +46,6 @@ var _ = Describe("create-service-broker Command", func() { fakeActor = new(v7fakes.FakeActor) fakeActor.CreateServiceBrokerReturns(v7action.Warnings{"some default warning"}, nil) - binaryName = "faceman" fakeConfig.BinaryNameReturns(binaryName) cmd = &v7.CreateServiceBrokerCommand{ @@ -45,8 +56,6 @@ var _ = Describe("create-service-broker Command", func() { Actor: fakeActor, }, } - - setPositionalFlags(cmd, "service-broker-name", "username", "password", "https://example.org/super-broker") }) JustBeforeEach(func() { @@ -66,6 +75,7 @@ var _ = Describe("create-service-broker Command", func() { When("fetching the current user fails", func() { BeforeEach(func() { fakeActor.GetCurrentUserReturns(configv3.User{}, errors.New("an error occurred")) + setPositionalFlags(cmd, serviceBrokerName, username, password, url) }) It("return an error", func() { @@ -75,7 +85,8 @@ var _ = Describe("create-service-broker Command", func() { When("fetching the current user succeeds", func() { BeforeEach(func() { - fakeActor.GetCurrentUserReturns(configv3.User{Name: "steve"}, nil) + fakeActor.GetCurrentUserReturns(configv3.User{Name: user}, nil) + setPositionalFlags(cmd, serviceBrokerName, username, password, url) }) It("checks that there is a valid target", func() { @@ -86,7 +97,7 @@ var _ = Describe("create-service-broker Command", func() { }) It("displays a message with the username", func() { - Expect(testUI.Out).To(Say(`Creating service broker %s as %s\.\.\.`, "service-broker-name", "steve")) + Expect(testUI.Out).To(Say(`Creating service broker %s as %s\.\.\.`, serviceBrokerName, user)) }) It("passes the data to the actor layer", func() { @@ -94,10 +105,10 @@ var _ = Describe("create-service-broker Command", func() { model := fakeActor.CreateServiceBrokerArgsForCall(0) - Expect(model.Name).To(Equal("service-broker-name")) - Expect(model.Username).To(Equal("username")) - Expect(model.Password).To(Equal("password")) - Expect(model.URL).To(Equal("https://example.org/super-broker")) + Expect(model.Name).To(Equal(serviceBrokerName)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(password)) + Expect(model.URL).To(Equal(url)) Expect(model.SpaceGUID).To(Equal("")) }) @@ -122,13 +133,19 @@ var _ = Describe("create-service-broker Command", func() { }) When("creating a space scoped broker", func() { + const ( + orgName = "fake-org-name" + spaceName = "fake-space-name" + spaceGUID = "fake-space-guid" + ) + BeforeEach(func() { cmd.SpaceScoped = true fakeConfig.TargetedSpaceReturns(configv3.Space{ - Name: "fake-space-name", - GUID: "fake-space-guid", + Name: spaceName, + GUID: spaceGUID, }) - fakeConfig.TargetedOrganizationNameReturns("fake-org-name") + fakeConfig.TargetedOrganizationNameReturns(orgName) }) It("checks that a space is targeted", func() { @@ -139,14 +156,129 @@ var _ = Describe("create-service-broker Command", func() { }) It("displays the space name in the message", func() { - Expect(testUI.Out).To(Say(`Creating service broker %s in org %s / space %s as %s\.\.\.`, "service-broker-name", "fake-org-name", "fake-space-name", "steve")) + Expect(testUI.Out).To(Say(`Creating service broker %s in org %s / space %s as %s\.\.\.`, serviceBrokerName, orgName, spaceName, user)) }) It("looks up the space guid and passes it to the actor", func() { Expect(fakeActor.CreateServiceBrokerCallCount()).To(Equal(1)) model := fakeActor.CreateServiceBrokerArgsForCall(0) - Expect(model.SpaceGUID).To(Equal("fake-space-guid")) + Expect(model.SpaceGUID).To(Equal(spaceGUID)) + }) + }) + }) + + When("password is provided as environment variable", func() { + const ( + varName = "CF_BROKER_PASSWORD" + varPassword = "var-password" + ) + + BeforeEach(func() { + setPositionalFlags(cmd, serviceBrokerName, username, url, "") + os.Setenv(varName, varPassword) + }) + + AfterEach(func() { + os.Unsetenv(varName) + }) + + It("passes the data to the actor layer", func() { + Expect(fakeActor.CreateServiceBrokerCallCount()).To(Equal(1)) + + model := fakeActor.CreateServiceBrokerArgsForCall(0) + + Expect(model.Name).To(Equal(serviceBrokerName)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(varPassword)) + Expect(model.URL).To(Equal(url)) + Expect(model.SpaceGUID).To(Equal("")) + }) + }) + + When("password is provided via prompt", func() { + const promptPassword = "prompt-password" + + BeforeEach(func() { + setPositionalFlags(cmd, serviceBrokerName, username, url, "") + + _, err := input.Write([]byte(fmt.Sprintf("%s\n", promptPassword))) + Expect(err).NotTo(HaveOccurred()) + }) + + It("prompts the user for credentials", func() { + Expect(testUI.Out).To(Say("Service Broker Password: ")) + }) + + It("does not echo the credentials", func() { + Expect(testUI.Out).NotTo(Say(promptPassword)) + Expect(testUI.Err).NotTo(Say(promptPassword)) + }) + + It("passes the data to the actor layer", func() { + Expect(fakeActor.CreateServiceBrokerCallCount()).To(Equal(1)) + + model := fakeActor.CreateServiceBrokerArgsForCall(0) + + Expect(model.Name).To(Equal(serviceBrokerName)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(promptPassword)) + Expect(model.URL).To(Equal(url)) + Expect(model.SpaceGUID).To(Equal("")) + }) + }) + + When("the --update-if-exists flag is used", func() { + BeforeEach(func() { + setPositionalFlags(cmd, serviceBrokerName, username, password, url) + setFlag(cmd, "--update-if-exists") + }) + + Context("and the broker does not exist", func() { + BeforeEach(func() { + fakeActor.GetServiceBrokerByNameReturns(resources.ServiceBroker{}, v7action.Warnings{}, actionerror.ServiceBrokerNotFoundError{}) + }) + + It("checks to see whether the broker exists", func() { + Expect(fakeActor.GetServiceBrokerByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetServiceBrokerByNameArgsForCall(0)).To(Equal(serviceBrokerName)) + }) + + It("creates a new service broker", func() { + Expect(fakeActor.CreateServiceBrokerCallCount()).To(Equal(1)) + + model := fakeActor.CreateServiceBrokerArgsForCall(0) + + Expect(model.Name).To(Equal(serviceBrokerName)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(password)) + Expect(model.URL).To(Equal(url)) + Expect(model.SpaceGUID).To(Equal("")) + }) + }) + + Context("and the broker already exists", func() { + const brokerGUID = "fake-broker-guid" + + BeforeEach(func() { + fakeActor.GetServiceBrokerByNameReturns(resources.ServiceBroker{GUID: brokerGUID}, v7action.Warnings{}, nil) + }) + + It("checks to see whether the broker exists", func() { + Expect(fakeActor.GetServiceBrokerByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetServiceBrokerByNameArgsForCall(0)).To(Equal(serviceBrokerName)) + }) + + It("updates an existing service broker", func() { + Expect(fakeActor.UpdateServiceBrokerCallCount()).To(Equal(1)) + + guid, model := fakeActor.UpdateServiceBrokerArgsForCall(0) + + Expect(guid).To(Equal(brokerGUID)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(password)) + Expect(model.URL).To(Equal(url)) + Expect(model.SpaceGUID).To(Equal("")) }) }) }) diff --git a/command/v7/create_service_command.go b/command/v7/create_service_command.go index ee10e723bba..34fa0829cdb 100644 --- a/command/v7/create_service_command.go +++ b/command/v7/create_service_command.go @@ -3,11 +3,11 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/types" ) type CreateServiceCommand struct { diff --git a/command/v7/create_service_command_test.go b/command/v7/create_service_command_test.go index 1deddb8d440..631955faca3 100644 --- a/command/v7/create_service_command_test.go +++ b/command/v7/create_service_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_service_key_command.go b/command/v7/create_service_key_command.go index 34bfba0542d..36f1381fd56 100644 --- a/command/v7/create_service_key_command.go +++ b/command/v7/create_service_key_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/types" ) type CreateServiceKeyCommand struct { diff --git a/command/v7/create_service_key_command_test.go b/command/v7/create_service_key_command_test.go index 83363defefa..4982956d8cb 100644 --- a/command/v7/create_service_key_command_test.go +++ b/command/v7/create_service_key_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_shared_domain_command.go b/command/v7/create_shared_domain_command.go index feb9940e213..2af8e50d5c8 100644 --- a/command/v7/create_shared_domain_command.go +++ b/command/v7/create_shared_domain_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreateSharedDomainCommand struct { diff --git a/command/v7/create_shared_domain_command_test.go b/command/v7/create_shared_domain_command_test.go index 9484348694d..f3f71f87372 100644 --- a/command/v7/create_shared_domain_command_test.go +++ b/command/v7/create_shared_domain_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_space_command.go b/command/v7/create_space_command.go index dd8b85dd7ba..196a7e8e2a2 100644 --- a/command/v7/create_space_command.go +++ b/command/v7/create_space_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type CreateSpaceActor interface { diff --git a/command/v7/create_space_command_test.go b/command/v7/create_space_command_test.go index d11c05f044f..261c467f1e9 100644 --- a/command/v7/create_space_command_test.go +++ b/command/v7/create_space_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_space_quota_command.go b/command/v7/create_space_quota_command.go index 892d04675e7..123cfa176b4 100644 --- a/command/v7/create_space_quota_command.go +++ b/command/v7/create_space_quota_command.go @@ -1,24 +1,26 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type CreateSpaceQuotaCommand struct { BaseCommand - RequiredArgs flag.SpaceQuota `positional-args:"yes"` - NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. (Default: unlimited)."` - PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans. (Default: disallowed)."` - PerProcessMemory flag.MemoryWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). (Default: unlimited)."` - TotalMemory flag.MemoryWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount. (Default: 0)."` - TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount. (Default: 0)."` - TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount. (Default: 0)."` - TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount. (Default: 0)."` - usage interface{} `usage:"CF_NAME create-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS]"` - relatedCommands interface{} `related_commands:"create-space, space-quotas, set-space-quota"` + RequiredArgs flag.SpaceQuota `positional-args:"yes"` + NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. (Default: unlimited)."` + PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans. (Default: disallowed)."` + PerProcessMemory flag.MegabytesWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). (Default: unlimited)."` + TotalMemory flag.MegabytesWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount. (Default: 0)."` + TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount. (Default: 0)."` + TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount. (Default: 0)."` + TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount. (Default: 0)."` + TotalLogVolume flag.BytesWithUnlimited `short:"l" description:"Total log volume per second all processes can have, in bytes (e.g. 128B, 4K, 1M). -1 represents an unlimited amount. (Default: -1)."` + + usage interface{} `usage:"CF_NAME create-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS] [-l LOG_VOLUME]"` + relatedCommands interface{} `related_commands:"create-space, space-quotas, set-space-quota"` } func (cmd CreateSpaceQuotaCommand) Execute([]string) error { @@ -49,6 +51,7 @@ func (cmd CreateSpaceQuotaCommand) Execute([]string) error { TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), + TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), }, ) diff --git a/command/v7/create_space_quota_command_test.go b/command/v7/create_space_quota_command_test.go index 6e94f2cb402..1e895060a20 100644 --- a/command/v7/create_space_quota_command_test.go +++ b/command/v7/create_space_quota_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -135,13 +135,14 @@ var _ = Describe("create-space-quota Command", func() { When("all flag limits are given", func() { BeforeEach(func() { - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 47} - cmd.PerProcessMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 23} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 47} + cmd.PerProcessMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 23} cmd.NumAppInstances = flag.IntegerLimit{IsSet: true, Value: 4} cmd.PaidServicePlans = true cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 9} cmd.TotalRoutes = flag.IntegerLimit{IsSet: true, Value: 1} cmd.TotalReservedPorts = flag.IntegerLimit{IsSet: true, Value: 7} + cmd.TotalLogVolume = flag.BytesWithUnlimited{IsSet: true, Value: 512} fakeActor.CreateSpaceQuotaReturns( v7action.Warnings{"warnings-1", "warnings-2"}, @@ -163,6 +164,7 @@ var _ = Describe("create-space-quota Command", func() { TotalServiceInstances: &types.NullInt{IsSet: true, Value: 9}, TotalRoutes: &types.NullInt{IsSet: true, Value: 1}, TotalReservedPorts: &types.NullInt{IsSet: true, Value: 7}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 512}, })) }) diff --git a/command/v7/create_user_command.go b/command/v7/create_user_command.go index c3647bc3daf..54d83834b82 100644 --- a/command/v7/create_user_command.go +++ b/command/v7/create_user_command.go @@ -3,10 +3,10 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type CreateUserCommand struct { diff --git a/command/v7/create_user_command_test.go b/command/v7/create_user_command_test.go index f60b5e7ff39..493c400e72a 100644 --- a/command/v7/create_user_command_test.go +++ b/command/v7/create_user_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/create_user_provided_service_command.go b/command/v7/create_user_provided_service_command.go index c0cc5e5083b..0c9512ffb7d 100644 --- a/command/v7/create_user_provided_service_command.go +++ b/command/v7/create_user_provided_service_command.go @@ -1,10 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type CreateUserProvidedServiceCommand struct { @@ -24,7 +25,7 @@ func (cmd CreateUserProvidedServiceCommand) Execute(args []string) error { return err } - if err := PromptUserForCredentialsIfRequired(&cmd.Credentials, cmd.UI); err != nil { + if err := promptUserForCredentialsIfRequired(&cmd.Credentials, cmd.UI); err != nil { return err } @@ -43,7 +44,16 @@ func (cmd CreateUserProvidedServiceCommand) Execute(args []string) error { warnings, err := cmd.Actor.CreateUserProvidedServiceInstance(serviceInstance) cmd.UI.DisplayWarnings(warnings) - if err != nil { + switch err.(type) { + case nil: + case ccerror.ServiceInstanceNameTakenError: + cmd.UI.DisplayTextWithFlavor("Service instance {{.ServiceInstanceName}} already exists", + map[string]interface{}{ + "ServiceInstanceName": serviceInstance.Name, + }) + cmd.UI.DisplayOK() + return nil + default: return err } @@ -69,7 +79,7 @@ func (cmd CreateUserProvidedServiceCommand) displayMessage() error { return nil } -func PromptUserForCredentialsIfRequired(flag *flag.CredentialsOrJSON, ui command.UI) error { +func promptUserForCredentialsIfRequired(flag *flag.CredentialsOrJSON, ui command.UI) error { if len(flag.UserPromptCredentials) > 0 { flag.Value = make(map[string]interface{}) diff --git a/command/v7/create_user_provided_service_command_test.go b/command/v7/create_user_provided_service_command_test.go index 805649e3942..c759cf6d3b8 100644 --- a/command/v7/create_user_provided_service_command_test.go +++ b/command/v7/create_user_provided_service_command_test.go @@ -3,17 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -215,5 +216,20 @@ var _ = Describe("create-user-provided-service Command", func() { )) }) }) + + When("the service instance name is taken", func() { + BeforeEach(func() { + fakeActor.CreateUserProvidedServiceInstanceReturns( + nil, + ccerror.ServiceInstanceNameTakenError{}, + ) + }) + + It("succeeds, displaying warnings, 'OK' and an informative message", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(testUI.Out).To(Say("Service instance %s already exists", fakeServiceInstanceName)) + Expect(testUI.Out).To(Say("OK")) + }) + }) }) }) diff --git a/command/v7/curl_command.go b/command/v7/curl_command.go index bddc3cc421b..da7aa4e5735 100644 --- a/command/v7/curl_command.go +++ b/command/v7/curl_command.go @@ -1,24 +1,27 @@ package v7 import ( - "io/ioutil" + "bytes" + "net/http" "net/http/httputil" + "os" + "strings" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type CurlCommand struct { BaseCommand - RequiredArgs flag.APIPath `positional-args:"yes"` - CustomHeaders []string `short:"H" description:"Custom headers to include in the request, flag can be specified multiple times"` - HTTPMethod string `short:"X" description:"HTTP method (GET,POST,PUT,DELETE,etc)"` - HTTPData flag.PathWithAt `short:"d" description:"HTTP data to include in the request body, or '@' followed by a file name to read the data from"` - FailOnHTTPError bool `short:"f" long:"fail" description:"Server errors return exit code 22"` - IncludeReponseHeaders bool `short:"i" description:"Include response headers in the output"` - OutputFile flag.Path `long:"output" description:"Write curl body to FILE instead of stdout"` - usage interface{} `usage:"CF_NAME curl PATH [-iv] [-X METHOD] [-H HEADER]... [-d DATA] [--output FILE]\n\n By default 'CF_NAME curl' will perform a GET to the specified PATH. If data\n is provided via -d, a POST will be performed instead, and the Content-Type\n will be set to application/json. You may override headers with -H and the\n request method with -X.\n\n For API documentation, please visit http://apidocs.cloudfoundry.org.\n\nEXAMPLES:\n CF_NAME curl \"/v2/apps\" -X GET -H \"Content-Type: application/x-www-form-urlencoded\" -d 'q=name:myapp'\n CF_NAME curl \"/v2/apps\" -d @/path/to/file"` + RequiredArgs flag.APIPath `positional-args:"yes"` + CustomHeaders []string `short:"H" description:"Custom headers to include in the request, flag can be specified multiple times"` + HTTPMethod string `short:"X" description:"HTTP method (GET,POST,PUT,DELETE,etc)"` + HTTPData flag.PathWithAt `short:"d" description:"HTTP data to include in the request body, or '@' followed by a file name to read the data from"` + FailOnHTTPError bool `short:"f" long:"fail" description:"Server errors return exit code 22"` + IncludeResponseHeaders bool `short:"i" description:"Include response headers in the output"` + OutputFile flag.Path `long:"output" description:"Write curl body to FILE instead of stdout"` + usage interface{} `usage:"CF_NAME curl PATH [-iv] [-X METHOD] [-H HEADER]... [-d DATA] [--output FILE]\n\n By default 'CF_NAME curl' will perform a GET to the specified PATH. If data\n is provided via -d, a POST will be performed instead, and the Content-Type\n will be set to application/json. You may override headers with -H and the\n request method with -X.\n\n For API documentation, please visit http://v2-apidocs.cloudfoundry.org.\n\nEXAMPLES:\n CF_NAME curl \"/v2/apps\" -X GET -H \"Content-Type: application/x-www-form-urlencoded\" -d 'q=name:myapp'\n CF_NAME curl \"/v2/apps\" -d @/path/to/file"` } func (cmd CurlCommand) Execute(args []string) error { @@ -39,24 +42,53 @@ func (cmd CurlCommand) Execute(args []string) error { } var bytesToWrite []byte - - if cmd.IncludeReponseHeaders { - headerBytes, _ := httputil.DumpResponse(httpResponse, false) + var headerBytes []byte + if cmd.IncludeResponseHeaders && httpResponse != nil { + headerBytes, _ = httputil.DumpResponse(httpResponse, false) bytesToWrite = append(bytesToWrite, headerBytes...) } bytesToWrite = append(bytesToWrite, responseBodyBytes...) if cmd.OutputFile != "" { - err = ioutil.WriteFile(cmd.OutputFile.String(), bytesToWrite, 0666) + err = os.WriteFile(cmd.OutputFile.String(), bytesToWrite, 0666) if err != nil { return translatableerror.FileCreationError{Err: err} } cmd.UI.DisplayOK() + return nil + } + + // Check if the response contains binary data + if isBinary(httpResponse, responseBodyBytes) { + // For binary data, write response headers with string conversion + // and the response body without string conversion + if cmd.IncludeResponseHeaders { + cmd.UI.DisplayTextLiteral(string(headerBytes)) + } + cmd.UI.GetOut().Write(responseBodyBytes) } else { - cmd.UI.DisplayText(string(bytesToWrite)) + cmd.UI.DisplayTextLiteral(string(bytesToWrite)) } return nil } + +// isBinary determines if the provided `data` is likely binary content. +// It first checks if the given `contentType` (e.g., from an HTTP header) is a known binary MIME type. +// If not, it then scans the `data` byte slice for the presence of null bytes (0x00), +// which are a strong heuristic for binary data. +// Returns `true` if identified as binary, `false` otherwise. +func isBinary(response *http.Response, data []byte) bool { + responseContextType := "" + if response != nil && response.Header != nil { + responseContextType = response.Header.Get("Content-Type") + } + if strings.Contains(responseContextType, "image/") || + strings.Contains(responseContextType, "application/octet-stream") || + strings.Contains(responseContextType, "application/pdf") { + return true + } + return bytes.ContainsRune(data, 0x00) // Check for null byte +} diff --git a/command/v7/curl_command_test.go b/command/v7/curl_command_test.go index c76d76bc55a..0811cf6126c 100644 --- a/command/v7/curl_command_test.go +++ b/command/v7/curl_command_test.go @@ -2,17 +2,16 @@ package v7_test import ( "errors" - "io/ioutil" "net/http" "os" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -26,13 +25,13 @@ var _ = Describe("curl Command", func() { fakeActor *v7fakes.FakeActor binaryName string - CustomHeaders []string - HTTPMethod string - HTTPData flag.PathWithAt - FailOnHTTPError bool - IncludeReponseHeaders bool - OutputFile flag.Path - executeErr error + CustomHeaders []string + HTTPMethod string + HTTPData flag.PathWithAt + FailOnHTTPError bool + IncludeResponseHeaders bool + OutputFile flag.Path + executeErr error ) BeforeEach(func() { @@ -49,13 +48,13 @@ var _ = Describe("curl Command", func() { SharedActor: fakeSharedActor, Actor: fakeActor, }, - RequiredArgs: flag.APIPath{Path: "/"}, - CustomHeaders: CustomHeaders, - HTTPMethod: HTTPMethod, - HTTPData: HTTPData, - FailOnHTTPError: FailOnHTTPError, - IncludeReponseHeaders: IncludeReponseHeaders, - OutputFile: OutputFile, + RequiredArgs: flag.APIPath{Path: "/"}, + CustomHeaders: CustomHeaders, + HTTPMethod: HTTPMethod, + HTTPData: HTTPData, + FailOnHTTPError: FailOnHTTPError, + IncludeResponseHeaders: IncludeResponseHeaders, + OutputFile: OutputFile, } binaryName = "faceman" @@ -98,6 +97,17 @@ var _ = Describe("curl Command", func() { Expect(testUI.Out).To(Say("sarah, teal, and reid were here")) }) + When("the request contains double curly braces", func() { + BeforeEach(func() { + fakeActor.MakeCurlRequestReturns([]byte("{{ }}"), &http.Response{}, nil) + }) + + It("returns the literal text", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(testUI.Out).To(Say("{{ }}")) + }) + }) + When("the request errors", func() { BeforeEach(func() { fakeActor.MakeCurlRequestReturns([]byte{}, &http.Response{}, errors.New("this sucks")) @@ -110,7 +120,7 @@ var _ = Describe("curl Command", func() { When("an output file is given", func() { BeforeEach(func() { - outputFile, err := ioutil.TempFile("", "") + outputFile, err := os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) outputFileName := outputFile.Name() cmd.OutputFile = flag.Path(outputFileName) @@ -121,18 +131,18 @@ var _ = Describe("curl Command", func() { }) It("writes the output to the file", func() { - fileContents, err := ioutil.ReadFile(string(cmd.OutputFile)) + fileContents, err := os.ReadFile(string(cmd.OutputFile)) Expect(string(fileContents)).To(Equal("sarah, teal, and reid were here")) Expect(err).ToNot(HaveOccurred()) }) When("the include-response-headers flag is set", func() { BeforeEach(func() { - cmd.IncludeReponseHeaders = true + cmd.IncludeResponseHeaders = true }) It("includes the headers in the output", func() { - fileContents, err := ioutil.ReadFile(string(cmd.OutputFile)) + fileContents, err := os.ReadFile(string(cmd.OutputFile)) Expect(string(fileContents)).To(ContainSubstring("X-Name: athleisure")) Expect(string(fileContents)).To(ContainSubstring("sarah, teal, and reid were here")) Expect(err).ToNot(HaveOccurred()) @@ -150,4 +160,88 @@ var _ = Describe("curl Command", func() { }) }) + When("the response contains binary data", func() { + var binaryData []byte + + BeforeEach(func() { + // Create binary data with null bytes (like a droplet file) + binaryData = []byte{0x50, 0x4B, 0x03, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00} + fakeActor.MakeCurlRequestReturns(binaryData, &http.Response{ + Header: http.Header{ + "Content-Type": []string{"application/octet-stream"}, + }, + }, nil) + }) + + It("writes binary data directly to stdout without string conversion", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(testUI.Out).To(Say(string(binaryData))) + }) + + When("Content-Type is not a known binary MIME type", func() { + BeforeEach(func() { + // Create binary data with null bytes (like a droplet file) + binaryData = []byte{0x50, 0x4B, 0x03, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00} + fakeActor.MakeCurlRequestReturns(binaryData, &http.Response{ + Header: http.Header{ + "Content-Type": []string{"text/plain"}, + }, + }, nil) + }) + It("inspects the response data and writes binary data directly to stdout without string conversion", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(testUI.Out).To(Say(string(binaryData))) + }) + }) + + When("include-response-headers flag is set", func() { + BeforeEach(func() { + cmd.IncludeResponseHeaders = true + }) + + It("writes headers as text and binary data separately", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + // Check that headers are written as text (using DisplayTextLiteral) + Expect(testUI.Out).To(Say("Content-Type: application/octet-stream")) + + // Check that binary data is preserved + Expect(testUI.Out).To(Say(string(binaryData))) + }) + }) + + When("output file is specified", func() { + BeforeEach(func() { + outputFile, err := os.CreateTemp("", "binary-output") + Expect(err).NotTo(HaveOccurred()) + cmd.OutputFile = flag.Path(outputFile.Name()) + }) + + AfterEach(func() { + os.RemoveAll(string(cmd.OutputFile)) + }) + + It("writes binary data to the file correctly", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + fileContents, err := os.ReadFile(string(cmd.OutputFile)) + Expect(err).ToNot(HaveOccurred()) + Expect(fileContents).To(Equal(binaryData)) + }) + }) + }) + + When("the response is empty", func() { + BeforeEach(func() { + fakeActor.MakeCurlRequestReturns([]byte{}, &http.Response{ + Header: http.Header{}, + }, nil) + }) + + It("handles empty response correctly", func() { + Expect(executeErr).NotTo(HaveOccurred()) + Expect(testUI.Out).To(Say("")) + }) + }) + }) diff --git a/command/v7/delete_buildpack_command.go b/command/v7/delete_buildpack_command.go index c0d0e5f5717..580928a95d6 100644 --- a/command/v7/delete_buildpack_command.go +++ b/command/v7/delete_buildpack_command.go @@ -1,18 +1,21 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteBuildpackCommand struct { BaseCommand RequiredArgs flag.BuildpackName `positional-args:"yes"` - usage interface{} `usage:"CF_NAME delete-buildpack BUILDPACK [-f] [-s STACK]"` + usage interface{} `usage:"CF_NAME delete-buildpack BUILDPACK [-f] [-s STACK] [-l LIFECYCLE]"` relatedCommands interface{} `related_commands:"buildpacks"` Force bool `long:"force" short:"f" description:"Force deletion without confirmation"` Stack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name. Required when buildpack name is ambiguous"` + Lifecycle string `long:"lifecycle" short:"l" description:"Specify lifecycle to disambiguate buildpacks with the same name. Required when buildpack name is ambiguous"` } func (cmd DeleteBuildpackCommand) Execute(args []string) error { @@ -21,6 +24,13 @@ func (cmd DeleteBuildpackCommand) Execute(args []string) error { return err } + if cmd.Lifecycle != "" { + err = command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionBuildpackLifecycleQuery, "--lifecycle") + if err != nil { + return err + } + } + if !cmd.Force { response, uiErr := cmd.UI.DisplayBoolPrompt(false, "Really delete the {{.ModelType}} {{.ModelName}}?", map[string]interface{}{ "ModelType": "buildpack", @@ -36,33 +46,14 @@ func (cmd DeleteBuildpackCommand) Execute(args []string) error { } } - if cmd.Stack == "" { - cmd.UI.DisplayTextWithFlavor("Deleting buildpack {{.BuildpackName}}...", map[string]interface{}{ - "BuildpackName": cmd.RequiredArgs.Buildpack, - }) - - } else { - cmd.UI.DisplayTextWithFlavor("Deleting buildpack {{.BuildpackName}} with stack {{.Stack}}...", map[string]interface{}{ - "BuildpackName": cmd.RequiredArgs.Buildpack, - "Stack": cmd.Stack, - }) - } - warnings, err := cmd.Actor.DeleteBuildpackByNameAndStack(cmd.RequiredArgs.Buildpack, cmd.Stack) + cmd.displayBuildpackDeletingMessage() + warnings, err := cmd.Actor.DeleteBuildpackByNameAndStackAndLifecycle(cmd.RequiredArgs.Buildpack, cmd.Stack, cmd.Lifecycle) cmd.UI.DisplayWarnings(warnings) if err != nil { switch err.(type) { case actionerror.BuildpackNotFoundError: - if cmd.Stack == "" { - cmd.UI.DisplayWarning("Buildpack '{{.BuildpackName}}' does not exist.", map[string]interface{}{ - "BuildpackName": cmd.RequiredArgs.Buildpack, - }) - } else { - cmd.UI.DisplayWarning("Buildpack '{{.BuildpackName}}' with stack '{{.Stack}}' not found.", map[string]interface{}{ - "BuildpackName": cmd.RequiredArgs.Buildpack, - "Stack": cmd.Stack, - }) - } + cmd.displayBuildpackNotFoundWarning() default: return err } @@ -72,3 +63,42 @@ func (cmd DeleteBuildpackCommand) Execute(args []string) error { return nil } + +func (cmd DeleteBuildpackCommand) displayBuildpackNotFoundWarning() { + warning := "Buildpack '{{.BuildpackName}}'" + if cmd.Stack != "" { + warning += " with stack '{{.Stack}}'" + } + + if cmd.Lifecycle != "" { + warning += " with lifecycle '{{.Lifecycle}}'" + } + + if cmd.Stack != "" && cmd.Lifecycle != "" { + warning += " does not exist." + } else { + warning += " not found." + } + cmd.UI.DisplayWarning(warning, map[string]interface{}{ + "BuildpackName": cmd.RequiredArgs.Buildpack, + "Stack": cmd.Stack, + "Lifecycle": cmd.Lifecycle, + }) +} + +func (cmd DeleteBuildpackCommand) displayBuildpackDeletingMessage() { + message := "Deleting buildpack {{.BuildpackName}}" + if cmd.Stack != "" { + message += " with stack {{.Stack}}" + } + + if cmd.Lifecycle != "" { + message += " with lifecycle {{.Lifecycle}}" + } + + cmd.UI.DisplayTextWithFlavor(message+"...", map[string]interface{}{ + "BuildpackName": cmd.RequiredArgs.Buildpack, + "Stack": cmd.Stack, + "Lifecycle": cmd.Lifecycle, + }) +} diff --git a/command/v7/delete_buildpack_command_test.go b/command/v7/delete_buildpack_command_test.go index 674b410fd20..97fa2e4d665 100644 --- a/command/v7/delete_buildpack_command_test.go +++ b/command/v7/delete_buildpack_command_test.go @@ -3,13 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -32,6 +33,7 @@ var _ = Describe("delete-buildpack Command", func() { input = NewBuffer() fakeActor = new(v7fakes.FakeActor) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns("4.0.0") fakeSharedActor = new(commandfakes.FakeSharedActor) testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) @@ -50,6 +52,23 @@ var _ = Describe("delete-buildpack Command", func() { cmd.Force = true }) + When("--lifecyle is provided", func() { + JustBeforeEach(func() { + cmd.Lifecycle = "some-lifecycle" + fakeConfig.APIVersionReturns("3.193.0") + }) + It("fails when the cc version is below the minimum", func() { + executeErr = cmd.Execute(nil) + + Expect(executeErr).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--lifecycle", + CurrentVersion: "3.193.0", + MinimumVersion: "3.194.0", + })) + }) + + }) + When("checking target fails", func() { BeforeEach(func() { fakeSharedActor.CheckTargetReturns(actionerror.NotLoggedInError{BinaryName: binaryName}) @@ -69,7 +88,7 @@ var _ = Describe("delete-buildpack Command", func() { When("the DeleteBuildpack actor completes successfully", func() { BeforeEach(func() { - fakeActor.DeleteBuildpackByNameAndStackReturns(nil, nil) + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(nil, nil) }) JustBeforeEach(func() { executeErr = cmd.Execute(nil) @@ -137,12 +156,9 @@ var _ = Describe("delete-buildpack Command", func() { }) When("the buildpack does not exist", func() { - BeforeEach(func() { - fakeActor.DeleteBuildpackByNameAndStackReturns(v7action.Warnings{"a-warning"}, actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: "stack!"}) - }) - When("deleting with a stack", func() { BeforeEach(func() { + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: "stack!"}) cmd.Stack = "stack!" executeErr = cmd.Execute(nil) }) @@ -153,34 +169,65 @@ var _ = Describe("delete-buildpack Command", func() { }) }) - When("deleting without a stack", func() { + When("deleting with a lifecycle", func() { + BeforeEach(func() { + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, Lifecycle: "cnb"}) + cmd.Lifecycle = "cnb" + executeErr = cmd.Execute(nil) + }) + + It("prints warnings and helpful error message (that includes the lifecycle name)", func() { + Expect(testUI.Err).To(Say("a-warning")) + Expect(testUI.Err).To(Say(`Buildpack 'the-buildpack' with lifecycle 'cnb' not found\.`)) + }) + + }) + When("deleting with a stack and lifecycle", func() { + BeforeEach(func() { + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: "stack!", Lifecycle: "cnb"}) + cmd.Stack = "stack!" + cmd.Lifecycle = "cnb" + executeErr = cmd.Execute(nil) + }) + + It("prints warnings and helpful error message (that includes both names)", func() { + Expect(testUI.Err).To(Say("a-warning")) + Expect(testUI.Err).To(Say(`Buildpack 'the-buildpack' with stack 'stack!' with lifecycle 'cnb' does not exist\.`)) + }) + + }) + When("deleting without a stack or lifecycle", func() { BeforeEach(func() { + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, actionerror.BuildpackNotFoundError{BuildpackName: buildpackName}) cmd.Stack = "" + cmd.Lifecycle = "" executeErr = cmd.Execute(nil) }) It("prints warnings and helpful error message", func() { Expect(testUI.Err).To(Say("a-warning")) - Expect(testUI.Err).To(Say(`Buildpack 'the-buildpack' does not exist\.`)) + Expect(testUI.Err).To(Say(`Buildpack 'the-buildpack' not found\.`)) }) }) }) It("delegates to the actor", func() { cmd.Stack = "the-stack" - fakeActor.DeleteBuildpackByNameAndStackReturns(nil, nil) + cmd.Lifecycle = "cnb" + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(nil, nil) executeErr = cmd.Execute(nil) Expect(executeErr).ToNot(HaveOccurred()) - actualBuildpack, actualStack := fakeActor.DeleteBuildpackByNameAndStackArgsForCall(0) + actualBuildpack, actualStack, actualLifecycle := fakeActor.DeleteBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(actualBuildpack).To(Equal("the-buildpack")) Expect(actualStack).To(Equal("the-stack")) + Expect(actualLifecycle).To(Equal("cnb")) }) It("prints warnings", func() { cmd.Stack = "a-stack" - fakeActor.DeleteBuildpackByNameAndStackReturns(v7action.Warnings{"a-warning"}, nil) + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, nil) executeErr = cmd.Execute(nil) @@ -191,7 +238,7 @@ var _ = Describe("delete-buildpack Command", func() { It("returns error from the actor and prints the errors", func() { cmd.Stack = "a-stack" - fakeActor.DeleteBuildpackByNameAndStackReturns(v7action.Warnings{"a-warning"}, errors.New("some-error")) + fakeActor.DeleteBuildpackByNameAndStackAndLifecycleReturns(v7action.Warnings{"a-warning"}, errors.New("some-error")) executeErr = cmd.Execute(nil) diff --git a/command/v7/delete_command.go b/command/v7/delete_command.go index 23edea0b683..1767fe0ea6c 100644 --- a/command/v7/delete_command.go +++ b/command/v7/delete_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteCommand struct { diff --git a/command/v7/delete_command_test.go b/command/v7/delete_command_test.go index 880f2629aa3..baa83816c32 100644 --- a/command/v7/delete_command_test.go +++ b/command/v7/delete_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -227,7 +227,7 @@ var _ = Describe("delete Command", func() { fakeActor.DeleteApplicationByNameAndSpaceReturns(v7action.Warnings{"some-warning"}, errors.New("some-error")) }) - It("displays all warnings, and returns the erorr", func() { + It("displays all warnings, and returns the error", func() { Expect(testUI.Err).To(Say("some-warning")) Expect(testUI.Out).To(Say(`Deleting app some-app in org some-org / space some-space as steve\.\.\.`)) Expect(testUI.Out).ToNot(Say("OK")) diff --git a/command/v7/delete_isolation_segment_command.go b/command/v7/delete_isolation_segment_command.go index 4858cf110f3..dd68f5f0d94 100644 --- a/command/v7/delete_isolation_segment_command.go +++ b/command/v7/delete_isolation_segment_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteIsolationSegmentCommand struct { diff --git a/command/v7/delete_isolation_segment_command_test.go b/command/v7/delete_isolation_segment_command_test.go index 32f5d672085..655c36510e5 100644 --- a/command/v7/delete_isolation_segment_command_test.go +++ b/command/v7/delete_isolation_segment_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_org_command.go b/command/v7/delete_org_command.go index 33c38d99a11..79a8d9ad4b7 100644 --- a/command/v7/delete_org_command.go +++ b/command/v7/delete_org_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteOrgCommand struct { diff --git a/command/v7/delete_org_command_test.go b/command/v7/delete_org_command_test.go index 8895d0c15fc..45a29468a38 100644 --- a/command/v7/delete_org_command_test.go +++ b/command/v7/delete_org_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_org_quota_command.go b/command/v7/delete_org_quota_command.go index b3199feb326..4f41c3242d0 100644 --- a/command/v7/delete_org_quota_command.go +++ b/command/v7/delete_org_quota_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteOrgQuotaCommand struct { diff --git a/command/v7/delete_org_quota_command_test.go b/command/v7/delete_org_quota_command_test.go index b160cad6920..ca45f2db99a 100644 --- a/command/v7/delete_org_quota_command_test.go +++ b/command/v7/delete_org_quota_command_test.go @@ -1,15 +1,15 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_orphaned_routes_command.go b/command/v7/delete_orphaned_routes_command.go index 3e006d9e630..56b3c0358f6 100644 --- a/command/v7/delete_orphaned_routes_command.go +++ b/command/v7/delete_orphaned_routes_command.go @@ -5,7 +5,7 @@ type DeleteOrphanedRoutesCommand struct { usage interface{} `usage:"CF_NAME delete-orphaned-routes [-f]\n"` Force bool `short:"f" description:"Force deletion without confirmation"` - relatedCommands interface{} `related_commands:"delete-routes, routes"` + relatedCommands interface{} `related_commands:"delete-route, routes"` } func (cmd DeleteOrphanedRoutesCommand) Execute(args []string) error { diff --git a/command/v7/delete_orphaned_routes_command_test.go b/command/v7/delete_orphaned_routes_command_test.go index 8e32faa7d0b..dfe32013d9c 100644 --- a/command/v7/delete_orphaned_routes_command_test.go +++ b/command/v7/delete_orphaned_routes_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_private_domain_command.go b/command/v7/delete_private_domain_command.go index 52152a26516..4ef1bdcf3b6 100644 --- a/command/v7/delete_private_domain_command.go +++ b/command/v7/delete_private_domain_command.go @@ -3,8 +3,8 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeletePrivateDomainCommand struct { diff --git a/command/v7/delete_private_domain_command_test.go b/command/v7/delete_private_domain_command_test.go index d2bea0cffc8..1c290dd657d 100644 --- a/command/v7/delete_private_domain_command_test.go +++ b/command/v7/delete_private_domain_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_route_command.go b/command/v7/delete_route_command.go index 9b707dc8fba..50e1a5cc77b 100644 --- a/command/v7/delete_route_command.go +++ b/command/v7/delete_route_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteRouteCommand struct { diff --git a/command/v7/delete_route_command_test.go b/command/v7/delete_route_command_test.go index 3180ad7f0eb..229d388caa4 100644 --- a/command/v7/delete_route_command_test.go +++ b/command/v7/delete_route_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_security_group_command.go b/command/v7/delete_security_group_command.go index cc446096cbf..091ece45400 100644 --- a/command/v7/delete_security_group_command.go +++ b/command/v7/delete_security_group_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteSecurityGroupCommand struct { @@ -10,7 +10,7 @@ type DeleteSecurityGroupCommand struct { RequiredArgs flag.SecurityGroup `positional-args:"yes"` Force bool `long:"force" short:"f" description:"Force deletion without confirmation"` - usage interface{} `usage:"CF_NAME delete-security-group SECURITY_GROUP [-f]\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME delete-security-group SECURITY_GROUP [-f]\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"security-groups"` } @@ -64,7 +64,7 @@ func (cmd *DeleteSecurityGroupCommand) Execute(args []string) error { cmd.UI.DisplayOK() cmd.UI.DisplayNewline() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/delete_security_group_command_test.go b/command/v7/delete_security_group_command_test.go index 4c322dff253..510bf7a3568 100644 --- a/command/v7/delete_security_group_command_test.go +++ b/command/v7/delete_security_group_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_service_broker_command.go b/command/v7/delete_service_broker_command.go index 3a7206d55f4..5b33fa32860 100644 --- a/command/v7/delete_service_broker_command.go +++ b/command/v7/delete_service_broker_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteServiceBrokerCommand struct { diff --git a/command/v7/delete_service_broker_command_test.go b/command/v7/delete_service_broker_command_test.go index da7ab2fbc23..cfab3c7abd2 100644 --- a/command/v7/delete_service_broker_command_test.go +++ b/command/v7/delete_service_broker_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_service_command.go b/command/v7/delete_service_command.go index 670d5d8b34a..3a6749a69f2 100644 --- a/command/v7/delete_service_command.go +++ b/command/v7/delete_service_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type DeleteServiceCommand struct { diff --git a/command/v7/delete_service_command_test.go b/command/v7/delete_service_command_test.go index bb8efba7fb5..5bbefe52bdb 100644 --- a/command/v7/delete_service_command_test.go +++ b/command/v7/delete_service_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_service_key_command.go b/command/v7/delete_service_key_command.go index 52cec6cc8cd..ef22c839b39 100644 --- a/command/v7/delete_service_key_command.go +++ b/command/v7/delete_service_key_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type DeleteServiceKeyCommand struct { diff --git a/command/v7/delete_service_key_command_test.go b/command/v7/delete_service_key_command_test.go index f2d3ec7c885..4292f3365db 100644 --- a/command/v7/delete_service_key_command_test.go +++ b/command/v7/delete_service_key_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_shared_domain_command.go b/command/v7/delete_shared_domain_command.go index f0045f6c0c8..c8a3242d64a 100644 --- a/command/v7/delete_shared_domain_command.go +++ b/command/v7/delete_shared_domain_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type DeleteSharedDomainCommand struct { diff --git a/command/v7/delete_shared_domain_command_test.go b/command/v7/delete_shared_domain_command_test.go index 11bbfc3e846..5da0318c848 100644 --- a/command/v7/delete_shared_domain_command_test.go +++ b/command/v7/delete_shared_domain_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -212,7 +212,7 @@ var _ = Describe("delete-shared-domain Command", func() { fakeActor.DeleteDomainReturns(v7action.Warnings{"some-warning"}, errors.New("some-error")) }) - It("displays all warnings, and returns the erorr", func() { + It("displays all warnings, and returns the error", func() { Expect(testUI.Err).To(Say("some-warning")) Expect(testUI.Out).To(Say(`Deleting domain some-domain.com as steve\.\.\.`)) Expect(testUI.Out).ToNot(Say("OK")) diff --git a/command/v7/delete_space_command.go b/command/v7/delete_space_command.go index efc65de0e2b..67f60388f56 100644 --- a/command/v7/delete_space_command.go +++ b/command/v7/delete_space_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteSpaceCommand struct { diff --git a/command/v7/delete_space_command_test.go b/command/v7/delete_space_command_test.go index 455e544dbe9..d86abce9c0c 100644 --- a/command/v7/delete_space_command_test.go +++ b/command/v7/delete_space_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_space_quota_command.go b/command/v7/delete_space_quota_command.go index a12b9648a36..83ffe42c07f 100644 --- a/command/v7/delete_space_quota_command.go +++ b/command/v7/delete_space_quota_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteSpaceQuotaCommand struct { diff --git a/command/v7/delete_space_quota_command_test.go b/command/v7/delete_space_quota_command_test.go index 224deef5ee1..b1e8d1a2c57 100644 --- a/command/v7/delete_space_quota_command_test.go +++ b/command/v7/delete_space_quota_command_test.go @@ -1,15 +1,15 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/delete_user_command.go b/command/v7/delete_user_command.go index a4ca2975918..964f9bd2a0d 100644 --- a/command/v7/delete_user_command.go +++ b/command/v7/delete_user_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DeleteUserCommand struct { diff --git a/command/v7/delete_user_command_test.go b/command/v7/delete_user_command_test.go index 247cd7bfff3..2c0176f2428 100644 --- a/command/v7/delete_user_command_test.go +++ b/command/v7/delete_user_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/disable_feature_flag_command.go b/command/v7/disable_feature_flag_command.go index 6c3e36678ab..f5000a47101 100644 --- a/command/v7/disable_feature_flag_command.go +++ b/command/v7/disable_feature_flag_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DisableFeatureFlagCommand struct { diff --git a/command/v7/disable_feature_flag_command_test.go b/command/v7/disable_feature_flag_command_test.go index a5ec2ab340c..82d95d0697b 100644 --- a/command/v7/disable_feature_flag_command_test.go +++ b/command/v7/disable_feature_flag_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -96,7 +96,7 @@ var _ = Describe("Disable Feature Flag Command", func() { fakeActor.DisableFeatureFlagReturns(v7action.Warnings{"this is a warning"}, nil) }) - It("diaplays the feature flag was enabled", func() { + It("displays the feature flag was enabled", func() { featureFlagArgs := fakeActor.DisableFeatureFlagArgsForCall(0) Expect(featureFlagArgs).To(Equal(featureFlagName)) Expect(executeErr).NotTo(HaveOccurred()) diff --git a/command/v7/disable_org_isolation_command.go b/command/v7/disable_org_isolation_command.go index a430f0ad058..a411bf8ba43 100644 --- a/command/v7/disable_org_isolation_command.go +++ b/command/v7/disable_org_isolation_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DisableOrgIsolationCommand struct { diff --git a/command/v7/disable_org_isolation_command_test.go b/command/v7/disable_org_isolation_command_test.go index 2b05b519f41..b45c563f906 100644 --- a/command/v7/disable_org_isolation_command_test.go +++ b/command/v7/disable_org_isolation_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/disable_service_access_command.go b/command/v7/disable_service_access_command.go index 5abd3b9359e..aafe11ba2f9 100644 --- a/command/v7/disable_service_access_command.go +++ b/command/v7/disable_service_access_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DisableServiceAccessCommand struct { diff --git a/command/v7/disable_service_access_command_test.go b/command/v7/disable_service_access_command_test.go index d7c597a2820..eea499a5c37 100644 --- a/command/v7/disable_service_access_command_test.go +++ b/command/v7/disable_service_access_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/disable_ssh_command.go b/command/v7/disable_ssh_command.go index 794f0b0f36a..62690e6d4f1 100644 --- a/command/v7/disable_ssh_command.go +++ b/command/v7/disable_ssh_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DisableSSHCommand struct { diff --git a/command/v7/disable_ssh_command_test.go b/command/v7/disable_ssh_command_test.go index b3715c66a0e..402c378810a 100644 --- a/command/v7/disable_ssh_command_test.go +++ b/command/v7/disable_ssh_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/disallow_space_ssh_command.go b/command/v7/disallow_space_ssh_command.go index 295d3d966de..f179c33f826 100644 --- a/command/v7/disallow_space_ssh_command.go +++ b/command/v7/disallow_space_ssh_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type DisallowSpaceSSHCommand struct { diff --git a/command/v7/disallow_space_ssh_command_test.go b/command/v7/disallow_space_ssh_command_test.go index d0dbe4bb951..0abab028b58 100644 --- a/command/v7/disallow_space_ssh_command_test.go +++ b/command/v7/disallow_space_ssh_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/docker_password_getter_test.go b/command/v7/docker_password_getter_test.go index 4c9bb9af121..bcaa2cfe13b 100644 --- a/command/v7/docker_password_getter_test.go +++ b/command/v7/docker_password_getter_test.go @@ -1,10 +1,10 @@ package v7_test import ( - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" diff --git a/command/v7/domains_command.go b/command/v7/domains_command.go index 09b59929f59..4e8d0aba55a 100644 --- a/command/v7/domains_command.go +++ b/command/v7/domains_command.go @@ -4,9 +4,9 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/sorting" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/sorting" + "code.cloudfoundry.org/cli/v8/util/ui" ) type DomainsCommand struct { diff --git a/command/v7/domains_command_test.go b/command/v7/domains_command_test.go index 498e45370a2..cc41b533684 100644 --- a/command/v7/domains_command_test.go +++ b/command/v7/domains_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/download_droplet_command.go b/command/v7/download_droplet_command.go index 0b4b55cb6a0..394b216450c 100644 --- a/command/v7/download_droplet_command.go +++ b/command/v7/download_droplet_command.go @@ -2,14 +2,13 @@ package v7 import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type DownloadDropletCommand struct { @@ -90,7 +89,7 @@ func (cmd DownloadDropletCommand) Execute(args []string) error { } } - err = ioutil.WriteFile(pathToDroplet, rawDropletBytes, 0666) + err = os.WriteFile(pathToDroplet, rawDropletBytes, 0666) if err != nil { return translatableerror.DropletFileError{Err: err} } diff --git a/command/v7/download_droplet_command_test.go b/command/v7/download_droplet_command_test.go index 826ba8b12a6..86834e69bd4 100644 --- a/command/v7/download_droplet_command_test.go +++ b/command/v7/download_droplet_command_test.go @@ -3,20 +3,19 @@ package v7_test import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "regexp" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -108,7 +107,7 @@ var _ = Describe("download-droplet Command", func() { Expect(appArg).To(Equal("some-app")) Expect(spaceGUIDArg).To(Equal("some-space-guid")) - fileContents, err := ioutil.ReadFile(pathToDropletFile) + fileContents, err := os.ReadFile(pathToDropletFile) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal("some-droplet-bytes")) }) @@ -150,7 +149,7 @@ var _ = Describe("download-droplet Command", func() { Expect(appArg).To(Equal("some-app")) Expect(spaceGUIDArg).To(Equal("some-space-guid")) - fileContents, err := ioutil.ReadFile(pathToDropletFile) + fileContents, err := os.ReadFile(pathToDropletFile) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal("some-droplet-bytes")) }) @@ -180,7 +179,7 @@ var _ = Describe("download-droplet Command", func() { It("creates a droplet tarball at the specified path", func() { Expect(executeErr).ToNot(HaveOccurred()) - fileContents, err := ioutil.ReadFile(filePath) + fileContents, err := os.ReadFile(filePath) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal("some-droplet")) }) @@ -199,7 +198,7 @@ var _ = Describe("download-droplet Command", func() { BeforeEach(func() { var err error - tmpDir, err = ioutil.TempDir("", "droplets") + tmpDir, err = os.MkdirTemp("", "droplets") Expect(err).NotTo(HaveOccurred()) setFlag(&cmd, "--path", tmpDir) @@ -214,7 +213,7 @@ var _ = Describe("download-droplet Command", func() { It("creates a droplet tarball at the specified path", func() { Expect(executeErr).ToNot(HaveOccurred()) - fileContents, err := ioutil.ReadFile(filepath.Join(tmpDir, "droplet_some-droplet-guid.tgz")) + fileContents, err := os.ReadFile(filepath.Join(tmpDir, "droplet_some-droplet-guid.tgz")) Expect(err).ToNot(HaveOccurred()) Expect(string(fileContents)).To(Equal("some-droplet")) }) diff --git a/command/v7/droplets_command.go b/command/v7/droplets_command.go index 2e61020c71e..306921061bd 100644 --- a/command/v7/droplets_command.go +++ b/command/v7/droplets_command.go @@ -5,8 +5,8 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type DropletsCommand struct { diff --git a/command/v7/droplets_command_test.go b/command/v7/droplets_command_test.go index bd9ef93014c..bfc5805b680 100644 --- a/command/v7/droplets_command_test.go +++ b/command/v7/droplets_command_test.go @@ -4,19 +4,19 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/enable_feature_flag_command.go b/command/v7/enable_feature_flag_command.go index f15945aa8e2..a0a72f59eef 100644 --- a/command/v7/enable_feature_flag_command.go +++ b/command/v7/enable_feature_flag_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type EnableFeatureFlagCommand struct { diff --git a/command/v7/enable_feature_flag_command_test.go b/command/v7/enable_feature_flag_command_test.go index 84717d362a4..d218e1de476 100644 --- a/command/v7/enable_feature_flag_command_test.go +++ b/command/v7/enable_feature_flag_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -96,7 +96,7 @@ var _ = Describe("Enable Feature Flag Command", func() { fakeActor.EnableFeatureFlagReturns(v7action.Warnings{"this is a warning"}, nil) }) - It("diaplays the feature flag was enabled", func() { + It("displays the feature flag was enabled", func() { featureFlagArgs := fakeActor.EnableFeatureFlagArgsForCall(0) Expect(featureFlagArgs).To(Equal(featureFlagName)) Expect(executeErr).NotTo(HaveOccurred()) diff --git a/command/v7/enable_org_isolation_command.go b/command/v7/enable_org_isolation_command.go index be089ce48c5..98469f4594c 100644 --- a/command/v7/enable_org_isolation_command.go +++ b/command/v7/enable_org_isolation_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type EnableOrgIsolationCommand struct { diff --git a/command/v7/enable_org_isolation_command_test.go b/command/v7/enable_org_isolation_command_test.go index ed6e1f29ad3..70ae99503db 100644 --- a/command/v7/enable_org_isolation_command_test.go +++ b/command/v7/enable_org_isolation_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/enable_service_access_command.go b/command/v7/enable_service_access_command.go index 3246cf9a3e8..bf7f2357524 100644 --- a/command/v7/enable_service_access_command.go +++ b/command/v7/enable_service_access_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" ) type EnableServiceAccessCommand struct { diff --git a/command/v7/enable_service_access_command_test.go b/command/v7/enable_service_access_command_test.go index b74631d2737..5b4aa9e43c8 100644 --- a/command/v7/enable_service_access_command_test.go +++ b/command/v7/enable_service_access_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/enable_ssh_command.go b/command/v7/enable_ssh_command.go index 836d2f9c487..5a2ca8fc7bf 100644 --- a/command/v7/enable_ssh_command.go +++ b/command/v7/enable_ssh_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type EnableSSHCommand struct { @@ -65,5 +65,13 @@ func (cmd *EnableSSHCommand) Execute(args []string) error { cmd.UI.DisplayText("TIP: Ensure ssh is also enabled on the space and global level.") } + if sshEnabled.Enabled && !appFeature.Enabled { + cmd.UI.DisplayText("TIP: An app restart is required for the change to take effect.") + } + + if appFeature.Enabled { + cmd.UI.DisplayText("TIP: An app restart may be required for the change to take effect.") + } + return nil } diff --git a/command/v7/enable_ssh_command_test.go b/command/v7/enable_ssh_command_test.go index 6f10da55d7e..7903aebbdd0 100644 --- a/command/v7/enable_ssh_command_test.go +++ b/command/v7/enable_ssh_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -125,6 +125,7 @@ var _ = Describe("enable-ssh Command", func() { Expect(testUI.Err).To(Say("some-get-ssh-enabled-warnings")) Expect(testUI.Out).To(Say(`Enabling ssh support for app %s as %s\.\.\.`, appName, currentUserName)) Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say("TIP: An app restart is required for the change to take effect.")) }) When("SSH is disabled at a level above the app level", func() { @@ -160,6 +161,7 @@ var _ = Describe("enable-ssh Command", func() { It("shows the app ssh is already enabled", func() { Expect(testUI.Out).To(Say("ssh support for app 'some-app' is already enabled.")) Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say("TIP: An app restart may be required for the change to take effect.")) }) }) diff --git a/command/v7/env_command.go b/command/v7/env_command.go index a021cdfc02f..18597e55314 100644 --- a/command/v7/env_command.go +++ b/command/v7/env_command.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" log "github.com/sirupsen/logrus" ) @@ -93,7 +93,7 @@ func (cmd EnvCommand) displayEnvGroup(group map[string]interface{}) { keys := sortKeys(group) for _, key := range keys { - cmd.UI.DisplayText(fmt.Sprintf("%s: %v", key, group[key])) + cmd.UI.DisplayTextLiteral(fmt.Sprintf("%s: %v", key, group[key])) } } diff --git a/command/v7/env_command_test.go b/command/v7/env_command_test.go index 73ffa2d1baa..b7f7f6b31a2 100644 --- a/command/v7/env_command_test.go +++ b/command/v7/env_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -232,6 +232,42 @@ var _ = Describe("env Command", func() { Expect(testUI.Err).To(Say("get-warning-2")) }) }) + + When("getting the environment returns env vars with special templating characters", func() { + BeforeEach(func() { + envGroups := v7action.EnvironmentVariableGroups{ + System: map[string]interface{}{"system-name": map[string]interface{}{"mysql": []string{"system-value"}, "password": "{{test<3"}}, + Application: map[string]interface{}{"application-name": "{{application-value"}, + EnvironmentVariables: map[string]interface{}{"user-name": "{{user-value"}, + Running: map[string]interface{}{"running-name": "{{running-value"}, + Staging: map[string]interface{}{"staging-name": "{{staging-value"}, + } + fakeActor.GetEnvironmentVariablesByApplicationNameAndSpaceReturns(envGroups, nil, nil) + }) + + It("displays the environment variable and value pair", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say(`Getting env variables for app some-app in org some-org / space some-space as banana\.\.\.`)) + Expect(testUI.Out).To(Say("System-Provided:")) + Expect(testUI.Out).To(Say("system-name: {")) + Expect(testUI.Out).To(Say(`"mysql": \[`)) + Expect(testUI.Out).To(Say(`"system-value"`)) + Expect(testUI.Out).To(Say(`\],`)) + Expect(testUI.Out).To(Say(`"password": "{{test<3"`)) + Expect(testUI.Out).To(Say("}")) + Expect(testUI.Out).To(Say(`application-name: "{{application-value"`)) + + Expect(testUI.Out).To(Say("User-Provided:")) + Expect(testUI.Out).To(Say(`user-name: {{user-value`)) + + Expect(testUI.Out).To(Say("Running Environment Variable Groups:")) + Expect(testUI.Out).To(Say(`running-name: {{running-value`)) + + Expect(testUI.Out).To(Say("Staging Environment Variable Groups:")) + Expect(testUI.Out).To(Say(`staging-name: {{staging-value`)) + }) + }) }) }) }) diff --git a/command/v7/events_command.go b/command/v7/events_command.go index bca46d76781..b9c2ad7f408 100644 --- a/command/v7/events_command.go +++ b/command/v7/events_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type EventsCommand struct { diff --git a/command/v7/events_command_test.go b/command/v7/events_command_test.go index 6f1e6faae61..1daba9a70e9 100644 --- a/command/v7/events_command_test.go +++ b/command/v7/events_command_test.go @@ -5,18 +5,18 @@ import ( "regexp" "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/feature_flag_command.go b/command/v7/feature_flag_command.go index 4a0db0e2aac..b271249b59c 100644 --- a/command/v7/feature_flag_command.go +++ b/command/v7/feature_flag_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type FeatureFlagCommand struct { diff --git a/command/v7/feature_flag_command_test.go b/command/v7/feature_flag_command_test.go index 8c6b191a134..a732e3bb033 100644 --- a/command/v7/feature_flag_command_test.go +++ b/command/v7/feature_flag_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/feature_flags_command.go b/command/v7/feature_flags_command.go index 64c6ce47d03..8468be7d305 100644 --- a/command/v7/feature_flags_command.go +++ b/command/v7/feature_flags_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type FeatureFlagsCommand struct { diff --git a/command/v7/feature_flags_command_test.go b/command/v7/feature_flags_command_test.go index c14ae693026..c17ca39a19d 100644 --- a/command/v7/feature_flags_command_test.go +++ b/command/v7/feature_flags_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/get_health_check_command.go b/command/v7/get_health_check_command.go index 050f6a568de..f8c2b5c7950 100644 --- a/command/v7/get_health_check_command.go +++ b/command/v7/get_health_check_command.go @@ -3,9 +3,9 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type GetHealthCheckCommand struct { diff --git a/command/v7/get_health_check_command_test.go b/command/v7/get_health_check_command_test.go index de730ad5fcb..3b7537456a9 100644 --- a/command/v7/get_health_check_command_test.go +++ b/command/v7/get_health_check_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/get_readiness_health_check_command.go b/command/v7/get_readiness_health_check_command.go new file mode 100644 index 00000000000..3d8fd2cd8bc --- /dev/null +++ b/command/v7/get_readiness_health_check_command.go @@ -0,0 +1,85 @@ +package v7 + +import ( + "fmt" + "strconv" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" +) + +type GetReadinessHealthCheckCommand struct { + BaseCommand + + RequiredArgs flag.AppName `positional-args:"yes"` + usage interface{} `usage:"CF_NAME get-readiness-health-check APP_NAME"` +} + +func (cmd GetReadinessHealthCheckCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + cmd.UI.DisplayTextWithFlavor("Getting readiness health check type for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ + "AppName": cmd.RequiredArgs.AppName, + "OrgName": cmd.Config.TargetedOrganization().Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "Username": user.Name, + }) + + processReadinessHealthChecks, warnings, err := cmd.Actor.GetApplicationProcessReadinessHealthChecksByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + cmd.UI.DisplayNewline() + + if len(processReadinessHealthChecks) == 0 { + cmd.UI.DisplayText("App has no processes") + return nil + } + + return cmd.DisplayProcessTable(processReadinessHealthChecks) +} + +func (cmd GetReadinessHealthCheckCommand) DisplayProcessTable(processReadinessHealthChecks []v7action.ProcessReadinessHealthCheck) error { + table := [][]string{ + { + cmd.UI.TranslateText("process"), + cmd.UI.TranslateText("type"), + cmd.UI.TranslateText("endpoint (for http)"), + cmd.UI.TranslateText("invocation timeout"), + cmd.UI.TranslateText("interval"), + }, + } + + for _, healthCheck := range processReadinessHealthChecks { + var invocationTimeout, interval string + if healthCheck.InvocationTimeout != 0 { + invocationTimeout = strconv.FormatInt(healthCheck.InvocationTimeout, 10) + } + if healthCheck.Interval != 0 { + interval = strconv.FormatInt(healthCheck.Interval, 10) + } + + table = append(table, []string{ + healthCheck.ProcessType, + string(healthCheck.HealthCheckType), + healthCheck.Endpoint, + fmt.Sprint(invocationTimeout), + fmt.Sprint(interval), + }) + } + + cmd.UI.DisplayTableWithHeader("", table, ui.DefaultTableSpacePadding) + + return nil +} diff --git a/command/v7/get_readiness_health_check_command_test.go b/command/v7/get_readiness_health_check_command_test.go new file mode 100644 index 00000000000..56cf505301a --- /dev/null +++ b/command/v7/get_readiness_health_check_command_test.go @@ -0,0 +1,161 @@ +package v7_test + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("get-readiness-health-check Command", func() { + var ( + cmd GetReadinessHealthCheckCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + app string + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "faceman" + fakeConfig.BinaryNameReturns(binaryName) + app = "some-app" + + cmd = GetReadinessHealthCheckCommand{ + RequiredArgs: flag.AppName{AppName: app}, + + BaseCommand: BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + } + + fakeConfig.TargetedOrganizationReturns(configv3.Organization{ + Name: "some-org", + GUID: "some-org-guid", + }) + fakeConfig.TargetedSpaceReturns(configv3.Space{ + Name: "some-space", + GUID: "some-space-guid", + }) + + fakeActor.GetCurrentUserReturns(configv3.User{Name: "steve"}, nil) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("getting the application process readiness health checks returns an error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = actionerror.ApplicationNotFoundError{Name: app} + fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceReturns(nil, v7action.Warnings{"warning-1", "warning-2"}, expectedErr) + }) + + It("returns the error and prints warnings", func() { + Expect(executeErr).To(Equal(actionerror.ApplicationNotFoundError{Name: app})) + + Expect(testUI.Out).To(Say("Getting readiness health check type for app some-app in org some-org / space some-space as steve...")) + + Expect(testUI.Err).To(Say("warning-1")) + Expect(testUI.Err).To(Say("warning-2")) + }) + }) + + When("app has no processes", func() { + BeforeEach(func() { + fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceReturns( + []v7action.ProcessReadinessHealthCheck{}, + v7action.Warnings{"warning-1", "warning-2"}, + nil) + }) + + It("displays a message that there are no processes", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("Getting readiness health check type for app some-app in org some-org / space some-space as steve...")) + Expect(testUI.Out).To(Say("App has no processes")) + + Expect(fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceCallCount()).To(Equal(1)) + appName, spaceGUID := fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall(0) + Expect(appName).To(Equal("some-app")) + Expect(spaceGUID).To(Equal("some-space-guid")) + }) + }) + + When("app has processes", func() { + BeforeEach(func() { + appProcessReadinessHealthChecks := []v7action.ProcessReadinessHealthCheck{ + {ProcessType: constant.ProcessTypeWeb, HealthCheckType: constant.HTTP, Endpoint: "/foo", InvocationTimeout: 10, Interval: 2}, + {ProcessType: "queue", HealthCheckType: constant.Port, Endpoint: "", InvocationTimeout: 0}, + {ProcessType: "timer", HealthCheckType: constant.Process, Endpoint: "", InvocationTimeout: 5}, + } + fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceReturns(appProcessReadinessHealthChecks, v7action.Warnings{"warning-1", "warning-2"}, nil) + }) + + It("prints the readiness health check type of each process and warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("Getting readiness health check type for app some-app in org some-org / space some-space as steve...")) + Expect(testUI.Out).To(Say(`process\s+type\s+endpoint\s+\(for http\)\s+invocation timeout\s+interval\n`)) + Expect(testUI.Out).To(Say(`web\s+http\s+/foo\s+10\s+2\n`)) + Expect(testUI.Out).To(Say(`queue\s+port\s+\n`)) + Expect(testUI.Out).To(Say(`timer\s+process\s+5\s+\n`)) + + Expect(fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceCallCount()).To(Equal(1)) + appName, spaceGUID := fakeActor.GetApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall(0) + Expect(appName).To(Equal("some-app")) + Expect(spaceGUID).To(Equal("some-space-guid")) + }) + }) +}) diff --git a/command/v7/isolation_segments_command.go b/command/v7/isolation_segments_command.go index 8eed00effa0..79870291def 100644 --- a/command/v7/isolation_segments_command.go +++ b/command/v7/isolation_segments_command.go @@ -3,7 +3,7 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" ) type IsolationSegmentsCommand struct { diff --git a/command/v7/isolation_segments_command_test.go b/command/v7/isolation_segments_command_test.go index 88bd5ce1b42..b9f17d82add 100644 --- a/command/v7/isolation_segments_command_test.go +++ b/command/v7/isolation_segments_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/label_updater.go b/command/v7/label_updater.go index ce48fcd2854..20259c33703 100644 --- a/command/v7/label_updater.go +++ b/command/v7/label_updater.go @@ -5,11 +5,11 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SetLabelActor @@ -17,7 +17,7 @@ import ( type SetLabelActor interface { GetCurrentUser() (configv3.User, error) UpdateApplicationLabelsByApplicationName(string, string, map[string]types.NullString) (v7action.Warnings, error) - UpdateBuildpackLabelsByBuildpackNameAndStack(string, string, map[string]types.NullString) (v7action.Warnings, error) + UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(string, string, string, map[string]types.NullString) (v7action.Warnings, error) UpdateDomainLabelsByDomainName(string, map[string]types.NullString) (v7action.Warnings, error) UpdateOrganizationLabelsByOrganizationName(string, map[string]types.NullString) (v7action.Warnings, error) UpdateRouteLabels(string, string, map[string]types.NullString) (v7action.Warnings, error) @@ -37,11 +37,12 @@ const ( ) type TargetResource struct { - ResourceType string - ResourceName string - BuildpackStack string - ServiceBroker string - ServiceOffering string + ResourceType string + ResourceName string + BuildpackStack string + BuildpackLifecycle string + ServiceBroker string + ServiceOffering string } type LabelUpdater struct { @@ -83,8 +84,8 @@ func (cmd *LabelUpdater) Execute(targetResource TargetResource, labels map[strin cmd.displayMessageWithOrgAndSpace() warnings, err = cmd.Actor.UpdateApplicationLabelsByApplicationName(cmd.targetResource.ResourceName, cmd.Config.TargetedSpace().GUID, cmd.labels) case Buildpack: - cmd.displayMessageWithStack() - warnings, err = cmd.Actor.UpdateBuildpackLabelsByBuildpackNameAndStack(cmd.targetResource.ResourceName, cmd.targetResource.BuildpackStack, cmd.labels) + cmd.displayMessageWithStackAndLifecycle() + warnings, err = cmd.Actor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(cmd.targetResource.ResourceName, cmd.targetResource.BuildpackStack, cmd.targetResource.BuildpackLifecycle, cmd.labels) case Domain: cmd.displayMessageDefault() warnings, err = cmd.Actor.UpdateDomainLabelsByDomainName(cmd.targetResource.ResourceName, cmd.labels) @@ -189,17 +190,23 @@ func (cmd *LabelUpdater) displayMessageWithOrgAndSpace() { }) } -func (cmd *LabelUpdater) displayMessageWithStack() { - var template string - if cmd.targetResource.BuildpackStack == "" { - template = actionForResourceString(string(cmd.Action), cmd.targetResource.ResourceType) + " {{.ResourceName}} as {{.User}}..." - } else { - template = actionForResourceString(string(cmd.Action), cmd.targetResource.ResourceType) + " {{.ResourceName}} with stack {{.StackName}} as {{.User}}..." +func (cmd *LabelUpdater) displayMessageWithStackAndLifecycle() { + template := actionForResourceString(string(cmd.Action), cmd.targetResource.ResourceType) + " {{.ResourceName}}" + + if cmd.targetResource.BuildpackStack != "" { + template += " with stack {{.StackName}}" + } + + if cmd.targetResource.BuildpackLifecycle != "" { + template += " with lifecycle {{.Lifecycle}}" } + template += " as {{.User}}..." + cmd.UI.DisplayTextWithFlavor(template, map[string]interface{}{ "ResourceName": cmd.targetResource.ResourceName, "StackName": cmd.targetResource.BuildpackStack, + "Lifecycle": cmd.targetResource.BuildpackLifecycle, "User": cmd.Username, }) } diff --git a/command/v7/label_updater_test.go b/command/v7/label_updater_test.go index de8411f0aac..b4d002694dd 100644 --- a/command/v7/label_updater_test.go +++ b/command/v7/label_updater_test.go @@ -5,16 +5,16 @@ import ( "regexp" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -131,7 +131,7 @@ var _ = Describe("LabelUpdater", func() { func(resourceType string) { targetResource = TargetResource{ ResourceType: resourceType, - BuildpackStack: "cflinuxfs3", + BuildpackStack: "cflinuxfs4", } err := cmd.Execute(targetResource, nil) @@ -141,7 +141,7 @@ var _ = Describe("LabelUpdater", func() { } Expect(err).To(MatchError(argumentCombinationError)) }, - labelSubcommands("buildpack")..., + labelSubcommands("buildpack"), ) DescribeTable( @@ -159,7 +159,7 @@ var _ = Describe("LabelUpdater", func() { } Expect(err).To(MatchError(argumentCombinationError)) }, - labelSubcommands("service-offering", "service-plan")..., + labelSubcommands("service-offering", "service-plan"), ) DescribeTable( @@ -177,7 +177,7 @@ var _ = Describe("LabelUpdater", func() { } Expect(err).To(MatchError(argumentCombinationError)) }, - labelSubcommands("service-plan")..., + labelSubcommands("service-plan"), ) DescribeTable( @@ -191,7 +191,7 @@ var _ = Describe("LabelUpdater", func() { err := cmd.Execute(targetResource, nil) Expect(err).To(MatchError("Target not found")) }, - labelSubcommands()..., + labelSubcommands(), ) DescribeTable( @@ -218,7 +218,7 @@ var _ = Describe("LabelUpdater", func() { Expect(checkSpace).To(BeFalse()) } }, - labelSubcommands()..., + labelSubcommands(), ) }) @@ -348,7 +348,7 @@ var _ = Describe("LabelUpdater", func() { } labels = expectedMap - fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackReturns( + fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns( v7action.Warnings([]string{"some-warning-1", "some-warning-2"}), nil, ) @@ -365,10 +365,11 @@ var _ = Describe("LabelUpdater", func() { }) It("passes the right parameters", func() { - Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackCallCount()).To(Equal(1)) - name, stack, labels := fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackArgsForCall(0) + Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount()).To(Equal(1)) + name, stack, lifecycle, labels := fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall(0) Expect(name).To(Equal(resourceName), "failed to pass buildpack name") Expect(stack).To(Equal("globinski"), "failed to pass stack name") + Expect(lifecycle).To(Equal(""), "failed to pass lifecycle name") Expect(labels).To(BeEquivalentTo(expectedMap)) }) @@ -379,12 +380,34 @@ var _ = Describe("LabelUpdater", func() { }) }) - When("the stack is not specified", func() { + When("the stack and lifecycle are not specified", func() { It("passes the right parameters", func() { - Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackCallCount()).To(Equal(1)) - name, stack, labels := fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackArgsForCall(0) + Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount()).To(Equal(1)) + name, stack, lifecycle, labels := fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall(0) Expect(name).To(Equal(resourceName), "failed to pass buildpack name") Expect(stack).To(Equal(""), "failed to pass stack name") + Expect(lifecycle).To(Equal(""), "failed to pass lifecycle name") + Expect(labels).To(BeEquivalentTo(expectedMap)) + }) + + It("prints all warnings and does not error ", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(testUI.Err).To(Say("some-warning-1")) + Expect(testUI.Err).To(Say("some-warning-2")) + }) + }) + + When("the lifecycle is specified", func() { + BeforeEach(func() { + targetResource.BuildpackLifecycle = "cnb" + }) + + It("passes the right parameters", func() { + Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount()).To(Equal(1)) + name, stack, lifecycle, labels := fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall(0) + Expect(name).To(Equal(resourceName), "failed to pass buildpack name") + Expect(stack).To(Equal(""), "failed to pass stack name") + Expect(lifecycle).To(Equal("cnb"), "failed to pass lifecycle name") Expect(labels).To(BeEquivalentTo(expectedMap)) }) @@ -399,9 +422,10 @@ var _ = Describe("LabelUpdater", func() { When("the resource type is not lowercase", func() { BeforeEach(func() { targetResource = TargetResource{ - ResourceType: "bUiLdPaCk", - ResourceName: resourceName, - BuildpackStack: "globinski", + ResourceType: "bUiLdPaCk", + ResourceName: resourceName, + BuildpackStack: "globinski", + BuildpackLifecycle: "cnb", } expectedMap = map[string]types.NullString{ "some-label": types.NewNullString("some-value"), @@ -411,7 +435,7 @@ var _ = Describe("LabelUpdater", func() { It("calls the right actor", func() { Expect(executeErr).ToNot(HaveOccurred()) - Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackCallCount()).To(Equal(1)) + Expect(fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount()).To(Equal(1)) }) It("displays a message in the right case", func() { @@ -422,7 +446,7 @@ var _ = Describe("LabelUpdater", func() { When("updating the buildpack labels fails", func() { BeforeEach(func() { - fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackReturns(v7action.Warnings{"some-warning-1", "some-warning-2"}, + fakeActor.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns(v7action.Warnings{"some-warning-1", "some-warning-2"}, errors.New("api call failed")) }) @@ -448,11 +472,29 @@ var _ = Describe("LabelUpdater", func() { }) }) - When("stack is not passed", func() { + When("stack and lifecycle not passed", func() { It("shows 'Removing' as action", func() { Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Removing label(s) for buildpack %s as some-user...`), resourceName)) }) }) + + When("lifecycle is passed", func() { + BeforeEach(func() { + targetResource.BuildpackLifecycle = "cnb" + }) + It("shows 'Removing' as action", func() { + Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Removing label(s) for buildpack %s with lifecycle %s as some-user...`), resourceName, targetResource.BuildpackLifecycle)) + }) + }) + When("stack and lifecycle are passed", func() { + BeforeEach(func() { + targetResource.BuildpackLifecycle = "cnb" + targetResource.BuildpackStack = "globinski" + }) + It("shows 'Removing' as action", func() { + Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Removing label(s) for buildpack %s with stack %s with lifecycle %s as some-user...`), resourceName, targetResource.BuildpackStack, targetResource.BuildpackLifecycle)) + }) + }) }) When("Setting labels", func() { @@ -470,11 +512,30 @@ var _ = Describe("LabelUpdater", func() { }) }) - When("stack is not passed", func() { + When("stack and lifecycle are not passed", func() { It("shows 'Setting' as action", func() { Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Setting label(s) for buildpack %s as some-user...`), resourceName)) }) }) + + When("lifecycle is passed", func() { + BeforeEach(func() { + targetResource.BuildpackLifecycle = "cnb" + }) + It("shows 'Setting' as action", func() { + Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Setting label(s) for buildpack %s with lifecycle %s as some-user...`), resourceName, targetResource.BuildpackLifecycle)) + }) + }) + + When("stack and lifecycle are passed", func() { + BeforeEach(func() { + targetResource.BuildpackLifecycle = "cnb" + targetResource.BuildpackStack = "globinski" + }) + It("shows 'Setting' as action", func() { + Expect(testUI.Out).To(Say(regexp.QuoteMeta(`Setting label(s) for buildpack %s with stack %s with lifecycle %s as some-user...`), resourceName, targetResource.BuildpackStack, targetResource.BuildpackLifecycle)) + }) + }) }) }) }) diff --git a/command/v7/labels_command.go b/command/v7/labels_command.go index 4b371508558..d92a1f01ad7 100644 --- a/command/v7/labels_command.go +++ b/command/v7/labels_command.go @@ -5,11 +5,11 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" ) type ResourceType string @@ -31,11 +31,12 @@ const ( type LabelsCommand struct { BaseCommand - RequiredArgs flag.LabelsArgs `positional-args:"yes"` - BuildpackStack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name"` - relatedCommands interface{} `related_commands:"set-label, unset-label"` - ServiceBroker string `long:"broker" short:"b" description:"Specify a service broker to disambiguate service offerings or service plans with the same name."` - ServiceOffering string `long:"offering" short:"e" description:"Specify a service offering to disambiguate service plans with the same name."` + RequiredArgs flag.LabelsArgs `positional-args:"yes"` + BuildpackStack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name"` + BuildpackLifecycle string `long:"lifecycle" short:"l" description:"Specify lifecycle to disambiguate buildpacks with the same name"` + relatedCommands interface{} `related_commands:"set-label, unset-label"` + ServiceBroker string `long:"broker" short:"b" description:"Specify a service broker to disambiguate service offerings or service plans with the same name."` + ServiceOffering string `long:"offering" short:"e" description:"Specify a service offering to disambiguate service plans with the same name."` username string } @@ -67,8 +68,8 @@ func (cmd LabelsCommand) Execute(args []string) error { cmd.displayMessageWithOrgAndSpace() labels, warnings, err = cmd.Actor.GetApplicationLabels(cmd.RequiredArgs.ResourceName, cmd.Config.TargetedSpace().GUID) case Buildpack: - cmd.displayMessageWithStack() - labels, warnings, err = cmd.Actor.GetBuildpackLabels(cmd.RequiredArgs.ResourceName, cmd.BuildpackStack) + cmd.displayMessageWithStackAndLifecycle() + labels, warnings, err = cmd.Actor.GetBuildpackLabels(cmd.RequiredArgs.ResourceName, cmd.BuildpackStack, cmd.BuildpackLifecycle) case Domain: cmd.displayMessageDefault() labels, warnings, err = cmd.Actor.GetDomainLabels(cmd.RequiredArgs.ResourceName) @@ -116,7 +117,7 @@ func (cmd LabelsCommand) Examples() string { return ` cf labels app dora cf labels org business -cf labels buildpack go_buildpack --stack cflinuxfs3` +cf labels buildpack go_buildpack --stack cflinuxfs4` } func (cmd LabelsCommand) Resources() string { @@ -232,19 +233,17 @@ func (cmd LabelsCommand) displayMessageWithOrg() { }) } -func (cmd LabelsCommand) displayMessageWithStack() { - var template string - if cmd.BuildpackStack == "" { - template = fmt.Sprintf("Getting labels for %s {{.ResourceName}} as {{.User}}...", cmd.RequiredArgs.ResourceType) - } else { - template = fmt.Sprintf("Getting labels for %s {{.ResourceName}} with stack {{.StackName}} as {{.User}}...", cmd.RequiredArgs.ResourceType) +func (cmd LabelsCommand) displayMessageWithStackAndLifecycle() { + template := fmt.Sprintf("Getting labels for %s %s", cmd.RequiredArgs.ResourceType, cmd.RequiredArgs.ResourceName) + if cmd.BuildpackStack != "" { + template = fmt.Sprintf("%s with stack %s", template, cmd.BuildpackStack) + } + if cmd.BuildpackLifecycle != "" { + template = fmt.Sprintf("%s with lifecycle %s", template, cmd.BuildpackLifecycle) } - cmd.UI.DisplayTextWithFlavor(template, map[string]interface{}{ - "ResourceName": cmd.RequiredArgs.ResourceName, - "StackName": cmd.BuildpackStack, - "User": cmd.username, - }) + template = fmt.Sprintf("%s as %s...", template, cmd.username) + cmd.UI.DisplayTextWithFlavor(template) } func (cmd LabelsCommand) displayMessageForServiceCommands() { diff --git a/command/v7/labels_command_test.go b/command/v7/labels_command_test.go index 200e4c78075..5407ad3ac40 100644 --- a/command/v7/labels_command_test.go +++ b/command/v7/labels_command_test.go @@ -5,17 +5,17 @@ import ( "regexp" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -73,7 +73,7 @@ var _ = Describe("labels command", func() { "Failure when --stack is combined with anything other than 'buildpack'", func(resourceType string) { cmd.RequiredArgs.ResourceType = resourceType - cmd.BuildpackStack = "cflinuxfs3" + cmd.BuildpackStack = "cflinuxfs4" executeErr = cmd.Execute(nil) @@ -82,7 +82,7 @@ var _ = Describe("labels command", func() { } Expect(executeErr).To(MatchError(argumentCombinationError)) }, - labelSubcommands("buildpack")..., + labelSubcommands("buildpack"), ) DescribeTable( @@ -98,7 +98,7 @@ var _ = Describe("labels command", func() { } Expect(executeErr).To(MatchError(argumentCombinationError)) }, - labelSubcommands("service-offering", "service-plan")..., + labelSubcommands("service-offering", "service-plan"), ) DescribeTable( @@ -114,7 +114,7 @@ var _ = Describe("labels command", func() { } Expect(err).To(MatchError(argumentCombinationError)) }, - labelSubcommands("service-plan")..., + labelSubcommands("service-plan"), ) DescribeTable( @@ -125,7 +125,7 @@ var _ = Describe("labels command", func() { err := cmd.Execute(nil) Expect(err).To(MatchError("Target not found")) }, - labelSubcommands()..., + labelSubcommands(), ) DescribeTable( @@ -150,7 +150,7 @@ var _ = Describe("labels command", func() { Expect(checkSpace).To(BeFalse()) } }, - labelSubcommands()..., + labelSubcommands(), ) type MethodCallCountType func() int @@ -751,14 +751,16 @@ var _ = Describe("labels command", func() { ResourceType: "buildpack", ResourceName: "oshkosh", } - cmd.BuildpackStack = "cflinuxfs3" + cmd.BuildpackStack = "cflinuxfs4" + cmd.BuildpackLifecycle = "cnb" }) It("retrieves the labels when resource type is buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(fakeLabelsActor.GetBuildpackLabelsCallCount()).To(Equal(1)) - buildpackName, stackName := fakeLabelsActor.GetBuildpackLabelsArgsForCall(0) + buildpackName, stackName, lifecycle := fakeLabelsActor.GetBuildpackLabelsArgsForCall(0) Expect(buildpackName).To(Equal("oshkosh")) - Expect(stackName).To(Equal("cflinuxfs3")) + Expect(stackName).To(Equal("cflinuxfs4")) + Expect(lifecycle).To(Equal("cnb")) }) }) }) diff --git a/command/v7/login_command.go b/command/v7/login_command.go index a98aaf695ac..8f44bdaacf0 100644 --- a/command/v7/login_command.go +++ b/command/v7/login_command.go @@ -6,19 +6,19 @@ import ( "net/url" "strings" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" "code.cloudfoundry.org/clock" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ActorReloader @@ -267,7 +267,7 @@ func (cmd *LoginCommand) authenticate() error { return err } - nonPasswordPrompts, passwordPrompts := cmd.groupPrompts(prompts) + nonSensitivePrompts, sensitivePrompts := cmd.groupPrompts(prompts) if value, ok := prompts["username"]; ok { credentials["username"], err = cmd.getFlagValOrPrompt(&cmd.Username, value, true) @@ -276,12 +276,8 @@ func (cmd *LoginCommand) authenticate() error { } } - for key, prompt := range nonPasswordPrompts { - if prompt.Type == coreconfig.AuthPromptTypeMenu { - credentials[key], err = cmd.UI.DisplayTextMenu(prompt.Entries, prompt.DisplayName) - } else { - credentials[key], err = cmd.UI.DisplayTextPrompt(prompt.DisplayName) - } + for key, prompt := range nonSensitivePrompts { + credentials[key], err = cmd.UI.DisplayTextPrompt(prompt.DisplayName) if err != nil { return err } @@ -296,7 +292,7 @@ func (cmd *LoginCommand) authenticate() error { } } - for key, prompt := range passwordPrompts { + for key, prompt := range sensitivePrompts { credentials[key], err = cmd.UI.DisplayPasswordPrompt(prompt.DisplayName) if err != nil { return err @@ -308,19 +304,17 @@ func (cmd *LoginCommand) authenticate() error { err = cmd.Actor.Authenticate(credentials, cmd.Origin, constant.GrantTypePassword) - if err != nil { - cmd.UI.DisplayWarning(translatableerror.ConvertToTranslatableError(err).Error()) - cmd.UI.DisplayNewline() - - if _, ok := err.(uaa.AccountLockedError); ok { - break - } - } - if err == nil { cmd.UI.DisplayOK() break } + + cmd.UI.DisplayWarning(translatableerror.ConvertToTranslatableError(err).Error()) + cmd.UI.DisplayNewline() + + if _, ok := err.(uaa.AccountLockedError); ok { + break + } } return err @@ -387,12 +381,16 @@ func (cmd *LoginCommand) getFlagValOrPrompt(field *string, prompt coreconfig.Aut value := *field *field = "" return value, nil - } else { - if isText { - return cmd.UI.DisplayTextPrompt(prompt.DisplayName) - } - return cmd.UI.DisplayPasswordPrompt(prompt.DisplayName) } + + if prompt.Type == coreconfig.AuthPromptTypeMenu { + return cmd.UI.DisplayTextMenu(prompt.Entries, prompt.DisplayName) + } + + if isText { + return cmd.UI.DisplayTextPrompt(prompt.DisplayName) + } + return cmd.UI.DisplayPasswordPrompt(prompt.DisplayName) } func (cmd *LoginCommand) showStatus() { @@ -586,17 +584,15 @@ func (cmd *LoginCommand) validateTargetSpecificFlags() error { } if cmd.Password != "" { - return translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "-p"} + cmd.UI.DisplayWarning("Warning: password is ignored when authenticating against Kubernetes.") } + if cmd.SSO { return translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "--sso"} } if cmd.SSOPasscode != "" { return translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "--sso-passcode"} } - if cmd.Username != "" { - return translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "-u"} - } if cmd.Origin != "" { return translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "--origin"} } diff --git a/command/v7/login_command_test.go b/command/v7/login_command_test.go index b2bcb502230..8ca691183ca 100644 --- a/command/v7/login_command_test.go +++ b/command/v7/login_command_test.go @@ -5,20 +5,20 @@ import ( "fmt" "io" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -130,17 +130,7 @@ var _ = Describe("login Command", func() { fakeConfig.TargetReturns("https://foo.bar") }) - When("password flag is provider", func() { - BeforeEach(func() { - cmd.Password = "pass" - }) - - It("returns unsupported flag error", func() { - Expect(executeErr).To(Equal(translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "-p"})) - }) - }) - - When("sso flag is provider", func() { + When("sso flag is provided", func() { BeforeEach(func() { cmd.SSO = true }) @@ -150,7 +140,7 @@ var _ = Describe("login Command", func() { }) }) - When("sso passcode flag is provider", func() { + When("sso passcode flag is provided", func() { BeforeEach(func() { cmd.SSOPasscode = "sso-pass" }) @@ -160,17 +150,7 @@ var _ = Describe("login Command", func() { }) }) - When("username flag is provider", func() { - BeforeEach(func() { - cmd.Username = "my-user" - }) - - It("returns unsupported flag error", func() { - Expect(executeErr).To(Equal(translatableerror.NotSupportedOnKubernetesArgumentError{Arg: "-u"})) - }) - }) - - When("origin flag is provider", func() { + When("origin flag is provided", func() { BeforeEach(func() { cmd.Origin = "my-origin" }) @@ -329,15 +309,27 @@ var _ = Describe("login Command", func() { }) }) - When("targeting the API fails due to an invalid certificate", func() { - BeforeEach(func() { - cmd.APIEndpoint = "api.example.com" - fakeActor.SetTargetReturns(nil, ccerror.UnverifiedServerError{URL: "https://api.example.com"}) + When("certificate is invalid", func() { + When("targeting the API without setting --skip-ssl-validation flag", func() { + BeforeEach(func() { + cmd.APIEndpoint = "api.example.com" + fakeActor.SetTargetReturns(nil, ccerror.UnverifiedServerError{URL: "https://api.example.com"}) + }) + + It("returns an error mentioning the login command", func() { + Expect(executeErr).To(MatchError( + translatableerror.InvalidSSLCertError{URL: "https://api.example.com", SuggestedCommand: "login"})) + }) }) - It("returns an error mentioning the login command", func() { - Expect(executeErr).To(MatchError( - translatableerror.InvalidSSLCertError{URL: "https://api.example.com", SuggestedCommand: "login"})) + When("targeting the API with --skip-ssl-validation flag", func() { + BeforeEach(func() { + cmd.APIEndpoint = "api.example.com" + }) + + It("login succeeds", func() { + Expect(executeErr).NotTo(HaveOccurred()) + }) }) }) }) @@ -684,6 +676,104 @@ var _ = Describe("login Command", func() { }) }) }) + + When("authenticating against Korifi", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + k8sLoginPrompts := map[string]coreconfig.AuthPrompt{ + "username": { + Type: coreconfig.AuthPromptTypeMenu, + Entries: []string{"myuser", "overly-powerful-admin"}, + DisplayName: "Choose your Kubernetes authentication info", + }, + } + fakeActor.GetLoginPromptsReturns(k8sLoginPrompts, nil) + }) + + When("the user selects a valid username", func() { + BeforeEach(func() { + _, err := input.Write([]byte("1\n")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("prompts the user with available k8s usernames", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(testUI.Out).To(Say("myuser")) + Expect(testUI.Out).To(Say("overly-powerful-admin")) + Expect(testUI.Out).To(Say("Choose your Kubernetes authentication info")) + }) + + It("authenticates with the chosen user", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, _, _ := fakeActor.AuthenticateArgsForCall(0) + Expect(credentials).To(Equal(map[string]string{ + "username": "myuser", + })) + }) + }) + + When("the user selects an invalid username", func() { + BeforeEach(func() { + _, err := input.Write([]byte("3\n")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("errors", func() { + Expect(executeErr).To(MatchError("Unable to authenticate.")) + Expect(fakeActor.AuthenticateCallCount()).To(Equal(0)) + }) + }) + + When("the username flag is set", func() { + BeforeEach(func() { + cmd.Username = "myuser" + }) + + It("sets that username in the credentials", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, _, _ := fakeActor.AuthenticateArgsForCall(0) + Expect(credentials).To(Equal(map[string]string{ + "username": "myuser", + })) + + Expect(testUI.Out).NotTo(Say("Choose your Kubernetes authentication info")) + }) + + When("the password flag is also set", func() { + BeforeEach(func() { + cmd.Password = "should-be-ignored" + }) + + It("succeeds and sets only the username in the credentials", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeActor.AuthenticateCallCount()).To(Equal(1)) + credentials, _, _ := fakeActor.AuthenticateArgsForCall(0) + Expect(credentials).To(Equal(map[string]string{ + "username": "myuser", + })) + }) + + It("displays a warning that password will be ignored", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(testUI.Err).To(Say("Warning: password is ignored when authenticating against Kubernetes.")) + }) + }) + + When("authentication fails", func() { + BeforeEach(func() { + fakeActor.AuthenticateReturns(errors.New("boom")) + }) + + It("errors", func() { + Expect(executeErr).To(MatchError("Unable to authenticate.")) + }) + }) + }) + }) }) Describe("SSO Passcode", func() { @@ -1380,7 +1470,7 @@ var _ = Describe("login Command", func() { fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space"}) }) - It("displays that the spacce has been targeted", func() { + It("displays that the space has been targeted", func() { Expect(testUI.Out).To(Say(`space:\s+some-space`)) }) }) diff --git a/command/v7/logout_command.go b/command/v7/logout_command.go index 0e7850c977f..ec8bb59a6ba 100644 --- a/command/v7/logout_command.go +++ b/command/v7/logout_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/v7/shared" "code.cloudfoundry.org/clock" ) @@ -38,7 +38,7 @@ func (cmd LogoutCommand) Execute(args []string) error { "Username": user.Name, }) - cmd.Actor.RevokeAccessAndRefreshTokens() + cmd.Actor.RevokeAccessAndRefreshTokens() //nolint:errcheck cmd.Config.UnsetUserInformation() cmd.UI.DisplayOK() diff --git a/command/v7/logout_command_test.go b/command/v7/logout_command_test.go index e0b09f5cb51..dd7c8f72acc 100644 --- a/command/v7/logout_command_test.go +++ b/command/v7/logout_command_test.go @@ -1,13 +1,13 @@ package v7_test import ( - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/logs_command.go b/command/v7/logs_command.go index e5232665010..572856a783d 100644 --- a/command/v7/logs_command.go +++ b/command/v7/logs_command.go @@ -5,10 +5,12 @@ import ( "os/signal" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" ) type LogsCommand struct { @@ -28,8 +30,8 @@ func (cmd *LogsCommand) Setup(config command.Config, ui command.UI) error { return err } - cmd.LogCacheClient = command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) - return nil + cmd.LogCacheClient, err = logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + return err } func (cmd LogsCommand) Execute(args []string) error { @@ -56,20 +58,23 @@ func (cmd LogsCommand) Execute(args []string) error { return cmd.displayRecentLogs() } - stop := make(chan struct{}) - stoppedRefreshing := make(chan struct{}) - stoppedOutputtingRefreshErrors := make(chan struct{}) - err = cmd.refreshTokenPeriodically(stop, stoppedRefreshing, stoppedOutputtingRefreshErrors) - if err != nil { - return err + if !cmd.Config.IsCFOnK8s() { + stop := make(chan struct{}) + stoppedRefreshing := make(chan struct{}) + stoppedOutputtingRefreshErrors := make(chan struct{}) + err = cmd.refreshTokenPeriodically(stop, stoppedRefreshing, stoppedOutputtingRefreshErrors) + if err != nil { + return err + } + defer func() { + close(stop) + <-stoppedRefreshing + <-stoppedOutputtingRefreshErrors + }() } err = cmd.streamLogs() - close(stop) - <-stoppedRefreshing - <-stoppedOutputtingRefreshErrors - return err } diff --git a/command/v7/logs_command_test.go b/command/v7/logs_command_test.go index ea188379989..0aa886bb70c 100644 --- a/command/v7/logs_command_test.go +++ b/command/v7/logs_command_test.go @@ -5,16 +5,16 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -248,6 +248,16 @@ var _ = Describe("logs command", func() { }) }) + When("isCFOnK8s is true", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("does not call ScheduleTokenRefresh", func() { + Expect(fakeActor.ScheduleTokenRefreshCallCount()).To(Equal(0)) + }) + }) + It("displays the error and all warnings", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Err).To(Say("steve for all I care")) @@ -268,7 +278,7 @@ var _ = Describe("logs command", func() { errorStream := make(chan error) go func() { - logStream <- *sharedaction.NewLogMessage("Here are some staging logs!", "OUT", time.Now(), sharedaction.StagingLog, "sourceInstance") //TODO: is it ok to leave staging logs here? + logStream <- *sharedaction.NewLogMessage("Here are some staging logs!", "OUT", time.Now(), sharedaction.StagingLog, "sourceInstance") // TODO: is it ok to leave staging logs here? logStream <- *sharedaction.NewLogMessage("Here are some other staging logs!", "OUT", time.Now(), sharedaction.StagingLog, "sourceInstance") close(logStream) close(errorStream) @@ -312,6 +322,24 @@ var _ = Describe("logs command", func() { When("there is an error refreshing a token sometime later", func() { BeforeEach(func() { cmd.Recent = false + fakeActor.GetStreamingLogsForApplicationByNameAndSpaceStub = + func(_ string, _ string, _ sharedaction.LogCacheClient) ( + <-chan sharedaction.LogMessage, + <-chan error, context.CancelFunc, + v7action.Warnings, + error) { + + logStream := make(chan sharedaction.LogMessage) + errorStream := make(chan error) + + go func() { + time.Sleep(100 * time.Millisecond) + close(logStream) + close(errorStream) + }() + + return logStream, errorStream, func() {}, v7action.Warnings{}, nil + } fakeActor.ScheduleTokenRefreshStub = func( after func(time.Duration) <-chan time.Time, stop chan struct{}, stoppedRefreshing chan struct{}) (<-chan error, error) { diff --git a/command/v7/map_route_command.go b/command/v7/map_route_command.go index c9ca6b381ac..1c572ed933f 100644 --- a/command/v7/map_route_command.go +++ b/command/v7/map_route_command.go @@ -1,38 +1,42 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type MapRouteCommand struct { BaseCommand - RequiredArgs flag.AppDomain `positional-args:"yes"` - Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` - Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` - Port int `long:"port" description:"Port for the TCP route (default: random port)"` - AppProtocol string `long:"app-protocol" description:"[Beta flag, subject to change] Protocol for the route destination (default: http1). Only applied to HTTP routes"` - - relatedCommands interface{} `related_commands:"create-route, routes, unmap-route"` + RequiredArgs flag.AppDomain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + Port int `long:"port" description:"Port for the TCP route (default: random port)"` + AppProtocol string `long:"app-protocol" description:"[Beta flag, subject to change] Protocol for the route destination (default: http1). Only applied to HTTP routes"` + Options []string `long:"option" short:"o" description:"Set the value of a per-route option"` + relatedCommands interface{} `related_commands:"create-route, update-route, routes, unmap-route"` } func (cmd MapRouteCommand) Usage() string { return ` Map an HTTP route: - CF_NAME map-route APP_NAME DOMAIN [--hostname HOSTNAME] [--path PATH] [--app-protocol PROTOCOL] + CF_NAME map-route APP_NAME DOMAIN [--hostname HOSTNAME] [--path PATH] [--app-protocol PROTOCOL] [--option OPTION=VALUE] Map a TCP route: - CF_NAME map-route APP_NAME DOMAIN [--port PORT]` + CF_NAME map-route APP_NAME DOMAIN [--port PORT] [--option OPTION=VALUE]` } func (cmd MapRouteCommand) Examples() string { return ` -CF_NAME map-route my-app example.com # example.com -CF_NAME map-route my-app example.com --hostname myhost # myhost.example.com -CF_NAME map-route my-app example.com --hostname myhost --path foo # myhost.example.com/foo -CF_NAME map-route my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com -CF_NAME map-route my-app example.com --port 5000 # example.com:5000` +CF_NAME map-route my-app example.com # example.com +CF_NAME map-route my-app example.com --hostname myhost # myhost.example.com +CF_NAME map-route my-app example.com --hostname myhost -o loadbalancing=least-connection # myhost.example.com with a per-route option +CF_NAME map-route my-app example.com --hostname myhost --path foo # myhost.example.com/foo +CF_NAME map-route my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com +CF_NAME map-route my-app example.com --port 5000 # example.com:5000` } func (cmd MapRouteCommand) Execute(args []string) error { @@ -61,12 +65,28 @@ func (cmd MapRouteCommand) Execute(args []string) error { path := cmd.Path.Path route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, cmd.Port) + url := desiredURL(domain.Name, cmd.Hostname, path, cmd.Port) cmd.UI.DisplayWarnings(warnings) if err != nil { if _, ok := err.(actionerror.RouteNotFoundError); !ok { return err } + + var routeOptions map[string]*string + if len(cmd.Options) > 0 && cmd.validateAPIVersionForPerRouteOptions() == nil { + var wrongOptSpec *string + routeOptions, wrongOptSpec = resources.CreateRouteOptions(cmd.Options) + if wrongOptSpec != nil { + return actionerror.RouteOptionError{ + Name: *wrongOptSpec, + DomainName: domain.Name, + Path: path, + Host: cmd.Hostname, + } + } + } + cmd.UI.DisplayTextWithFlavor("Creating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.User}}...", map[string]interface{}{ "URL": url, @@ -74,18 +94,24 @@ func (cmd MapRouteCommand) Execute(args []string) error { "SpaceName": cmd.Config.TargetedSpace().Name, "OrgName": cmd.Config.TargetedOrganization().Name, }) + route, warnings, err = cmd.Actor.CreateRoute( cmd.Config.TargetedSpace().GUID, domain.Name, cmd.Hostname, path, cmd.Port, + routeOptions, ) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } cmd.UI.DisplayOK() + } else { + if len(cmd.Options) > 0 { + return actionerror.RouteOptionSupportError{ErrorText: "Route specific options can only be specified for nonexistent routes."} + } } if cmd.AppProtocol != "" { @@ -121,6 +147,7 @@ func (cmd MapRouteCommand) Execute(args []string) error { cmd.UI.DisplayOK() return nil } + warnings, err = cmd.Actor.MapRoute(route.GUID, app.GUID, cmd.AppProtocol) cmd.UI.DisplayWarnings(warnings) if err != nil { @@ -130,3 +157,15 @@ func (cmd MapRouteCommand) Execute(args []string) error { return nil } + +func (cmd MapRouteCommand) validateAPIVersionForPerRouteOptions() error { + err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionPerRouteOpts) + if err != nil { + cmd.UI.DisplayWarning("Your CC API version ({{.APIVersion}}) does not support per-route options."+ + "Upgrade to a newer version of the API (minimum version {{.MinSupportedVersion}}). ", map[string]interface{}{ + "APIVersion": cmd.Config.APIVersion(), + "MinSupportedVersion": ccversion.MinVersionPerRouteOpts, + }) + } + return err +} diff --git a/command/v7/map_route_command_test.go b/command/v7/map_route_command_test.go index 3e7b111edeb..dd1c62ecf21 100644 --- a/command/v7/map_route_command_test.go +++ b/command/v7/map_route_command_test.go @@ -2,18 +2,21 @@ package v7_test import ( "errors" + "strconv" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -34,6 +37,9 @@ var _ = Describe("map-route Command", func() { path string orgGUID string spaceGUID string + options []string + expectedOptions map[string]*string + cCAPIOldVersion string ) BeforeEach(func() { @@ -42,6 +48,9 @@ var _ = Describe("map-route Command", func() { fakeConfig = new(commandfakes.FakeConfig) fakeSharedActor = new(commandfakes.FakeSharedActor) fakeActor = new(v7fakes.FakeActor) + fakeConfig.APIVersionReturns(ccversion.MinVersionPerRouteOpts) + + expectedOptions = map[string]*string{} binaryName = "faceman" fakeConfig.BinaryNameReturns(binaryName) @@ -51,12 +60,14 @@ var _ = Describe("map-route Command", func() { path = `path` orgGUID = "some-org-guid" spaceGUID = "some-space-guid" + options = []string{} cmd = MapRouteCommand{ RequiredArgs: flag.AppDomain{App: appName, Domain: domain}, Hostname: hostname, Path: flag.V7RoutePath{Path: path}, AppProtocol: "http2", + Options: options, BaseCommand: BaseCommand{ UI: testUI, Config: fakeConfig, @@ -220,11 +231,15 @@ var _ = Describe("map-route Command", func() { When("the requested route does not exist", func() { BeforeEach(func() { + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal fakeActor.GetRouteByAttributesReturns( resources.Route{}, v7action.Warnings{"get-route-warnings"}, actionerror.RouteNotFoundError{}, ) + cmd.Options = []string{"loadbalancing=least-connection"} + expectedOptions = map[string]*string{"loadbalancing": lbLeastConnections} }) It("creates the route", func() { @@ -250,19 +265,80 @@ var _ = Describe("map-route Command", func() { Expect(actualPort).To(Equal(cmd.Port)) Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) - actualSpaceGUID, actualDomainName, actualHostname, actualPath, actualPort := fakeActor.CreateRouteArgsForCall(0) + actualSpaceGUID, actualDomainName, actualHostname, actualPath, actualPort, actualOptions := fakeActor.CreateRouteArgsForCall(0) Expect(actualSpaceGUID).To(Equal(spaceGUID)) Expect(actualDomainName).To(Equal("some-domain.com")) Expect(actualHostname).To(Equal(hostname)) Expect(actualPath).To(Equal(path)) Expect(actualPort).To(Equal(cmd.Port)) + Expect(actualOptions).To(Equal(expectedOptions)) + }) + }) + + When("the requested route does not exist and options are specified incorrectly", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + nil, + actionerror.RouteNotFoundError{}, + ) + cmd.Options = []string{"loadbalancing"} + }) + + It("gives an error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(executeErr).To(MatchError(actionerror.RouteOptionError{Name: "loadbalancing", DomainName: domain, Path: path, Host: hostname})) + Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) + }) + }) + + When("the requested route does not exist and CC API version is too old for route options", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + cmd.Options = []string{"loadbalancing=round-robin"} + cCAPIOldVersion = strconv.Itoa(1) + fakeConfig.APIVersionReturns(cCAPIOldVersion) + }) + + It("gives an error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(testUI.Err).To(Say("CC API version")) + Expect(testUI.Err).To(Say("does not support per-route options")) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) + }) + }) + + When("the requested route does not exist and CC API version is too old for route options", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + cmd.Options = nil + cCAPIOldVersion = strconv.Itoa(1) + fakeConfig.APIVersionReturns(cCAPIOldVersion) + }) + + It("succeeds because the options were not specified", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) }) }) When("the requested route exists", func() { BeforeEach(func() { fakeActor.GetRouteByAttributesReturns( - resources.Route{GUID: "route-guid"}, + resources.Route{GUID: "route-guid", Options: map[string]*string{}}, v7action.Warnings{"get-route-warnings"}, nil, ) @@ -421,6 +497,27 @@ var _ = Describe("map-route Command", func() { }) }) + When("the requested route exists and the options are specified", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid", Options: map[string]*string{}}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + cmd.Options = []string{"loadbalancing=least-connection"} + }) + + When("getting the per-route options error", func() { + BeforeEach(func() { + fakeActor.GetRouteDestinationByAppGUIDReturns(resources.RouteDestination{}, nil) + }) + It("returns the error message", func() { + Expect(executeErr).To(MatchError(actionerror.RouteOptionSupportError{ErrorText: "Route specific options can only be specified for nonexistent routes."})) + Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) + }) + }) + }) + When("a tcp route is requested without a port", func() { BeforeEach(func() { fakeActor.GetRouteByAttributesReturns( diff --git a/command/v7/marketplace_command.go b/command/v7/marketplace_command.go index 47adc8eb88a..e250d5326d2 100644 --- a/command/v7/marketplace_command.go +++ b/command/v7/marketplace_command.go @@ -4,10 +4,10 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type MarketplaceCommand struct { diff --git a/command/v7/marketplace_command_test.go b/command/v7/marketplace_command_test.go index ca4410c572e..1b998b61a5e 100644 --- a/command/v7/marketplace_command_test.go +++ b/command/v7/marketplace_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" "github.com/pkg/errors" diff --git a/command/v7/move_route_command.go b/command/v7/move_route_command.go new file mode 100644 index 00000000000..2c2edf365f3 --- /dev/null +++ b/command/v7/move_route_command.go @@ -0,0 +1,103 @@ +package v7 + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" +) + +type MoveRouteCommand struct { + BaseCommand + + RequireArgs flag.Domain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + DestinationOrg string `short:"o" description:"The org of the destination app (Default: targeted org)"` + DestinationSpace string `short:"s" description:"The space of the destination app (Default: targeted space)"` + + relatedCommands interface{} `related_commands:"create-route, map-route, unmap-route, routes"` +} + +func (cmd MoveRouteCommand) Usage() string { + return ` + Transfers the ownership of a route to a another space: + CF_NAME move-route DOMAIN [--hostname HOSTNAME] [--path PATH] -s OTHER_SPACE [-o OTHER_ORG]` +} + +func (cmd MoveRouteCommand) Examples() string { + return ` + CF_NAME move-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo + CF_NAME move-route example.com --hostname myHost -s TargetSpace # myhost.example.com + CF_NAME move-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com` +} + +func (cmd MoveRouteCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequireArgs.Domain) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + path := cmd.Path.Path + route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.RouteNotFoundError); ok { + cmd.UI.DisplayText("Can not transfer ownership of route:") + return err + } + } + + destinationOrgName := cmd.DestinationOrg + + if destinationOrgName == "" { + destinationOrgName = cmd.Config.TargetedOrganizationName() + } + + destinationOrg, warnings, err := cmd.Actor.GetOrganizationByName(destinationOrgName) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.OrganizationNotFoundError); ok { + cmd.UI.DisplayText("Can not transfer ownership of route:") + return err + } + } + + targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.SpaceNotFoundError); ok { + cmd.UI.DisplayText("Can not transfer ownership of route:") + return err + } + } + + url := desiredURL(domain.Name, cmd.Hostname, path, 0) + cmd.UI.DisplayTextWithFlavor("Move ownership of route {{.URL}} to space {{.DestinationSpace}} as {{.User}}", + map[string]interface{}{ + "URL": url, + "DestinationSpace": cmd.DestinationSpace, + "User": user.Name, + }) + warnings, err = cmd.Actor.MoveRoute( + route.GUID, + targetedSpace.GUID, + ) + + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + cmd.UI.DisplayOK() + + return nil +} diff --git a/command/v7/move_route_command_test.go b/command/v7/move_route_command_test.go new file mode 100644 index 00000000000..e6393fd20e9 --- /dev/null +++ b/command/v7/move_route_command_test.go @@ -0,0 +1,279 @@ +package v7_test + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("move-route Command", func() { + var ( + cmd v7.MoveRouteCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + domainName string + orgName string + spaceName string + hostname string + path string + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "myBinaryBread" + fakeConfig.BinaryNameReturns(binaryName) + + domainName = "some-domain.com" + orgName = "org-name-a" + spaceName = "space-name-a" + hostname = "myHostname" + path = "myPath" + + cmd = v7.MoveRouteCommand{ + BaseCommand: v7.BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + RequireArgs: flag.Domain{Domain: domainName}, + Hostname: hostname, + Path: flag.V7RoutePath{Path: path}, + DestinationOrg: orgName, + DestinationSpace: spaceName, + } + + fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space", GUID: "some-space-guid"}) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{Name: "some-org"}) + fakeConfig.CurrentUserReturns(configv3.User{Name: "some-user"}, nil) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + It("checks that target", func() { + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in and targeted", func() { + When("getting the domain errors", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(0)) + + Expect(fakeActor.MoveRouteCallCount()).To(Equal(0)) + }) + }) + + When("getting the domain succeeds", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns( + resources.Domain{Name: domainName, GUID: "domain-guid"}, + v7action.Warnings{"get-domain-warnings"}, + nil, + ) + }) + + When("the requested route does not exist", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + }) + + It("displays error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + }) + }) + + When("the requested route exists", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + When("getting the target space errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.SpaceNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetOrganizationByNameArgsForCall(0)).To(Equal(orgName)) + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + + Expect(fakeActor.MoveRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target org errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.OrganizationNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.MoveRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target space succeeds", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{GUID: "space-guid-b"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + It("exits 0 with helpful message that the route is now transferred", func() { + Expect(executeErr).ShouldNot(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + Expect(fakeActor.MoveRouteCallCount()).To(Equal(1)) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/network_policies_command.go b/command/v7/network_policies_command.go index 6a8a6e1f1d5..70bd175a626 100644 --- a/command/v7/network_policies_command.go +++ b/command/v7/network_policies_command.go @@ -4,10 +4,10 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/util/ui" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . NetworkPoliciesActor diff --git a/command/v7/network_policies_command_test.go b/command/v7/network_policies_command_test.go index 97b0fb57d0a..4b724915cf8 100644 --- a/command/v7/network_policies_command_test.go +++ b/command/v7/network_policies_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/oauth_token_command.go b/command/v7/oauth_token_command.go index a5feff234a1..7ea580cb690 100644 --- a/command/v7/oauth_token_command.go +++ b/command/v7/oauth_token_command.go @@ -4,7 +4,7 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" ) type OauthTokenCommand struct { diff --git a/command/v7/oauth_token_command_test.go b/command/v7/oauth_token_command_test.go index e9f94cdcc1a..5f3f5beadca 100644 --- a/command/v7/oauth_token_command_test.go +++ b/command/v7/oauth_token_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" "github.com/SermoDigital/jose/crypto" "github.com/SermoDigital/jose/jws" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/org_command.go b/command/v7/org_command.go index 0f2a238713c..70c104a1893 100644 --- a/command/v7/org_command.go +++ b/command/v7/org_command.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type OrgCommand struct { diff --git a/command/v7/org_command_test.go b/command/v7/org_command_test.go index 2dccc3a8c49..aab3538850e 100644 --- a/command/v7/org_command_test.go +++ b/command/v7/org_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/org_quota_command.go b/command/v7/org_quota_command.go index 5458bb24fb7..7a4a63967b6 100644 --- a/command/v7/org_quota_command.go +++ b/command/v7/org_quota_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type OrgQuotaCommand struct { diff --git a/command/v7/org_quota_command_test.go b/command/v7/org_quota_command_test.go index 187fcda8d56..3ff8f1777c4 100644 --- a/command/v7/org_quota_command_test.go +++ b/command/v7/org_quota_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -105,6 +105,7 @@ var _ = Describe("Org Quota Command", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2048}, InstanceMemory: &types.NullInt{IsSet: true, Value: 1024}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 2}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 512}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{IsSet: false}, @@ -138,6 +139,7 @@ var _ = Describe("Org Quota Command", func() { Expect(testUI.Out).To(Say(`paid service plans:\s+disallowed`)) Expect(testUI.Out).To(Say(`app instances:\s+2`)) Expect(testUI.Out).To(Say(`route ports:\s+unlimited`)) + Expect(testUI.Out).To(Say(`log volume per second:\s+512B`)) }) }) }) diff --git a/command/v7/org_quotas_command.go b/command/v7/org_quotas_command.go index 2fb561d07f0..7bc67a6b8e4 100644 --- a/command/v7/org_quotas_command.go +++ b/command/v7/org_quotas_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type OrgQuotasCommand struct { diff --git a/command/v7/org_quotas_command_test.go b/command/v7/org_quotas_command_test.go index d69e632c6f0..6a5e5391f01 100644 --- a/command/v7/org_quotas_command_test.go +++ b/command/v7/org_quotas_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -66,6 +66,7 @@ var _ = Describe("org-quotas command", func() { TotalMemory: &types.NullInt{Value: 1048576, IsSet: true}, InstanceMemory: &types.NullInt{Value: 32, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 3, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 3, IsSet: true}, @@ -91,8 +92,8 @@ var _ = Describe("org-quotas command", func() { It("retrieves and displays all quotas", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(fakeActor.GetOrganizationQuotasCallCount()).To(Equal(1)) - Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Expect(testUI.Out).To(Say(`org-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2`)) + Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Expect(testUI.Out).To(Say(`org-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2\s+512B`)) }) When("there are limits that have not been configured", func() { @@ -105,6 +106,7 @@ var _ = Describe("org-quotas command", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -123,9 +125,8 @@ var _ = Describe("org-quotas command", func() { It("should convert default values from the API into readable outputs", func() { Expect(executeErr).NotTo(HaveOccurred()) - Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited`)) - + Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited\s+unlimited`)) }) }) }) diff --git a/command/v7/org_users_command.go b/command/v7/org_users_command.go index f7af79783b4..2a5060cfe57 100644 --- a/command/v7/org_users_command.go +++ b/command/v7/org_users_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type OrgUsersCommand struct { diff --git a/command/v7/org_users_command_test.go b/command/v7/org_users_command_test.go index cdba41439e2..d6881a3ef9c 100644 --- a/command/v7/org_users_command_test.go +++ b/command/v7/org_users_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/orgs_command.go b/command/v7/orgs_command.go index 92c2cd179b4..82cb8fddb78 100644 --- a/command/v7/orgs_command.go +++ b/command/v7/orgs_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type OrgsCommand struct { diff --git a/command/v7/orgs_command_test.go b/command/v7/orgs_command_test.go index 161ee27f9c7..c3126062bdf 100644 --- a/command/v7/orgs_command_test.go +++ b/command/v7/orgs_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/packages_command.go b/command/v7/packages_command.go index 2aa01385d7f..e6cfef70e8b 100644 --- a/command/v7/packages_command.go +++ b/command/v7/packages_command.go @@ -4,8 +4,8 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type PackagesCommand struct { diff --git a/command/v7/packages_command_test.go b/command/v7/packages_command_test.go index 87ae1f29039..0542dd1b7ff 100644 --- a/command/v7/packages_command_test.go +++ b/command/v7/packages_command_test.go @@ -4,18 +4,18 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/passwd_command.go b/command/v7/passwd_command.go index f68baa1cb12..8b91693313d 100644 --- a/command/v7/passwd_command.go +++ b/command/v7/passwd_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type PasswdCommand struct { diff --git a/command/v7/passwd_command_test.go b/command/v7/passwd_command_test.go index 8a3bf5d3972..129ef14116a 100644 --- a/command/v7/passwd_command_test.go +++ b/command/v7/passwd_command_test.go @@ -3,13 +3,13 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/v7/purge_service_instance_command.go b/command/v7/purge_service_instance_command.go index fc646e47cf8..bc5cbc12968 100644 --- a/command/v7/purge_service_instance_command.go +++ b/command/v7/purge_service_instance_command.go @@ -3,8 +3,8 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) const purgeServiceInstanceWarning = "WARNING: This operation assumes that the service broker responsible for this service instance is no longer available or is not responding with a 200 or 410, and the service instance has been deleted, leaving orphan records in Cloud Foundry's database. All knowledge of the service instance will be removed from Cloud Foundry, including service bindings and service keys." diff --git a/command/v7/purge_service_instance_command_test.go b/command/v7/purge_service_instance_command_test.go index d5f3e7e32f3..1b174c02bea 100644 --- a/command/v7/purge_service_instance_command_test.go +++ b/command/v7/purge_service_instance_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/purge_service_offering_command.go b/command/v7/purge_service_offering_command.go index a8268c612ab..ec4aa8132ce 100644 --- a/command/v7/purge_service_offering_command.go +++ b/command/v7/purge_service_offering_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type PurgeServiceOfferingCommand struct { diff --git a/command/v7/purge_service_offering_command_test.go b/command/v7/purge_service_offering_command_test.go index 3d48ea0d109..9e37dfe69a7 100644 --- a/command/v7/purge_service_offering_command_test.go +++ b/command/v7/purge_service_offering_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/push_command.go b/command/v7/push_command.go index c7becf02fef..75594f65875 100644 --- a/command/v7/push_command.go +++ b/command/v7/push_command.go @@ -4,26 +4,30 @@ import ( "context" "fmt" "os" + "strconv" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/manifestparser" - "code.cloudfoundry.org/cli/util/progressbar" "github.com/cloudfoundry/bosh-cli/director/template" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/progressbar" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . ProgressBar @@ -38,6 +42,7 @@ type ProgressBar interface { type PushActor interface { HandleFlagOverrides(baseManifest manifestparser.Manifest, flagOverrides v7pushaction.FlagOverrides) (manifestparser.Manifest, error) + HandleDeploymentScaleFlagOverrides(manifest manifestparser.Manifest, flagOverrides v7pushaction.FlagOverrides) (manifestparser.Manifest, error) CreatePushPlans(spaceGUID string, orgGUID string, manifest manifestparser.Manifest, overrides v7pushaction.FlagOverrides) ([]v7pushaction.PushPlan, v7action.Warnings, error) // Actualize applies any necessary changes. Actualize(plan v7pushaction.PushPlan, progressBar v7pushaction.ProgressBar) <-chan *v7pushaction.PushEvent @@ -86,7 +91,11 @@ type PushCommand struct { HealthCheckHTTPEndpoint string `long:"endpoint" description:"Valid path on the app for an HTTP health check. Only used when specifying --health-check-type=http"` HealthCheckType flag.HealthCheckType `long:"health-check-type" short:"u" description:"Application health check type. Defaults to 'port'. 'http' requires a valid endpoint, for example, '/health'."` Instances flag.Instances `long:"instances" short:"i" description:"Number of instances"` + InstanceSteps string `long:"instance-steps" description:"An array of percentage steps to deploy when using deployment strategy canary. (e.g. 20,40,60)"` + Lifecycle constant.AppLifecycleType `long:"lifecycle" description:"App lifecycle type to stage and run the app" default:""` + LogRateLimit string `long:"log-rate-limit" short:"l" description:"Log rate limit per second, in bytes (e.g. 128B, 4K, 1M). -l=-1 represents unlimited"` PathToManifest flag.ManifestPathWithExistenceCheck `long:"manifest" short:"f" description:"Path to manifest"` + MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively being started. Only applies when --strategy flag is specified."` Memory string `long:"memory" short:"m" description:"Memory limit (e.g. 256M, 1024M, 1G)"` NoManifest bool `long:"no-manifest" description:"Ignore manifest file"` NoRoute bool `long:"no-route" description:"Do not map a route to this app"` @@ -94,14 +103,15 @@ type PushCommand struct { NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` AppPath flag.PathWithExistenceCheck `long:"path" short:"p" description:"Path to app directory or to a zip file of the contents of the app directory"` RandomRoute bool `long:"random-route" description:"Create a random route for this app (except when no-route is specified in the manifest)"` + RedactEnv bool `long:"redact-env" description:"Do not print values for environment vars set in the application manifest"` Stack string `long:"stack" short:"s" description:"Stack to use (a stack is a pre-built file system, including an operating system, that can run apps)"` StartCommand flag.Command `long:"start-command" short:"c" description:"Startup command, set to null to reset to default start command"` - Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy, either rolling or null."` + Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary, rolling or null."` Task bool `long:"task" description:"Push an app that is used only to execute tasks. The app will be staged, but not started and will have no route assigned."` Vars []template.VarKV `long:"var" description:"Variable key value pair for variable substitution, (e.g., name=app1); can specify multiple times"` PathsToVarsFiles []flag.PathWithExistenceCheck `long:"vars-file" description:"Path to a variable substitution file for manifest; can specify multiple times"` dockerPassword interface{} `environmentName:"CF_DOCKER_PASSWORD" environmentDescription:"Password used for private docker repository"` - usage interface{} `usage:"CF_NAME push APP_NAME [-b BUILDPACK_NAME]\n [-c COMMAND] [-f MANIFEST_PATH | --no-manifest] [--no-start] [--no-wait] [-i NUM_INSTANCES]\n [-k DISK] [-m MEMORY] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [--task TASK]\n [-u (process | port | http)] [--no-route | --random-route]\n [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]...\n \n CF_NAME push APP_NAME --docker-image [REGISTRY_HOST:PORT/]IMAGE[:TAG] [--docker-username USERNAME]\n [-c COMMAND] [-f MANIFEST_PATH | --no-manifest] [--no-start] [--no-wait] [-i NUM_INSTANCES]\n [-k DISK] [-m MEMORY] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [--task TASK]\n [-u (process | port | http)] [--no-route | --random-route ]\n [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]..."` + usage interface{} `usage:"CF_NAME push APP_NAME [-b BUILDPACK_NAME]\n [-c COMMAND] [-f MANIFEST_PATH | --no-manifest] [--lifecycle (buildpack | docker | cnb)] [--no-start] [--no-wait] [-i NUM_INSTANCES]\n [-k DISK] [-m MEMORY] [-l LOG_RATE_LIMIT] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [--task TASK]\n [-u (process | port | http)] [--no-route | --random-route]\n [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]...\n \n CF_NAME push APP_NAME --docker-image [REGISTRY_HOST:PORT/]IMAGE[:TAG] [--docker-username USERNAME]\n [-c COMMAND] [-f MANIFEST_PATH | --no-manifest] [--no-start] [--no-wait] [-i NUM_INSTANCES]\n [-k DISK] [-m MEMORY] [-l LOG_RATE_LIMIT] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [--task TASK]\n [-u (process | port | http)] [--no-route | --random-route ]\n [--var KEY=VALUE] [--vars-file VARS_FILE_PATH]..."` envCFStagingTimeout interface{} `environmentName:"CF_STAGING_TIMEOUT" environmentDescription:"Max wait time for staging, in minutes" environmentDefault:"15"` envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` @@ -127,14 +137,17 @@ func (cmd *PushCommand) Setup(config command.Config, ui command.UI) error { cmd.VersionActor = cmd.Actor cmd.PushActor = v7pushaction.NewActor(cmd.Actor, sharedaction.NewActor(config)) - cmd.LogCacheClient = command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + cmd.LogCacheClient, err = logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } currentDir, err := os.Getwd() cmd.CWD = currentDir cmd.ManifestLocator = manifestparser.NewLocator() cmd.ManifestParser = manifestparser.ManifestParser{} - cmd.DiffDisplayer = shared.NewManifestDiffDisplayer(ui) + cmd.DiffDisplayer = &shared.ManifestDiffDisplayer{UI: ui, RedactEnv: cmd.RedactEnv} return err } @@ -156,6 +169,11 @@ func (cmd PushCommand) Execute(args []string) error { return err } + err = command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCNB) + if flagOverrides.Lifecycle != "" && err != nil { + return err + } + err = cmd.ValidateFlags() if err != nil { return err @@ -166,54 +184,58 @@ func (cmd PushCommand) Execute(args []string) error { return err } - transformedManifest, err := cmd.PushActor.HandleFlagOverrides(baseManifest, flagOverrides) + flagOverrides.CNBCredentials, err = cmd.Config.CNBCredentials() if err != nil { return err } - flagOverrides.DockerPassword, err = cmd.GetDockerPassword(flagOverrides.DockerUsername, transformedManifest.ContainsPrivateDockerImages()) + // Transform manifest from base using flag overrides + transformedInitialManifest, err := cmd.PushActor.HandleFlagOverrides(baseManifest, flagOverrides) if err != nil { return err } - transformedRawManifest, err := cmd.ManifestParser.MarshalManifest(transformedManifest) + flagOverrides.DockerPassword, err = cmd.GetDockerPassword(flagOverrides.DockerUsername, transformedInitialManifest.ContainsPrivateDockerImages()) if err != nil { return err } - cmd.announcePushing(transformedManifest.AppNames(), user) + transformedRawInitialManifest, err := cmd.ManifestParser.MarshalManifest(transformedInitialManifest) + if err != nil { + return err + } - hasManifest := transformedManifest.PathToManifest != "" + // Apply deployment scale options (this gives us the final manifest) + transformedFinalManifest, err := cmd.PushActor.HandleDeploymentScaleFlagOverrides(transformedInitialManifest, flagOverrides) + if err != nil { + return err + } + transformedRawFinalManifest, err := cmd.ManifestParser.MarshalManifest(transformedFinalManifest) + if err != nil { + return err + } + + cmd.announcePushing(transformedFinalManifest.AppNames(), user) + + hasManifest := transformedFinalManifest.PathToManifest != "" spaceGUID := cmd.Config.TargetedSpace().GUID if hasManifest { cmd.UI.DisplayText("Applying manifest file {{.Path}}...", map[string]interface{}{ - "Path": transformedManifest.PathToManifest, + "Path": transformedFinalManifest.PathToManifest, }) - diff, warnings, err := cmd.Actor.DiffSpaceManifest(spaceGUID, transformedRawManifest) - - cmd.UI.DisplayWarnings(warnings) + err := cmd.showManifestDiff(spaceGUID, transformedRawFinalManifest) if err != nil { - if _, isUnexpectedError := err.(ccerror.V3UnexpectedResponseError); isUnexpectedError { - cmd.UI.DisplayWarning("Unable to generate diff. Continuing to apply manifest...") - } else { - return err - } - } else { - cmd.UI.DisplayNewline() - cmd.UI.DisplayText("Updating with these attributes...") - - err = cmd.DiffDisplayer.DisplayDiff(transformedRawManifest, diff) - if err != nil { - return err - } + return err } + } + // Set space manifest using initial (non-scaled for rolling/canary deployment strategy) manifest v7ActionWarnings, err := cmd.VersionActor.SetSpaceManifest( cmd.Config.TargetedSpace().GUID, - transformedRawManifest, + transformedRawInitialManifest, ) cmd.UI.DisplayWarnings(v7ActionWarnings) @@ -227,9 +249,10 @@ func (cmd PushCommand) Execute(args []string) error { pushPlans, warnings, err := cmd.PushActor.CreatePushPlans( cmd.Config.TargetedSpace().GUID, cmd.Config.TargetedOrganization().GUID, - transformedManifest, + transformedFinalManifest, flagOverrides, ) + cmd.UI.DisplayWarnings(warnings) if err != nil { return err @@ -328,6 +351,17 @@ func (cmd PushCommand) GetFlagOverrides() (v7pushaction.FlagOverrides, error) { pathsToVarsFiles = append(pathsToVarsFiles, string(varFilePath)) } + var instanceSteps []int64 + if len(cmd.InstanceSteps) > 0 { + for _, v := range strings.Split(cmd.InstanceSteps, ",") { + parsedInt, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return v7pushaction.FlagOverrides{}, err + } + instanceSteps = append(instanceSteps, parsedInt) + } + } + return v7pushaction.FlagOverrides{ AppName: cmd.OptionalArgs.AppName, Buildpacks: cmd.Buildpacks, @@ -340,6 +374,8 @@ func (cmd PushCommand) GetFlagOverrides() (v7pushaction.FlagOverrides, error) { HealthCheckType: cmd.HealthCheckType.Type, HealthCheckTimeout: cmd.HealthCheckTimeout.Value, Instances: cmd.Instances.NullInt, + InstanceSteps: instanceSteps, + MaxInFlight: cmd.MaxInFlight, Memory: cmd.Memory, NoStart: cmd.NoStart, NoWait: cmd.NoWait, @@ -353,11 +389,71 @@ func (cmd PushCommand) GetFlagOverrides() (v7pushaction.FlagOverrides, error) { Vars: cmd.Vars, NoManifest: cmd.NoManifest, Task: cmd.Task, + LogRateLimit: cmd.LogRateLimit, + Lifecycle: cmd.Lifecycle, }, nil } func (cmd PushCommand) ValidateFlags() error { switch { + // Lifecycle buildpack requested + case cmd.Lifecycle == constant.AppLifecycleTypeBuildpack && cmd.DockerImage.Path != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle buildpack", + "--docker-image, -o", + }, + } + + case cmd.Lifecycle == constant.AppLifecycleTypeBuildpack && cmd.DockerUsername != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle buildpack", + "--docker-username", + }, + } + + // Lifecycle docker requested + case cmd.Lifecycle == constant.AppLifecycleTypeDocker && cmd.Buildpacks != nil: + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--buildpack, -b", + }, + } + + case cmd.Lifecycle == constant.AppLifecycleTypeDocker && cmd.Stack != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--stack, -s", + }, + } + case cmd.Lifecycle == constant.AppLifecycleTypeDocker && cmd.DropletPath != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--droplet", + }, + } + + // Lifecycle cnb requested + case cmd.Lifecycle == constant.AppLifecycleTypeCNB && cmd.DockerImage.Path != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle cnb", + "--docker-image, -o", + }, + } + + case cmd.Lifecycle == constant.AppLifecycleTypeCNB && cmd.DockerUsername != "": + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle cnb", + "--docker-username", + }, + } + case cmd.DockerUsername != "" && cmd.DockerImage.Path == "": return translatableerror.RequiredFlagsError{ Arg1: "--docker-image, -o", @@ -444,6 +540,22 @@ func (cmd PushCommand) ValidateFlags() error { }, } + case cmd.NoStart && cmd.Strategy == flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary}: + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--no-start", + "--strategy=canary", + }, + } + + case cmd.Task && cmd.Strategy == flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary}: + return translatableerror.ArgumentCombinationError{ + Args: []string{ + "--task", + "--strategy=canary", + }, + } + case cmd.NoStart && cmd.NoWait: return translatableerror.ArgumentCombinationError{ Args: []string{ @@ -461,11 +573,34 @@ func (cmd PushCommand) ValidateFlags() error { } case !cmd.validBuildpacks(): return translatableerror.InvalidBuildpacksError{} + + case cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil: + return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} + case cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1: + return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} + case len(cmd.InstanceSteps) > 0 && cmd.Strategy.Name != constant.DeploymentStrategyCanary: + return translatableerror.ArgumentCombinationError{Args: []string{"--instance-steps", "--strategy=rolling or --strategy not provided"}} + case len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps): + return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} + } + + if len(cmd.InstanceSteps) > 0 { + return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") } return nil } +func validateInstanceSteps(instanceSteps string) bool { + for _, v := range strings.Split(instanceSteps, ",") { + _, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return false + } + } + return true +} + func (cmd PushCommand) validBuildpacks() bool { for _, buildpack := range cmd.Buildpacks { if (buildpack == "null" || buildpack == "default") && len(cmd.Buildpacks) > 1 { @@ -646,3 +781,26 @@ func (cmd PushCommand) getLogs(logStream <-chan sharedaction.LogMessage, errStre } } } + +func (cmd PushCommand) showManifestDiff(spaceGUID string, transformedRawFinalManifest []byte) error { + diff, warnings, err := cmd.Actor.DiffSpaceManifest(spaceGUID, transformedRawFinalManifest) + + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, isUnexpectedError := err.(ccerror.V3UnexpectedResponseError); isUnexpectedError { + cmd.UI.DisplayWarning("Unable to generate diff. Continuing to apply manifest...") + } else { + return err + } + } else { + cmd.UI.DisplayNewline() + cmd.UI.DisplayText("Updating with these attributes...") + + err = cmd.DiffDisplayer.DisplayDiff(transformedRawFinalManifest, diff) + if err != nil { + return err + } + } + + return nil +} diff --git a/command/v7/push_command_test.go b/command/v7/push_command_test.go index 6d5d77fdcef..39ac05ca362 100644 --- a/command/v7/push_command_test.go +++ b/command/v7/push_command_test.go @@ -5,26 +5,26 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7pushaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/manifestparser" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/manifestparser" + "code.cloudfoundry.org/cli/v8/util/ui" "github.com/cloudfoundry/bosh-cli/director/template" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -212,7 +212,7 @@ var _ = Describe("push Command", func() { When("the flags are all valid", func() { It("delegating to the GetBaseManifest", func() { - // This tells us GetBaseManifest is being called because we dont have a fake + // This tells us GetBaseManifest is being called because we don't have a fake Expect(fakeManifestLocator.PathCallCount()).To(Equal(1)) }) @@ -275,6 +275,14 @@ var _ = Describe("push Command", func() { }, nil, ) + fakeActor.HandleDeploymentScaleFlagOverridesReturns( + manifestparser.Manifest{ + Applications: []manifestparser.Application{ + {Name: "some-app-name"}, + }, + }, + nil, + ) }) When("the docker password is needed", func() { @@ -299,7 +307,7 @@ var _ = Describe("push Command", func() { }) It("delegates to the manifest parser", func() { - Expect(fakeManifestParser.MarshalManifestCallCount()).To(Equal(1)) + Expect(fakeManifestParser.MarshalManifestCallCount()).To(Equal(2)) Expect(fakeManifestParser.MarshalManifestArgsForCall(0)).To(Equal( manifestparser.Manifest{ Applications: []manifestparser.Application{ @@ -319,7 +327,7 @@ var _ = Describe("push Command", func() { }) }) - When("marsahlling the manifest succeeds", func() { + When("marshalling the manifest succeeds", func() { BeforeEach(func() { fakeManifestParser.MarshalManifestReturns([]byte("our-manifest"), nil) }) @@ -341,6 +349,12 @@ var _ = Describe("push Command", func() { }, nil, ) + fakeActor.HandleDeploymentScaleFlagOverridesReturns( + manifestparser.Manifest{ + PathToManifest: "path/to/manifest", + }, + nil, + ) expectedDiff = resources.ManifestDiff{ Diffs: []resources.Diff{ {Op: resources.AddOperation, Path: "/path/to/field", Value: "hello"}, @@ -620,6 +634,31 @@ var _ = Describe("push Command", func() { }) }) + Describe("canary steps", func() { + BeforeEach(func() { + cmd.InstanceSteps = "1,2,3,4" + }) + + When("canary strategy is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: "canary"} + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("4.0.0") + cmd.Config = fakeConfig + }) + + It("should succeed", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) + + When("canary strategy is NOT provided", func() { + It("it just fails", func() { + Expect(executeErr).To(HaveOccurred()) + }) + }) + }) + When("when getting the application summary succeeds", func() { BeforeEach(func() { summary := v7action.DetailedApplicationSummary{ @@ -1072,12 +1111,16 @@ var _ = Describe("push Command", func() { cmd.RandomRoute = false cmd.NoStart = true cmd.NoWait = true + maxInFlight := 1 + cmd.MaxInFlight = &maxInFlight cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} cmd.Instances = flag.Instances{NullInt: types.NullInt{Value: 10, IsSet: true}} cmd.PathToManifest = "/manifest/path" cmd.PathsToVarsFiles = []flag.PathWithExistenceCheck{"/vars1", "/vars2"} cmd.Vars = []template.VarKV{{Name: "key", Value: "val"}} cmd.Task = true + cmd.LogRateLimit = "512M" + cmd.Lifecycle = constant.AppLifecycleTypeBuildpack }) JustBeforeEach(func() { @@ -1106,6 +1149,9 @@ var _ = Describe("push Command", func() { Expect(overrides.PathsToVarsFiles).To(Equal([]string{"/vars1", "/vars2"})) Expect(overrides.Vars).To(Equal([]template.VarKV{{Name: "key", Value: "val"}})) Expect(overrides.Task).To(BeTrue()) + Expect(overrides.LogRateLimit).To(Equal("512M")) + Expect(*overrides.MaxInFlight).To(Equal(1)) + Expect(overrides.Lifecycle).To(BeEquivalentTo("buildpack")) }) When("a docker image is provided", func() { @@ -1216,6 +1262,17 @@ var _ = Describe("push Command", func() { }, }), + Entry("when strategy 'canary' and no-start flags are passed", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.NoStart = true + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--no-start", "--strategy=canary", + }, + }), + Entry("when strategy is not set and no-start flags are passed", func() { cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyDefault} @@ -1256,7 +1313,7 @@ var _ = Describe("push Command", func() { }, translatableerror.InvalidBuildpacksError{}), - Entry("task and strategy flags are passed", + Entry("task and 'rolling' strategy flags are passed", func() { cmd.Task = true cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} @@ -1266,5 +1323,153 @@ var _ = Describe("push Command", func() { "--task", "--strategy=rolling", }, }), + + Entry("task and 'canary' strategy flags are passed", + func() { + cmd.Task = true + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--task", "--strategy=canary", + }, + }), + + Entry("max-in-flight is passed without strategy", + func() { + maxInFlight := 10 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.RequiredFlagsError{ + Arg1: "--max-in-flight", + Arg2: "--strategy", + }), + + Entry("max-in-flight is smaller than 1", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + maxInFlight := 0 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.IncorrectUsageError{ + Message: "--max-in-flight must be greater than or equal to 1", + }), + + Entry("lifecycle buildpack and docker-image flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeBuildpack + cmd.DockerImage = flag.DockerImage{Path: "foo"} + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle buildpack", + "--docker-image, -o", + }, + }), + + Entry("lifecycle buildpack and docker-username flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeBuildpack + cmd.DockerUsername = "user" + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle buildpack", + "--docker-username", + }, + }), + + Entry("lifecycle docker and buildpacks flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeDocker + cmd.Buildpacks = []string{"nodejs"} + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--buildpack, -b", + }, + }), + + Entry("lifecycle docker and stck flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeDocker + cmd.Stack = "stack" + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--stack, -s", + }, + }), + + Entry("lifecycle docker and droplet flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeDocker + cmd.DropletPath = flag.PathWithExistenceCheck("path") + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle docker", + "--droplet", + }, + }), + + Entry("lifecycle cnb and docker-image flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeCNB + cmd.DockerImage = flag.DockerImage{Path: "foo"} + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle cnb", + "--docker-image, -o", + }, + }), + + Entry("lifecycle cnb and docker-username flags are passed", + func() { + cmd.Lifecycle = constant.AppLifecycleTypeCNB + cmd.DockerUsername = "user" + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--lifecycle cnb", + "--docker-username", + }, + }), + + Entry("instance-steps is not a list of ints", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "impossible" + }, + translatableerror.ParseArgumentError{ + ArgumentName: "--instance-steps", + ExpectedType: "list of weights", + }), + + Entry("instance-steps can only be used with canary strategy", + func() { + cmd.InstanceSteps = "impossible" + }, + translatableerror.ArgumentCombinationError{ + Args: []string{ + "--instance-steps", "--strategy=rolling or --strategy not provided", + }}), + + Entry("instance-steps used when CAPI does not support canary steps", + func() { + cmd.InstanceSteps = "1,2,3" + cmd.Strategy.Name = constant.DeploymentStrategyCanary + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("3.0.0") + cmd.Config = fakeConfig + }, + translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--instance-steps", + CurrentVersion: "3.0.0", + MinimumVersion: "3.189.0", + }), ) }) diff --git a/command/v7/remove_network_policy_command.go b/command/v7/remove_network_policy_command.go index c959bd40678..183d3141189 100644 --- a/command/v7/remove_network_policy_command.go +++ b/command/v7/remove_network_policy_command.go @@ -1,12 +1,12 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RemoveNetworkPolicyActor diff --git a/command/v7/remove_network_policy_command_test.go b/command/v7/remove_network_policy_command_test.go index 66247bc31ff..447d83f94f0 100644 --- a/command/v7/remove_network_policy_command_test.go +++ b/command/v7/remove_network_policy_command_test.go @@ -1,18 +1,18 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/rename_command.go b/command/v7/rename_command.go index a2bb0b6efe0..5cf755fb494 100644 --- a/command/v7/rename_command.go +++ b/command/v7/rename_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type RenameCommand struct { diff --git a/command/v7/rename_command_test.go b/command/v7/rename_command_test.go index 4700666540b..7853d8a9533 100644 --- a/command/v7/rename_command_test.go +++ b/command/v7/rename_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/rename_org_command.go b/command/v7/rename_org_command.go index 628095f80d5..e0b059f3e24 100644 --- a/command/v7/rename_org_command.go +++ b/command/v7/rename_org_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type RenameOrgCommand struct { diff --git a/command/v7/rename_org_command_test.go b/command/v7/rename_org_command_test.go index 5a61f65bb23..785b3e574c0 100644 --- a/command/v7/rename_org_command_test.go +++ b/command/v7/rename_org_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/rename_service_broker_command.go b/command/v7/rename_service_broker_command.go index 4cd5ad001a8..c44fd30cd53 100644 --- a/command/v7/rename_service_broker_command.go +++ b/command/v7/rename_service_broker_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type RenameServiceBrokerCommand struct { diff --git a/command/v7/rename_service_broker_command_test.go b/command/v7/rename_service_broker_command_test.go index c5cc9947952..1bd6a036c85 100644 --- a/command/v7/rename_service_broker_command_test.go +++ b/command/v7/rename_service_broker_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/rename_service_command.go b/command/v7/rename_service_command.go index f298e75c307..39e90a717d4 100644 --- a/command/v7/rename_service_command.go +++ b/command/v7/rename_service_command.go @@ -1,10 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" "strings" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type RenameServiceCommand struct { diff --git a/command/v7/rename_service_command_test.go b/command/v7/rename_service_command_test.go index 1a7aeeca305..6ca31e7118a 100644 --- a/command/v7/rename_service_command_test.go +++ b/command/v7/rename_service_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/rename_space_command.go b/command/v7/rename_space_command.go index cf63ebf7d14..cfaba1f91e0 100644 --- a/command/v7/rename_space_command.go +++ b/command/v7/rename_space_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type RenameSpaceCommand struct { diff --git a/command/v7/rename_space_command_test.go b/command/v7/rename_space_command_test.go index fbb020fdb8e..51e0d2e460f 100644 --- a/command/v7/rename_space_command_test.go +++ b/command/v7/rename_space_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/reset_org_default_isolation_segment_command.go b/command/v7/reset_org_default_isolation_segment_command.go index 26763b4ff45..ba7413f3fca 100644 --- a/command/v7/reset_org_default_isolation_segment_command.go +++ b/command/v7/reset_org_default_isolation_segment_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type ResetOrgDefaultIsolationSegmentCommand struct { diff --git a/command/v7/reset_org_default_isolation_segment_command_test.go b/command/v7/reset_org_default_isolation_segment_command_test.go index aa76bf487f8..26bb36687a5 100644 --- a/command/v7/reset_org_default_isolation_segment_command_test.go +++ b/command/v7/reset_org_default_isolation_segment_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/reset_space_isolation_segment_command.go b/command/v7/reset_space_isolation_segment_command.go index 4d878135064..49a9fe2763c 100644 --- a/command/v7/reset_space_isolation_segment_command.go +++ b/command/v7/reset_space_isolation_segment_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type ResetSpaceIsolationSegmentCommand struct { diff --git a/command/v7/reset_space_isolation_segment_command_test.go b/command/v7/reset_space_isolation_segment_command_test.go index 0a8638d2422..bfd7719223d 100644 --- a/command/v7/reset_space_isolation_segment_command_test.go +++ b/command/v7/reset_space_isolation_segment_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/restage_command.go b/command/v7/restage_command.go index 628bd852130..7aa3a5aba4d 100644 --- a/command/v7/restage_command.go +++ b/command/v7/restage_command.go @@ -1,21 +1,30 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" + "strconv" + "strings" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type RestageCommand struct { BaseCommand RequiredArgs flag.AppName `positional-args:"yes"` - Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy, either rolling or null."` + InstanceSteps string `long:"instance-steps" description:"An array of percentage steps to deploy when using deployment strategy canary. (e.g. 20,40,60)"` + MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively being restaged. Only applies when --strategy flag is specified."` NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` - usage interface{} `usage:"CF_NAME restage APP_NAME\n\n This command will cause downtime unless you use '--strategy rolling'.\n\nEXAMPLES:\n CF_NAME restage APP_NAME\n CF_NAME restage APP_NAME --strategy rolling\n CF_NAME restage APP_NAME --strategy rolling --no-wait"` + Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary, rolling or null."` + usage interface{} `usage:"CF_NAME restage APP_NAME\n\n This command will cause downtime unless you use '--strategy' flag.\n\nEXAMPLES:\n CF_NAME restage APP_NAME\n CF_NAME restage APP_NAME --strategy rolling\n CF_NAME restage APP_NAME --strategy canary --no-wait"` relatedCommands interface{} `related_commands:"restart"` envCFStagingTimeout interface{} `environmentName:"CF_STAGING_TIMEOUT" environmentDescription:"Max wait time for staging, in minutes" environmentDefault:"15"` envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` @@ -29,7 +38,11 @@ func (cmd *RestageCommand) Setup(config command.Config, ui command.UI) error { return err } - logCacheClient := command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + logCacheClient, err := logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } + cmd.Stager = shared.NewAppStager(cmd.Actor, cmd.UI, cmd.Config, logCacheClient) return nil @@ -46,7 +59,12 @@ func (cmd RestageCommand) Execute(args []string) error { return err } - if cmd.Strategy.Name != constant.DeploymentStrategyRolling { + err = cmd.ValidateFlags() + if err != nil { + return err + } + + if len(cmd.Strategy.Name) <= 0 { cmd.UI.DisplayWarning("This action will cause app downtime.") } @@ -71,15 +89,29 @@ func (cmd RestageCommand) Execute(args []string) error { return mapErr(cmd.Config, cmd.RequiredArgs.AppName, err) } - err = cmd.Stager.StageAndStart( - app, - cmd.Config.TargetedSpace(), - cmd.Config.TargetedOrganization(), - pkg.GUID, - cmd.Strategy.Name, - cmd.NoWait, - constant.ApplicationRestarting, - ) + opts := shared.AppStartOpts{ + AppAction: constant.ApplicationRestarting, + NoWait: cmd.NoWait, + Strategy: cmd.Strategy.Name, + } + + if cmd.MaxInFlight != nil { + opts.MaxInFlight = *cmd.MaxInFlight + } + + if cmd.InstanceSteps != "" { + if len(cmd.InstanceSteps) > 0 { + for _, v := range strings.Split(cmd.InstanceSteps, ",") { + parsedInt, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return err + } + opts.CanarySteps = append(opts.CanarySteps, resources.CanaryStep{InstanceWeight: parsedInt}) + } + } + } + + err = cmd.Stager.StageAndStart(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), pkg.GUID, opts) if err != nil { return mapErr(cmd.Config, cmd.RequiredArgs.AppName, err) } @@ -87,6 +119,25 @@ func (cmd RestageCommand) Execute(args []string) error { return nil } +func (cmd RestageCommand) ValidateFlags() error { + switch { + case cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil: + return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} + case cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1: + return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} + case cmd.Strategy.Name != constant.DeploymentStrategyCanary && cmd.InstanceSteps != "": + return translatableerror.RequiredFlagsError{Arg1: "--instance-steps", Arg2: "--strategy=canary"} + case len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps): + return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} + } + + if len(cmd.InstanceSteps) > 0 { + return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") + } + + return nil +} + func mapErr(config command.Config, appName string, err error) error { switch err.(type) { case actionerror.AllInstancesCrashedError: diff --git a/command/v7/restage_command_test.go b/command/v7/restage_command_test.go index 7de6e0488b1..14396031246 100644 --- a/command/v7/restage_command_test.go +++ b/command/v7/restage_command_test.go @@ -3,18 +3,19 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared/sharedfakes" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -73,6 +74,10 @@ var _ = Describe("restage Command", func() { v7action.Warnings{"get-package-warning"}, nil, ) + + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + maxInFlight := 4 + cmd.MaxInFlight = &maxInFlight }) JustBeforeEach(func() { @@ -105,15 +110,40 @@ var _ = Describe("restage Command", func() { }) }) - When("it's NOT a rolling deploy", func() { + When("No strategy flag is given", func() { BeforeEach(func() { cmd.Strategy.Name = constant.DeploymentStrategyDefault + cmd.MaxInFlight = nil }) It("warns that there will be app downtime", func() { Expect(testUI.Err).To(Say("This action will cause app downtime.")) }) }) + When("canary strategy is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "1,2,4" + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("4.0.0") + cmd.Config = fakeConfig + }) + + It("starts the app with the current droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) + + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StageAndStartArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputDropletGuid).To(Equal("earliest-package-guid")) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 4}})) + }) + }) + It("displays that it's restaging", func() { Expect(testUI.Out).To(Say("Restaging app some-app in org some-org / space some-space as steve...")) }) @@ -165,14 +195,15 @@ var _ = Describe("restage Command", func() { It("stages and starts the app", func() { Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - returnedApp, spaceForApp, orgForApp, pkgGUID, strategy, noWait, appAction := fakeAppStager.StageAndStartArgsForCall(0) + returnedApp, spaceForApp, orgForApp, pkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) Expect(returnedApp).To(Equal(app)) Expect(spaceForApp).To(Equal(fakeConfig.TargetedSpace())) Expect(orgForApp).To(Equal(fakeConfig.TargetedOrganization())) Expect(pkgGUID).To(Equal("earliest-package-guid")) - Expect(strategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(noWait).To(Equal(false)) - Expect(appAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyRolling)) + Expect(opts.MaxInFlight).To(Equal(4)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) }) When("staging and starting the app fails", func() { @@ -188,4 +219,79 @@ var _ = Describe("restage Command", func() { It("succeeds", func() { Expect(executeErr).To(Not(HaveOccurred())) }) + + DescribeTable("ValidateFlags returns an error", + func(setup func(), expectedErr error) { + setup() + err := cmd.ValidateFlags() + if expectedErr == nil { + Expect(err).To(BeNil()) + } else { + Expect(err).To(MatchError(expectedErr)) + } + }, + Entry("max-in-flight is passed without strategy", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyDefault} + maxInFlight := 10 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.RequiredFlagsError{ + Arg1: "--max-in-flight", + Arg2: "--strategy", + }), + + Entry("max-in-flight is smaller than 1", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + maxInFlight := 0 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.IncorrectUsageError{ + Message: "--max-in-flight must be greater than or equal to 1", + }), + + Entry("instance-steps provided with rolling deployment", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps no strategy provided", + func() { + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps a valid list of ints", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "some,thing,not,right" + }, + translatableerror.ParseArgumentError{ + ArgumentName: "--instance-steps", + ExpectedType: "list of weights", + }), + + Entry("instance-steps used when CAPI does not support canary steps", + func() { + cmd.InstanceSteps = "1,2,3" + cmd.Strategy.Name = constant.DeploymentStrategyCanary + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("3.0.0") + cmd.Config = fakeConfig + }, + translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--instance-steps", + CurrentVersion: "3.0.0", + MinimumVersion: "3.189.0", + }), + ) }) diff --git a/command/v7/restart_app_instance_command.go b/command/v7/restart_app_instance_command.go index 756f3941022..d1c0f1717b2 100644 --- a/command/v7/restart_app_instance_command.go +++ b/command/v7/restart_app_instance_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type RestartAppInstanceCommand struct { diff --git a/command/v7/restart_app_instance_command_test.go b/command/v7/restart_app_instance_command_test.go index 4108024c61a..fbdc905efc8 100644 --- a/command/v7/restart_app_instance_command_test.go +++ b/command/v7/restart_app_instance_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/restart_command.go b/command/v7/restart_command.go index 66652cc0cf8..dbfe4ee738d 100644 --- a/command/v7/restart_command.go +++ b/command/v7/restart_command.go @@ -1,19 +1,29 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "strconv" + "strings" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type RestartCommand struct { BaseCommand + InstanceSteps string `long:"instance-steps" description:"An array of percentage steps to deploy when using deployment strategy canary. (e.g. 20,40,60)"` + MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively restarted at any given time. Only applies when --strategy flag is specified."` RequiredArgs flag.AppName `positional-args:"yes"` - Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy, either rolling or null."` + Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary, rolling or null."` NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` - usage interface{} `usage:"CF_NAME restart APP_NAME\n\n This command will cause downtime unless you use '--strategy rolling'.\n\n If the app's most recent package is unstaged, restarting the app will stage and run that package.\n Otherwise, the app's current droplet will be run."` + usage interface{} `usage:"CF_NAME restart APP_NAME\n\n This command will cause downtime unless you use '--strategy canary' or '--strategy rolling'.\n\n If the app's most recent package is unstaged, restarting the app will stage and run that package.\n Otherwise, the app's current droplet will be run."` relatedCommands interface{} `related_commands:"restage, restart-app-instance"` envCFStagingTimeout interface{} `environmentName:"CF_STAGING_TIMEOUT" environmentDescription:"Max wait time for staging, in minutes" environmentDefault:"15"` envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` @@ -26,7 +36,12 @@ func (cmd *RestartCommand) Setup(config command.Config, ui command.UI) error { if err != nil { return err } - logCacheClient := command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + + logCacheClient, err := logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } + cmd.Stager = shared.NewAppStager(cmd.Actor, cmd.UI, cmd.Config, logCacheClient) return nil @@ -43,6 +58,11 @@ func (cmd RestartCommand) Execute(args []string) error { return err } + err = cmd.ValidateFlags() + if err != nil { + return err + } + app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID) cmd.UI.DisplayWarnings(warnings) if err != nil { @@ -55,7 +75,7 @@ func (cmd RestartCommand) Execute(args []string) error { return err } - if packageGUID != "" || cmd.Strategy.Name == constant.DeploymentStrategyRolling { + if packageGUID != "" || len(cmd.Strategy.Name) > 0 { cmd.UI.DisplayTextWithFlavor("Restarting app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ "AppName": cmd.RequiredArgs.AppName, "OrgName": cmd.Config.TargetedOrganization().Name, @@ -65,13 +85,35 @@ func (cmd RestartCommand) Execute(args []string) error { cmd.UI.DisplayNewline() } + opts := shared.AppStartOpts{ + Strategy: cmd.Strategy.Name, + NoWait: cmd.NoWait, + AppAction: constant.ApplicationRestarting, + } + + if cmd.MaxInFlight != nil { + opts.MaxInFlight = *cmd.MaxInFlight + } + + if cmd.InstanceSteps != "" { + if len(cmd.InstanceSteps) > 0 { + for _, v := range strings.Split(cmd.InstanceSteps, ",") { + parsedInt, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return err + } + opts.CanarySteps = append(opts.CanarySteps, resources.CanaryStep{InstanceWeight: parsedInt}) + } + } + } + if packageGUID != "" { - err = cmd.Stager.StageAndStart(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), packageGUID, cmd.Strategy.Name, cmd.NoWait, constant.ApplicationRestarting) + err = cmd.Stager.StageAndStart(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), packageGUID, opts) if err != nil { return err } } else { - err = cmd.Stager.StartApp(app, "", cmd.Strategy.Name, cmd.NoWait, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), constant.ApplicationRestarting) + err = cmd.Stager.StartApp(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), "", opts) if err != nil { return err } @@ -79,3 +121,22 @@ func (cmd RestartCommand) Execute(args []string) error { return nil } + +func (cmd RestartCommand) ValidateFlags() error { + switch true { + case cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil: + return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} + case cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1: + return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} + case cmd.Strategy.Name != constant.DeploymentStrategyCanary && cmd.InstanceSteps != "": + return translatableerror.RequiredFlagsError{Arg1: "--instance-steps", Arg2: "--strategy=canary"} + case len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps): + return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} + } + + if len(cmd.InstanceSteps) > 0 { + return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") + } + + return nil +} diff --git a/command/v7/restart_command_test.go b/command/v7/restart_command_test.go index fbe3f8b6d5c..24310b41039 100644 --- a/command/v7/restart_command_test.go +++ b/command/v7/restart_command_test.go @@ -3,18 +3,19 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared/sharedfakes" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -132,18 +133,46 @@ var _ = Describe("restart Command", func() { fakeActor.GetUnstagedNewestPackageGUIDReturns("package-guid", v7action.Warnings{}, nil) }) - It("stages the new package and starts the app with the new droplet", func() { - Expect(executeErr).ToNot(HaveOccurred()) - Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) + When("no strategy is provided", func() { + It("stages the new package and starts the app with the new droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - inputApp, inputSpace, inputOrg, inputPkgGUID, inputStrategy, inputNoWait, inputAppAction := fakeAppStager.StageAndStartArgsForCall(0) - Expect(inputApp).To(Equal(app)) - Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) - Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) - Expect(inputPkgGUID).To(Equal("package-guid")) - Expect(inputStrategy).To(Equal(strategy)) - Expect(inputNoWait).To(Equal(noWait)) - Expect(inputAppAction).To(Equal(constant.ApplicationRestarting)) + inputApp, inputSpace, inputOrg, inputPkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(inputPkgGUID).To(Equal("package-guid")) + Expect(opts.Strategy).To(Equal(strategy)) + Expect(opts.NoWait).To(Equal(noWait)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(HaveLen(0)) + }) + }) + + When("canary strategy is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "1,2,4" + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("4.0.0") + cmd.Config = fakeConfig + }) + + It("starts the app with the current droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) + + inputApp, inputSpace, inputOrg, inputPkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(inputPkgGUID).To(Equal("package-guid")) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.NoWait).To(Equal(noWait)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 4}})) + }) }) Context("staging and starting the app returns an error", func() { @@ -162,18 +191,47 @@ var _ = Describe("restart Command", func() { fakeActor.GetUnstagedNewestPackageGUIDReturns("", v7action.Warnings{}, nil) }) - It("starts the app with the current droplet", func() { - Expect(executeErr).ToNot(HaveOccurred()) - Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) + When("no strategy is provided", func() { + It("starts the app with the current droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) + + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StartAppArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputDropletGuid).To(Equal("")) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(opts.Strategy).To(Equal(strategy)) + Expect(opts.NoWait).To(Equal(noWait)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(HaveLen(0)) + }) + }) + + When("canary strategy is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "1,2,4" + + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("4.0.0") + cmd.Config = fakeConfig + }) + + It("starts the app with the current droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) - inputApp, inputDropletGuid, inputStrategy, inputNoWait, inputSpace, inputOrg, inputAppAction := fakeAppStager.StartAppArgsForCall(0) - Expect(inputApp).To(Equal(app)) - Expect(inputDropletGuid).To(Equal("")) - Expect(inputStrategy).To(Equal(strategy)) - Expect(inputNoWait).To(Equal(noWait)) - Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) - Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) - Expect(inputAppAction).To(Equal(constant.ApplicationRestarting)) + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StartAppArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputDropletGuid).To(Equal("")) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.NoWait).To(Equal(noWait)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRestarting)) + Expect(opts.CanarySteps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 4}})) + }) }) When("starting the app returns an error", func() { @@ -187,4 +245,78 @@ var _ = Describe("restart Command", func() { }) }) + DescribeTable("ValidateFlags returns an error", + func(setup func(), expectedErr error) { + setup() + err := cmd.ValidateFlags() + if expectedErr == nil { + Expect(err).To(BeNil()) + } else { + Expect(err).To(MatchError(expectedErr)) + } + }, + + Entry("max-in-flight is passed without strategy", + func() { + maxInFlight := 10 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.RequiredFlagsError{ + Arg1: "--max-in-flight", + Arg2: "--strategy", + }), + + Entry("max-in-flight is smaller than 1", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + maxInFlight := 0 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.IncorrectUsageError{ + Message: "--max-in-flight must be greater than or equal to 1", + }), + + Entry("instance-steps provided with rolling deployment", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyRolling} + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps no strategy provided", + func() { + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps a valid list of ints", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "some,thing,not,right" + }, + translatableerror.ParseArgumentError{ + ArgumentName: "--instance-steps", + ExpectedType: "list of weights", + }), + + Entry("instance-steps used when CAPI does not support canary steps", + func() { + cmd.InstanceSteps = "1,2,3" + cmd.Strategy.Name = constant.DeploymentStrategyCanary + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("3.0.0") + cmd.Config = fakeConfig + }, + translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--instance-steps", + CurrentVersion: "3.0.0", + MinimumVersion: "3.189.0", + }), + ) }) diff --git a/command/v7/revision_command.go b/command/v7/revision_command.go index ebd429291b4..eedfafa5cbf 100644 --- a/command/v7/revision_command.go +++ b/command/v7/revision_command.go @@ -1,20 +1,152 @@ package v7 import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" + "fmt" + "strconv" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type RevisionCommand struct { BaseCommand usage interface{} `usage:"CF_NAME revision APP_NAME [--version VERSION]"` RequiredArgs flag.AppName `positional-args:"yes"` - Version flag.Revision `long:"version" required:"true" description:"The integer representing the specific revision to show"` + Version flag.Revision `long:"version" description:"The integer representing the specific revision to show"` relatedCommands interface{} `related_commands:"revisions, rollback"` } func (cmd RevisionCommand) Execute(_ []string) error { - cmd.UI.DisplayWarning(command.ExperimentalWarning) + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Config.CurrentUser() + if err != nil { + return err + } + + appName := cmd.RequiredArgs.AppName + if cmd.Version.Value > 0 { + cmd.UI.DisplayTextWithFlavor("Showing revision {{.Version}} for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ + "AppName": appName, + "OrgName": cmd.Config.TargetedOrganization().Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "Username": user.Name, + "Version": cmd.Version.Value, + }) + } else { + cmd.UI.DisplayTextWithFlavor("Showing revisions for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ + "AppName": appName, + "OrgName": cmd.Config.TargetedOrganization().Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "Username": user.Name, + }) + } + cmd.UI.DisplayNewline() + + app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(appName, cmd.Config.TargetedSpace().GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + deployedRevisions, warnings, err := cmd.Actor.GetApplicationRevisionsDeployed(app.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + if cmd.Version.Value > 0 { + revision, warnings, err := cmd.Actor.GetRevisionByApplicationAndVersion( + app.GUID, + cmd.Version.Value, + ) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + isDeployed := cmd.revisionDeployed(revision, deployedRevisions) + + err = cmd.displayRevisionInfo(revision, isDeployed) + if err != nil { + return err + } + } else { + for _, deployedRevision := range deployedRevisions { + err = cmd.displayRevisionInfo(deployedRevision, true) + if err != nil { + return err + } + } + } return nil } + +func (cmd RevisionCommand) displayRevisionInfo(revision resources.Revision, isDeployed bool) error { + cmd.displayBasicRevisionInfo(revision, isDeployed) + cmd.UI.DisplayNewline() + + cmd.UI.DisplayHeader("labels:") + cmd.displayMetaData(revision.Metadata.Labels) + + cmd.UI.DisplayHeader("annotations:") + cmd.displayMetaData(revision.Metadata.Annotations) + + cmd.UI.DisplayHeader("application environment variables:") + envVars, isPresent, warnings, err := cmd.Actor.GetEnvironmentVariableGroupByRevision(revision) + if err != nil { + return err + } + cmd.UI.DisplayWarnings(warnings) + if isPresent { + cmd.displayEnvVarGroup(envVars) + cmd.UI.DisplayNewline() + } + return nil +} + +func (cmd RevisionCommand) displayBasicRevisionInfo(revision resources.Revision, isDeployed bool) { + keyValueTable := [][]string{ + {"revision:", fmt.Sprintf("%d", revision.Version)}, + {"deployed:", strconv.FormatBool(isDeployed)}, + {"description:", revision.Description}, + {"deployable:", strconv.FormatBool(revision.Deployable)}, + {"revision GUID:", revision.GUID}, + {"droplet GUID:", revision.Droplet.GUID}, + {"created on:", revision.CreatedAt}, + } + cmd.UI.DisplayKeyValueTable("", keyValueTable, 3) +} + +func (cmd RevisionCommand) displayEnvVarGroup(envVarGroup v7action.EnvironmentVariableGroup) { + envVarTable := [][]string{} + for k, v := range envVarGroup { + envVarTable = append(envVarTable, []string{fmt.Sprintf("%s:", k), v.Value}) + } + cmd.UI.DisplayKeyValueTable("", envVarTable, 3) +} + +func (cmd RevisionCommand) displayMetaData(data map[string]types.NullString) { + if len(data) > 0 { + tableData := [][]string{} + for k, v := range data { + tableData = append(tableData, []string{fmt.Sprintf("%s:", k), v.Value}) + } + cmd.UI.DisplayKeyValueTable("", tableData, 3) + cmd.UI.DisplayNewline() + } +} + +func (cmd RevisionCommand) revisionDeployed(revision resources.Revision, deployedRevisions []resources.Revision) bool { + for _, deployedRevision := range deployedRevisions { + if revision.GUID == deployedRevision.GUID { + return true + } + } + return false +} diff --git a/command/v7/revision_command_test.go b/command/v7/revision_command_test.go index dbf0391774c..bd30ecad931 100644 --- a/command/v7/revision_command_test.go +++ b/command/v7/revision_command_test.go @@ -1,11 +1,19 @@ package v7_test import ( - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "errors" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -18,6 +26,7 @@ var _ = Describe("revision Command", func() { fakeSharedActor *commandfakes.FakeSharedActor fakeActor *v7fakes.FakeActor binaryName string + executeErr error appName string out *Buffer @@ -46,10 +55,308 @@ var _ = Describe("revision Command", func() { }) JustBeforeEach(func() { - cmd.Execute(nil) + executeErr = cmd.Execute(nil) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NotLoggedInError{BinaryName: binaryName}) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NotLoggedInError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) }) - It("displays the experimental warning", func() { - Expect(testUI.Err).To(Say("This command is in EXPERIMENTAL stage and may change without notice")) + When("the user is logged in, an org is targeted and a space is targeted", func() { + BeforeEach(func() { + fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space", GUID: "some-space-guid"}) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{Name: "some-org"}) + }) + + When("getting the current user returns an error", func() { + BeforeEach(func() { + fakeConfig.CurrentUserReturns(configv3.User{}, errors.New("some-error")) + }) + + It("returns the error", func() { + Expect(executeErr).To(MatchError("some-error")) + }) + }) + + When("getting the current user succeeds", func() { + BeforeEach(func() { + fakeConfig.CurrentUserReturns(configv3.User{Name: "banana"}, nil) + }) + + When("when the requested app and revision exist", func() { + var revision resources.Revision + BeforeEach(func() { + fakeApp := resources.Application{ + GUID: "fake-guid", + Name: "some-app", + } + fakeActor.GetApplicationByNameAndSpaceReturns(fakeApp, nil, nil) + + revision = resources.Revision{ + Version: 3, + GUID: "A68F13F7-7E5E-4411-88E8-1FAC54F73F50", + Description: "On a different note", + CreatedAt: "2020-03-10T17:11:58Z", + Deployable: true, + Droplet: resources.Droplet{ + GUID: "droplet-guid", + }, + Links: resources.APILinks{ + "environment_variables": resources.APILink{ + HREF: "revision-environment-variables-link-3", + }, + }, + Metadata: &resources.Metadata{ + Labels: map[string]types.NullString{ + "label": types.NewNullString("foo3"), + }, + Annotations: map[string]types.NullString{ + "annotation": types.NewNullString("foo3"), + }, + }, + } + fakeActor.GetRevisionByApplicationAndVersionReturns(revision, nil, nil) + fakeActor.GetApplicationByNameAndSpaceReturns(resources.Application{GUID: "app-guid"}, nil, nil) + fakeActor.GetApplicationRevisionsDeployedReturns([]resources.Revision{revision}, nil, nil) + + environmentVariableGroup := v7action.EnvironmentVariableGroup{ + "foo": *types.NewFilteredString("bar3"), + } + fakeActor.GetEnvironmentVariableGroupByRevisionReturns( + environmentVariableGroup, + true, + nil, + nil, + ) + + cmd.Version = flag.Revision{NullInt: types.NullInt{Value: 3, IsSet: true}} + }) + + It("gets the app guid", func() { + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + appName, spaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(appName).To(Equal("some-app")) + Expect(spaceGUID).To(Equal("some-space-guid")) + }) + + It("retrieves the requested revision for the app", func() { + Expect(fakeActor.GetRevisionByApplicationAndVersionCallCount()).To(Equal(1)) + appGUID, version := fakeActor.GetRevisionByApplicationAndVersionArgsForCall(0) + Expect(appGUID).To(Equal("app-guid")) + Expect(version).To(Equal(3)) + }) + + It("retrieves the deployed revisions", func() { + Expect(fakeActor.GetApplicationRevisionsDeployedCallCount()).To(Equal(1)) + Expect(fakeActor.GetApplicationRevisionsDeployedArgsForCall(0)).To(Equal("app-guid")) + }) + + It("retrieves the environment variables for the revision", func() { + Expect(fakeActor.GetEnvironmentVariableGroupByRevisionCallCount()).To(Equal(1)) + Expect(fakeActor.GetEnvironmentVariableGroupByRevisionArgsForCall(0)).To(Equal( + revision, + )) + }) + + It("displays the revision", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say(`Showing revision 3 for app some-app in org some-org / space some-space as banana...`)) + Expect(testUI.Out).To(Say(`revision: 3`)) + Expect(testUI.Out).To(Say(`deployed: true`)) + Expect(testUI.Out).To(Say(`description: On a different note`)) + Expect(testUI.Out).To(Say(`deployable: true`)) + Expect(testUI.Out).To(Say(`revision GUID: A68F13F7-7E5E-4411-88E8-1FAC54F73F50`)) + Expect(testUI.Out).To(Say(`droplet GUID: droplet-guid`)) + Expect(testUI.Out).To(Say(`created on: 2020-03-10T17:11:58Z`)) + + Expect(testUI.Out).To(Say(`labels:`)) + Expect(testUI.Out).To(Say(`label: foo3`)) + + Expect(testUI.Out).To(Say(`annotations:`)) + Expect(testUI.Out).To(Say(`annotation: foo3`)) + + Expect(testUI.Out).To(Say(`application environment variables:`)) + Expect(testUI.Out).To(Say(`foo: bar3`)) + + }) + + When("there are no environment_variables link and metadata provided", func() { + BeforeEach(func() { + revision = resources.Revision{ + Version: 3, + GUID: "A68F13F7-7E5E-4411-88E8-1FAC54F73F50", + Description: "No env var link", + CreatedAt: "2020-03-10T17:11:58Z", + Deployable: true, + Droplet: resources.Droplet{ + GUID: "droplet-guid", + }, + Links: resources.APILinks{}, + Metadata: &resources.Metadata{}, + } + fakeActor.GetRevisionByApplicationAndVersionReturns(revision, nil, nil) + fakeActor.GetApplicationRevisionsDeployedReturns([]resources.Revision{revision}, nil, nil) + fakeActor.GetEnvironmentVariableGroupByRevisionReturns(nil, false, v7action.Warnings{"warn-env-var"}, nil) + }) + + It("warns the user it will not display env vars ", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(testUI.Err).To(Say("warn-env-var")) + Expect(testUI.Out).To(Say("labels:")) + Expect(testUI.Out).To(Say("annotations:")) + Expect(testUI.Out).To(Say("application environment variables:")) + }) + }) + + When("revision is not deployed", func() { + BeforeEach(func() { + revisionDeployed := resources.Revision{ + Version: 12345, + GUID: "Fake-guid", + Description: "derployed and definitely not your revision", + CreatedAt: "2020-03-10T17:11:58Z", + Deployable: true, + Droplet: resources.Droplet{ + GUID: "droplet-guid", + }, + } + fakeActor.GetApplicationRevisionsDeployedReturns([]resources.Revision{revisionDeployed}, nil, nil) + }) + + It("displays deployed field correctly", func() { + Expect(testUI.Out).To(Say(`deployed: false`)) + }) + }) + + When("no revisions were deployed", func() { + BeforeEach(func() { + fakeActor.GetApplicationRevisionsDeployedReturns([]resources.Revision{}, nil, nil) + }) + + It("displays deployed field correctly", func() { + Expect(testUI.Out).To(Say(`deployed: false`)) + }) + }) + }) + + When("no revision version is provided", func() { + BeforeEach(func() { + deployedRevisions := []resources.Revision{ + { + Version: 3, + GUID: "A68F13F7-7E5E-4411-88E8-1FAC54F73F50", + Description: "On a different note", + CreatedAt: "2020-03-10T17:11:58Z", + Deployable: true, + Droplet: resources.Droplet{ + GUID: "droplet-guid", + }, + Links: resources.APILinks{ + "environment_variables": resources.APILink{ + HREF: "revision-environment-variables-link-3", + }, + }, + Metadata: &resources.Metadata{ + Labels: map[string]types.NullString{ + "label": types.NewNullString("foo3"), + }, + Annotations: map[string]types.NullString{ + "annotation": types.NewNullString("foo3"), + }, + }, + }, + { + Version: 2, + GUID: "A89F8259-D32B-491A-ABD6-F100AC42D74C", + Description: "Something else", + CreatedAt: "2020-03-08T12:43:30Z", + Deployable: true, + Droplet: resources.Droplet{ + GUID: "droplet-guid2", + }, + Metadata: &resources.Metadata{}, + }, + } + fakeActor.GetApplicationByNameAndSpaceReturns(resources.Application{GUID: "app-guid"}, nil, nil) + fakeActor.GetApplicationRevisionsDeployedReturns(deployedRevisions, nil, nil) + + environmentVariableGroup := v7action.EnvironmentVariableGroup{ + "foo": *types.NewFilteredString("bar3"), + } + fakeActor.GetEnvironmentVariableGroupByRevisionReturns( + environmentVariableGroup, + true, + nil, + nil, + ) + cmd.Version = flag.Revision{NullInt: types.NullInt{Value: 0, IsSet: false}} + }) + + It("displays all deployed revisions", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say(`Showing revisions for app some-app in org some-org / space some-space as banana...`)) + Expect(testUI.Out).To(Say(`revision: 3`)) + Expect(testUI.Out).To(Say(`deployed: true`)) + Expect(testUI.Out).To(Say(`description: On a different note`)) + Expect(testUI.Out).To(Say(`deployable: true`)) + Expect(testUI.Out).To(Say(`revision GUID: A68F13F7-7E5E-4411-88E8-1FAC54F73F50`)) + Expect(testUI.Out).To(Say(`droplet GUID: droplet-guid`)) + Expect(testUI.Out).To(Say(`created on: 2020-03-10T17:11:58Z`)) + + Expect(testUI.Out).To(Say(`labels:`)) + Expect(testUI.Out).To(Say(`label: foo3`)) + + Expect(testUI.Out).To(Say(`annotations:`)) + Expect(testUI.Out).To(Say(`annotation: foo3`)) + + Expect(testUI.Out).To(Say(`application environment variables:`)) + Expect(testUI.Out).To(Say(`foo: bar3`)) + + Expect(testUI.Out).To(Say(`revision: 2`)) + Expect(testUI.Out).To(Say(`deployed: true`)) + Expect(testUI.Out).To(Say(`description: Something else`)) + Expect(testUI.Out).To(Say(`deployable: true`)) + Expect(testUI.Out).To(Say(`revision GUID: A89F8259-D32B-491A-ABD6-F100AC42D74C`)) + Expect(testUI.Out).To(Say(`droplet GUID: droplet-guid2`)) + Expect(testUI.Out).To(Say(`created on: 2020-03-08T12:43:30Z`)) + + Expect(testUI.Out).To(Say(`labels:`)) + Expect(testUI.Out).To(Say(`annotations:`)) + Expect(testUI.Out).To(Say(`application environment variables:`)) + Expect(testUI.Out).To(Say(`foo: bar3`)) + }) + }) + + When("there are no revisions available", func() { + BeforeEach(func() { + revision := resources.Revision{ + Version: 120, + } + cmd.Version = flag.Revision{NullInt: types.NullInt{Value: 120, IsSet: true}} + fakeActor.GetRevisionByApplicationAndVersionReturns( + revision, + nil, + errors.New("Revision 120 not found"), + ) + }) + + It("returns 'revision not found'", func() { + Expect(executeErr).To(MatchError("Revision 120 not found")) + }) + }) + }) }) }) diff --git a/command/v7/revisions_command.go b/command/v7/revisions_command.go index c6c484fff5b..03351f06830 100644 --- a/command/v7/revisions_command.go +++ b/command/v7/revisions_command.go @@ -4,11 +4,10 @@ import ( "fmt" "strconv" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . RevisionsActor @@ -22,13 +21,10 @@ type RevisionsCommand struct { usage interface{} `usage:"CF_NAME revisions APP_NAME"` BaseCommand - relatedCommands interface{} `related_commands:"rollback"` + relatedCommands interface{} `related_commands:"revision, rollback"` } func (cmd RevisionsCommand) Execute(_ []string) error { - cmd.UI.DisplayWarning(command.ExperimentalWarning) - cmd.UI.DisplayNewline() - err := cmd.SharedActor.CheckTarget(true, true) if err != nil { return err @@ -94,6 +90,11 @@ func (cmd RevisionsCommand) Execute(_ []string) error { return err } + if len(revisionsDeployed) > 1 { + cmd.UI.DisplayText("Info: this app is in the middle of a rolling deployment. More than one revision is deployed.") + cmd.UI.DisplayNewline() + } + table := [][]string{{ "revision", "description", @@ -113,7 +114,7 @@ func (cmd RevisionsCommand) Execute(_ []string) error { } if len(revisionsDeployed) > 1 { - cmd.UI.DisplayText("Info: this app is in the middle of a rolling deployment. More than one revision is deployed.") + cmd.UI.DisplayText("Info: this app is in the middle of a deployment. More than one revision is deployed.") cmd.UI.DisplayNewline() } diff --git a/command/v7/revisions_command_test.go b/command/v7/revisions_command_test.go index 8323069fa27..d9db541c226 100644 --- a/command/v7/revisions_command_test.go +++ b/command/v7/revisions_command_test.go @@ -4,24 +4,23 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) var _ = Describe("revisions Command", func() { var ( - cmd RevisionsCommand + cmd v7.RevisionsCommand testUI *ui.UI fakeConfig *commandfakes.FakeConfig fakeSharedActor *commandfakes.FakeSharedActor @@ -59,10 +58,6 @@ var _ = Describe("revisions Command", func() { executeErr = cmd.Execute(nil) }) - It("displays the experimental warning", func() { - Expect(testUI.Err).To(Say("This command is in EXPERIMENTAL stage and may change without notice")) - }) - When("checking target fails", func() { BeforeEach(func() { fakeSharedActor.CheckTargetReturns(actionerror.NotLoggedInError{BinaryName: binaryName}) @@ -166,7 +161,7 @@ var _ = Describe("revisions Command", func() { }) It("does not display an informative message", func() { - Expect(testUI.Out).NotTo(Say("Info: this app is in the middle of a rolling deployment. More than one revision is deployed.")) + Expect(testUI.Out).NotTo(Say("Info: this app is in the middle of a deployment. More than one revision is deployed.")) }) When("there is more than one revision deployed", func() { @@ -195,7 +190,7 @@ var _ = Describe("revisions Command", func() { Expect(testUI.Out).To(Say("2\\(deployed\\) Something else true A89F8259-D32B-491A-ABD6-F100AC42D74C 2020-03-08T12:43:30Z")) }) It("displays an informative message", func() { - Expect(testUI.Out).To(Say("Info: this app is in the middle of a rolling deployment. More than one revision is deployed.")) + Expect(testUI.Out).To(Say("Info: this app is in the middle of a deployment. More than one revision is deployed.")) }) }) diff --git a/command/v7/rollback_command.go b/command/v7/rollback_command.go index 8c3e0f005ca..1c62e534181 100644 --- a/command/v7/rollback_command.go +++ b/command/v7/rollback_command.go @@ -2,23 +2,31 @@ package v7 import ( "fmt" - - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "strconv" + "strings" + + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type RollbackCommand struct { BaseCommand - Force bool `short:"f" description:"Force rollback without confirmation"` - RequiredArgs flag.AppName `positional-args:"yes"` - Version flag.Revision `long:"version" required:"true" description:"Roll back to the specified revision"` - relatedCommands interface{} `related_commands:"revisions"` - usage interface{} `usage:"CF_NAME rollback APP_NAME [--version VERSION] [-f]"` + RequiredArgs flag.AppName `positional-args:"yes"` + Force bool `short:"f" description:"Force rollback without confirmation"` + InstanceSteps string `long:"instance-steps" description:"An array of percentage steps to deploy when using deployment strategy canary. (e.g. 20,40,60)"` + MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively being rolled back."` + Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary or rolling. When not specified, it defaults to rolling."` + Version flag.Revision `long:"version" required:"true" description:"Roll back to the specified revision"` + relatedCommands interface{} `related_commands:"revision, revisions"` + usage interface{} `usage:"CF_NAME rollback APP_NAME [--version VERSION] [-f]"` LogCacheClient sharedaction.LogCacheClient Stager shared.AppStager @@ -35,9 +43,6 @@ func (cmd *RollbackCommand) Setup(config command.Config, ui command.UI) error { } func (cmd RollbackCommand) Execute(args []string) error { - cmd.UI.DisplayWarning(command.ExperimentalWarning) - cmd.UI.DisplayNewline() - targetRevision := int(cmd.Version.Value) err := cmd.SharedActor.CheckTarget(true, true) if err != nil { @@ -49,6 +54,11 @@ func (cmd RollbackCommand) Execute(args []string) error { return err } + err = cmd.ValidateFlags() + if err != nil { + return err + } + app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID) cmd.UI.DisplayWarnings(warnings) if err != nil { @@ -71,10 +81,6 @@ func (cmd RollbackCommand) Execute(args []string) error { return err } - if err != nil { - return err - } - // TODO Localization? if !cmd.Force { cmd.UI.DisplayTextWithFlavor("Rolling '{{.AppName}}' back to revision '{{.TargetRevision}}' will create a new revision. The new revision will use the settings from revision '{{.TargetRevision}}'.", map[string]interface{}{ @@ -106,15 +112,32 @@ func (cmd RollbackCommand) Execute(args []string) error { "Username": user.Name, }) - startAppErr := cmd.Stager.StartApp( - app, - revision.GUID, - constant.DeploymentStrategyRolling, - false, - cmd.Config.TargetedSpace(), - cmd.Config.TargetedOrganization(), - constant.ApplicationRollingBack, - ) + opts := shared.AppStartOpts{ + AppAction: constant.ApplicationRollingBack, + NoWait: false, + Strategy: constant.DeploymentStrategyRolling, + } + if cmd.MaxInFlight != nil { + opts.MaxInFlight = *cmd.MaxInFlight + } + + if cmd.Strategy.Name != "" { + opts.Strategy = cmd.Strategy.Name + } + + if cmd.InstanceSteps != "" { + if len(cmd.InstanceSteps) > 0 { + for _, v := range strings.Split(cmd.InstanceSteps, ",") { + parsedInt, err := strconv.ParseInt(v, 0, 64) + if err != nil { + return err + } + opts.CanarySteps = append(opts.CanarySteps, resources.CanaryStep{InstanceWeight: parsedInt}) + } + } + } + + startAppErr := cmd.Stager.StartApp(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), revision.GUID, opts) if startAppErr != nil { return startAppErr } @@ -123,3 +146,20 @@ func (cmd RollbackCommand) Execute(args []string) error { return nil } + +func (cmd RollbackCommand) ValidateFlags() error { + switch { + case cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1: + return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} + case cmd.Strategy.Name != constant.DeploymentStrategyCanary && cmd.InstanceSteps != "": + return translatableerror.RequiredFlagsError{Arg1: "--instance-steps", Arg2: "--strategy=canary"} + case len(cmd.InstanceSteps) > 0 && !validateInstanceSteps(cmd.InstanceSteps): + return translatableerror.ParseArgumentError{ArgumentName: "--instance-steps", ExpectedType: "list of weights"} + } + + if len(cmd.InstanceSteps) > 0 { + return command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionCanarySteps, "--instance-steps") + } + + return nil +} diff --git a/command/v7/rollback_command_test.go b/command/v7/rollback_command_test.go index ac2a0aa7ce5..d69dfc95841 100644 --- a/command/v7/rollback_command_test.go +++ b/command/v7/rollback_command_test.go @@ -3,26 +3,27 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared/sharedfakes" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) var _ = Describe("rollback Command", func() { var ( - app string + appName string binaryName string executeErr error fakeActor *v7fakes.FakeActor @@ -30,13 +31,14 @@ var _ = Describe("rollback Command", func() { fakeSharedActor *commandfakes.FakeSharedActor input *Buffer testUI *ui.UI + app resources.Application fakeAppStager *sharedfakes.FakeAppStager cmd v7.RollbackCommand ) BeforeEach(func() { - app = "some-app" + appName = "some-app" binaryName = "faceman" fakeActor = new(v7fakes.FakeActor) fakeAppStager = new(sharedfakes.FakeAppStager) @@ -49,6 +51,10 @@ var _ = Describe("rollback Command", func() { resources.Revision{Version: 2}, resources.Revision{Version: 1}, } + app = resources.Application{ + GUID: "123", + Name: "some-app", + } fakeActor.GetRevisionsByApplicationNameAndSpaceReturns( revisions, v7action.Warnings{"warning-2"}, nil, @@ -67,7 +73,7 @@ var _ = Describe("rollback Command", func() { }) cmd = v7.RollbackCommand{ - RequiredArgs: flag.AppName{AppName: app}, + RequiredArgs: flag.AppName{AppName: appName}, BaseCommand: v7.BaseCommand{ UI: testUI, Config: fakeConfig, @@ -76,16 +82,14 @@ var _ = Describe("rollback Command", func() { }, Stager: fakeAppStager, } + maxInFlight := 5 + cmd.MaxInFlight = &maxInFlight }) JustBeforeEach(func() { executeErr = cmd.Execute(nil) }) - It("displays the experimental warning", func() { - Expect(testUI.Err).To(Say("This command is in EXPERIMENTAL stage and may change without notice")) - }) - When("checking target fails", func() { BeforeEach(func() { fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) @@ -151,7 +155,7 @@ var _ = Describe("rollback Command", func() { When("the app has at least one revision", func() { BeforeEach(func() { fakeActor.GetApplicationByNameAndSpaceReturns( - resources.Application{GUID: "123"}, + app, v7action.Warnings{"app-warning-1"}, nil, ) @@ -170,7 +174,7 @@ var _ = Describe("rollback Command", func() { It("fetches the app and revision revision", func() { Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1), "GetApplicationByNameAndSpace call count") appName, spaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) - Expect(appName).To(Equal(app)) + Expect(appName).To(Equal(appName)) Expect(spaceGUID).To(Equal("some-space-guid")) Expect(fakeActor.GetRevisionByApplicationAndVersionCallCount()).To(Equal(1), "GetRevisionByApplicationAndVersion call count") @@ -188,12 +192,12 @@ var _ = Describe("rollback Command", func() { It("skips the prompt and executes the rollback", func() { Expect(fakeAppStager.StartAppCallCount()).To(Equal(1), "GetStartApp call count") - application, revisionGUID, _, _, _, _, appAction := fakeAppStager.StartAppArgsForCall(0) + application, _, _, revisionGUID, opts := fakeAppStager.StartAppArgsForCall(0) Expect(application.GUID).To(Equal("123")) Expect(revisionGUID).To(Equal("some-1-guid")) - Expect(appAction).To(Equal(constant.ApplicationRollingBack)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRollingBack)) - Expect(testUI.Out).ToNot(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision '3' will use the settings from revision '1'.", app)) + Expect(testUI.Out).ToNot(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision '3' will use the settings from revision '1'.", appName)) Expect(testUI.Out).ToNot(Say("Are you sure you want to continue?")) Expect(testUI.Out).To(Say("Rolling back to revision 1 for app some-app in org some-org / space some-space as steve...")) @@ -215,12 +219,14 @@ var _ = Describe("rollback Command", func() { It("successfully executes the command and outputs warnings", func() { Expect(fakeAppStager.StartAppCallCount()).To(Equal(1), "GetStartApp call count") - application, revisionGUID, _, _, _, _, appAction := fakeAppStager.StartAppArgsForCall(0) + application, _, _, revisionGUID, opts := fakeAppStager.StartAppArgsForCall(0) Expect(application.GUID).To(Equal("123")) Expect(revisionGUID).To(Equal("some-1-guid")) - Expect(appAction).To(Equal(constant.ApplicationRollingBack)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRollingBack)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyRolling)) + Expect(opts.MaxInFlight).To(Equal(5)) - Expect(testUI.Out).To(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision will use the settings from revision '1'.", app)) + Expect(testUI.Out).To(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision will use the settings from revision '1'.", appName)) Expect(testUI.Out).To(Say("Are you sure you want to continue?")) Expect(testUI.Out).To(Say("Rolling back to revision 1 for app some-app in org some-org / space some-space as steve...")) @@ -232,6 +238,53 @@ var _ = Describe("rollback Command", func() { }) }) + When("the strategy flag is passed", func() { + BeforeEach(func() { + cmd.Strategy.Name = constant.DeploymentStrategyCanary + + _, err := input.Write([]byte("y\n")) + Expect(err).NotTo(HaveOccurred()) + }) + It("uses the specified strategy to rollback", func() { + Expect(fakeAppStager.StartAppCallCount()).To(Equal(1), "GetStartApp call count") + + application, _, _, revisionGUID, opts := fakeAppStager.StartAppArgsForCall(0) + Expect(executeErr).NotTo(HaveOccurred()) + Expect(application.GUID).To(Equal("123")) + Expect(revisionGUID).To(Equal("some-1-guid")) + Expect(opts.AppAction).To(Equal(constant.ApplicationRollingBack)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + }) + }) + + When("canary strategy is provided", func() { + BeforeEach(func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "1,2,4" + + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("4.0.0") + cmd.Config = fakeConfig + + _, err := input.Write([]byte("y\n")) + Expect(err).NotTo(HaveOccurred()) + }) + + It("starts the app with the current droplet", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) + + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StartAppArgsForCall(0) + Expect(inputApp).To(Equal(app)) + Expect(inputDropletGuid).To(Equal("some-1-guid")) + Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) + Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(opts.AppAction).To(Equal(constant.ApplicationRollingBack)) + Expect(opts.CanarySteps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 4}})) + }) + }) + When("user says no to prompt", func() { BeforeEach(func() { _, err := input.Write([]byte("n\n")) @@ -241,8 +294,8 @@ var _ = Describe("rollback Command", func() { It("does not execute the command and outputs warnings", func() { Expect(fakeAppStager.StartAppCallCount()).To(Equal(0), "GetStartApp call count") - Expect(testUI.Out).To(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision will use the settings from revision '1'.", app)) - Expect(testUI.Out).To(Say("App '%s' has not been rolled back to revision '1'.", app)) + Expect(testUI.Out).To(Say("Rolling '%s' back to revision '1' will create a new revision. The new revision will use the settings from revision '1'.", appName)) + Expect(testUI.Out).To(Say("App '%s' has not been rolled back to revision '1'.", appName)) Expect(testUI.Err).To(Say("app-warning-1")) Expect(testUI.Err).To(Say("revision-warning-3")) @@ -260,9 +313,63 @@ var _ = Describe("rollback Command", func() { Expect(fakeAppStager.StartAppCallCount()).To(Equal(0), "GetStartApp call count") - Expect(testUI.Out).To(Say("App '%s' has not been rolled back to revision '1'.", app)) + Expect(testUI.Out).To(Say("App '%s' has not been rolled back to revision '1'.", appName)) }) }) }) }) + + DescribeTable("ValidateFlags returns an error", + func(setup func(), expectedErr error) { + setup() + err := cmd.ValidateFlags() + if expectedErr == nil { + Expect(err).To(BeNil()) + } else { + Expect(err).To(MatchError(expectedErr)) + } + }, + + Entry("max-in-flight is smaller than 1", + func() { + maxInFlight := 0 + cmd.MaxInFlight = &maxInFlight + }, + translatableerror.IncorrectUsageError{ + Message: "--max-in-flight must be greater than or equal to 1", + }), + + Entry("instance-steps no strategy provided", + func() { + cmd.InstanceSteps = "1,2,3" + }, + translatableerror.RequiredFlagsError{ + Arg1: "--instance-steps", + Arg2: "--strategy=canary", + }), + + Entry("instance-steps a valid list of ints", + func() { + cmd.Strategy = flag.DeploymentStrategy{Name: constant.DeploymentStrategyCanary} + cmd.InstanceSteps = "some,thing,not,right" + }, + translatableerror.ParseArgumentError{ + ArgumentName: "--instance-steps", + ExpectedType: "list of weights", + }), + + Entry("instance-steps used when CAPI does not support canary steps", + func() { + cmd.InstanceSteps = "1,2,3" + cmd.Strategy.Name = constant.DeploymentStrategyCanary + fakeConfig = &commandfakes.FakeConfig{} + fakeConfig.APIVersionReturns("3.0.0") + cmd.Config = fakeConfig + }, + translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--instance-steps", + CurrentVersion: "3.0.0", + MinimumVersion: "3.189.0", + }), + ) }) diff --git a/command/v7/route_command.go b/command/v7/route_command.go index 1ed64478ee6..faa81460296 100644 --- a/command/v7/route_command.go +++ b/command/v7/route_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "strconv" - "strconv" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type RouteCommand struct { @@ -97,6 +97,7 @@ func (cmd RouteCommand) Execute(args []string) error { {cmd.UI.TranslateText("port:"), port}, {cmd.UI.TranslateText("path:"), route.Path}, {cmd.UI.TranslateText("protocol:"), route.Protocol}, + {cmd.UI.TranslateText("options:"), route.FormattedOptions()}, } cmd.UI.DisplayKeyValueTable("", table, 3) diff --git a/command/v7/route_command_test.go b/command/v7/route_command_test.go index 2249d13ee7a..dd82c504fde 100644 --- a/command/v7/route_command_test.go +++ b/command/v7/route_command_test.go @@ -1,17 +1,17 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -26,6 +26,7 @@ var _ = Describe("route Command", func() { binaryName string executeErr error domainName string + options map[string]*string ) BeforeEach(func() { @@ -192,7 +193,11 @@ var _ = Describe("route Command", func() { destinationB := resources.RouteDestination{App: destAppB, Port: 1337, Protocol: "http2"} destinations := []resources.RouteDestination{destinationA, destinationB} - route := resources.Route{GUID: "route-guid", Host: cmd.Hostname, Path: cmd.Path.Path, Protocol: "http", Destinations: destinations} + + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + options = map[string]*string{"loadbalancing": lbLeastConnections} + route := resources.Route{GUID: "route-guid", Host: cmd.Hostname, Path: cmd.Path.Path, Protocol: "http", Destinations: destinations, Options: options} fakeActor.GetRouteByAttributesReturns( route, @@ -218,6 +223,7 @@ var _ = Describe("route Command", func() { Expect(testUI.Out).To(Say(`host:\s+%s`, cmd.Hostname)) Expect(testUI.Out).To(Say(`path:\s+%s`, cmd.Path.Path)) Expect(testUI.Out).To(Say(`protocol:\s+http`)) + Expect(testUI.Out).To(Say(`options:\s+{loadbalancing=%s}`, *options["loadbalancing"])) Expect(testUI.Out).To(Say(`\n`)) Expect(testUI.Out).To(Say(`Destinations:`)) Expect(testUI.Out).To(Say(`\s+app\s+process\s+port\s+app-protocol`)) diff --git a/command/v7/router_groups_command.go b/command/v7/router_groups_command.go index 924d8b44e08..3f092586239 100644 --- a/command/v7/router_groups_command.go +++ b/command/v7/router_groups_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/util/ui" ) type RouterGroupsCommand struct { diff --git a/command/v7/router_groups_command_test.go b/command/v7/router_groups_command_test.go index 32c64b543b2..cf64597bcf1 100644 --- a/command/v7/router_groups_command_test.go +++ b/command/v7/router_groups_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/routes_command.go b/command/v7/routes_command.go index 437704cdc8f..0b63d618a72 100644 --- a/command/v7/routes_command.go +++ b/command/v7/routes_command.go @@ -4,9 +4,9 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type RoutesCommand struct { @@ -85,6 +85,7 @@ func (cmd RoutesCommand) displayRoutesTable(routeSummaries []v7action.RouteSumma cmd.UI.TranslateText("app-protocol"), cmd.UI.TranslateText("apps"), cmd.UI.TranslateText("service instance"), + cmd.UI.TranslateText("options"), }, } @@ -93,6 +94,7 @@ func (cmd RoutesCommand) displayRoutesTable(routeSummaries []v7action.RouteSumma if routeSummary.Port != 0 { port = strconv.Itoa(routeSummary.Port) } + routesTable = append(routesTable, []string{ routeSummary.SpaceName, routeSummary.Host, @@ -103,6 +105,7 @@ func (cmd RoutesCommand) displayRoutesTable(routeSummaries []v7action.RouteSumma strings.Join(routeSummary.AppProtocols, ", "), strings.Join(routeSummary.AppNames, ", "), routeSummary.ServiceInstanceName, + routeSummary.Route.FormattedOptions(), }) } diff --git a/command/v7/routes_command_test.go b/command/v7/routes_command_test.go index bc43f357733..96c67dfa104 100644 --- a/command/v7/routes_command_test.go +++ b/command/v7/routes_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/run_task_command.go b/command/v7/run_task_command.go index c01bbe2e243..2f812e5a82c 100644 --- a/command/v7/run_task_command.go +++ b/command/v7/run_task_command.go @@ -3,21 +3,23 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type RunTaskCommand struct { BaseCommand - RequiredArgs flag.RunTaskArgsV7 `positional-args:"yes"` - Command string `long:"command" short:"c" description:"The command to execute"` - Disk flag.Megabytes `short:"k" description:"Disk limit (e.g. 256M, 1024M, 1G)"` - Memory flag.Megabytes `short:"m" description:"Memory limit (e.g. 256M, 1024M, 1G)"` - Name string `long:"name" description:"Name to give the task (generated if omitted)"` - Process string `long:"process" description:"Process type to use as a template for command, memory, and disk for the created task."` - usage interface{} `usage:"CF_NAME run-task APP_NAME [--command COMMAND] [-k DISK] [-m MEMORY] [--name TASK_NAME] [--process PROCESS_TYPE]\n\nTIP:\n Use 'cf logs' to display the logs of the app and all its tasks. If your task name is unique, grep this command's output for the task name to view task-specific logs.\n\nEXAMPLES:\n CF_NAME run-task my-app --command \"bundle exec rake db:migrate\" --name migrate\n\n CF_NAME run-task my-app --process batch_job\n\n CF_NAME run-task my-app"` - relatedCommands interface{} `related_commands:"logs, tasks, terminate-task"` + RequiredArgs flag.RunTaskArgsV7 `positional-args:"yes"` + Command string `long:"command" short:"c" description:"The command to execute"` + Disk flag.Megabytes `short:"k" description:"Disk limit (e.g. 256M, 1024M, 1G)"` + LogRateLimit flag.BytesWithUnlimited `short:"l" description:"Log rate limit per second, in bytes (e.g. 128B, 4K, 1M). -l=-1 represents unlimited"` + Memory flag.Megabytes `short:"m" description:"Memory limit (e.g. 256M, 1024M, 1G)"` + Name string `long:"name" description:"Name to give the task (generated if omitted)"` + Process string `long:"process" description:"Process type to use as a template for command, memory, and disk for the created task."` + Wait bool `long:"wait" short:"w" description:"Wait for the task to complete before exiting"` + usage interface{} `usage:"CF_NAME run-task APP_NAME [--command COMMAND] [-k DISK] [-m MEMORY] [-l LOG_RATE_LIMIT] [--name TASK_NAME] [--process PROCESS_TYPE]\n\nTIP:\n Use 'cf logs' to display the logs of the app and all its tasks. If your task name is unique, grep this command's output for the task name to view task-specific logs.\n\nEXAMPLES:\n CF_NAME run-task my-app --command \"bundle exec rake db:migrate\" --name migrate\n\n CF_NAME run-task my-app --process batch_job\n\n CF_NAME run-task my-app"` + relatedCommands interface{} `related_commands:"logs, tasks, task, terminate-task"` } func (cmd RunTaskCommand) Execute(args []string) error { @@ -59,6 +61,9 @@ func (cmd RunTaskCommand) Execute(args []string) error { if cmd.Memory.IsSet { inputTask.MemoryInMB = cmd.Memory.Value } + if cmd.LogRateLimit.IsSet { + inputTask.LogRateLimitInBPS = cmd.LogRateLimit.Value + } if cmd.Command == "" && cmd.Process == "" { cmd.Process = "task" } @@ -90,5 +95,21 @@ func (cmd RunTaskCommand) Execute(args []string) error { {cmd.UI.TranslateText("task id:"), fmt.Sprint(task.SequenceID)}, }, 3) + if cmd.Wait { + cmd.UI.DisplayNewline() + cmd.UI.DisplayText("Waiting for task to complete execution...") + + _, pollWarnings, err := cmd.Actor.PollTask(task) + cmd.UI.DisplayWarnings(pollWarnings) + if err != nil { + return err + } + + cmd.UI.DisplayNewline() + cmd.UI.DisplayText("Task has completed successfully.") + } + + cmd.UI.DisplayOK() + return nil } diff --git a/command/v7/run_task_command_test.go b/command/v7/run_task_command_test.go index 34233afe90b..01c75b4537a 100644 --- a/command/v7/run_task_command_test.go +++ b/command/v7/run_task_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -145,6 +145,7 @@ var _ = Describe("run-task Command", func() { Expect(testUI.Out).To(Say(`task name:\s+31337ddd`)) Expect(testUI.Out).To(Say(`task id:\s+3`)) + Expect(testUI.Out).To(Say("OK")) Expect(testUI.Err).To(Say("get-application-warning-1")) Expect(testUI.Err).To(Say("get-application-warning-2")) @@ -188,6 +189,50 @@ var _ = Describe("run-task Command", func() { Expect(testUI.Out).To(Say("Task has been submitted successfully for execution.")) Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say(`task name:\s+some-task-name`)) + Expect(testUI.Out).To(Say(`task id:\s+3`)) + Expect(testUI.Out).To(Say("OK")) + + Expect(testUI.Err).To(Say("get-application-warning-1")) + Expect(testUI.Err).To(Say("get-application-warning-2")) + Expect(testUI.Err).To(Say("get-application-warning-3")) + }) + }) + + When("task log rate limit is provided", func() { + BeforeEach(func() { + cmd.Name = "some-task-name" + cmd.LogRateLimit = flag.BytesWithUnlimited{Value: 1024 * 5, IsSet: true} + fakeActor.RunTaskReturns( + resources.Task{ + Name: "some-task-name", + SequenceID: 3, + }, + v7action.Warnings{"get-application-warning-3"}, + nil) + }) + + It("creates a new task and outputs all warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + appName, spaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(appName).To(Equal("some-app-name")) + Expect(spaceGUID).To(Equal("some-space-guid")) + + Expect(fakeActor.RunTaskCallCount()).To(Equal(1)) + appGUID, task := fakeActor.RunTaskArgsForCall(0) + Expect(appGUID).To(Equal("some-app-guid")) + Expect(task).To(Equal(resources.Task{ + Command: "some command", + Name: "some-task-name", + LogRateLimitInBPS: 1024 * 5, + })) + + Expect(testUI.Out).To(Say("Creating task for app some-app-name in org some-org / space some-space as some-user...")) + Expect(testUI.Out).To(Say("Task has been submitted successfully for execution.")) + Expect(testUI.Out).To(Say("OK")) + Expect(testUI.Out).To(Say(`task name:\s+some-task-name`)) Expect(testUI.Out).To(Say(`task id:\s+3`)) @@ -237,6 +282,7 @@ var _ = Describe("run-task Command", func() { Expect(testUI.Out).To(Say(`task name:\s+some-task-name`)) Expect(testUI.Out).To(Say(`task id:\s+3`)) + Expect(testUI.Out).To(Say("OK")) Expect(testUI.Err).To(Say("get-application-warning-1")) Expect(testUI.Err).To(Say("get-application-warning-2")) @@ -288,6 +334,7 @@ var _ = Describe("run-task Command", func() { Expect(testUI.Out).To(Say(`task name:\s+some-task-name`)) Expect(testUI.Out).To(Say(`task id:\s+3`)) + Expect(testUI.Out).To(Say("OK")) Expect(testUI.Err).To(Say("get-application-warning-1")) Expect(testUI.Err).To(Say("get-application-warning-2")) @@ -295,6 +342,49 @@ var _ = Describe("run-task Command", func() { Expect(testUI.Err).To(Say("get-application-warning-3")) }) }) + + When("wait is provided", func() { + BeforeEach(func() { + cmd.Name = "some-task-name" + cmd.Command = "echo hello" + cmd.Wait = true + fakeActor.RunTaskReturns( + resources.Task{ + Name: "some-task-name", + SequenceID: 3, + }, + v7action.Warnings{"get-application-warning-3"}, + nil) + fakeActor.PollTaskReturns( + resources.Task{ + Name: "some-task-name", + SequenceID: 3, + }, + v7action.Warnings{"poll-warnings"}, + nil) + }) + + It("waits for the task to complete before exiting", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("Creating task for app some-app-name in org some-org / space some-space as some-user...")) + + Expect(testUI.Out).To(Say("Task has been submitted successfully for execution.")) + Expect(testUI.Out).To(Say(`task name:\s+some-task-name`)) + Expect(testUI.Out).To(Say(`task id:\s+3`)) + + Expect(testUI.Out).To(Say(`Waiting for task to complete execution...`)) + + Expect(testUI.Out).To(Say(`Task has completed successfully.`)) + Expect(testUI.Out).To(Say("OK")) + + Expect(testUI.Err).To(Say("get-application-warning-1")) + Expect(testUI.Err).To(Say("get-application-warning-2")) + Expect(testUI.Err).To(Say("get-application-warning-3")) + Expect(testUI.Err).To(Say("poll-warnings")) + + }) + }) }) When("there are errors", func() { @@ -338,6 +428,31 @@ var _ = Describe("run-task Command", func() { Expect(executeErr).To(MatchError(returnedErr)) }) }) + + When("polling the task returns the error", func() { + var returnedErr error + + BeforeEach(func() { + cmd.Wait = true + returnedErr = ccerror.UnverifiedServerError{URL: "some-url"} + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + nil, + nil) + fakeActor.RunTaskReturns( + resources.Task{}, + nil, + nil) + fakeActor.PollTaskReturns( + resources.Task{}, + nil, + returnedErr) + }) + + It("returns a translatable error", func() { + Expect(executeErr).To(MatchError(returnedErr)) + }) + }) }) When("the error is not translatable", func() { diff --git a/command/v7/running_environment_variable_group_command.go b/command/v7/running_environment_variable_group_command.go index 9f36b48809e..2cead40194d 100644 --- a/command/v7/running_environment_variable_group_command.go +++ b/command/v7/running_environment_variable_group_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/util/ui" ) type RunningEnvironmentVariableGroupCommand struct { diff --git a/command/v7/running_environment_variable_group_command_test.go b/command/v7/running_environment_variable_group_command_test.go index 7e259a60f5c..d4cc8e7f03c 100644 --- a/command/v7/running_environment_variable_group_command_test.go +++ b/command/v7/running_environment_variable_group_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/running_security_groups_command.go b/command/v7/running_security_groups_command.go index 07969d0e485..2a3aa419ffa 100644 --- a/command/v7/running_security_groups_command.go +++ b/command/v7/running_security_groups_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" ) type RunningSecurityGroupsCommand struct { diff --git a/command/v7/running_security_groups_command_test.go b/command/v7/running_security_groups_command_test.go index dda4ab5ba08..b3a608bf621 100644 --- a/command/v7/running_security_groups_command_test.go +++ b/command/v7/running_security_groups_command_test.go @@ -1,15 +1,15 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/scale_command.go b/command/v7/scale_command.go index fd0ed4f5469..fc4eab322af 100644 --- a/command/v7/scale_command.go +++ b/command/v7/scale_command.go @@ -1,26 +1,28 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type ScaleCommand struct { BaseCommand - RequiredArgs flag.AppName `positional-args:"yes"` - Force bool `long:"force" short:"f" description:"Force restart of app without prompt"` - Instances flag.Instances `long:"instances" short:"i" required:"false" description:"Number of instances"` - DiskLimit flag.Megabytes `short:"k" required:"false" description:"Disk limit (e.g. 256M, 1024M, 1G)"` - MemoryLimit flag.Megabytes `short:"m" required:"false" description:"Memory limit (e.g. 256M, 1024M, 1G)"` - ProcessType string `long:"process" default:"web" description:"App process to scale"` - usage interface{} `usage:"CF_NAME scale APP_NAME [--process PROCESS] [-i INSTANCES] [-k DISK] [-m MEMORY] [-f]\n\n Modifying the app's disk or memory will cause the app to restart."` - relatedCommands interface{} `related_commands:"push"` - envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` + RequiredArgs flag.AppName `positional-args:"yes"` + Force bool `long:"force" short:"f" description:"Force restart of app without prompt"` + Instances flag.Instances `long:"instances" short:"i" required:"false" description:"Number of instances"` + DiskLimit flag.Megabytes `short:"k" required:"false" description:"Disk limit (e.g. 256M, 1024M, 1G)"` + LogRateLimit flag.BytesWithUnlimited `short:"l" required:"false" description:"Log rate limit per second, in bytes (e.g. 128B, 4K, 1M). -l=-1 represents unlimited"` + MemoryLimit flag.Megabytes `short:"m" required:"false" description:"Memory limit (e.g. 256M, 1024M, 1G)"` + ProcessType string `long:"process" default:"web" description:"App process to scale"` + usage interface{} `usage:"CF_NAME scale APP_NAME [--process PROCESS] [-i INSTANCES] [-k DISK] [-m MEMORY] [-l LOG_RATE_LIMIT] [-f]\n\n Modifying the app's disk, memory, or log rate will cause the app to restart."` + relatedCommands interface{} `related_commands:"push"` + envCFStartupTimeout interface{} `environmentName:"CF_STARTUP_TIMEOUT" environmentDescription:"Max wait time for app instance startup, in minutes" environmentDefault:"5"` } func (cmd ScaleCommand) Execute(args []string) error { @@ -40,7 +42,7 @@ func (cmd ScaleCommand) Execute(args []string) error { return err } - if !cmd.Instances.IsSet && !cmd.DiskLimit.IsSet && !cmd.MemoryLimit.IsSet { + if !cmd.Instances.IsSet && !cmd.DiskLimit.IsSet && !cmd.MemoryLimit.IsSet && !cmd.LogRateLimit.IsSet { return cmd.showCurrentScale(user.Name, err) } @@ -113,10 +115,11 @@ func (cmd ScaleCommand) scaleProcess(appGUID string, username string) (bool, err } warnings, err := cmd.Actor.ScaleProcessByApplication(appGUID, resources.Process{ - Type: cmd.ProcessType, - Instances: cmd.Instances.NullInt, - MemoryInMB: cmd.MemoryLimit.NullUint64, - DiskInMB: cmd.DiskLimit.NullUint64, + Type: cmd.ProcessType, + Instances: cmd.Instances.NullInt, + MemoryInMB: cmd.MemoryLimit.NullUint64, + DiskInMB: cmd.DiskLimit.NullUint64, + LogRateLimitInBPS: types.NullInt(cmd.LogRateLimit), }) cmd.UI.DisplayWarnings(warnings) if err != nil { @@ -203,5 +206,5 @@ func shouldShowCurrentScale(err error) bool { } func (cmd ScaleCommand) shouldRestart() bool { - return cmd.DiskLimit.IsSet || cmd.MemoryLimit.IsSet + return cmd.DiskLimit.IsSet || cmd.MemoryLimit.IsSet || cmd.LogRateLimit.IsSet } diff --git a/command/v7/scale_command_test.go b/command/v7/scale_command_test.go index 0286c41ebfe..a87f1b27d10 100644 --- a/command/v7/scale_command_test.go +++ b/command/v7/scale_command_test.go @@ -4,19 +4,19 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -154,55 +154,65 @@ var _ = Describe("scale Command", func() { ProcessSummaries: v7action.ProcessSummaries{ { Process: resources.Process{ - Type: constant.ProcessTypeWeb, - MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, - DiskInMB: types.NullUint64{Value: 1024, IsSet: true}, + Type: constant.ProcessTypeWeb, + MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, + DiskInMB: types.NullUint64{Value: 1024, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 1024 * 10, IsSet: true}, }, InstanceDetails: []v7action.ProcessInstance{ v7action.ProcessInstance{ - Index: 0, - State: constant.ProcessInstanceRunning, - MemoryUsage: 1000000, - DiskUsage: 1000000, - MemoryQuota: 33554432, - DiskQuota: 2000000, - Uptime: time.Since(time.Unix(267321600, 0)), + Index: 0, + State: constant.ProcessInstanceRunning, + MemoryUsage: 1000000, + DiskUsage: 1000000, + LogRate: 1024 * 5, + MemoryQuota: 33554432, + DiskQuota: 2000000, + LogRateLimit: 1024 * 10, + Uptime: time.Since(time.Unix(267321600, 0)), }, v7action.ProcessInstance{ - Index: 1, - State: constant.ProcessInstanceRunning, - MemoryUsage: 2000000, - DiskUsage: 2000000, - MemoryQuota: 33554432, - DiskQuota: 4000000, - Uptime: time.Since(time.Unix(330480000, 0)), + Index: 1, + State: constant.ProcessInstanceRunning, + MemoryUsage: 2000000, + DiskUsage: 2000000, + LogRate: 1024 * 3, + MemoryQuota: 33554432, + DiskQuota: 4000000, + LogRateLimit: 1024 * 10, + Uptime: time.Since(time.Unix(330480000, 0)), }, v7action.ProcessInstance{ - Index: 2, - State: constant.ProcessInstanceRunning, - MemoryUsage: 3000000, - DiskUsage: 3000000, - MemoryQuota: 33554432, - DiskQuota: 6000000, - Uptime: time.Since(time.Unix(1277164800, 0)), + Index: 2, + State: constant.ProcessInstanceRunning, + MemoryUsage: 3000000, + DiskUsage: 3000000, + LogRate: 1024 * 4, + MemoryQuota: 33554432, + DiskQuota: 6000000, + LogRateLimit: 1024 * 10, + Uptime: time.Since(time.Unix(1277164800, 0)), }, }, }, { Process: resources.Process{ - Type: "console", - MemoryInMB: types.NullUint64{Value: 16, IsSet: true}, - DiskInMB: types.NullUint64{Value: 512, IsSet: true}, + Type: "console", + MemoryInMB: types.NullUint64{Value: 16, IsSet: true}, + DiskInMB: types.NullUint64{Value: 512, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 1024 * 5, IsSet: true}, }, InstanceDetails: []v7action.ProcessInstance{ v7action.ProcessInstance{ - Index: 0, - State: constant.ProcessInstanceRunning, - MemoryUsage: 1000000, - DiskUsage: 1000000, - MemoryQuota: 33554432, - DiskQuota: 8000000, - Uptime: time.Since(time.Unix(167572800, 0)), + Index: 0, + State: constant.ProcessInstanceRunning, + MemoryUsage: 1000000, + DiskUsage: 1000000, + LogRate: 1024, + MemoryQuota: 33554432, + DiskQuota: 8000000, + LogRateLimit: 1024 * 5, + Uptime: time.Since(time.Unix(167572800, 0)), }, }, }, @@ -241,14 +251,17 @@ var _ = Describe("scale Command", func() { Expect(webProcessSummary.Instances[0].Memory).To(Equal("976.6K of 32M")) Expect(webProcessSummary.Instances[0].Disk).To(Equal("976.6K of 1.9M")) Expect(webProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[0].LogRate).To(Equal("5K/s of 10K/s")) Expect(webProcessSummary.Instances[1].Memory).To(Equal("1.9M of 32M")) Expect(webProcessSummary.Instances[1].Disk).To(Equal("1.9M of 3.8M")) Expect(webProcessSummary.Instances[1].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[1].LogRate).To(Equal("3K/s of 10K/s")) Expect(webProcessSummary.Instances[2].Memory).To(Equal("2.9M of 32M")) Expect(webProcessSummary.Instances[2].Disk).To(Equal("2.9M of 5.7M")) Expect(webProcessSummary.Instances[2].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[2].LogRate).To(Equal("4K/s of 10K/s")) consoleProcessSummary := firstAppTable.Processes[1] Expect(consoleProcessSummary.Type).To(Equal("console")) @@ -258,6 +271,7 @@ var _ = Describe("scale Command", func() { Expect(consoleProcessSummary.Instances[0].Memory).To(Equal("976.6K of 32M")) Expect(consoleProcessSummary.Instances[0].Disk).To(Equal("976.6K of 7.6M")) Expect(consoleProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(consoleProcessSummary.Instances[0].LogRate).To(Equal("1K/s of 5K/s")) Expect(testUI.Err).To(Say("get-app-warning")) Expect(testUI.Err).To(Say("get-app-summary-warning")) @@ -292,6 +306,8 @@ var _ = Describe("scale Command", func() { cmd.DiskLimit.IsSet = true cmd.MemoryLimit.Value = 100 cmd.MemoryLimit.IsSet = true + cmd.LogRateLimit.Value = 1024 + cmd.LogRateLimit.IsSet = true fakeActor.ScaleProcessByApplicationReturns( v7action.Warnings{"scale-warning"}, nil) @@ -407,14 +423,17 @@ var _ = Describe("scale Command", func() { Expect(webProcessSummary.Instances[0].Memory).To(Equal("976.6K of 32M")) Expect(webProcessSummary.Instances[0].Disk).To(Equal("976.6K of 1.9M")) Expect(webProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[0].LogRate).To(Equal("5K/s of 10K/s")) Expect(webProcessSummary.Instances[1].Memory).To(Equal("1.9M of 32M")) Expect(webProcessSummary.Instances[1].Disk).To(Equal("1.9M of 3.8M")) Expect(webProcessSummary.Instances[1].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[1].LogRate).To(Equal("3K/s of 10K/s")) Expect(webProcessSummary.Instances[2].Memory).To(Equal("2.9M of 32M")) Expect(webProcessSummary.Instances[2].Disk).To(Equal("2.9M of 5.7M")) Expect(webProcessSummary.Instances[2].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[2].LogRate).To(Equal("4K/s of 10K/s")) consoleProcessSummary := firstAppTable.Processes[1] Expect(consoleProcessSummary.Type).To(Equal("console")) @@ -424,6 +443,7 @@ var _ = Describe("scale Command", func() { Expect(consoleProcessSummary.Instances[0].Memory).To(Equal("976.6K of 32M")) Expect(consoleProcessSummary.Instances[0].Disk).To(Equal("976.6K of 7.6M")) Expect(consoleProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(consoleProcessSummary.Instances[0].LogRate).To(Equal("1K/s of 5K/s")) Expect(testUI.Err).To(Say("get-app-warning")) Expect(testUI.Err).To(Say("scale-warning")) @@ -440,10 +460,11 @@ var _ = Describe("scale Command", func() { appGUIDArg, scaleProcess := fakeActor.ScaleProcessByApplicationArgsForCall(0) Expect(appGUIDArg).To(Equal("some-app-guid")) Expect(scaleProcess).To(Equal(resources.Process{ - Type: constant.ProcessTypeWeb, - Instances: types.NullInt{Value: 2, IsSet: true}, - DiskInMB: types.NullUint64{Value: 50, IsSet: true}, - MemoryInMB: types.NullUint64{Value: 100, IsSet: true}, + Type: constant.ProcessTypeWeb, + Instances: types.NullInt{Value: 2, IsSet: true}, + DiskInMB: types.NullUint64{Value: 50, IsSet: true}, + MemoryInMB: types.NullUint64{Value: 100, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 1024, IsSet: true}, })) Expect(fakeActor.StopApplicationCallCount()).To(Equal(1)) @@ -752,6 +773,59 @@ var _ = Describe("scale Command", func() { }) }) + When("only the log rate limit option is provided", func() { + BeforeEach(func() { + cmd.LogRateLimit.Value = 2048 + cmd.LogRateLimit.IsSet = true + fakeActor.ScaleProcessByApplicationReturns( + v7action.Warnings{"scale-warning"}, + nil) + fakeActor.GetDetailedAppSummaryReturns( + appSummary, + v7action.Warnings{"get-instances-warning"}, + nil) + + _, err := input.Write([]byte("y\n")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("scales, restarts, and displays scale properties", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(testUI.Out).To(Say("Scaling")) + Expect(testUI.Out).To(Say("This will cause the app to restart")) + Expect(testUI.Out).To(Say("Stopping")) + Expect(testUI.Out).To(Say("Starting")) + + Expect(testUI.Err).To(Say("get-app-warning")) + Expect(testUI.Err).To(Say("scale-warning")) + Expect(testUI.Err).To(Say("get-instances-warning")) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + appNameArg, spaceGUIDArg := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(appNameArg).To(Equal(app.Name)) + Expect(spaceGUIDArg).To(Equal("some-space-guid")) + + Expect(fakeActor.ScaleProcessByApplicationCallCount()).To(Equal(1)) + appGUIDArg, scaleProcess := fakeActor.ScaleProcessByApplicationArgsForCall(0) + Expect(appGUIDArg).To(Equal("some-app-guid")) + Expect(scaleProcess).To(Equal(resources.Process{ + Type: constant.ProcessTypeWeb, + LogRateLimitInBPS: types.NullInt{Value: 2048, IsSet: true}, + })) + + Expect(fakeActor.StopApplicationCallCount()).To(Equal(1)) + appGUID := fakeActor.StopApplicationArgsForCall(0) + Expect(appGUID).To(Equal("some-app-guid")) + + Expect(fakeActor.StartApplicationCallCount()).To(Equal(1)) + appGUID = fakeActor.StartApplicationArgsForCall(0) + Expect(appGUID).To(Equal("some-app-guid")) + + Expect(fakeActor.GetDetailedAppSummaryCallCount()).To(Equal(1)) + }) + }) + When("an error is encountered scaling the application", func() { var expectedErr error diff --git a/command/v7/security_group_command.go b/command/v7/security_group_command.go index b264d4a0009..195607df68b 100644 --- a/command/v7/security_group_command.go +++ b/command/v7/security_group_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type SecurityGroupCommand struct { diff --git a/command/v7/security_group_command_test.go b/command/v7/security_group_command_test.go index faa3ddbabfd..b05d61279b4 100644 --- a/command/v7/security_group_command_test.go +++ b/command/v7/security_group_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/security_groups_command.go b/command/v7/security_groups_command.go index b5b1442b794..976da4dee17 100644 --- a/command/v7/security_groups_command.go +++ b/command/v7/security_groups_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" ) type SecurityGroupsCommand struct { diff --git a/command/v7/security_groups_command_test.go b/command/v7/security_groups_command_test.go index 0d682e1f4c6..453ec62dbd7 100644 --- a/command/v7/security_groups_command_test.go +++ b/command/v7/security_groups_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/service_access_command.go b/command/v7/service_access_command.go index f61fb64ac3f..a9e30721e22 100644 --- a/command/v7/service_access_command.go +++ b/command/v7/service_access_command.go @@ -3,10 +3,10 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" ) type ServiceAccessCommand struct { diff --git a/command/v7/service_access_command_test.go b/command/v7/service_access_command_test.go index 0424f118218..4029d0b09bc 100644 --- a/command/v7/service_access_command_test.go +++ b/command/v7/service_access_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/service_brokers_command.go b/command/v7/service_brokers_command.go index 4c36910b29b..59365e167de 100644 --- a/command/v7/service_brokers_command.go +++ b/command/v7/service_brokers_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type ServiceBrokersCommand struct { diff --git a/command/v7/service_brokers_command_test.go b/command/v7/service_brokers_command_test.go index d4f35de0786..490086a89ab 100644 --- a/command/v7/service_brokers_command_test.go +++ b/command/v7/service_brokers_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/service_command.go b/command/v7/service_command.go index c528d7ae59f..625b8c8089f 100644 --- a/command/v7/service_command.go +++ b/command/v7/service_command.go @@ -2,12 +2,13 @@ package v7 import ( "fmt" + "sort" "strconv" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) const indent = " " @@ -240,13 +241,25 @@ func (cmd ServiceCommand) displayBoundApps(serviceInstanceWithDetails v7action.S return } - table := [][]string{{"name", "binding name", "status", "message"}} - for _, app := range serviceInstanceWithDetails.BoundApps { + table := [][]string{{"name", "binding name", "status", "message", "guid", "created_at"}} + + bindings := serviceInstanceWithDetails.BoundApps + // sort by app name, then by created at descending + sort.Slice(bindings, func(i, j int) bool { + if bindings[i].AppName == bindings[j].AppName { + return bindings[i].CreatedAt > bindings[j].CreatedAt + } + return bindings[i].AppName < bindings[j].AppName + }) + + for _, app := range bindings { table = append(table, []string{ app.AppName, app.Name, fmt.Sprintf("%s %s", app.LastOperation.Type, app.LastOperation.State), app.LastOperation.Description, + app.GUID, + app.CreatedAt, }) } diff --git a/command/v7/service_command_test.go b/command/v7/service_command_test.go index 5a0985311e5..b797b0f3103 100644 --- a/command/v7/service_command_test.go +++ b/command/v7/service_command_test.go @@ -4,15 +4,15 @@ import ( "errors" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -271,19 +271,23 @@ var _ = Describe("service command", func() { { Name: "named-binding", AppName: "app-1", + GUID: "guid-1", LastOperation: resources.LastOperation{ Type: resources.CreateOperation, State: resources.OperationSucceeded, Description: "great", }, + CreatedAt: "created-at-1", }, { AppName: "app-2", + GUID: "guid-2", LastOperation: resources.LastOperation{ Type: resources.UpdateOperation, State: resources.OperationFailed, Description: "sorry", }, + CreatedAt: "created-at-2", }, }, }, @@ -295,9 +299,9 @@ var _ = Describe("service command", func() { It("prints the bound apps table", func() { Expect(testUI.Out).To(SatisfyAll( Say(`Showing bound apps:\n`), - Say(` name\s+binding name\s+status\s+message\n`), - Say(` app-1\s+named-binding\s+create succeeded\s+great\n`), - Say(` app-2\s+update failed\s+sorry\n`), + Say(` name\s+binding name\s+status\s+message\s+guid\s+created_at\n`), + Say(` app-1\s+named-binding\s+create succeeded\s+great\s+guid-1\s+created-at-1\n`), + Say(` app-2\s+update failed\s+sorry\s+guid-2\s+created-at-2\n`), )) }) }) @@ -348,7 +352,7 @@ var _ = Describe("service command", func() { ServiceBrokerName: serviceBrokerName, SharedStatus: v7action.SharedStatus{ IsSharedToOtherSpaces: true, - UsageSummary: []v7action.UsageSummaryWithSpaceAndOrg{{"shared-to-space", "some-org", 3}}, + UsageSummary: []v7action.UsageSummaryWithSpaceAndOrg{{SpaceName: "shared-to-space", OrganizationName: "some-org", BoundAppCount: 3}}, }, }, v7action.Warnings{"warning one", "warning two"}, @@ -704,19 +708,34 @@ var _ = Describe("service command", func() { { Name: "named-binding", AppName: "app-1", + GUID: "guid-1", LastOperation: resources.LastOperation{ Type: resources.CreateOperation, State: resources.OperationSucceeded, Description: "great", }, + CreatedAt: "created-at-1", }, { AppName: "app-2", + GUID: "guid-2", LastOperation: resources.LastOperation{ Type: resources.UpdateOperation, State: resources.OperationFailed, Description: "sorry", }, + CreatedAt: "created-at-2", + }, + { + Name: "named-binding", + AppName: "app-1", + GUID: "guid-3", + LastOperation: resources.LastOperation{ + Type: resources.CreateOperation, + State: resources.OperationSucceeded, + Description: "great", + }, + CreatedAt: "created-at-2", }, }, }, @@ -728,9 +747,10 @@ var _ = Describe("service command", func() { It("prints the bound apps table", func() { Expect(testUI.Out).To(SatisfyAll( Say(`Showing bound apps:\n`), - Say(`name\s+binding name\s+status\s+message\n`), - Say(`app-1\s+named-binding\s+create succeeded\s+great\n`), - Say(`app-2\s+update failed\s+sorry\n`), + Say(`name\s+binding name\s+status\s+message\s+guid\s+created_at\n`), + Say(`app-1\s+named-binding\s+create succeeded\s+great\s+guid-3\s+created-at-2\n`), + Say(`app-1\s+named-binding\s+create succeeded\s+great\s+guid-1\s+created-at-1\n`), + Say(`app-2\s+update failed\s+sorry\s+guid-2\s+created-at-2\n`), )) }) }) diff --git a/command/v7/service_key_command.go b/command/v7/service_key_command.go index 9bb96a4007e..bd317d4dd95 100644 --- a/command/v7/service_key_command.go +++ b/command/v7/service_key_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type ServiceKeyCommand struct { diff --git a/command/v7/service_key_command_test.go b/command/v7/service_key_command_test.go index 14710e52f85..c046756bb5d 100644 --- a/command/v7/service_key_command_test.go +++ b/command/v7/service_key_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/service_keys_command.go b/command/v7/service_keys_command.go index 2d5c7f5affa..1c1d7a7f1c1 100644 --- a/command/v7/service_keys_command.go +++ b/command/v7/service_keys_command.go @@ -3,9 +3,9 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type ServiceKeysCommand struct { diff --git a/command/v7/service_keys_command_test.go b/command/v7/service_keys_command_test.go index 7cd2fff5b62..76618ec75e0 100644 --- a/command/v7/service_keys_command_test.go +++ b/command/v7/service_keys_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/services_command.go b/command/v7/services_command.go index a8c0df21f6b..23787a1b064 100644 --- a/command/v7/services_command.go +++ b/command/v7/services_command.go @@ -3,11 +3,11 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/resources" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" ) type ServicesCommand struct { diff --git a/command/v7/services_command_test.go b/command/v7/services_command_test.go index 24ddaabf1b2..3075e4cb690 100644 --- a/command/v7/services_command_test.go +++ b/command/v7/services_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_droplet_command.go b/command/v7/set_droplet_command.go index 4528c1d6492..0a5888291ca 100644 --- a/command/v7/set_droplet_command.go +++ b/command/v7/set_droplet_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetDropletCommand struct { diff --git a/command/v7/set_droplet_command_test.go b/command/v7/set_droplet_command_test.go index 3b1dcfb14e7..945f0da021b 100644 --- a/command/v7/set_droplet_command_test.go +++ b/command/v7/set_droplet_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_env_command.go b/command/v7/set_env_command.go index 2dc01c88a44..69d965ab398 100644 --- a/command/v7/set_env_command.go +++ b/command/v7/set_env_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetEnvCommand struct { diff --git a/command/v7/set_env_command_test.go b/command/v7/set_env_command_test.go index ef109a614b1..4249001ae97 100644 --- a/command/v7/set_env_command_test.go +++ b/command/v7/set_env_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_health_check_command.go b/command/v7/set_health_check_command.go index 83059b3d2d8..24239921bf1 100644 --- a/command/v7/set_health_check_command.go +++ b/command/v7/set_health_check_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetHealthCheckCommand struct { diff --git a/command/v7/set_health_check_command_test.go b/command/v7/set_health_check_command_test.go index 18c7451828c..2b746cffe4a 100644 --- a/command/v7/set_health_check_command_test.go +++ b/command/v7/set_health_check_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_label_command.go b/command/v7/set_label_command.go index 05f833e058d..024349eb2ac 100644 --- a/command/v7/set_label_command.go +++ b/command/v7/set_label_command.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . LabelSetter @@ -18,11 +18,12 @@ type LabelSetter interface { type SetLabelCommand struct { BaseCommand - RequiredArgs flag.SetLabelArgs `positional-args:"yes"` - relatedCommands interface{} `related_commands:"labels, unset-label"` - BuildpackStack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name"` - ServiceBroker string `long:"broker" short:"b" description:"Specify a service broker to disambiguate service offerings or service plans with the same name."` - ServiceOffering string `long:"offering" short:"e" description:"Specify a service offering to disambiguate service plans with the same name."` + RequiredArgs flag.SetLabelArgs `positional-args:"yes"` + relatedCommands interface{} `related_commands:"labels, unset-label"` + BuildpackStack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name"` + BuildpackLifecycle string `long:"lifecycle" short:"l" description:"Specify lifecycle to disambiguate buildpacks with the same name"` + ServiceBroker string `long:"broker" short:"b" description:"Specify a service broker to disambiguate service offerings or service plans with the same name."` + ServiceOffering string `long:"offering" short:"e" description:"Specify a service offering to disambiguate service plans with the same name."` LabelSetter LabelSetter } @@ -72,7 +73,7 @@ func (cmd SetLabelCommand) Examples() string { return ` cf set-label app dora env=production cf set-label org business pci=true public-facing=false -cf set-label buildpack go_buildpack go=1.12 -s cflinuxfs3` +cf set-label buildpack go_buildpack go=1.12 -s cflinuxfs4` } func (cmd SetLabelCommand) Resources() string { diff --git a/command/v7/set_label_command_test.go b/command/v7/set_label_command_test.go index 5cc16ca2eaa..e8d630789dd 100644 --- a/command/v7/set_label_command_test.go +++ b/command/v7/set_label_command_test.go @@ -1,11 +1,11 @@ package v7_test import ( - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/v7/set_org_default_isolation_segment_command.go b/command/v7/set_org_default_isolation_segment_command.go index a19f517fa00..da90098f0b8 100644 --- a/command/v7/set_org_default_isolation_segment_command.go +++ b/command/v7/set_org_default_isolation_segment_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetOrgDefaultIsolationSegmentCommand struct { diff --git a/command/v7/set_org_default_isolation_segment_command_test.go b/command/v7/set_org_default_isolation_segment_command_test.go index 982064c0a58..e911f5c9c3a 100644 --- a/command/v7/set_org_default_isolation_segment_command_test.go +++ b/command/v7/set_org_default_isolation_segment_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_org_quota_command.go b/command/v7/set_org_quota_command.go index 2baad4c8efe..506fa2f66ed 100644 --- a/command/v7/set_org_quota_command.go +++ b/command/v7/set_org_quota_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetOrgQuotaCommand struct { diff --git a/command/v7/set_org_quota_command_test.go b/command/v7/set_org_quota_command_test.go index 88ac05c07f5..d437549a34c 100644 --- a/command/v7/set_org_quota_command_test.go +++ b/command/v7/set_org_quota_command_test.go @@ -1,17 +1,17 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "code.cloudfoundry.org/cli/command/v7" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "code.cloudfoundry.org/cli/v8/command/v7" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_org_role_command.go b/command/v7/set_org_role_command.go index a57ea353999..66c3aab939e 100644 --- a/command/v7/set_org_role_command.go +++ b/command/v7/set_org_role_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type SetOrgRoleCommand struct { diff --git a/command/v7/set_org_role_command_test.go b/command/v7/set_org_role_command_test.go index 6c4ad32269b..31f60428578 100644 --- a/command/v7/set_org_role_command_test.go +++ b/command/v7/set_org_role_command_test.go @@ -1,20 +1,20 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_running_environment_variable_group_command.go b/command/v7/set_running_environment_variable_group_command.go index c305199768d..7b14ada9255 100644 --- a/command/v7/set_running_environment_variable_group_command.go +++ b/command/v7/set_running_environment_variable_group_command.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type SetRunningEnvironmentVariableGroupCommand struct { diff --git a/command/v7/set_running_environment_variable_group_command_test.go b/command/v7/set_running_environment_variable_group_command_test.go index a7e5b5d76ac..80aaa1e5a9f 100644 --- a/command/v7/set_running_environment_variable_group_command_test.go +++ b/command/v7/set_running_environment_variable_group_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_space_isolation_segment_command.go b/command/v7/set_space_isolation_segment_command.go index 53588995591..6f9412d2bde 100644 --- a/command/v7/set_space_isolation_segment_command.go +++ b/command/v7/set_space_isolation_segment_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetSpaceIsolationSegmentCommand struct { diff --git a/command/v7/set_space_isolation_segment_command_test.go b/command/v7/set_space_isolation_segment_command_test.go index c6554154b83..74dc1825423 100644 --- a/command/v7/set_space_isolation_segment_command_test.go +++ b/command/v7/set_space_isolation_segment_command_test.go @@ -1,15 +1,15 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_space_quota_command.go b/command/v7/set_space_quota_command.go index ab97cfabcd7..6371913cb54 100644 --- a/command/v7/set_space_quota_command.go +++ b/command/v7/set_space_quota_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SetSpaceQuotaCommand struct { diff --git a/command/v7/set_space_quota_command_test.go b/command/v7/set_space_quota_command_test.go index e94e62f841e..3a4aecad89c 100644 --- a/command/v7/set_space_quota_command_test.go +++ b/command/v7/set_space_quota_command_test.go @@ -1,18 +1,18 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "code.cloudfoundry.org/cli/command/v7" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "code.cloudfoundry.org/cli/v8/command/v7" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_space_role_command.go b/command/v7/set_space_role_command.go index 77ba20ced8b..5b6133e960d 100644 --- a/command/v7/set_space_role_command.go +++ b/command/v7/set_space_role_command.go @@ -3,11 +3,11 @@ package v7 import ( "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type SetSpaceRoleCommand struct { diff --git a/command/v7/set_space_role_command_test.go b/command/v7/set_space_role_command_test.go index ac29113070d..bdba102e833 100644 --- a/command/v7/set_space_role_command_test.go +++ b/command/v7/set_space_role_command_test.go @@ -1,20 +1,20 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/set_staging_environment_variable_group_command.go b/command/v7/set_staging_environment_variable_group_command.go index 20cd146d30f..bba7d047e0b 100644 --- a/command/v7/set_staging_environment_variable_group_command.go +++ b/command/v7/set_staging_environment_variable_group_command.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type SetStagingEnvironmentVariableGroupCommand struct { diff --git a/command/v7/set_staging_environment_variable_group_command_test.go b/command/v7/set_staging_environment_variable_group_command_test.go index 511a8df6616..82f1c354a91 100644 --- a/command/v7/set_staging_environment_variable_group_command_test.go +++ b/command/v7/set_staging_environment_variable_group_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/share_private_domain_command.go b/command/v7/share_private_domain_command.go index 2ba4f0a8612..0dabac7bdb2 100644 --- a/command/v7/share_private_domain_command.go +++ b/command/v7/share_private_domain_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SharePrivateDomainCommand struct { diff --git a/command/v7/share_private_domain_command_test.go b/command/v7/share_private_domain_command_test.go index 6d01497b177..e7b34460f16 100644 --- a/command/v7/share_private_domain_command_test.go +++ b/command/v7/share_private_domain_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/share_route_command.go b/command/v7/share_route_command.go new file mode 100644 index 00000000000..767d9573eb4 --- /dev/null +++ b/command/v7/share_route_command.go @@ -0,0 +1,103 @@ +package v7 + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" +) + +type ShareRouteCommand struct { + BaseCommand + + RequireArgs flag.Domain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + DestinationOrg string `short:"o" description:"The org of the destination space (Default: targeted org)"` + DestinationSpace string `short:"s" description:"The space the route will be shared with (Default: targeted space)"` + + relatedCommands interface{} `related_commands:"create-route, map-route, unmap-route, routes"` +} + +func (cmd ShareRouteCommand) Usage() string { + return ` +Share an existing route in between two spaces: + CF_NAME share-route DOMAIN [--hostname HOSTNAME] [--path PATH] -s OTHER_SPACE [-o OTHER_ORG]` +} + +func (cmd ShareRouteCommand) Examples() string { + return ` +CF_NAME share-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo +CF_NAME share-route example.com --hostname myHost -s TargetSpace # myhost.example.com +CF_NAME share-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com` +} + +func (cmd ShareRouteCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequireArgs.Domain) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + path := cmd.Path.Path + route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.RouteNotFoundError); ok { + cmd.UI.DisplayText("Can not share route:") + return err + } + } + + destinationOrgName := cmd.DestinationOrg + + if destinationOrgName == "" { + destinationOrgName = cmd.Config.TargetedOrganizationName() + } + + destinationOrg, warnings, err := cmd.Actor.GetOrganizationByName(destinationOrgName) + cmd.UI.DisplayWarnings(warnings) + + if err != nil { + if _, ok := err.(actionerror.OrganizationNotFoundError); ok { + cmd.UI.DisplayText("Can not share route:") + return err + } + } + + targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.SpaceNotFoundError); ok { + cmd.UI.DisplayText("Can not share route:") + return err + } + } + + url := desiredURL(domain.Name, cmd.Hostname, path, 0) + cmd.UI.DisplayTextWithFlavor("Sharing route {{.URL}} to space {{.DestinationSpace}} as {{.User}}", + map[string]interface{}{ + "URL": url, + "DestinationSpace": cmd.DestinationSpace, + "User": user.Name, + }) + warnings, err = cmd.Actor.ShareRoute( + route.GUID, + targetedSpace.GUID, + ) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + cmd.UI.DisplayOK() + + return nil +} diff --git a/command/v7/share_route_command_test.go b/command/v7/share_route_command_test.go new file mode 100644 index 00000000000..67047a8c10e --- /dev/null +++ b/command/v7/share_route_command_test.go @@ -0,0 +1,279 @@ +package v7_test + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("share-route Command", func() { + var ( + cmd v7.ShareRouteCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + domainName string + orgName string + spaceName string + hostname string + path string + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "myBinaryBread" + fakeConfig.BinaryNameReturns(binaryName) + + domainName = "some-domain.com" + orgName = "org-name-a" + spaceName = "space-name-a" + hostname = "myHostname" + path = "myPath" + + cmd = v7.ShareRouteCommand{ + BaseCommand: v7.BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + RequireArgs: flag.Domain{Domain: domainName}, + Hostname: hostname, + Path: flag.V7RoutePath{Path: path}, + DestinationOrg: orgName, + DestinationSpace: spaceName, + } + + fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space", GUID: "some-space-guid"}) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{Name: "some-org"}) + fakeConfig.CurrentUserReturns(configv3.User{Name: "some-user"}, nil) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + It("checks that target", func() { + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in and targeted", func() { + When("getting the domain errors", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(0)) + + Expect(fakeActor.ShareRouteCallCount()).To(Equal(0)) + }) + }) + + When("getting the domain succeeds", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns( + resources.Domain{Name: domainName, GUID: "domain-guid"}, + v7action.Warnings{"get-domain-warnings"}, + nil, + ) + }) + + When("the requested route does not exist", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + }) + + It("displays error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + }) + }) + + When("the requested route exists", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + When("getting the target space errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.SpaceNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetOrganizationByNameArgsForCall(0)).To(Equal(orgName)) + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + + Expect(fakeActor.ShareRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target org errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.OrganizationNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.ShareRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target space succeeds", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{GUID: "space-guid-b"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + It("exits 0 with helpful message that the route is now being shared", func() { + Expect(executeErr).ShouldNot(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + Expect(fakeActor.ShareRouteCallCount()).To(Equal(1)) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/share_service_command.go b/command/v7/share_service_command.go index fdf72c1ad50..76a46b15044 100644 --- a/command/v7/share_service_command.go +++ b/command/v7/share_service_command.go @@ -1,9 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" ) type ShareServiceCommand struct { @@ -38,7 +39,14 @@ func (cmd ShareServiceCommand) Execute(args []string) error { }) cmd.UI.DisplayWarnings(warnings) - if err != nil { + + switch err.(type) { + case nil: + case ccerror.ServiceInstanceAlreadySharedError: + cmd.UI.DisplayOK() + cmd.UI.DisplayTextWithFlavor("A service instance called {{.ServiceInstanceName}} has already been shared", map[string]interface{}{"ServiceInstanceName": cmd.RequiredArgs.ServiceInstance}) + return nil + default: return err } diff --git a/command/v7/share_service_command_test.go b/command/v7/share_service_command_test.go index 46fd5a8f349..78026f1e360 100644 --- a/command/v7/share_service_command_test.go +++ b/command/v7/share_service_command_test.go @@ -3,19 +3,20 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/util/configv3" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" - "code.cloudfoundry.org/cli/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -141,6 +142,23 @@ var _ = Describe("share-service command", func() { }) }) + When("the service instance is already shared", func() { + BeforeEach(func() { + fakeActor.ShareServiceInstanceToSpaceAndOrgReturns(v7action.Warnings{"warning one", "warning two"}, ccerror.ServiceInstanceAlreadySharedError{}) + }) + + It("succeeds, displaying warnings, 'OK' and an informative message", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(testUI.Out).To(Say(`OK`)) + Expect(testUI.Err).To(SatisfyAll( + Say("warning one"), + Say("warning two"), + )) + Expect(testUI.Out).To(Say("A service instance called %s has already been shared", expectedServiceInstanceName)) + }) + }) + When("the actor errors", func() { BeforeEach(func() { fakeSharedActor.CheckTargetReturns(nil) diff --git a/command/v7/shared/app_stager.go b/command/v7/shared/app_stager.go index a94f168a9ae..5395f732277 100644 --- a/command/v7/shared/app_stager.go +++ b/command/v7/shared/app_stager.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) /* @@ -21,31 +21,19 @@ import ( //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . AppStager type AppStager interface { - StageAndStart( - app resources.Application, - space configv3.Space, - organization configv3.Organization, - packageGUID string, - strategy constant.DeploymentStrategy, - noWait bool, - appAction constant.ApplicationAction, - ) error - - StageApp( - app resources.Application, - packageGUID string, - space configv3.Space, - ) (resources.Droplet, error) - - StartApp( - app resources.Application, - resourceGuid string, - strategy constant.DeploymentStrategy, - noWait bool, - space configv3.Space, - organization configv3.Organization, - appAction constant.ApplicationAction, - ) error + StageAndStart(app resources.Application, space configv3.Space, organization configv3.Organization, packageGUID string, opts AppStartOpts) error + + StageApp(app resources.Application, packageGUID string, space configv3.Space) (resources.Droplet, error) + + StartApp(app resources.Application, space configv3.Space, organization configv3.Organization, resourceGuid string, opts AppStartOpts) error +} + +type AppStartOpts struct { + AppAction constant.ApplicationAction + MaxInFlight int + NoWait bool + Strategy constant.DeploymentStrategy + CanarySteps []resources.CanaryStep } type Stager struct { @@ -56,13 +44,12 @@ type Stager struct { } type stagingAndStartActor interface { - CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, v7action.Warnings, error) - CreateDeploymentByApplicationAndRevision(appGUID string, revisionGUID string) (string, v7action.Warnings, error) + CreateDeployment(dep resources.Deployment) (string, v7action.Warnings, error) GetCurrentUser() (configv3.User, error) GetDetailedAppSummary(appName string, spaceGUID string, withObfuscatedValues bool) (v7action.DetailedApplicationSummary, v7action.Warnings, error) GetStreamingLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client sharedaction.LogCacheClient) (<-chan sharedaction.LogMessage, <-chan error, context.CancelFunc, v7action.Warnings, error) PollStart(app resources.Application, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) - PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) + PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error) SetApplicationDroplet(appGUID string, dropletGUID string) (v7action.Warnings, error) StagePackage(packageGUID, appName, spaceGUID string) (<-chan resources.Droplet, <-chan v7action.Warnings, <-chan error) StartApplication(appGUID string) (v7action.Warnings, error) @@ -78,16 +65,7 @@ func NewAppStager(actor stagingAndStartActor, ui command.UI, config command.Conf } } -func (stager *Stager) StageAndStart( - app resources.Application, - space configv3.Space, - organization configv3.Organization, - packageGUID string, - strategy constant.DeploymentStrategy, - noWait bool, - appAction constant.ApplicationAction, -) error { - +func (stager *Stager) StageAndStart(app resources.Application, space configv3.Space, organization configv3.Organization, packageGUID string, opts AppStartOpts) error { droplet, err := stager.StageApp(app, packageGUID, space) if err != nil { return err @@ -95,7 +73,7 @@ func (stager *Stager) StageAndStart( stager.UI.DisplayNewline() - err = stager.StartApp(app, droplet.GUID, strategy, noWait, space, organization, appAction) + err = stager.StartApp(app, space, organization, droplet.GUID, opts) if err != nil { return err } @@ -126,16 +104,8 @@ func (stager *Stager) StageApp(app resources.Application, packageGUID string, sp return droplet, nil } -func (stager *Stager) StartApp( - app resources.Application, - resourceGuid string, - strategy constant.DeploymentStrategy, - noWait bool, - space configv3.Space, - organization configv3.Organization, - appAction constant.ApplicationAction, -) error { - if strategy == constant.DeploymentStrategyRolling { +func (stager *Stager) StartApp(app resources.Application, space configv3.Space, organization configv3.Organization, resourceGuid string, opts AppStartOpts) error { + if len(opts.Strategy) > 0 { stager.UI.DisplayText("Creating deployment for app {{.AppName}}...\n", map[string]interface{}{ "AppName": app.Name, @@ -148,11 +118,23 @@ func (stager *Stager) StartApp( err error ) - switch appAction { + dep := resources.Deployment{ + Strategy: opts.Strategy, + Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: app.GUID}}, + } + + if opts.Strategy == constant.DeploymentStrategyCanary && len(opts.CanarySteps) > 0 { + dep.Options = resources.DeploymentOpts{CanaryDeploymentOptions: &resources.CanaryDeploymentOptions{Steps: opts.CanarySteps}} + } + switch opts.AppAction { case constant.ApplicationRollingBack: - deploymentGUID, warnings, err = stager.Actor.CreateDeploymentByApplicationAndRevision(app.GUID, resourceGuid) + dep.RevisionGUID = resourceGuid + dep.Options.MaxInFlight = opts.MaxInFlight + deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep) default: - deploymentGUID, warnings, err = stager.Actor.CreateDeploymentByApplicationAndDroplet(app.GUID, resourceGuid) + dep.DropletGUID = resourceGuid + dep.Options.MaxInFlight = opts.MaxInFlight + deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep) } stager.UI.DisplayWarnings(warnings) @@ -166,19 +148,24 @@ func (stager *Stager) StartApp( stager.UI.DisplayText(instanceDetails) } - warnings, err = stager.Actor.PollStartForRolling(app, deploymentGUID, noWait, handleInstanceDetails) + warnings, err = stager.Actor.PollStartForDeployment(app, deploymentGUID, opts.NoWait, handleInstanceDetails) stager.UI.DisplayNewline() stager.UI.DisplayWarnings(warnings) if err != nil { return err } + + if opts.NoWait && opts.Strategy != constant.DeploymentStrategyCanary { + stager.UI.DisplayText("First instance restaged correctly, restaging remaining in the background") + return nil + } } else { user, err := stager.Actor.GetCurrentUser() if err != nil { return err } - flavorText := fmt.Sprintf("%s app {{.App}} in org {{.Org}} / space {{.Space}} as {{.UserName}}...", appAction) + flavorText := fmt.Sprintf("%s app {{.App}} in org {{.Org}} / space {{.Space}} as {{.UserName}}...", opts.AppAction) stager.UI.DisplayTextWithFlavor(flavorText, map[string]interface{}{ "App": app.Name, @@ -190,7 +177,7 @@ func (stager *Stager) StartApp( stager.UI.DisplayNewline() if app.Started() { - if appAction == constant.ApplicationStarting { + if opts.AppAction == constant.ApplicationStarting { stager.UI.DisplayText("App '{{.AppName}}' is already started.", map[string]interface{}{ "AppName": app.Name, @@ -233,7 +220,7 @@ func (stager *Stager) StartApp( stager.UI.DisplayText(instanceDetails) } - warnings, err = stager.Actor.PollStart(app, noWait, handleInstanceDetails) + warnings, err = stager.Actor.PollStart(app, opts.NoWait, handleInstanceDetails) stager.UI.DisplayNewline() stager.UI.DisplayWarnings(warnings) if err != nil { diff --git a/command/v7/shared/app_stager_test.go b/command/v7/shared/app_stager_test.go index 0650715bbea..471766bc632 100644 --- a/command/v7/shared/app_stager_test.go +++ b/command/v7/shared/app_stager_test.go @@ -5,18 +5,18 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -30,13 +30,15 @@ var _ = Describe("app stager", func() { fakeActor *v7fakes.FakeActor fakeLogCacheClient *sharedactionfakes.FakeLogCacheClient - app resources.Application - space configv3.Space - organization configv3.Organization - pkgGUID string - strategy constant.DeploymentStrategy - noWait bool - appAction constant.ApplicationAction + app resources.Application + space configv3.Space + organization configv3.Organization + pkgGUID string + strategy constant.DeploymentStrategy + maxInFlight int + noWait bool + appAction constant.ApplicationAction + canaryWeightSteps []resources.CanaryStep allLogsWritten chan bool closedTheStreams bool @@ -58,6 +60,7 @@ var _ = Describe("app stager", func() { space = configv3.Space{Name: "some-space", GUID: "some-space-guid"} organization = configv3.Organization{Name: "some-org"} strategy = constant.DeploymentStrategyDefault + maxInFlight = 2 appAction = constant.ApplicationRestarting fakeActor.GetStreamingLogsForApplicationByNameAndSpaceStub = func(appName string, spaceGUID string, client sharedaction.LogCacheClient) (<-chan sharedaction.LogMessage, <-chan error, context.CancelFunc, v7action.Warnings, error) { @@ -106,15 +109,14 @@ var _ = Describe("app stager", func() { JustBeforeEach(func() { appStager = shared.NewAppStager(fakeActor, testUI, fakeConfig, fakeLogCacheClient) - executeErr = appStager.StageAndStart( - app, - space, - organization, - pkgGUID, - strategy, - noWait, - appAction, - ) + opts := shared.AppStartOpts{ + AppAction: appAction, + MaxInFlight: maxInFlight, + NoWait: noWait, + Strategy: strategy, + CanarySteps: canaryWeightSteps, + } + executeErr = appStager.StageAndStart(app, space, organization, pkgGUID, opts) }) It("stages and starts the app", func() { @@ -125,6 +127,7 @@ var _ = Describe("app stager", func() { Expect(err).NotTo(HaveOccurred()) Expect(testUI.Out).To(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, app.Name, organization.Name, space.Name, user.Name)) Expect(testUI.Out).To(Say("Waiting for app to start...")) + }) When("staging fails", func() { @@ -170,6 +173,49 @@ var _ = Describe("app stager", func() { Expect(executeErr).To(MatchError("start-app-error")) }) }) + + When("The deployment strategy is rolling with nowait", func() { + BeforeEach(func() { + strategy = constant.DeploymentStrategyRolling + noWait = true + maxInFlight = 5 + appStager = shared.NewAppStager(fakeActor, testUI, fakeConfig, fakeLogCacheClient) + }) + + It("Restages and starts the app", func() { + Expect(executeErr).NotTo(HaveOccurred()) + + Expect(testUI.Out).To(Say("Creating deployment for app %s...", app.Name)) + Expect(testUI.Out).To(Say("Waiting for app to deploy...")) + + Expect(testUI.Out).To(Say("First instance restaged correctly, restaging remaining in the background")) + }) + + It("creates expected deployment", func() { + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1), "CreateDeployment...") + dep := fakeActor.CreateDeploymentArgsForCall(0) + Expect(dep.Options.MaxInFlight).To(Equal(5)) + Expect(string(dep.Strategy)).To(Equal("rolling")) + }) + }) + + When("deployment strategy is canary", func() { + BeforeEach(func() { + strategy = constant.DeploymentStrategyCanary + noWait = true + maxInFlight = 5 + canaryWeightSteps = []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 3}} + appStager = shared.NewAppStager(fakeActor, testUI, fakeConfig, fakeLogCacheClient) + }) + + It("creates expected deployment", func() { + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1), "CreateDeployment...") + dep := fakeActor.CreateDeploymentArgsForCall(0) + Expect(dep.Options.MaxInFlight).To(Equal(5)) + Expect(string(dep.Strategy)).To(Equal("canary")) + Expect(dep.Options.CanaryDeploymentOptions.Steps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 3}})) + }) + }) }) Context("StageApp", func() { @@ -323,7 +369,9 @@ var _ = Describe("app stager", func() { strategy = constant.DeploymentStrategyDefault noWait = true + maxInFlight = 2 appAction = constant.ApplicationRestarting + canaryWeightSteps = nil app = resources.Application{GUID: "app-guid", Name: "app-name", State: constant.ApplicationStarted} space = configv3.Space{Name: "some-space", GUID: "some-space-guid"} @@ -336,27 +384,26 @@ var _ = Describe("app stager", func() { JustBeforeEach(func() { appStager = shared.NewAppStager(fakeActor, testUI, fakeConfig, fakeLogCacheClient) - executeErr = appStager.StartApp( - app, - resourceGUID, - strategy, - noWait, - space, - organization, - appAction, - ) + opts := shared.AppStartOpts{ + Strategy: strategy, + NoWait: noWait, + MaxInFlight: maxInFlight, + AppAction: appAction, + CanarySteps: canaryWeightSteps, + } + executeErr = appStager.StartApp(app, space, organization, resourceGUID, opts) }) When("the deployment strategy is rolling", func() { BeforeEach(func() { strategy = constant.DeploymentStrategyRolling - fakeActor.CreateDeploymentByApplicationAndDropletReturns( + fakeActor.CreateDeploymentReturns( "some-deployment-guid", v7action.Warnings{"create-deployment-warning"}, nil, ) - fakeActor.PollStartForRollingReturns( + fakeActor.PollStartForDeploymentReturns( v7action.Warnings{"poll-start-warning"}, nil, ) @@ -366,7 +413,7 @@ var _ = Describe("app stager", func() { BeforeEach(func() { appAction = constant.ApplicationRollingBack resourceGUID = "revision-guid" - fakeActor.CreateDeploymentByApplicationAndRevisionReturns( + fakeActor.CreateDeploymentReturns( "some-deployment-guid", v7action.Warnings{"create-deployment-warning"}, nil, @@ -377,38 +424,44 @@ var _ = Describe("app stager", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Out).To(Say("Creating deployment for app %s...", app.Name)) - Expect(fakeActor.CreateDeploymentByApplicationAndRevisionCallCount()).To(Equal(1), "CreateDeployment...") - appGUID, revisionGUID := fakeActor.CreateDeploymentByApplicationAndRevisionArgsForCall(0) - Expect(appGUID).To(Equal(app.GUID)) - Expect(revisionGUID).To(Equal("revision-guid")) + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1), "CreateDeployment...") + dep := fakeActor.CreateDeploymentArgsForCall(0) + Expect(dep.Relationships[constant.RelationshipTypeApplication].GUID).To(Equal(app.GUID)) + Expect(dep.RevisionGUID).To(Equal("revision-guid")) + Expect(dep.Options.MaxInFlight).To(Equal(2)) Expect(testUI.Err).To(Say("create-deployment-warning")) Expect(testUI.Out).To(Say("Waiting for app to deploy...")) - Expect(fakeActor.PollStartForRollingCallCount()).To(Equal(1)) + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) Expect(testUI.Err).To(Say("poll-start-warning")) }) }) When("the app starts successfully", func() { + BeforeEach(func() { + maxInFlight = 3 + }) + It("displays output for each step of deploying", func() { Expect(executeErr).To(BeNil()) Expect(testUI.Out).To(Say("Creating deployment for app %s...", app.Name)) - Expect(fakeActor.CreateDeploymentByApplicationAndDropletCallCount()).To(Equal(1)) - appGUID, dropletGUID := fakeActor.CreateDeploymentByApplicationAndDropletArgsForCall(0) - Expect(appGUID).To(Equal(app.GUID)) - Expect(dropletGUID).To(Equal("droplet-guid")) + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1)) + dep := fakeActor.CreateDeploymentArgsForCall(0) + Expect(dep.Relationships[constant.RelationshipTypeApplication].GUID).To(Equal(app.GUID)) + Expect(dep.DropletGUID).To(Equal("droplet-guid")) + Expect(dep.Options.MaxInFlight).To(Equal(3)) Expect(testUI.Err).To(Say("create-deployment-warning")) Expect(testUI.Out).To(Say("Waiting for app to deploy...")) - Expect(fakeActor.PollStartForRollingCallCount()).To(Equal(1)) + Expect(fakeActor.PollStartForDeploymentCallCount()).To(Equal(1)) Expect(testUI.Err).To(Say("poll-start-warning")) }) }) When("creating a deployment fails", func() { BeforeEach(func() { - fakeActor.CreateDeploymentByApplicationAndDropletReturns( + fakeActor.CreateDeploymentReturns( "", v7action.Warnings{"create-deployment-warning"}, errors.New("create-deployment-error"), @@ -422,7 +475,7 @@ var _ = Describe("app stager", func() { When("polling fails for a rolling restage", func() { BeforeEach(func() { - fakeActor.PollStartForRollingReturns( + fakeActor.PollStartForDeploymentReturns( v7action.Warnings{"poll-start-warning"}, errors.New("poll-start-error"), ) @@ -486,6 +539,24 @@ var _ = Describe("app stager", func() { }) }) + When("the app action is rollback", func() { + BeforeEach(func() { + appAction = constant.ApplicationRollingBack + strategy = constant.DeploymentStrategyCanary + canaryWeightSteps = []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}} + app = resources.Application{GUID: "app-guid", Name: "app-name", State: constant.ApplicationStarted} + }) + + It("displays output for each step of starting", func() { + Expect(executeErr).To(BeNil()) + + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1)) + deployment := fakeActor.CreateDeploymentArgsForCall(0) + Expect(deployment.Strategy).To(Equal(constant.DeploymentStrategyCanary)) + Expect(deployment.Options.CanaryDeploymentOptions.Steps).To(Equal(canaryWeightSteps)) + }) + }) + When("the app action is restarting", func() { It("displays output for each step of restarting", func() { Expect(executeErr).To(BeNil()) @@ -533,6 +604,24 @@ var _ = Describe("app stager", func() { }) }) + When("deployment is canary and steps are provided", func() { + BeforeEach(func() { + appAction = constant.ApplicationStarting + strategy = constant.DeploymentStrategyCanary + canaryWeightSteps = []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 3}} + app = resources.Application{GUID: "app-guid", Name: "app-name", State: constant.ApplicationStopped} + }) + + It("displays output for each step of starting", func() { + Expect(executeErr).To(BeNil()) + Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1), "CreateDeployment...") + dep := fakeActor.CreateDeploymentArgsForCall(0) + Expect(dep.Options.MaxInFlight).To(Equal(2)) + Expect(string(dep.Strategy)).To(Equal("canary")) + Expect(dep.Options.CanaryDeploymentOptions.Steps).To(Equal([]resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}, {InstanceWeight: 3}})) + }) + }) + When("a droplet guid is not provided", func() { BeforeEach(func() { resourceGUID = "" diff --git a/command/v7/shared/app_summary_displayer.go b/command/v7/shared/app_summary_displayer.go index 38978ee148d..38f8dcc7df9 100644 --- a/command/v7/shared/app_summary_displayer.go +++ b/command/v7/shared/app_summary_displayer.go @@ -2,15 +2,17 @@ package shared import ( "fmt" + "strconv" "strings" "time" "code.cloudfoundry.org/bytefmt" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" log "github.com/sirupsen/logrus" ) @@ -31,33 +33,24 @@ func (display AppSummaryDisplayer) AppDisplay(summary v7action.DetailedApplicati isoRow = append(isoRow, display.UI.TranslateText("isolation segment:"), name) } + keyValueTable = [][]string{ + {display.UI.TranslateText("name:"), summary.Application.Name}, + {display.UI.TranslateText("requested state:"), strings.ToLower(string(summary.State))}, + isoRow, + {display.UI.TranslateText("routes:"), routeSummary(summary.Routes)}, + {display.UI.TranslateText("last uploaded:"), display.getCreatedTime(summary)}, + {display.UI.TranslateText("stack:"), summary.CurrentDroplet.Stack}, + } + if summary.LifecycleType == constant.AppLifecycleTypeDocker { - keyValueTable = [][]string{ - {display.UI.TranslateText("name:"), summary.Application.Name}, - {display.UI.TranslateText("requested state:"), strings.ToLower(string(summary.State))}, - isoRow, - {display.UI.TranslateText("routes:"), routeSummary(summary.Routes)}, - {display.UI.TranslateText("last uploaded:"), display.getCreatedTime(summary)}, - {display.UI.TranslateText("stack:"), summary.CurrentDroplet.Stack}, - {display.UI.TranslateText("docker image:"), summary.CurrentDroplet.Image}, - isoRow, - } + keyValueTable = append(keyValueTable, []string{display.UI.TranslateText("docker image:"), summary.CurrentDroplet.Image}, isoRow) } else { - keyValueTable = [][]string{ - {display.UI.TranslateText("name:"), summary.Application.Name}, - {display.UI.TranslateText("requested state:"), strings.ToLower(string(summary.State))}, - isoRow, - {display.UI.TranslateText("routes:"), routeSummary(summary.Routes)}, - {display.UI.TranslateText("last uploaded:"), display.getCreatedTime(summary)}, - {display.UI.TranslateText("stack:"), summary.CurrentDroplet.Stack}, - {display.UI.TranslateText("buildpacks:"), ""}, - isoRow, - } + keyValueTable = append(keyValueTable, []string{display.UI.TranslateText("buildpacks:"), ""}, isoRow) } - display.UI.DisplayKeyValueTable("", keyValueTable, 3) + display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding) - if summary.LifecycleType == constant.AppLifecycleTypeBuildpack { + if summary.LifecycleType != constant.AppLifecycleTypeDocker { display.displayBuildpackTable(summary.CurrentDroplet.Buildpacks) } @@ -72,6 +65,29 @@ func routeSummary(rs []resources.Route) string { return strings.Join(formattedRoutes, ", ") } +func formatLogRateLimit(limit int64) string { + if limit == -1 { + return "unlimited" + } else { + return bytefmt.ByteSize(uint64(limit)) + "/s" + } +} + +func formatCPUEntitlement(cpuEntitlement types.NullFloat64) string { + if !cpuEntitlement.IsSet { + return "" + } + return fmt.Sprintf("%.1f%%", cpuEntitlement.Value*100) +} + +func formatRoutable(b *bool) string { + if b == nil { + return "-" + } + + return fmt.Sprintf("%t", *b) +} + func (display AppSummaryDisplayer) displayAppInstancesTable(processSummary v7action.ProcessSummary) { table := [][]string{ { @@ -81,7 +97,10 @@ func (display AppSummaryDisplayer) displayAppInstancesTable(processSummary v7act display.UI.TranslateText("cpu"), display.UI.TranslateText("memory"), display.UI.TranslateText("disk"), + display.UI.TranslateText("logging"), + display.UI.TranslateText("cpu entitlement"), display.UI.TranslateText("details"), + display.UI.TranslateText("ready"), }, } @@ -99,7 +118,13 @@ func (display AppSummaryDisplayer) displayAppInstancesTable(processSummary v7act "DiskUsage": bytefmt.ByteSize(instance.DiskUsage), "DiskQuota": bytefmt.ByteSize(instance.DiskQuota), }), + display.UI.TranslateText("{{.LogRate}}/s of {{.LogRateLimit}}", map[string]interface{}{ + "LogRate": bytefmt.ByteSize(instance.LogRate), + "LogRateLimit": formatLogRateLimit(instance.LogRateLimit), + }), + formatCPUEntitlement(instance.CPUEntitlement), instance.Details, + formatRoutable(instance.Routable), }) } @@ -128,7 +153,7 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed startCommandRow, } - display.UI.DisplayKeyValueTable("", keyValueTable, 3) + display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding) if len(process.InstanceDetails) == 0 { display.UI.DisplayText("There are no running instances of this process.") @@ -136,6 +161,48 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed } display.displayAppInstancesTable(process) } + + if summary.Deployment.StatusValue == constant.DeploymentStatusValueActive { + display.UI.DisplayNewline() + display.UI.DisplayText(display.getDeploymentStatusText(summary)) + + var maxInFlightRow []string + var maxInFlight = summary.Deployment.Options.MaxInFlight + if maxInFlight > 0 { + maxInFlightRow = append(maxInFlightRow, display.UI.TranslateText("max-in-flight:"), strconv.Itoa(maxInFlight)) + } + var canaryStepsRow []string + if summary.Deployment.CanaryStatus.Steps.TotalSteps > 0 { + stepStatus := summary.Deployment.CanaryStatus.Steps + canaryStepsRow = []string{display.UI.TranslateText("canary-steps:"), fmt.Sprintf("%d/%d", stepStatus.CurrentStep, stepStatus.TotalSteps)} + + } + + keyValueTable := [][]string{ + {display.UI.TranslateText("strategy:"), strings.ToLower(string(summary.Deployment.Strategy))}, + maxInFlightRow, + canaryStepsRow, + } + + display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding) + + if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused { + display.UI.DisplayNewline() + display.UI.DisplayText(fmt.Sprintf("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", summary.Application.Name, summary.Application.Name)) + } + } +} + +func (display AppSummaryDisplayer) getDeploymentStatusText(summary v7action.DetailedApplicationSummary) string { + var lastStatusChangeTime = display.getLastStatusChangeTime(summary) + if lastStatusChangeTime != "" { + return fmt.Sprintf("Active deployment with status %s (since %s)", + summary.Deployment.StatusReason, + lastStatusChangeTime) + } else { + return fmt.Sprintf("Active deployment with status %s.", + summary.Deployment.StatusReason) + } } func (display AppSummaryDisplayer) getCreatedTime(summary v7action.DetailedApplicationSummary) string { @@ -151,6 +218,19 @@ func (display AppSummaryDisplayer) getCreatedTime(summary v7action.DetailedAppli return "" } +func (display AppSummaryDisplayer) getLastStatusChangeTime(summary v7action.DetailedApplicationSummary) string { + if summary.Deployment.LastStatusChange != "" { + timestamp, err := time.Parse(time.RFC3339, summary.Deployment.LastStatusChange) + if err != nil { + log.WithField("last_status_change", summary.Deployment.LastStatusChange).Errorln("error parsing last status change:", err) + } + + return display.UI.UserFriendlyDate(timestamp) + } + + return "" +} + func (AppSummaryDisplayer) appInstanceDate(input time.Time) string { return input.UTC().Format(time.RFC3339) } diff --git a/command/v7/shared/app_summary_displayer_test.go b/command/v7/shared/app_summary_displayer_test.go index d35d31af5cf..8986c1b0592 100644 --- a/command/v7/shared/app_summary_displayer_test.go +++ b/command/v7/shared/app_summary_displayer_test.go @@ -3,19 +3,22 @@ package shared_test import ( "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - . "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + . "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) var _ = Describe("app summary displayer", func() { + + const instanceStatsTitles = `state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details\s+ready` + var ( appSummaryDisplayer *AppSummaryDisplayer output *Buffer @@ -45,6 +48,10 @@ var _ = Describe("app summary displayer", func() { BeforeEach(func() { uptime = time.Since(time.Unix(267321600, 0)) + var ( + bTrue = true + bFalse = false + ) summary = v7action.DetailedApplicationSummary{ ApplicationSummary: v7action.ApplicationSummary{ Application: resources.Application{ @@ -54,59 +61,76 @@ var _ = Describe("app summary displayer", func() { ProcessSummaries: v7action.ProcessSummaries{ { Process: resources.Process{ - Type: constant.ProcessTypeWeb, - MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, - DiskInMB: types.NullUint64{Value: 1024, IsSet: true}, + Type: constant.ProcessTypeWeb, + MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, + DiskInMB: types.NullUint64{Value: 1024, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 1024 * 5, IsSet: true}, }, Sidecars: []resources.Sidecar{}, InstanceDetails: []v7action.ProcessInstance{ v7action.ProcessInstance{ - Index: 0, - State: constant.ProcessInstanceRunning, - MemoryUsage: 1000000, - DiskUsage: 1000000, - MemoryQuota: 33554432, - DiskQuota: 2000000, - Uptime: uptime, - Details: "Some Details 1", + Index: 0, + State: constant.ProcessInstanceRunning, + CPUEntitlement: types.NullFloat64{Value: 0, IsSet: true}, + MemoryUsage: 1000000, + DiskUsage: 1000000, + LogRate: 1024, + MemoryQuota: 33554432, + DiskQuota: 2000000, + LogRateLimit: 1024 * 5, + Uptime: uptime, + Details: "Some Details 1", + Routable: &bTrue, }, v7action.ProcessInstance{ - Index: 1, - State: constant.ProcessInstanceRunning, - MemoryUsage: 2000000, - DiskUsage: 2000000, - MemoryQuota: 33554432, - DiskQuota: 4000000, - Uptime: time.Since(time.Unix(330480000, 0)), - Details: "Some Details 2", + Index: 1, + State: constant.ProcessInstanceRunning, + CPUEntitlement: types.NullFloat64{Value: 0, IsSet: false}, + MemoryUsage: 2000000, + DiskUsage: 2000000, + LogRate: 1024 * 2, + MemoryQuota: 33554432, + DiskQuota: 4000000, + LogRateLimit: 1024 * 5, + Uptime: time.Since(time.Unix(330480000, 0)), + Details: "Some Details 2", + Routable: &bTrue, }, v7action.ProcessInstance{ - Index: 2, - State: constant.ProcessInstanceRunning, - MemoryUsage: 3000000, - DiskUsage: 3000000, - MemoryQuota: 33554432, - DiskQuota: 6000000, - Uptime: time.Since(time.Unix(1277164800, 0)), + Index: 2, + State: constant.ProcessInstanceRunning, + CPUEntitlement: types.NullFloat64{Value: 0.03, IsSet: true}, + MemoryUsage: 3000000, + DiskUsage: 3000000, + LogRate: 1024 * 3, + MemoryQuota: 33554432, + DiskQuota: 6000000, + LogRateLimit: 1024 * 5, + Uptime: time.Since(time.Unix(1277164800, 0)), + Routable: &bFalse, }, }, }, { Process: resources.Process{ - Type: "console", - MemoryInMB: types.NullUint64{Value: 16, IsSet: true}, - DiskInMB: types.NullUint64{Value: 512, IsSet: true}, + Type: "console", + MemoryInMB: types.NullUint64{Value: 16, IsSet: true}, + DiskInMB: types.NullUint64{Value: 512, IsSet: true}, + LogRateLimitInBPS: types.NullInt{Value: 256, IsSet: true}, }, Sidecars: []resources.Sidecar{}, InstanceDetails: []v7action.ProcessInstance{ v7action.ProcessInstance{ - Index: 0, - State: constant.ProcessInstanceRunning, - MemoryUsage: 1000000, - DiskUsage: 1000000, - MemoryQuota: 33554432, - DiskQuota: 8000000, - Uptime: time.Since(time.Unix(167572800, 0)), + Index: 0, + State: constant.ProcessInstanceRunning, + MemoryUsage: 1000000, + DiskUsage: 1000000, + LogRate: 128, + MemoryQuota: 33554432, + DiskQuota: 8000000, + LogRateLimit: 256, + Uptime: time.Since(time.Unix(167572800, 0)), + Routable: &bTrue, }, }, }, @@ -130,16 +154,25 @@ var _ = Describe("app summary displayer", func() { Expect(time.Parse(time.RFC3339, webProcessSummary.Instances[0].Since)).To(BeTemporally("~", time.Now().Add(-uptime), 2*time.Second)) Expect(webProcessSummary.Instances[0].Disk).To(Equal("976.6K of 1.9M")) Expect(webProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[0].CPUEntitlement).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[0].LogRate).To(Equal("1K/s of 5K/s")) Expect(webProcessSummary.Instances[0].Details).To(Equal("Some Details 1")) + Expect(webProcessSummary.Instances[0].Ready).To(Equal("true")) Expect(webProcessSummary.Instances[1].Memory).To(Equal("1.9M of 32M")) Expect(webProcessSummary.Instances[1].Disk).To(Equal("1.9M of 3.8M")) Expect(webProcessSummary.Instances[1].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[1].CPUEntitlement).To(Equal("")) + Expect(webProcessSummary.Instances[1].LogRate).To(Equal("2K/s of 5K/s")) Expect(webProcessSummary.Instances[1].Details).To(Equal("Some Details 2")) + Expect(webProcessSummary.Instances[1].Ready).To(Equal("true")) Expect(webProcessSummary.Instances[2].Memory).To(Equal("2.9M of 32M")) Expect(webProcessSummary.Instances[2].Disk).To(Equal("2.9M of 5.7M")) Expect(webProcessSummary.Instances[2].CPU).To(Equal("0.0%")) + Expect(webProcessSummary.Instances[2].CPUEntitlement).To(Equal("3.0%")) + Expect(webProcessSummary.Instances[2].LogRate).To(Equal("3K/s of 5K/s")) + Expect(webProcessSummary.Instances[2].Ready).To(Equal("false")) consoleProcessSummary := processTable.Processes[1] Expect(consoleProcessSummary.Type).To(Equal("console")) @@ -150,6 +183,46 @@ var _ = Describe("app summary displayer", func() { Expect(consoleProcessSummary.Instances[0].Memory).To(Equal("976.6K of 32M")) Expect(consoleProcessSummary.Instances[0].Disk).To(Equal("976.6K of 7.6M")) Expect(consoleProcessSummary.Instances[0].CPU).To(Equal("0.0%")) + Expect(consoleProcessSummary.Instances[0].CPUEntitlement).To(Equal("")) + Expect(consoleProcessSummary.Instances[0].LogRate).To(Equal("128B/s of 256B/s")) + }) + }) + + When("the log rate is unlimited", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + ApplicationSummary: v7action.ApplicationSummary{ + Application: resources.Application{ + GUID: "some-app-guid", + State: constant.ApplicationStarted, + }, + ProcessSummaries: v7action.ProcessSummaries{ + { + Process: resources.Process{ + Type: constant.ProcessTypeWeb, + MemoryInMB: types.NullUint64{Value: 32, IsSet: true}, + DiskInMB: types.NullUint64{Value: 1024, IsSet: true}, + }, + Sidecars: []resources.Sidecar{}, + InstanceDetails: []v7action.ProcessInstance{ + v7action.ProcessInstance{ + Index: 0, + State: constant.ProcessInstanceRunning, + LogRate: 1024, + LogRateLimit: -1, + }, + }, + }, + }, + }, + } + }) + + It("renders unlimited log rate limits correctly", func() { + processTable := helpers.ParseV3AppProcessTable(output.Contents()) + webProcessSummary := processTable.Processes[0] + + Expect(webProcessSummary.Instances[0].LogRate).To(Equal("1K/s of unlimited")) }) }) @@ -197,7 +270,7 @@ var _ = Describe("app summary displayer", func() { It("lists instance stats for process types that have > 0 instances", func() { Expect(testUI.Out).To(Say(`type:\s+web`)) Expect(testUI.Out).To(Say(`sidecars: `)) - Expect(testUI.Out).To(Say(`state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Expect(testUI.Out).To(Say(instanceStatsTitles)) }) It("does not show the instance stats table for process types with 0 instances", func() { @@ -227,7 +300,7 @@ var _ = Describe("app summary displayer", func() { It("displays the instances table", func() { Expect(testUI.Out).To(Say(`type:\s+web`)) Expect(testUI.Out).To(Say(`sidecars: `)) - Expect(testUI.Out).To(Say(`state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Expect(testUI.Out).To(Say(instanceStatsTitles)) }) }) @@ -342,7 +415,7 @@ var _ = Describe("app summary displayer", func() { }) It("does not display the instance table", func() { - Expect(testUI.Out).NotTo(Say(`state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Expect(testUI.Out).NotTo(Say(instanceStatsTitles)) }) }) @@ -380,7 +453,7 @@ var _ = Describe("app summary displayer", func() { }) It("does not display the instance table", func() { - Expect(testUI.Out).NotTo(Say(`state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Expect(testUI.Out).NotTo(Say(instanceStatsTitles)) }) }) @@ -421,7 +494,7 @@ var _ = Describe("app summary displayer", func() { }) It("does not display the instance table", func() { - Expect(testUI.Out).NotTo(Say(`state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Expect(testUI.Out).NotTo(Say(instanceStatsTitles)) }) }) @@ -504,6 +577,22 @@ var _ = Describe("app summary displayer", func() { }) }) + When("the application has routes with options", func() { + BeforeEach(func() { + lbLCVal := "least-connection" + options := map[string]*string{"loadbalancing": &lbLCVal} + + summary.Routes = []resources.Route{ + {Host: "route1", URL: "route1.example.com", Options: options}, + {Host: "route2", URL: "route2.example.com"}, + } + }) + + It("displays routes without their options", func() { + Expect(testUI.Out).To(Say(`routes:\s+%s, %s`, "route1.example.com", "route2.example.com")) + }) + }) + When("the application has a stack", func() { BeforeEach(func() { summary.CurrentDroplet.Stack = "some-stack" @@ -553,7 +642,7 @@ var _ = Describe("app summary displayer", func() { }, }, CurrentDroplet: resources.Droplet{ - Stack: "cflinuxfs2", + Stack: "cflinuxfs4", Buildpacks: []resources.DropletBuildpack{ { Name: "ruby_buildpack", @@ -583,12 +672,405 @@ var _ = Describe("app summary displayer", func() { }) It("displays stack and buildpacks", func() { - Expect(testUI.Out).To(Say(`stack:\s+cflinuxfs2\n`)) + Expect(testUI.Out).To(Say(`stack:\s+cflinuxfs4\n`)) Expect(testUI.Out).To(Say(`buildpacks:\s+\n`)) Expect(testUI.Out).To(Say(`name\s+version\s+detect output\s+buildpack name\n`)) Expect(testUI.Out).To(Say(`ruby_buildpack\s+0.0.1\s+some-detect-output\s+ruby_buildpack_name\n`)) Expect(testUI.Out).To(Say(`some-buildpack`)) }) }) + + When("there is an active deployment", func() { + var LastStatusChangeTimeString = "2024-07-29T17:32:29Z" + var dateTimeRegexPattern = `[a-zA-Z]{3}\s\d{2}\s[a-zA-Z]{3}\s\d{2}\:\d{2}\:\d{2}\s[A-Z]{3,4}\s\d{4}` + var maxInFlightDefaultValue = 1 + + When("the deployment strategy is rolling", func() { + When("the deployment is in progress", func() { + When("last status change has a timestamp and max-in-flight is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + }) + + When("last status change has a timestamp and max-in-flight is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + }) + }) + + When("an older version of CAPI does not return max-in-flight", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + LastStatusChange: LastStatusChangeTimeString, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + Expect(testUI.Out).ToNot(Say(`max-in-flight`)) + }) + }) + + When("last status change is an empty string and max-in-flight is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + LastStatusChange: "", + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING`)) + Expect(testUI.Out).NotTo(Say(`\(since`)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + }) + + When("last status change is an empty string and max-in-flight is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + LastStatusChange: "", + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING`)) + Expect(testUI.Out).NotTo(Say(`\(since`)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + }) + }) + }) + + When("the deployment is cancelled", func() { + When("max-in-flight value is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonCanceling, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + }) + + When("max-in-flight value is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyRolling, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonCanceling, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: rolling`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + }) + }) + }) + }) + + When("the deployment strategy is canary", func() { + When("the deployment is in progress", func() { + When("max-in-flight value is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + CanaryStatus: resources.CanaryStatus{ + Steps: resources.CanaryStepStatus{ + CurrentStep: 2, + TotalSteps: 5, + }, + }, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).NotTo(Say(`promote the canary deployment`)) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + + It("displays the step the deployment is currently in", func() { + Expect(testUI.Out).To(Say(`canary-steps: 2/5`)) + }) + }) + + When("max-in-flight value is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonDeploying, + CanaryStatus: resources.CanaryStatus{ + Steps: resources.CanaryStepStatus{ + CurrentStep: 2, + TotalSteps: 5, + }, + }, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).NotTo(Say(`promote the canary deployment`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + }) + }) + }) + + When("the deployment is paused", func() { + When("max-in-flight value is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + ApplicationSummary: v7action.ApplicationSummary{ + Application: resources.Application{ + Name: "foobar", + }, + }, + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonPaused, + CanaryStatus: resources.CanaryStatus{ + Steps: resources.CanaryStepStatus{ + CurrentStep: 2, + TotalSteps: 5, + }, + }, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status PAUSED \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version.")) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + }) + + When("max-in-flight value is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + ApplicationSummary: v7action.ApplicationSummary{ + Application: resources.Application{ + Name: "foobar", + }, + }, + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonPaused, + CanaryStatus: resources.CanaryStatus{ + Steps: resources.CanaryStepStatus{ + CurrentStep: 2, + TotalSteps: 5, + }, + }, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status PAUSED \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version.")) + }) + }) + }) + + When("the deployment is canceling", func() { + When("max-in-flight value is non-default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonCanceling, + CanaryStatus: resources.CanaryStatus{ + Steps: resources.CanaryStepStatus{ + CurrentStep: 2, + TotalSteps: 5, + }, + }, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: 2, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).NotTo(Say(`promote the canary deployment`)) + }) + + It("displays max-in-flight value", func() { + Expect(testUI.Out).To(Say(`max-in-flight: 2`)) + }) + }) + + When("max-in-flight value is default", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: constant.DeploymentStrategyCanary, + StatusValue: constant.DeploymentStatusValueActive, + StatusReason: constant.DeploymentStatusReasonCanceling, + LastStatusChange: LastStatusChangeTimeString, + Options: resources.DeploymentOpts{ + MaxInFlight: maxInFlightDefaultValue, + }, + }, + } + }) + + It("displays the message", func() { + Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern)) + Expect(testUI.Out).To(Say(`strategy: canary`)) + Expect(testUI.Out).To(Say(`max-in-flight: 1`)) + Expect(testUI.Out).NotTo(Say(`promote the canary deployment`)) + }) + }) + }) + }) + }) + + When("there is no active deployment", func() { + BeforeEach(func() { + summary = v7action.DetailedApplicationSummary{ + Deployment: resources.Deployment{ + Strategy: "", + StatusValue: "", + StatusReason: "", + }, + } + }) + + It("does not display deployment info", func() { + Expect(testUI.Out).NotTo(Say(`Active deployment with status`)) + }) + + It("does not display max-in-flight", func() { + Expect(testUI.Out).NotTo(Say(`max-in-flight`)) + }) + }) }) }) diff --git a/command/v7/shared/manifest_diff_displayer.go b/command/v7/shared/manifest_diff_displayer.go index 4a9038e53a8..eaac038ad6a 100644 --- a/command/v7/shared/manifest_diff_displayer.go +++ b/command/v7/shared/manifest_diff_displayer.go @@ -1,29 +1,64 @@ package shared import ( + "errors" "path" "reflect" "strconv" "strings" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/resources" - "github.com/pkg/errors" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" "gopkg.in/yaml.v2" ) +var redacted = "" + type ManifestDiffDisplayer struct { - UI command.UI + UI command.UI + RedactEnv bool } -func NewManifestDiffDisplayer(ui command.UI) *ManifestDiffDisplayer { - return &ManifestDiffDisplayer{ - UI: ui, +func redactEnvVarsInRawManifest(rawManifest []byte) ([]byte, error) { + var manifestDataStructure struct { + Version int `yaml:"version,omitempty"` + Applications []yaml.MapSlice `yaml:"applications"` } -} + if err := yaml.Unmarshal(rawManifest, &manifestDataStructure); err != nil { + return []byte{}, err + } + for appListIndex, application := range manifestDataStructure.Applications { + for appDataIndex, appDataKV := range application { + if appDataKV.Key == "env" { + envMapSlice := appDataKV.Value.(yaml.MapSlice) + for envKeyIndex := range envMapSlice { + envMapSlice[envKeyIndex].Value = redacted + } + appDataKV.Value = envMapSlice + application[appDataIndex] = appDataKV + manifestDataStructure.Applications[appListIndex] = application + } + } + } + return yaml.Marshal(manifestDataStructure) +} func (display *ManifestDiffDisplayer) DisplayDiff(rawManifest []byte, diff resources.ManifestDiff) error { - // If there are no diffs, just print the manifest + + // Redact RAW manifest envVarValues in all apps + // The below could probably be achieved easier if we stop trying to avoid changing map element ordering.. + if display.RedactEnv { + var err error + rawManifest, err = redactEnvVarsInRawManifest(rawManifest) + if err != nil { + return errors.New("unable to process manifest diff because its format is invalid") + } + } + + // Always display the yaml header line + display.UI.DisplayDiffUnchanged("---", 0, false) + + // If there are no diffs, just print the (redacted) manifest if len(diff.Diffs) == 0 { display.UI.DisplayDiffUnchanged(string(rawManifest), 0, false) return nil @@ -33,7 +68,7 @@ func (display *ManifestDiffDisplayer) DisplayDiff(rawManifest []byte, diff resou var yamlManifest yaml.MapSlice err := yaml.Unmarshal(rawManifest, &yamlManifest) if err != nil { - return errors.New("Unable to process manifest diff because its format is invalid.") + return errors.New("unable to process manifest diff because its format is invalid") } // Distinguish between add/remove and replace diffs @@ -41,6 +76,7 @@ func (display *ManifestDiffDisplayer) DisplayDiff(rawManifest []byte, diff resou // Add/Remove diffs will not, so we need to know their parent's path to insert the diff as a child pathAddReplaceMap := make(map[string]resources.Diff) pathRemoveMap := make(map[string]resources.Diff) + for _, diff := range diff.Diffs { switch diff.Op { case resources.AddOperation, resources.ReplaceOperation: @@ -50,9 +86,6 @@ func (display *ManifestDiffDisplayer) DisplayDiff(rawManifest []byte, diff resou } } - // Always display the yaml header line - display.UI.DisplayDiffUnchanged("---", 0, false) - // For each entry in the provided manifest, process any diffs at or below that entry for _, entry := range yamlManifest { display.processDiffsRecursively("/"+interfaceToString(entry.Key), entry.Value, 0, &pathAddReplaceMap, &pathRemoveMap, false) @@ -119,14 +152,58 @@ func (display *ManifestDiffDisplayer) processDiffsRecursively( // Otherwise, print the unchanged field and value display.UI.DisplayDiffUnchanged(formatKeyValue(field, value), depth, addHyphen) } +func redactDiff(diff resources.Diff) resources.Diff { + // there are 3 possible ways that a diff can contain env data + // - the diff applies to a path /applications/0/env/key that identifies a changed KV pair in the env object + // in that case we want to change the diff.Value && diff.Was to ensure that no env item is printed + // - the diff applies to a path /applications/0/env that identifies `env` itself, all subvalues must be replaced + // in that case we want to change the diff.Value && diff.Was to ensure that no env item is printed + // - the diff applies to a path /applications/0 that identifies the parent element that contains `env` itself, all subvalues in `env` must be replaced + + isEnvKV := strings.HasSuffix(path.Dir(diff.Path), "env") + isEnvMap := strings.HasSuffix(diff.Path, "env") + fullMap, containsMap := diff.Value.(map[string]interface{}) + if isEnvKV { + diff.Value = redacted + diff.Was = redacted + } + if isEnvMap { + cleanMap := diff.Value.(map[string]interface{}) + for index := range cleanMap { + cleanMap[index] = redacted + } + diff.Value = cleanMap + } else if envMap, containsEnvInMap := fullMap["env"].(map[string]interface{}); containsMap && containsEnvInMap { + for index := range envMap { + envMap[index] = redacted + } + fullMap["env"] = envMap + diff.Value = fullMap + } + return diff +} + +func redactCNBCredentials(diff resources.Diff) resources.Diff { + if strings.HasSuffix(diff.Path, "cnb-credentials") { + diff.Value = "[PRIVATE DATA HIDDEN]" + } + + return diff +} func (display *ManifestDiffDisplayer) formatDiff(field string, diff resources.Diff, depth int, addHyphen bool) { + if display.RedactEnv { + diff = redactDiff(diff) + } + + diff = redactCNBCredentials(diff) addHyphen = isInt(field) || addHyphen switch diff.Op { case resources.AddOperation: display.UI.DisplayDiffAddition(formatKeyValue(field, diff.Value), depth, addHyphen) case resources.ReplaceOperation: + display.UI.DisplayDiffRemoval(formatKeyValue(field, diff.Was), depth, addHyphen) display.UI.DisplayDiffAddition(formatKeyValue(field, diff.Value), depth, addHyphen) diff --git a/command/v7/shared/manifest_diff_displayer_test.go b/command/v7/shared/manifest_diff_displayer_test.go index 28c87d9fd3b..f9d990911bf 100644 --- a/command/v7/shared/manifest_diff_displayer_test.go +++ b/command/v7/shared/manifest_diff_displayer_test.go @@ -1,11 +1,11 @@ package shared_test import ( - . "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + . "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -18,7 +18,10 @@ var _ = Describe("ManifestDiffDisplayer", func() { BeforeEach(func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) - displayer = NewManifestDiffDisplayer(testUI) + displayer = &ManifestDiffDisplayer{ + UI: testUI, + RedactEnv: false, + } }) Describe("DisplayDiff", func() { @@ -63,7 +66,7 @@ applications: parameters: key1: value1 key2: value2 - stack: cflinuxfs3 + stack: cflinuxfs4 metadata: annotations: contact: "bob@example.com jane@example.com" @@ -109,7 +112,7 @@ applications: parameters: key1: value1 key2: value2 - stack: cflinuxfs3 + stack: cflinuxfs4 metadata: annotations: contact: "bob@example.com jane@example.com" @@ -160,7 +163,6 @@ applications: \+ r: m`)) }) }) - When("adding a map value within an array", func() { BeforeEach(func() { rawManifest = []byte(`--- @@ -319,8 +321,356 @@ applications: }) It("returns an error", func() { - Expect(err).To(MatchError("Unable to process manifest diff because its format is invalid.")) + Expect(err).To(MatchError("unable to process manifest diff because its format is invalid")) + }) + }) + }) + + When("redacting is enabled", func() { + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + displayer = &ManifestDiffDisplayer{ + UI: testUI, + RedactEnv: true, + } + }) + + Describe("DisplayDiff", func() { + var ( + rawManifest []byte + diff resources.ManifestDiff + err error + ) + + BeforeEach(func() { + rawManifest = []byte("") + }) + + JustBeforeEach(func() { + err = displayer.DisplayDiff(rawManifest, diff) + }) + + It("does not return an error", func() { + Expect(err).NotTo(HaveOccurred()) + }) + + Context("No diffs", func() { + BeforeEach(func() { + diff = resources.ManifestDiff{} + rawManifest = []byte(`--- +version: 1 +applications: +- name: app1 + buildpacks: + - ruby_buildpack + - java_buildpack + env: + VAR1: value1 + VAR2: value2 + TEST: | + crazy things + routes: + - route: route.example.com + - route: another-route.example.com + services: + - my-service1 + - my-service2 + - name: my-service-with-arbitrary-params + parameters: + key1: value1 + key2: value2 + stack: cflinuxfs4 + metadata: + annotations: + contact: "bob@example.com jane@example.com" + labels: + sensitive: true + processes: + - type: web + command: start-web.sh + disk_quota: 512M + health-check-http-endpoint: /healthcheck + health-check-type: http + health-check-invocation-timeout: 10 + instances: 3 + memory: 500M + timeout: 10 + - type: worker + command: start-worker.sh + disk_quota: 1G + health-check-type: process + instances: 2 + memory: 256M + timeout: 15`) + }) + + It("outputs the manifest without + or -", func() { + Expect(testUI.Out).To(Say(`--- + version: 1 + applications: + - name: app1 + buildpacks: + - ruby_buildpack + - java_buildpack + env: + VAR1: + VAR2: + TEST: + routes: + - route: route.example.com + - route: another-route.example.com + services: + - my-service1 + - my-service2 + - name: my-service-with-arbitrary-params + parameters: + key1: value1 + key2: value2 + stack: cflinuxfs4 + metadata: + annotations: + contact: bob@example.com jane@example.com + labels: + sensitive: true + processes: + - type: web + command: start-web.sh + disk_quota: 512M + health-check-http-endpoint: /healthcheck + health-check-type: http + health-check-invocation-timeout: 10 + instances: 3 + memory: 500M + timeout: 10 + - type: worker + command: start-worker.sh + disk_quota: 1G + health-check-type: process + instances: 2 + memory: 256M + timeout: 15`, + )) + }) + }) + + Context("Operation kinds", func() { + When("adding a string value", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + env: + a: b + r: m`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + {Op: resources.AddOperation, Path: "/applications/0/env/r", Value: "m"}, + }, + } + }) + + It("outputs a diff indicating addition for a single line", func() { + Expect(testUI.Out).To(Say(` --- + applications: + - name: dora + env: + a: +\+ r: `)) + }) + }) + When("adding a map value within an array", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora +`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + { + Op: resources.AddOperation, + Path: "/applications/0", + Was: nil, + Value: map[string]interface{}{"env": map[string]interface{}{"a": "b"}}, + }, + }, + } + }) + + It("outputs a diff indicating addition of a map type", func() { + Expect(testUI.Out).To(Say(` --- + applications: +\+ - env: +\+ a: +`)) + }) + }) + + When("adding a map value within a map", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + env: + a: b`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + {Op: resources.AddOperation, Path: "/applications/0/env", Value: map[string]interface{}{ + "a": "b", + }}, + }, + } + }) + + It("outputs a diff indicating addition of a map type", func() { + Expect(testUI.Out).To(Say(` --- + applications: + - name: dora +\+ env: +\+ a: `)) + }) + }) + + When("adding an array value", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + env: + r: m + routes: + - route: route1.cli.fun + - route: route2.cli.fun`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + { + Op: resources.AddOperation, + Path: "/applications/0/routes", + Value: []map[string]interface{}{ + { + "route": "route1.cli.fun", + }, + { + "route": "route2.cli.fun", + }, + }, + }, + }, + } + }) + + When("each element of the array is a map value", func() { + It("outputs a diff indicating addition for each map type", func() { + Expect(testUI.Out).To(Say(` --- + applications: + - name: dora + env: + r: +\+ routes: +\+ - route: route1.cli.fun +\+ - route: route2.cli.fun`)) + }) + }) + }) + + When("adding cnb-credentials", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + lifecycle: cnb + cnb-credentials: + foo: bar`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + { + Op: resources.AddOperation, + Path: "/applications/0/cnb-credentials", + Value: []map[string]interface{}{ + { + "foo": "Bar", + }, + }, + }, + }, + } + }) + + It("redacts output", func() { + Expect(testUI.Out).To(Say(` --- + applications: + - name: dora + lifecycle: cnb +\+ cnb-credentials: '\[PRIVATE DATA HIDDEN\]'`)) + }) + }) + + When("remove", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + env: + r: m`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + {Op: resources.RemoveOperation, Path: "/applications/0/env/a", Was: "b"}, + }, + } + }) + + It("outputs correctly formatted diff with key removed", func() { + Expect(testUI.Out).To(Say(` --- + applications: + - name: dora + env: + r: +- a: `)) + }) + }) + + When("replace", func() { + BeforeEach(func() { + rawManifest = []byte(`--- +applications: +- name: dora + env: + a: c + r: m`) + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + {Op: resources.ReplaceOperation, Path: "/applications/0/env/a", Was: "b", Value: "c"}, + }, + } + }) + + It("outputs correctly formatted diff", func() { + Expect(testUI.Out).To(Say(`--- + applications: + - name: dora + env: +- a: +\+ a: + r: +`)) + }) + }) + }) + + Context("when the YAML cannot be parsed", func() { + BeforeEach(func() { + diff = resources.ManifestDiff{ + Diffs: []resources.Diff{ + {Op: resources.ReplaceOperation, Path: "/applications/0/env/a", Was: "b", Value: "c"}, + }, + } + rawManifest = []byte(`not-real-yaml!`) + }) + + It("returns an error", func() { + Expect(err).To(MatchError("unable to process manifest diff because its format is invalid")) + }) }) }) + }) }) diff --git a/command/v7/shared/new_clients.go b/command/v7/shared/new_clients.go index 4486bd8ffab..309e5264635 100644 --- a/command/v7/shared/new_clients.go +++ b/command/v7/shared/new_clients.go @@ -1,15 +1,15 @@ package shared import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - ccWrapper "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper" - "code.cloudfoundry.org/cli/api/router" - routingWrapper "code.cloudfoundry.org/cli/api/router/wrapper" - "code.cloudfoundry.org/cli/api/uaa" - uaaWrapper "code.cloudfoundry.org/cli/api/uaa/wrapper" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + ccWrapper "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper" + "code.cloudfoundry.org/cli/v8/api/router" + routingWrapper "code.cloudfoundry.org/cli/v8/api/router/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" + uaaWrapper "code.cloudfoundry.org/cli/v8/api/uaa/wrapper" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) func GetNewClientsAndConnectToCF(config command.Config, ui command.UI, minVersionV3 string) (*ccv3.Client, *uaa.Client, *router.Client, error) { @@ -47,6 +47,7 @@ func NewWrappedCloudControllerClient(config command.Config, ui command.UI, extra } ccWrappers = append(ccWrappers, extraWrappers...) + ccWrappers = append(ccWrappers, ccWrapper.NewCCTraceHeaderRequest(config.B3TraceID())) ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount())) return ccv3.NewClient(ccv3.Config{ @@ -85,6 +86,7 @@ func newWrappedUAAClient(config command.Config, ui command.UI) (*uaa.Client, err uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(uaaClient, config) uaaClient.WrapConnection(uaaAuthWrapper) + uaaClient.WrapConnection(uaaWrapper.NewUAATraceHeaderRequest(config.B3TraceID())) uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount())) err = uaaClient.SetupResources(config.UAAEndpoint(), config.AuthorizationEndpoint()) @@ -121,6 +123,8 @@ func newWrappedRoutingClient(config command.Config, ui command.UI, uaaClient *ua authWrapper := routingWrapper.NewUAAAuthentication(uaaClient, config) routingWrappers = append(routingWrappers, authWrapper) + routingWrappers = append(routingWrappers, routingWrapper.NewRoutingTraceHeaderRequest(config.B3TraceID())) + routingConfig.Wrappers = routingWrappers routingClient := router.NewClient(routingConfig) diff --git a/command/v7/shared/new_clients_test.go b/command/v7/shared/new_clients_test.go index 04bb1ec4b87..751d101039a 100644 --- a/command/v7/shared/new_clients_test.go +++ b/command/v7/shared/new_clients_test.go @@ -4,12 +4,12 @@ import ( "runtime" "time" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/util/ui" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -57,7 +57,7 @@ var _ = Describe("New Clients", func() { }) }) - When("not targetting", func() { + When("not targeting", func() { It("does not target", func() { ccClient := NewWrappedCloudControllerClient(fakeConfig, testUI) Expect(ccClient).ToNot(BeNil()) diff --git a/command/v7/shared/new_networking_client.go b/command/v7/shared/new_networking_client.go index 24057e3df88..ffd379ded50 100644 --- a/command/v7/shared/new_networking_client.go +++ b/command/v7/shared/new_networking_client.go @@ -1,11 +1,11 @@ package shared import ( - "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1" - "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/wrapper" - "code.cloudfoundry.org/cli/api/uaa" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/cfnetv1" + "code.cloudfoundry.org/cli/v8/api/cfnetworking/wrapper" + "code.cloudfoundry.org/cli/v8/api/uaa" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) // NewNetworkingClient creates a new cfnetworking client. diff --git a/command/v7/shared/new_networking_client_test.go b/command/v7/shared/new_networking_client_test.go index 1b9e4b57856..d1ec72d355e 100644 --- a/command/v7/shared/new_networking_client_test.go +++ b/command/v7/shared/new_networking_client_test.go @@ -1,13 +1,13 @@ package shared_test import ( - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/util/ui" - "code.cloudfoundry.org/cli/api/uaa" + "code.cloudfoundry.org/cli/v8/api/uaa" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -17,7 +17,7 @@ var _ = Describe("New Clients", func() { binaryName string fakeConfig *commandfakes.FakeConfig testUI *ui.UI - fakeUAAClient *uaa.Client + fakeUAAClient = &uaa.Client{} ) BeforeEach(func() { diff --git a/command/v7/shared/package_displayer.go b/command/v7/shared/package_displayer.go index 615c851102f..3d013c37411 100644 --- a/command/v7/shared/package_displayer.go +++ b/command/v7/shared/package_displayer.go @@ -1,7 +1,7 @@ package shared import ( - "code.cloudfoundry.org/cli/command" + "code.cloudfoundry.org/cli/v8/command" ) type PackageDisplayer struct { diff --git a/command/v7/shared/quota_displayer.go b/command/v7/shared/quota_displayer.go index d209223b18c..09815fa4323 100644 --- a/command/v7/shared/quota_displayer.go +++ b/command/v7/shared/quota_displayer.go @@ -5,14 +5,15 @@ import ( "strconv" "strings" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/ui" ) const ( - MEGABYTE = 1024 * 1024 + KILOBYTE = 1024 + MEGABYTE = 1024 * KILOBYTE GIGABYTE = 1024 * MEGABYTE TERABYTE = 1024 * GIGABYTE ) @@ -32,7 +33,7 @@ func (displayer QuotaDisplayer) DisplayQuotasTable(quotas []resources.Quota, emp } var keyValueTable = [][]string{ - {"name", "total memory", "instance memory", "routes", "service instances", "paid service plans", "app instances", "route ports"}, + {"name", "total memory", "instance memory", "routes", "service instances", "paid service plans", "app instances", "route ports", "log volume per second"}, } for _, quota := range quotas { @@ -45,6 +46,7 @@ func (displayer QuotaDisplayer) DisplayQuotasTable(quotas []resources.Quota, emp displayer.presentBooleanValue(*quota.Services.PaidServicePlans), displayer.presentQuotaValue(*quota.Apps.TotalAppInstances), displayer.presentQuotaValue(*quota.Routes.TotalReservedPorts), + displayer.presentQuotaBytesValue(*quota.Apps.TotalLogVolume), }) } @@ -60,6 +62,7 @@ func (displayer QuotaDisplayer) DisplaySingleQuota(quota resources.Quota) { {displayer.ui.TranslateText("paid service plans:"), displayer.presentBooleanValue(*quota.Services.PaidServicePlans)}, {displayer.ui.TranslateText("app instances:"), displayer.presentQuotaValue(*quota.Apps.TotalAppInstances)}, {displayer.ui.TranslateText("route ports:"), displayer.presentQuotaValue(*quota.Routes.TotalReservedPorts)}, + {displayer.ui.TranslateText("log volume per second:"), displayer.presentQuotaBytesValue(*quota.Apps.TotalLogVolume)}, } displayer.ui.DisplayKeyValueTable("", quotaTable, 3) @@ -81,6 +84,14 @@ func (displayer QuotaDisplayer) presentQuotaValue(limit types.NullInt) string { } } +func (displayer QuotaDisplayer) presentQuotaBytesValue(limit types.NullInt) string { + if !limit.IsSet { + return "unlimited" + } else { + return addMemoryUnits(float64(limit.Value)) + } +} + func (displayer QuotaDisplayer) presentQuotaMemoryValue(limit types.NullInt) string { if !limit.IsSet { return "unlimited" @@ -103,6 +114,11 @@ func addMemoryUnits(bytes float64) string { case bytes >= MEGABYTE: unit = "M" value /= MEGABYTE + case bytes >= KILOBYTE: + unit = "K" + value /= KILOBYTE + case bytes >= 1: + unit = "B" case bytes == 0: return "0" } diff --git a/command/v7/shared/result_waiter.go b/command/v7/shared/result_waiter.go index f16f5c3668f..45922a9a1b2 100644 --- a/command/v7/shared/result_waiter.go +++ b/command/v7/shared/result_waiter.go @@ -3,8 +3,8 @@ package shared import ( "fmt" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" ) func WaitForResult(stream chan v7action.PollJobEvent, ui command.UI, waitForCompletion bool) (bool, error) { diff --git a/command/v7/shared/shared_suite_test.go b/command/v7/shared/shared_suite_test.go index 599b4ca7e1a..83b5cbf8e80 100644 --- a/command/v7/shared/shared_suite_test.go +++ b/command/v7/shared/shared_suite_test.go @@ -1,7 +1,7 @@ package shared_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/command/v7/shared/sharedfakes/fake_app_stager.go b/command/v7/shared/sharedfakes/fake_app_stager.go index 39ba63146d4..ba9d830a0f4 100644 --- a/command/v7/shared/sharedfakes/fake_app_stager.go +++ b/command/v7/shared/sharedfakes/fake_app_stager.go @@ -4,23 +4,20 @@ package sharedfakes import ( "sync" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeAppStager struct { - StageAndStartStub func(resources.Application, configv3.Space, configv3.Organization, string, constant.DeploymentStrategy, bool, constant.ApplicationAction) error + StageAndStartStub func(resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) error stageAndStartMutex sync.RWMutex stageAndStartArgsForCall []struct { arg1 resources.Application arg2 configv3.Space arg3 configv3.Organization arg4 string - arg5 constant.DeploymentStrategy - arg6 bool - arg7 constant.ApplicationAction + arg5 shared.AppStartOpts } stageAndStartReturns struct { result1 error @@ -43,16 +40,14 @@ type FakeAppStager struct { result1 resources.Droplet result2 error } - StartAppStub func(resources.Application, string, constant.DeploymentStrategy, bool, configv3.Space, configv3.Organization, constant.ApplicationAction) error + StartAppStub func(resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) error startAppMutex sync.RWMutex startAppArgsForCall []struct { arg1 resources.Application - arg2 string - arg3 constant.DeploymentStrategy - arg4 bool - arg5 configv3.Space - arg6 configv3.Organization - arg7 constant.ApplicationAction + arg2 configv3.Space + arg3 configv3.Organization + arg4 string + arg5 shared.AppStartOpts } startAppReturns struct { result1 error @@ -64,7 +59,7 @@ type FakeAppStager struct { invocationsMutex sync.RWMutex } -func (fake *FakeAppStager) StageAndStart(arg1 resources.Application, arg2 configv3.Space, arg3 configv3.Organization, arg4 string, arg5 constant.DeploymentStrategy, arg6 bool, arg7 constant.ApplicationAction) error { +func (fake *FakeAppStager) StageAndStart(arg1 resources.Application, arg2 configv3.Space, arg3 configv3.Organization, arg4 string, arg5 shared.AppStartOpts) error { fake.stageAndStartMutex.Lock() ret, specificReturn := fake.stageAndStartReturnsOnCall[len(fake.stageAndStartArgsForCall)] fake.stageAndStartArgsForCall = append(fake.stageAndStartArgsForCall, struct { @@ -72,19 +67,18 @@ func (fake *FakeAppStager) StageAndStart(arg1 resources.Application, arg2 config arg2 configv3.Space arg3 configv3.Organization arg4 string - arg5 constant.DeploymentStrategy - arg6 bool - arg7 constant.ApplicationAction - }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) - fake.recordInvocation("StageAndStart", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) + arg5 shared.AppStartOpts + }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.StageAndStartStub + fakeReturns := fake.stageAndStartReturns + fake.recordInvocation("StageAndStart", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.stageAndStartMutex.Unlock() - if fake.StageAndStartStub != nil { - return fake.StageAndStartStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1 } - fakeReturns := fake.stageAndStartReturns return fakeReturns.result1 } @@ -94,17 +88,17 @@ func (fake *FakeAppStager) StageAndStartCallCount() int { return len(fake.stageAndStartArgsForCall) } -func (fake *FakeAppStager) StageAndStartCalls(stub func(resources.Application, configv3.Space, configv3.Organization, string, constant.DeploymentStrategy, bool, constant.ApplicationAction) error) { +func (fake *FakeAppStager) StageAndStartCalls(stub func(resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) error) { fake.stageAndStartMutex.Lock() defer fake.stageAndStartMutex.Unlock() fake.StageAndStartStub = stub } -func (fake *FakeAppStager) StageAndStartArgsForCall(i int) (resources.Application, configv3.Space, configv3.Organization, string, constant.DeploymentStrategy, bool, constant.ApplicationAction) { +func (fake *FakeAppStager) StageAndStartArgsForCall(i int) (resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) { fake.stageAndStartMutex.RLock() defer fake.stageAndStartMutex.RUnlock() argsForCall := fake.stageAndStartArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 } func (fake *FakeAppStager) StageAndStartReturns(result1 error) { @@ -138,15 +132,16 @@ func (fake *FakeAppStager) StageApp(arg1 resources.Application, arg2 string, arg arg2 string arg3 configv3.Space }{arg1, arg2, arg3}) + stub := fake.StageAppStub + fakeReturns := fake.stageAppReturns fake.recordInvocation("StageApp", []interface{}{arg1, arg2, arg3}) fake.stageAppMutex.Unlock() - if fake.StageAppStub != nil { - return fake.StageAppStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stageAppReturns return fakeReturns.result1, fakeReturns.result2 } @@ -195,27 +190,26 @@ func (fake *FakeAppStager) StageAppReturnsOnCall(i int, result1 resources.Drople }{result1, result2} } -func (fake *FakeAppStager) StartApp(arg1 resources.Application, arg2 string, arg3 constant.DeploymentStrategy, arg4 bool, arg5 configv3.Space, arg6 configv3.Organization, arg7 constant.ApplicationAction) error { +func (fake *FakeAppStager) StartApp(arg1 resources.Application, arg2 configv3.Space, arg3 configv3.Organization, arg4 string, arg5 shared.AppStartOpts) error { fake.startAppMutex.Lock() ret, specificReturn := fake.startAppReturnsOnCall[len(fake.startAppArgsForCall)] fake.startAppArgsForCall = append(fake.startAppArgsForCall, struct { arg1 resources.Application - arg2 string - arg3 constant.DeploymentStrategy - arg4 bool - arg5 configv3.Space - arg6 configv3.Organization - arg7 constant.ApplicationAction - }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) - fake.recordInvocation("StartApp", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) + arg2 configv3.Space + arg3 configv3.Organization + arg4 string + arg5 shared.AppStartOpts + }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.StartAppStub + fakeReturns := fake.startAppReturns + fake.recordInvocation("StartApp", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.startAppMutex.Unlock() - if fake.StartAppStub != nil { - return fake.StartAppStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1 } - fakeReturns := fake.startAppReturns return fakeReturns.result1 } @@ -225,17 +219,17 @@ func (fake *FakeAppStager) StartAppCallCount() int { return len(fake.startAppArgsForCall) } -func (fake *FakeAppStager) StartAppCalls(stub func(resources.Application, string, constant.DeploymentStrategy, bool, configv3.Space, configv3.Organization, constant.ApplicationAction) error) { +func (fake *FakeAppStager) StartAppCalls(stub func(resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) error) { fake.startAppMutex.Lock() defer fake.startAppMutex.Unlock() fake.StartAppStub = stub } -func (fake *FakeAppStager) StartAppArgsForCall(i int) (resources.Application, string, constant.DeploymentStrategy, bool, configv3.Space, configv3.Organization, constant.ApplicationAction) { +func (fake *FakeAppStager) StartAppArgsForCall(i int) (resources.Application, configv3.Space, configv3.Organization, string, shared.AppStartOpts) { fake.startAppMutex.RLock() defer fake.startAppMutex.RUnlock() argsForCall := fake.startAppArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 } func (fake *FakeAppStager) StartAppReturns(result1 error) { diff --git a/command/v7/shared/v3_poll_stage.go b/command/v7/shared/v3_poll_stage.go index 1c48365d620..0898caf3f8a 100644 --- a/command/v7/shared/v3_poll_stage.go +++ b/command/v7/shared/v3_poll_stage.go @@ -1,11 +1,11 @@ package shared import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/resources" ) func PollStage(dropletStream <-chan resources.Droplet, warningsStream <-chan v7action.Warnings, errStream <-chan error, logStream <-chan sharedaction.LogMessage, logErrStream <-chan error, ui command.UI) (resources.Droplet, error) { diff --git a/command/v7/shared/v3_poll_stage_test.go b/command/v7/shared/v3_poll_stage_test.go index a33b59d936a..f1f06032add 100644 --- a/command/v7/shared/v3_poll_stage_test.go +++ b/command/v7/shared/v3_poll_stage_test.go @@ -4,13 +4,13 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - . "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + . "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/shared/version_checker.go b/command/v7/shared/version_checker.go index bfd35ec22e9..b7a2b997008 100644 --- a/command/v7/shared/version_checker.go +++ b/command/v7/shared/version_checker.go @@ -3,8 +3,8 @@ package shared import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "github.com/blang/semver/v4" ) func CheckCCAPIVersion(currentAPIVersion string) (string, error) { diff --git a/command/v7/shared/version_checker_test.go b/command/v7/shared/version_checker_test.go index 451ff6e9893..2e46ac589e4 100644 --- a/command/v7/shared/version_checker_test.go +++ b/command/v7/shared/version_checker_test.go @@ -1,8 +1,8 @@ package shared_test import ( - "code.cloudfoundry.org/cli/command/v7/shared" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/v7/space_command.go b/command/v7/space_command.go index cf5d52ea7d3..533fb7dbf4d 100644 --- a/command/v7/space_command.go +++ b/command/v7/space_command.go @@ -4,10 +4,10 @@ import ( "sort" "strings" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type SpaceCommand struct { diff --git a/command/v7/space_command_test.go b/command/v7/space_command_test.go index 5f2a9cbd0fc..ce33a303ca4 100644 --- a/command/v7/space_command_test.go +++ b/command/v7/space_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/space_quota_command.go b/command/v7/space_quota_command.go index 8cbdcc2d45d..06161db629d 100644 --- a/command/v7/space_quota_command.go +++ b/command/v7/space_quota_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type SpaceQuotaCommand struct { diff --git a/command/v7/space_quota_command_test.go b/command/v7/space_quota_command_test.go index ce15a9c9fc4..ce5d8467d3e 100644 --- a/command/v7/space_quota_command_test.go +++ b/command/v7/space_quota_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -102,6 +102,7 @@ var _ = Describe("Space Quota Command", func() { TotalMemory: &types.NullInt{IsSet: true, Value: 2048}, InstanceMemory: &types.NullInt{IsSet: true, Value: 1024}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 2}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 512}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{IsSet: false}, @@ -135,6 +136,7 @@ var _ = Describe("Space Quota Command", func() { Expect(testUI.Out).To(Say(`paid service plans:\s+disallowed`)) Expect(testUI.Out).To(Say(`app instances:\s+2`)) Expect(testUI.Out).To(Say(`route ports:\s+unlimited`)) + Expect(testUI.Out).To(Say(`log volume per second:\s+512B`)) }) }) }) diff --git a/command/v7/space_quotas_command.go b/command/v7/space_quotas_command.go index 481cd6c61f5..3903bc40a88 100644 --- a/command/v7/space_quotas_command.go +++ b/command/v7/space_quotas_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type SpaceQuotasCommand struct { diff --git a/command/v7/space_quotas_command_test.go b/command/v7/space_quotas_command_test.go index c0626293045..81e671e606a 100644 --- a/command/v7/space_quotas_command_test.go +++ b/command/v7/space_quotas_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -69,6 +69,7 @@ var _ = Describe("space-quotas command", func() { TotalMemory: &types.NullInt{Value: 1048576, IsSet: true}, InstanceMemory: &types.NullInt{Value: 32, IsSet: true}, TotalAppInstances: &types.NullInt{Value: 3, IsSet: true}, + TotalLogVolume: &types.NullInt{Value: 512, IsSet: true}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 3, IsSet: true}, @@ -98,8 +99,8 @@ var _ = Describe("space-quotas command", func() { orgGUID := fakeActor.GetSpaceQuotasByOrgGUIDArgsForCall(0) Expect(orgGUID).To(Equal(fakeConfig.TargetedOrganization().GUID)) - Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Expect(testUI.Out).To(Say(`space-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2`)) + Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Expect(testUI.Out).To(Say(`space-quota-1\s+1T\s+32M\s+5\s+3\s+allowed\s+3\s+2\s+512B`)) }) When("there are limits that have not been configured", func() { @@ -112,6 +113,7 @@ var _ = Describe("space-quotas command", func() { TotalMemory: &types.NullInt{Value: 0, IsSet: false}, InstanceMemory: &types.NullInt{Value: 0, IsSet: false}, TotalAppInstances: &types.NullInt{Value: 0, IsSet: false}, + TotalLogVolume: &types.NullInt{Value: 0, IsSet: false}, }, Services: resources.ServiceLimit{ TotalServiceInstances: &types.NullInt{Value: 0, IsSet: false}, @@ -130,8 +132,8 @@ var _ = Describe("space-quotas command", func() { It("should convert default values from the API into readable outputs", func() { Expect(executeErr).NotTo(HaveOccurred()) - Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited`)) + Expect(testUI.Out).To(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Expect(testUI.Out).To(Say(`default\s+unlimited\s+unlimited\s+unlimited\s+unlimited\s+allowed\s+unlimited\s+unlimited\s+unlimited`)) }) }) diff --git a/command/v7/space_ssh_allowed_command.go b/command/v7/space_ssh_allowed_command.go index eabef97c5ad..b6f552c1829 100644 --- a/command/v7/space_ssh_allowed_command.go +++ b/command/v7/space_ssh_allowed_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type SpaceSSHAllowedCommand struct { diff --git a/command/v7/space_ssh_allowed_command_test.go b/command/v7/space_ssh_allowed_command_test.go index 262f9b48a45..75a6583ea12 100644 --- a/command/v7/space_ssh_allowed_command_test.go +++ b/command/v7/space_ssh_allowed_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/space_users_command.go b/command/v7/space_users_command.go index 149ddb9aa3a..b9aa2daae73 100644 --- a/command/v7/space_users_command.go +++ b/command/v7/space_users_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type SpaceUsersCommand struct { diff --git a/command/v7/space_users_command_test.go b/command/v7/space_users_command_test.go index 062e6ab69c8..35ac70c1485 100644 --- a/command/v7/space_users_command_test.go +++ b/command/v7/space_users_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/spaces_command.go b/command/v7/spaces_command.go index 430c264dba6..1c5e22cd85b 100644 --- a/command/v7/spaces_command.go +++ b/command/v7/spaces_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/ui" ) type SpacesCommand struct { diff --git a/command/v7/spaces_command_test.go b/command/v7/spaces_command_test.go index bd2a53bc1ab..baa0e8902f1 100644 --- a/command/v7/spaces_command_test.go +++ b/command/v7/spaces_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/ssh_code_command_test.go b/command/v7/ssh_code_command_test.go index dcc55d44a23..09b27380a4e 100644 --- a/command/v7/ssh_code_command_test.go +++ b/command/v7/ssh_code_command_test.go @@ -3,20 +3,20 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) var _ = Describe("ssh-code Command", func() { var ( - cmd SSHCodeCommand + cmd v7.SSHCodeCommand testUI *ui.UI fakeConfig *commandfakes.FakeConfig fakeSharedActor *commandfakes.FakeSharedActor diff --git a/command/v7/ssh_command.go b/command/v7/ssh_command.go index c9caf5d2f64..3cd2b72c57e 100644 --- a/command/v7/ssh_command.go +++ b/command/v7/ssh_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/clissh" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . SharedSSHActor diff --git a/command/v7/ssh_command_test.go b/command/v7/ssh_command_test.go index 492e0158220..9077596a4a4 100644 --- a/command/v7/ssh_command_test.go +++ b/command/v7/ssh_command_test.go @@ -3,18 +3,18 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -203,14 +203,14 @@ var _ = Describe("ssh Command", func() { Entry("default - auto TTY", false, false, false, nil, sharedaction.RequestTTYAuto), Entry("disable tty - no TTY", true, false, false, nil, sharedaction.RequestTTYNo), Entry("force tty - forced TTY", false, true, false, nil, sharedaction.RequestTTYForce), - Entry("psudo tty - yes TTY", false, false, true, nil, sharedaction.RequestTTYYes), + Entry("pseudo tty - yes TTY", false, false, true, nil, sharedaction.RequestTTYYes), Entry("disable and force tty", true, true, false, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }}, sharedaction.TTYOption(0), ), - Entry("disable and requst tty", true, false, true, + Entry("disable and request tty", true, false, true, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }}, diff --git a/command/v7/ssh_enabled_command.go b/command/v7/ssh_enabled_command.go index 9ddf1a9f15d..17c725196c9 100644 --- a/command/v7/ssh_enabled_command.go +++ b/command/v7/ssh_enabled_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type SSHEnabledCommand struct { diff --git a/command/v7/ssh_enabled_command_test.go b/command/v7/ssh_enabled_command_test.go index abcd806db66..c0d1fd3c2c4 100644 --- a/command/v7/ssh_enabled_command_test.go +++ b/command/v7/ssh_enabled_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/stack_command.go b/command/v7/stack_command.go index a7ca6add762..d721055442e 100644 --- a/command/v7/stack_command.go +++ b/command/v7/stack_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type StackCommand struct { diff --git a/command/v7/stack_command_test.go b/command/v7/stack_command_test.go index c7127c3b589..5f8da5f189b 100644 --- a/command/v7/stack_command_test.go +++ b/command/v7/stack_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/stacks_command.go b/command/v7/stacks_command.go index 0e4b7926331..38cdf9368f7 100644 --- a/command/v7/stacks_command.go +++ b/command/v7/stacks_command.go @@ -3,16 +3,16 @@ package v7 import ( "sort" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/sorting" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/sorting" + "code.cloudfoundry.org/cli/v8/util/ui" ) type StacksCommand struct { BaseCommand usage interface{} `usage:"CF_NAME stacks [--labels SELECTOR]\n\nEXAMPLES:\n CF_NAME stacks\n CF_NAME stacks --labels 'environment in (production,staging),tier in (backend)'\n CF_NAME stacks --labels 'env=dev,!chargeback-code,tier in (backend,worker)'"` - relatedCommands interface{} `related_commands:"create-buildpack, delete-buildpack, rename-buildpack, stack, update-buildpack"` + relatedCommands interface{} `related_commands:"create-buildpack, delete-buildpack, stack, update-buildpack"` Labels string `long:"labels" description:"Selector to filter stacks by labels"` } diff --git a/command/v7/stacks_command_test.go b/command/v7/stacks_command_test.go index dff97b6ee03..08b14de0b18 100644 --- a/command/v7/stacks_command_test.go +++ b/command/v7/stacks_command_test.go @@ -3,16 +3,16 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/stage_package_command.go b/command/v7/stage_package_command.go index 729f497461b..9f08112d235 100644 --- a/command/v7/stage_package_command.go +++ b/command/v7/stage_package_command.go @@ -4,11 +4,13 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/resources" ) type StagePackageCommand struct { @@ -30,7 +32,10 @@ func (cmd *StagePackageCommand) Setup(config command.Config, ui command.UI) erro return err } - cmd.LogCacheClient = command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + cmd.LogCacheClient, err = logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } return nil } diff --git a/command/v7/stage_package_command_test.go b/command/v7/stage_package_command_test.go index a1906806f47..edb157f1a58 100644 --- a/command/v7/stage_package_command_test.go +++ b/command/v7/stage_package_command_test.go @@ -5,19 +5,19 @@ import ( "errors" "time" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/staging_environment_variable_group_command.go b/command/v7/staging_environment_variable_group_command.go index 3746e7a458d..54fdf366832 100644 --- a/command/v7/staging_environment_variable_group_command.go +++ b/command/v7/staging_environment_variable_group_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/util/ui" ) type StagingEnvironmentVariableGroupCommand struct { diff --git a/command/v7/staging_environment_variable_group_command_test.go b/command/v7/staging_environment_variable_group_command_test.go index 9ecf27e568a..d9795fbf37f 100644 --- a/command/v7/staging_environment_variable_group_command_test.go +++ b/command/v7/staging_environment_variable_group_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/staging_security_groups_command.go b/command/v7/staging_security_groups_command.go index 8b4203eb577..82bcea7be8a 100644 --- a/command/v7/staging_security_groups_command.go +++ b/command/v7/staging_security_groups_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" ) type StagingSecurityGroupsCommand struct { diff --git a/command/v7/staging_security_groups_command_test.go b/command/v7/staging_security_groups_command_test.go index c0fe38d6f07..2cfd7097a4c 100644 --- a/command/v7/staging_security_groups_command_test.go +++ b/command/v7/staging_security_groups_command_test.go @@ -1,15 +1,15 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/start_command.go b/command/v7/start_command.go index 23271215110..babc0c6acf8 100644 --- a/command/v7/start_command.go +++ b/command/v7/start_command.go @@ -1,11 +1,13 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/logcache" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type StartCommand struct { @@ -27,7 +29,11 @@ func (cmd *StartCommand) Setup(config command.Config, ui command.UI) error { return err } - cmd.LogCacheClient = command.NewLogCacheClient(config.LogCacheEndpoint(), config, ui) + cmd.LogCacheClient, err = logcache.NewClient(config.LogCacheEndpoint(), config, ui, v7action.NewDefaultKubernetesConfigGetter()) + if err != nil { + return err + } + cmd.Stager = shared.NewAppStager(cmd.Actor, cmd.UI, cmd.Config, cmd.LogCacheClient) return nil @@ -56,6 +62,12 @@ func (cmd StartCommand) Execute(args []string) error { return err } + opts := shared.AppStartOpts{ + Strategy: constant.DeploymentStrategyDefault, + NoWait: false, + AppAction: constant.ApplicationStarting, + } + if packageGUID != "" && app.Stopped() { cmd.UI.DisplayTextWithFlavor("Starting app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ "AppName": cmd.RequiredArgs.AppName, @@ -65,17 +77,8 @@ func (cmd StartCommand) Execute(args []string) error { }) cmd.UI.DisplayNewline() - err = cmd.Stager.StageAndStart(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), packageGUID, constant.DeploymentStrategyDefault, false, constant.ApplicationStarting) - if err != nil { - return err - } - } else { - err = cmd.Stager.StartApp(app, "", constant.DeploymentStrategyDefault, false, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), constant.ApplicationStarting) - if err != nil { - return err - } + return cmd.Stager.StageAndStart(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), packageGUID, opts) } - return nil - + return cmd.Stager.StartApp(app, cmd.Config.TargetedSpace(), cmd.Config.TargetedOrganization(), "", opts) } diff --git a/command/v7/start_command_test.go b/command/v7/start_command_test.go index 24ec6f7b185..ef092aeab48 100644 --- a/command/v7/start_command_test.go +++ b/command/v7/start_command_test.go @@ -3,19 +3,19 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/shared/sharedfakes" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/sharedaction/sharedactionfakes" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/shared/sharedfakes" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -140,14 +140,14 @@ var _ = Describe("start Command", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(fakeAppStager.StageAndStartCallCount()).To(Equal(1)) - inputApp, inputSpace, inputOrg, inputPkgGUID, inputStrategy, inputNoWait, inputAppAction := fakeAppStager.StageAndStartArgsForCall(0) + inputApp, inputSpace, inputOrg, inputPkgGUID, opts := fakeAppStager.StageAndStartArgsForCall(0) Expect(inputApp).To(Equal(app)) Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) Expect(inputPkgGUID).To(Equal("package-guid")) - Expect(inputStrategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(inputNoWait).To(Equal(false)) - Expect(inputAppAction).To(Equal(constant.ApplicationStarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationStarting)) }) When("staging and starting the app returns an error", func() { @@ -171,14 +171,14 @@ var _ = Describe("start Command", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) - inputApp, inputDropletGuid, inputStrategy, inputNoWait, inputSpace, inputOrg, inputAppAction := fakeAppStager.StartAppArgsForCall(0) + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StartAppArgsForCall(0) Expect(inputApp).To(Equal(app)) Expect(inputDropletGuid).To(Equal("")) - Expect(inputStrategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(inputNoWait).To(Equal(false)) Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) - Expect(inputAppAction).To(Equal(constant.ApplicationStarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationStarting)) }) When("starting the app returns an error", func() { @@ -202,14 +202,14 @@ var _ = Describe("start Command", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(fakeAppStager.StartAppCallCount()).To(Equal(1)) - inputApp, inputDropletGuid, inputStrategy, inputNoWait, inputSpace, inputOrg, inputAppAction := fakeAppStager.StartAppArgsForCall(0) + inputApp, inputSpace, inputOrg, inputDropletGuid, opts := fakeAppStager.StartAppArgsForCall(0) Expect(inputApp).To(Equal(app)) Expect(inputDropletGuid).To(Equal("")) - Expect(inputStrategy).To(Equal(constant.DeploymentStrategyDefault)) - Expect(inputNoWait).To(Equal(false)) Expect(inputSpace).To(Equal(cmd.Config.TargetedSpace())) Expect(inputOrg).To(Equal(cmd.Config.TargetedOrganization())) - Expect(inputAppAction).To(Equal(constant.ApplicationStarting)) + Expect(opts.Strategy).To(Equal(constant.DeploymentStrategyDefault)) + Expect(opts.NoWait).To(Equal(false)) + Expect(opts.AppAction).To(Equal(constant.ApplicationStarting)) }) When("starting the app returns an error", func() { diff --git a/command/v7/stop_command.go b/command/v7/stop_command.go index 514f1ecba58..7ba757456d7 100644 --- a/command/v7/stop_command.go +++ b/command/v7/stop_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type StopCommand struct { diff --git a/command/v7/stop_command_test.go b/command/v7/stop_command_test.go index 18efa1d4de7..c549b768256 100644 --- a/command/v7/stop_command_test.go +++ b/command/v7/stop_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/target_command.go b/command/v7/target_command.go index 05595ca294a..e8948419801 100644 --- a/command/v7/target_command.go +++ b/command/v7/target_command.go @@ -3,8 +3,8 @@ package v7 import ( "fmt" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type TargetCommand struct { diff --git a/command/v7/target_command_test.go b/command/v7/target_command_test.go index 3d245ad0899..92318dc4b4f 100644 --- a/command/v7/target_command_test.go +++ b/command/v7/target_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/task_command.go b/command/v7/task_command.go new file mode 100644 index 00000000000..87ae419fafb --- /dev/null +++ b/command/v7/task_command.go @@ -0,0 +1,71 @@ +package v7 + +import ( + "strconv" + + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" +) + +type TaskCommand struct { + BaseCommand + + RequiredArgs flag.TaskArgs `positional-args:"yes"` + usage interface{} `usage:"CF_NAME task APP_NAME TASK_ID"` + relatedCommands interface{} `related_commands:"apps, logs, run-task, tasks, terminate-task"` +} + +func (cmd TaskCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + space := cmd.Config.TargetedSpace() + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + application, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, space.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + cmd.UI.DisplayTextWithFlavor("Getting task {{.TaskID}} for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...", map[string]interface{}{ + "TaskID": cmd.RequiredArgs.TaskID, + "AppName": cmd.RequiredArgs.AppName, + "OrgName": cmd.Config.TargetedOrganization().Name, + "SpaceName": space.Name, + "CurrentUser": user.Name, + }) + cmd.UI.DisplayNewline() + + task, warnings, err := cmd.Actor.GetTaskBySequenceIDAndApplication(cmd.RequiredArgs.TaskID, application.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + if task.Command == "" { + task.Command = "[hidden]" + } + + table := [][]string{ + {cmd.UI.TranslateText("id:"), strconv.FormatInt(task.SequenceID, 10)}, + {cmd.UI.TranslateText("name:"), task.Name}, + {cmd.UI.TranslateText("state:"), string(task.State)}, + {cmd.UI.TranslateText("start time:"), task.CreatedAt}, + {cmd.UI.TranslateText("command:"), task.Command}, + {cmd.UI.TranslateText("memory in mb:"), strconv.FormatUint(task.MemoryInMB, 10)}, + {cmd.UI.TranslateText("disk in mb:"), strconv.FormatUint(task.DiskInMB, 10)}, + {cmd.UI.TranslateText("log rate limit:"), strconv.Itoa(task.LogRateLimitInBPS)}, + {cmd.UI.TranslateText("failure reason:"), task.Result.FailureReason}, + } + + cmd.UI.DisplayKeyValueTable("", table, ui.DefaultTableSpacePadding) + + return nil +} diff --git a/command/v7/task_command_test.go b/command/v7/task_command_test.go new file mode 100644 index 00000000000..6ca9b81d45f --- /dev/null +++ b/command/v7/task_command_test.go @@ -0,0 +1,282 @@ +package v7_test + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("task Command", func() { + var ( + cmd TaskCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + cmd = TaskCommand{ + BaseCommand: BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + } + + cmd.RequiredArgs.AppName = "some-app-name" + cmd.RequiredArgs.TaskID = 3 + + binaryName = "faceman" + fakeConfig.BinaryNameReturns(binaryName) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NotLoggedInError{BinaryName: binaryName}) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NotLoggedInError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is logged in, and a space and org are targeted", func() { + BeforeEach(func() { + fakeConfig.HasTargetedOrganizationReturns(true) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{ + GUID: "some-org-guid", + Name: "some-org", + }) + fakeConfig.HasTargetedSpaceReturns(true) + fakeConfig.TargetedSpaceReturns(configv3.Space{ + GUID: "some-space-guid", + Name: "some-space", + }) + }) + + When("getting the current user returns an error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("get current user error") + fakeActor.GetCurrentUserReturns( + configv3.User{}, + expectedErr) + }) + + It("returns the error", func() { + Expect(executeErr).To(MatchError(expectedErr)) + }) + }) + + When("getting the current user does not return an error", func() { + BeforeEach(func() { + fakeActor.GetCurrentUserReturns( + configv3.User{Name: "some-user"}, + nil) + }) + + When("provided a valid application name", func() { + BeforeEach(func() { + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + v7action.Warnings{"get-application-warning-1", "get-application-warning-2"}, + nil) + fakeActor.GetTaskBySequenceIDAndApplicationReturns( + resources.Task{ + GUID: "task-3-guid", + SequenceID: 3, + Name: "task-3", + State: constant.TaskRunning, + CreatedAt: "2016-11-08T22:26:02Z", + Command: "some-command", + MemoryInMB: 100, + DiskInMB: 200, + LogRateLimitInBPS: 300, + Result: &resources.TaskResult{ + FailureReason: "some failure message", + }, + }, + v7action.Warnings{"get-task-warning-1"}, + nil) + }) + + It("outputs the task and all warnings", func() { + Expect(executeErr).ToNot(HaveOccurred()) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + appName, spaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(appName).To(Equal("some-app-name")) + Expect(spaceGUID).To(Equal("some-space-guid")) + + Expect(fakeActor.GetTaskBySequenceIDAndApplicationCallCount()).To(Equal(1)) + taskId, appGuid := fakeActor.GetTaskBySequenceIDAndApplicationArgsForCall(0) + Expect(taskId).To(Equal(3)) + Expect(appGuid).To(Equal("some-app-guid")) + + Expect(testUI.Out).To(Say("Getting task 3 for app some-app-name in org some-org / space some-space as some-user...")) + + Expect(testUI.Out).To(Say(`id:\s+3`)) + Expect(testUI.Out).To(Say(`name:\s+task-3`)) + Expect(testUI.Out).To(Say(`state:\s+RUNNING`)) + Expect(testUI.Out).To(Say(`start time:\s+2016-11-08T22:26:02Z`)) + Expect(testUI.Out).To(Say(`command:\s+some-command`)) + Expect(testUI.Out).To(Say(`memory in mb:\s+100`)) + Expect(testUI.Out).To(Say(`disk in mb:\s+200`)) + Expect(testUI.Out).To(Say(`log rate limit:\s+300`)) + Expect(testUI.Out).To(Say(`failure reason:\s+some failure message`)) + + Expect(testUI.Err).To(Say("get-application-warning-1")) + Expect(testUI.Err).To(Say("get-application-warning-2")) + Expect(testUI.Err).To(Say("get-task-warning-1")) + }) + + When("the API does not return a command", func() { + BeforeEach(func() { + fakeActor.GetTaskBySequenceIDAndApplicationReturns( + resources.Task{ + GUID: "task-3-guid", + SequenceID: 3, + Name: "task-3", + State: constant.TaskRunning, + CreatedAt: "2016-11-08T22:26:02Z", + Command: "", + MemoryInMB: 100, + DiskInMB: 200, + LogRateLimitInBPS: 300, + Result: &resources.TaskResult{ + FailureReason: "some failure message", + }, + }, + v7action.Warnings{"get-task-warning-1"}, + nil) + }) + It("displays [hidden] for the command", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(testUI.Out).To(Say(`.*command:\s+\[hidden\]`)) + }) + }) + }) + + When("there are errors", func() { + When("the error is translatable", func() { + When("getting the application returns the error", func() { + var ( + returnedErr error + expectedErr error + ) + + BeforeEach(func() { + expectedErr = errors.New("request-error") + returnedErr = ccerror.RequestError{Err: expectedErr} + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + nil, + returnedErr) + }) + + It("returns a translatable error", func() { + Expect(executeErr).To(MatchError(ccerror.RequestError{Err: expectedErr})) + }) + }) + + When("getting the app task returns the error", func() { + var returnedErr error + + BeforeEach(func() { + returnedErr = ccerror.UnverifiedServerError{URL: "some-url"} + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + nil, + nil) + fakeActor.GetTaskBySequenceIDAndApplicationReturns( + resources.Task{}, + nil, + returnedErr) + }) + + It("returns a translatable error", func() { + Expect(executeErr).To(MatchError(returnedErr)) + }) + }) + }) + + When("the error is not translatable", func() { + When("getting the app returns the error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("bananapants") + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + v7action.Warnings{"get-application-warning-1", "get-application-warning-2"}, + expectedErr) + }) + + It("return the error and outputs all warnings", func() { + Expect(executeErr).To(MatchError(expectedErr)) + + Expect(testUI.Err).To(Say("get-application-warning-1")) + Expect(testUI.Err).To(Say("get-application-warning-2")) + }) + }) + + When("getting the app task returns the error", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("bananapants??") + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "some-app-guid"}, + v7action.Warnings{"get-application-warning-1", "get-application-warning-2"}, + nil) + fakeActor.GetTaskBySequenceIDAndApplicationReturns( + resources.Task{}, + v7action.Warnings{"get-task-warning-1", "get-task-warning-2"}, + expectedErr) + }) + + It("returns the error and outputs all warnings", func() { + Expect(executeErr).To(MatchError(expectedErr)) + + Expect(testUI.Err).To(Say("get-application-warning-1")) + Expect(testUI.Err).To(Say("get-application-warning-2")) + Expect(testUI.Err).To(Say("get-task-warning-1")) + Expect(testUI.Err).To(Say("get-task-warning-2")) + }) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/tasks_command.go b/command/v7/tasks_command.go index 9c3cf8fcdf6..ec6295958a7 100644 --- a/command/v7/tasks_command.go +++ b/command/v7/tasks_command.go @@ -4,9 +4,9 @@ import ( "strconv" "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/util/ui" ) type TasksCommand struct { @@ -14,7 +14,7 @@ type TasksCommand struct { RequiredArgs flag.AppName `positional-args:"yes"` usage interface{} `usage:"CF_NAME tasks APP_NAME"` - relatedCommands interface{} `related_commands:"apps, logs, run-task, terminate-task"` + relatedCommands interface{} `related_commands:"apps, logs, run-task, task, terminate-task"` } func (cmd TasksCommand) Execute(args []string) error { diff --git a/command/v7/tasks_command_test.go b/command/v7/tasks_command_test.go index aeccd989a18..433a441c0e2 100644 --- a/command/v7/tasks_command_test.go +++ b/command/v7/tasks_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/terminate_task_command.go b/command/v7/terminate_task_command.go index 0099980f16c..f20bad8ea7d 100644 --- a/command/v7/terminate_task_command.go +++ b/command/v7/terminate_task_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type TerminateTaskCommand struct { @@ -10,7 +10,7 @@ type TerminateTaskCommand struct { RequiredArgs flag.TerminateTaskArgs `positional-args:"yes"` usage interface{} `usage:"CF_NAME terminate-task APP_NAME TASK_ID\n\nEXAMPLES:\n CF_NAME terminate-task my-app 3"` - relatedCommands interface{} `related_commands:"tasks"` + relatedCommands interface{} `related_commands:"tasks, task"` } func (cmd TerminateTaskCommand) Execute(args []string) error { diff --git a/command/v7/terminate_task_command_test.go b/command/v7/terminate_task_command_test.go index 5528bf0fa66..dbff427df65 100644 --- a/command/v7/terminate_task_command_test.go +++ b/command/v7/terminate_task_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unbind_route_service_command.go b/command/v7/unbind_route_service_command.go index d973dc6c48b..d77a474b216 100644 --- a/command/v7/unbind_route_service_command.go +++ b/command/v7/unbind_route_service_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type UnbindRouteServiceCommand struct { diff --git a/command/v7/unbind_route_service_command_test.go b/command/v7/unbind_route_service_command_test.go index 4b0c5e6044f..05910c0157e 100644 --- a/command/v7/unbind_route_service_command_test.go +++ b/command/v7/unbind_route_service_command_test.go @@ -4,15 +4,15 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unbind_running_group_command_test.go b/command/v7/unbind_running_group_command_test.go index cef38fad9c6..c0f25e2a4f3 100644 --- a/command/v7/unbind_running_group_command_test.go +++ b/command/v7/unbind_running_group_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -66,7 +66,7 @@ var _ = Describe("unbind-running-security-group Command", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Out).To(Say("Unbinding security group %s from defaults for running as some-user...", cmd.RequiredArgs.SecurityGroup)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) }) diff --git a/command/v7/unbind_running_security_group_command.go b/command/v7/unbind_running_security_group_command.go index 264a4ab86cd..58d818c4b4f 100644 --- a/command/v7/unbind_running_security_group_command.go +++ b/command/v7/unbind_running_security_group_command.go @@ -1,16 +1,16 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnbindRunningSecurityGroupCommand struct { BaseCommand RequiredArgs flag.SecurityGroup `positional-args:"yes"` - usage interface{} `usage:"CF_NAME unbind-running-security-group SECURITY_GROUP\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME unbind-running-security-group SECURITY_GROUP\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, restart, running-security-groups, security-groups"` } @@ -45,7 +45,7 @@ func (cmd UnbindRunningSecurityGroupCommand) Execute(args []string) error { } cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/unbind_security_group.go b/command/v7/unbind_security_group.go index 9bc55399cc8..6c5bd4f4c7e 100644 --- a/command/v7/unbind_security_group.go +++ b/command/v7/unbind_security_group.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnbindSecurityGroupCommand struct { @@ -12,7 +12,7 @@ type UnbindSecurityGroupCommand struct { RequiredArgs flag.UnbindSecurityGroupV7Args `positional-args:"yes"` Lifecycle flag.SecurityGroupLifecycle `long:"lifecycle" choice:"running" choice:"staging" default:"running" description:"Lifecycle phase the group applies to"` - usage interface{} `usage:"CF_NAME unbind-security-group SECURITY_GROUP ORG SPACE [--lifecycle (running | staging)]\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME unbind-security-group SECURITY_GROUP ORG SPACE [--lifecycle (running | staging)]\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, restart, security-groups"` } @@ -52,7 +52,7 @@ func (cmd UnbindSecurityGroupCommand) Execute(args []string) error { cmd.UI.DisplayWarning(err.Error()) cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } @@ -60,7 +60,7 @@ func (cmd UnbindSecurityGroupCommand) Execute(args []string) error { } cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/unbind_security_group_test.go b/command/v7/unbind_security_group_test.go index 4af1a6edb30..1140dd1f420 100644 --- a/command/v7/unbind_security_group_test.go +++ b/command/v7/unbind_security_group_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -126,7 +126,7 @@ var _ = Describe("unbind-security-group Command", func() { Expect(lifecycle).To(Equal(constant.SecurityGroupLifecycle("some-lifecycle"))) Expect(testUI.Err).To(Say("Security group some-security-group not bound to space some-space for lifecycle phase 'some-lifecycle'.")) Expect(testUI.Out).To(Say("OK\n\n")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(executeErr).NotTo(HaveOccurred()) }) }) @@ -143,7 +143,7 @@ var _ = Describe("unbind-security-group Command", func() { It("indicates it successfully unbound the security group", func() { Expect(testUI.Out).To(Say("OK\n\n")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) }) }) diff --git a/command/v7/unbind_service_command.go b/command/v7/unbind_service_command.go index ccf2f134fd7..9ba1d95ae51 100644 --- a/command/v7/unbind_service_command.go +++ b/command/v7/unbind_service_command.go @@ -1,10 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type UnbindServiceCommand struct { @@ -52,8 +52,6 @@ func (cmd UnbindServiceCommand) Execute(args []string) error { cmd.UI.DisplayText("Unbinding in progress. Use 'cf service {{.ServiceInstanceName}}' to check operation status.", cmd.names()) return nil } - - return nil } func (cmd UnbindServiceCommand) Usage() string { diff --git a/command/v7/unbind_service_command_test.go b/command/v7/unbind_service_command_test.go index 686708b3761..8085bef8698 100644 --- a/command/v7/unbind_service_command_test.go +++ b/command/v7/unbind_service_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unbind_staging_security_group_command.go b/command/v7/unbind_staging_security_group_command.go index 3734ed62483..e67680127ee 100644 --- a/command/v7/unbind_staging_security_group_command.go +++ b/command/v7/unbind_staging_security_group_command.go @@ -1,16 +1,16 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnbindStagingSecurityGroupCommand struct { BaseCommand RequiredArgs flag.SecurityGroup `positional-args:"yes"` - usage interface{} `usage:"CF_NAME unbind-staging-security-group SECURITY_GROUP\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME unbind-staging-security-group SECURITY_GROUP\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"apps, restart, security-groups, staging-security-groups"` } @@ -45,7 +45,7 @@ func (cmd UnbindStagingSecurityGroupCommand) Execute(args []string) error { } cmd.UI.DisplayOK() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/unbind_staging_security_group_command_test.go b/command/v7/unbind_staging_security_group_command_test.go index 7588628cc73..8e4a47dad84 100644 --- a/command/v7/unbind_staging_security_group_command_test.go +++ b/command/v7/unbind_staging_security_group_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -66,7 +66,7 @@ var _ = Describe("unbind-staging-security-group Command", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Out).To(Say("Unbinding security group %s from defaults for staging as some-user...", cmd.RequiredArgs.SecurityGroup)) Expect(testUI.Out).To(Say("OK")) - Expect(testUI.Out).To(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Expect(testUI.Out).To(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Expect(testUI.Err).To(Say("get security group warning")) }) diff --git a/command/v7/unmap_route_command.go b/command/v7/unmap_route_command.go index d6bc80da0a2..9e4d0176b74 100644 --- a/command/v7/unmap_route_command.go +++ b/command/v7/unmap_route_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnmapRouteCommand struct { diff --git a/command/v7/unmap_route_command_test.go b/command/v7/unmap_route_command_test.go index 03ab812213a..12887207d73 100644 --- a/command/v7/unmap_route_command_test.go +++ b/command/v7/unmap_route_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unset_env_command.go b/command/v7/unset_env_command.go index 47243449dda..7b1b639d118 100644 --- a/command/v7/unset_env_command.go +++ b/command/v7/unset_env_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnsetEnvCommand struct { diff --git a/command/v7/unset_env_command_test.go b/command/v7/unset_env_command_test.go index 2e1175dc50b..e12f63c9df7 100644 --- a/command/v7/unset_env_command_test.go +++ b/command/v7/unset_env_command_test.go @@ -3,14 +3,14 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unset_label_command.go b/command/v7/unset_label_command.go index 2fa752cf396..3f93f2178b9 100644 --- a/command/v7/unset_label_command.go +++ b/command/v7/unset_label_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . LabelUnsetter @@ -64,7 +64,7 @@ func (cmd UnsetLabelCommand) Examples() string { return ` cf unset-label app dora ci_signature_sha2 cf unset-label org business pci public-facing -cf unset-label buildpack go_buildpack go -s cflinuxfs3` +cf unset-label buildpack go_buildpack go -s cflinuxfs4` } func (cmd UnsetLabelCommand) Resources() string { diff --git a/command/v7/unset_label_command_test.go b/command/v7/unset_label_command_test.go index e5513e83af6..e1607ce38c4 100644 --- a/command/v7/unset_label_command_test.go +++ b/command/v7/unset_label_command_test.go @@ -1,11 +1,11 @@ package v7_test import ( - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/command/v7/unset_org_role_command.go b/command/v7/unset_org_role_command.go index c7798f0d174..3c9782cf7ac 100644 --- a/command/v7/unset_org_role_command.go +++ b/command/v7/unset_org_role_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type UnsetOrgRoleCommand struct { diff --git a/command/v7/unset_org_role_command_test.go b/command/v7/unset_org_role_command_test.go index 7e4695e4ec9..0a6b0c93c6e 100644 --- a/command/v7/unset_org_role_command_test.go +++ b/command/v7/unset_org_role_command_test.go @@ -1,19 +1,19 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unset_space_quota_command.go b/command/v7/unset_space_quota_command.go index 39d4f8bd6ef..cf4d2374c2c 100644 --- a/command/v7/unset_space_quota_command.go +++ b/command/v7/unset_space_quota_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnsetSpaceQuotaCommand struct { diff --git a/command/v7/unset_space_quota_command_test.go b/command/v7/unset_space_quota_command_test.go index 3a93e9dd666..0485ee6eceb 100644 --- a/command/v7/unset_space_quota_command_test.go +++ b/command/v7/unset_space_quota_command_test.go @@ -1,16 +1,16 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - - . "code.cloudfoundry.org/cli/command/v7" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "code.cloudfoundry.org/cli/v8/command/v7" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unset_space_role_command.go b/command/v7/unset_space_role_command.go index 56abfc332fb..094d67de109 100644 --- a/command/v7/unset_space_role_command.go +++ b/command/v7/unset_space_role_command.go @@ -1,8 +1,8 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type UnsetSpaceRoleCommand struct { diff --git a/command/v7/unset_space_role_command_test.go b/command/v7/unset_space_role_command_test.go index e5c9e760943..7a14d7e153c 100644 --- a/command/v7/unset_space_role_command_test.go +++ b/command/v7/unset_space_role_command_test.go @@ -1,19 +1,19 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unshare_private_domain_command.go b/command/v7/unshare_private_domain_command.go index d2fe3878251..95cb25f20be 100644 --- a/command/v7/unshare_private_domain_command.go +++ b/command/v7/unshare_private_domain_command.go @@ -1,7 +1,7 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UnsharePrivateDomainCommand struct { diff --git a/command/v7/unshare_private_domain_command_test.go b/command/v7/unshare_private_domain_command_test.go index 12e92e52b17..01c1c899698 100644 --- a/command/v7/unshare_private_domain_command_test.go +++ b/command/v7/unshare_private_domain_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/util/ui" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/unshare_route_command.go b/command/v7/unshare_route_command.go new file mode 100644 index 00000000000..cc6eedc1111 --- /dev/null +++ b/command/v7/unshare_route_command.go @@ -0,0 +1,103 @@ +package v7 + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" +) + +type UnshareRouteCommand struct { + BaseCommand + + RequireArgs flag.Domain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + DestinationOrg string `short:"o" description:"The org of the destination space (Default: targeted org)"` + DestinationSpace string `short:"s" description:"The space to be unshared (Default: targeted space)"` + + relatedCommands interface{} `related_commands:" share-route, delete-route, map-route, unmap-route, routes"` +} + +func (cmd UnshareRouteCommand) Usage() string { + return ` +Unshare an existing route from a space: + CF_NAME unshare-route DOMAIN [--hostname HOSTNAME] [--path PATH] -s OTHER_SPACE [-o OTHER_ORG]` +} + +func (cmd UnshareRouteCommand) Examples() string { + return ` +CF_NAME unshare-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo +CF_NAME unshare-route example.com --hostname myHost -s TargetSpace # myhost.example.com +CF_NAME unshare-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com` +} + +func (cmd UnshareRouteCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequireArgs.Domain) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + path := cmd.Path.Path + route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.RouteNotFoundError); ok { + cmd.UI.DisplayText("Can not unshare route:") + return err + } + } + + destinationOrgName := cmd.DestinationOrg + + if destinationOrgName == "" { + destinationOrgName = cmd.Config.TargetedOrganizationName() + } + + destinationOrg, warnings, err := cmd.Actor.GetOrganizationByName(destinationOrgName) + cmd.UI.DisplayWarnings(warnings) + + if err != nil { + if _, ok := err.(actionerror.OrganizationNotFoundError); ok { + cmd.UI.DisplayText("Can not unshare route:") + return err + } + } + + targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + if _, ok := err.(actionerror.SpaceNotFoundError); ok { + cmd.UI.DisplayText("Can not unshare route:") + return err + } + } + + url := desiredURL(domain.Name, cmd.Hostname, path, 0) + cmd.UI.DisplayTextWithFlavor("Unsharing route {{.URL}} from space {{.DestinationSpace}} as {{.User}}", + map[string]interface{}{ + "URL": url, + "DestinationSpace": cmd.DestinationSpace, + "User": user.Name, + }) + warnings, err = cmd.Actor.UnshareRoute( + route.GUID, + targetedSpace.GUID, + ) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + cmd.UI.DisplayOK() + + return nil +} diff --git a/command/v7/unshare_route_command_test.go b/command/v7/unshare_route_command_test.go new file mode 100644 index 00000000000..06afafc7fa4 --- /dev/null +++ b/command/v7/unshare_route_command_test.go @@ -0,0 +1,280 @@ +package v7_test + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("unshare-route Command", func() { + var ( + cmd v7.UnshareRouteCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + domainName string + orgName string + spaceName string + hostname string + path string + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "myBinaryBread" + fakeConfig.BinaryNameReturns(binaryName) + + domainName = "some-domain.com" + orgName = "org-name-a" + spaceName = "space-name-a" + hostname = "myHostname" + path = "myPath" + + cmd = v7.UnshareRouteCommand{ + BaseCommand: v7.BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + RequireArgs: flag.Domain{Domain: domainName}, + Hostname: hostname, + Path: flag.V7RoutePath{Path: path}, + DestinationOrg: orgName, + DestinationSpace: spaceName, + } + + fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space", GUID: "some-space-guid"}) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{Name: "some-org"}) + fakeConfig.CurrentUserReturns(configv3.User{Name: "some-user"}, nil) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + It("checks that target", func() { + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in and targeted", func() { + When("getting the domain errors", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(0)) + + Expect(fakeActor.UnshareRouteCallCount()).To(Equal(0)) + }) + }) + + When("getting the domain succeeds", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns( + resources.Domain{Name: domainName, GUID: "domain-guid"}, + v7action.Warnings{"get-domain-warnings"}, + nil, + ) + }) + + When("the requested route does not exist", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + }) + + It("displays error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + }) + }) + + When("the requested route exists", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + When("getting the target space errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.SpaceNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetOrganizationByNameArgsForCall(0)).To(Equal(orgName)) + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + + Expect(fakeActor.UnshareRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target org errors", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.OrganizationNotFoundError{}, + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.UnshareRouteCallCount()).To(Equal(0)) + }) + }) + When("getting the target space succeeds", func() { + BeforeEach(func() { + fakeActor.GetOrganizationByNameReturns( + resources.Organization{GUID: "org-guid-a"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + fakeActor.GetSpaceByNameAndOrganizationReturns( + resources.Space{GUID: "space-guid-b"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + It("exits 0 with helpful message that the route is now being unshared", func() { + Expect(executeErr).ShouldNot(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetOrganizationByNameCallCount()).To(Equal(1)) + orgName := fakeActor.GetOrganizationByNameArgsForCall(0) + Expect(orgName).To(Equal("org-name-a")) + + Expect(fakeActor.GetSpaceByNameAndOrganizationCallCount()).To(Equal(1)) + spaceName, orgGuid := fakeActor.GetSpaceByNameAndOrganizationArgsForCall(0) + Expect(spaceName).To(Equal("space-name-a")) + Expect(orgGuid).To(Equal("org-guid-a")) + Expect(fakeActor.UnshareRouteCallCount()).To(Equal(1)) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/unshare_service_command.go b/command/v7/unshare_service_command.go index 73d1d213cbf..c6a8cbb6496 100644 --- a/command/v7/unshare_service_command.go +++ b/command/v7/unshare_service_command.go @@ -1,9 +1,9 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/types" ) type UnshareServiceCommand struct { diff --git a/command/v7/unshare_service_command_test.go b/command/v7/unshare_service_command_test.go index e5ae7caa0fc..d4addada982 100644 --- a/command/v7/unshare_service_command_test.go +++ b/command/v7/unshare_service_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -219,7 +219,8 @@ var _ = Describe("unshare-service command", func() { When("getting the username fails", func() { BeforeEach(func() { - input.Write([]byte("y\n")) + _, err := input.Write([]byte("y\n")) + Expect(err).NotTo(HaveOccurred()) fakeActor.GetCurrentUserReturns(configv3.User{}, errors.New("boom")) }) diff --git a/command/v7/update_buildpack_command.go b/command/v7/update_buildpack_command.go index b0e40dee66b..58b6f0b3ea1 100644 --- a/command/v7/update_buildpack_command.go +++ b/command/v7/update_buildpack_command.go @@ -1,20 +1,20 @@ package v7 import ( - "io/ioutil" "os" "time" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/download" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/download" ) type UpdateBuildpackActor interface { @@ -28,7 +28,7 @@ type UpdateBuildpackCommand struct { BaseCommand RequiredArgs flag.BuildpackName `positional-args:"Yes"` - usage interface{} `usage:"CF_NAME update-buildpack BUILDPACK [-p PATH | -s STACK | --assign-stack NEW_STACK] [-i POSITION] [--rename NEW_NAME] [--enable|--disable] [--lock|--unlock]\n\nTIP:\nPath should be a zip file, a url to a zip file, or a local directory. Position is a positive integer, sets priority, and is sorted from lowest to highest.\n\nUse '--assign-stack' with caution. Associating a buildpack with a stack that it does not support may result in undefined behavior. Additionally, changing this association once made may require a local copy of the buildpack.\n\n"` + usage interface{} `usage:"CF_NAME update-buildpack BUILDPACK [-p PATH | -s STACK | --assign-stack NEW_STACK] [-i POSITION] [--rename NEW_NAME] [--enable|--disable] [--lock|--unlock]\n\nTIP:\nWhen using the 'buildpack' lifecycle type, Path should be a zip file, a url to a zip file, or a local directory. When using the 'cnb' lifecycle, Path should be a cnb file or gzipped oci image. Position is a positive integer, sets priority, and is sorted from lowest to highest.\n\nUse '--assign-stack' with caution. Associating a buildpack with a stack that it does not support may result in undefined behavior. Additionally, changing this association once made may require a local copy of the buildpack.\n\n"` relatedCommands interface{} `related_commands:"buildpacks, create-buildpack, delete-buildpack"` NewStack string `long:"assign-stack" description:"Assign a stack to a buildpack that does not have a stack association"` Disable bool `long:"disable" description:"Disable the buildpack from being used for staging"` @@ -38,6 +38,7 @@ type UpdateBuildpackCommand struct { Position types.NullInt `long:"position" short:"i" description:"The order in which the buildpacks are checked during buildpack auto-detection"` NewName string `long:"rename" description:"Rename an existing buildpack"` CurrentStack string `long:"stack" short:"s" description:"Specify stack to disambiguate buildpacks with the same name"` + Lifecycle string `long:"lifecycle" short:"l" description:"Specify lifecycle to disambiguate buildpacks with the same name"` Unlock bool `long:"unlock" description:"Unlock the buildpack to enable updates"` ProgressBar v7action.SimpleProgressBar @@ -56,6 +57,13 @@ func (cmd UpdateBuildpackCommand) Execute(args []string) error { return err } + if cmd.Lifecycle != "" { + err = command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionBuildpackLifecycleQuery, "--lifecycle") + if err != nil { + return err + } + } + cmd.printInitialText(user.Name) if cmd.Path != "" { @@ -96,7 +104,7 @@ func (cmd UpdateBuildpackCommand) validateSetup() (configv3.User, error) { func (cmd UpdateBuildpackCommand) prepareBuildpackBits() (string, string, error) { downloader := download.NewDownloader(time.Second * 30) - tmpDirPath, err := ioutil.TempDir("", "buildpack-dir-") + tmpDirPath, err := os.MkdirTemp("", "buildpack-dir-") if err != nil { return "", "", err } @@ -120,9 +128,10 @@ func (cmd UpdateBuildpackCommand) updateBuildpack() (resources.Buildpack, error) desiredBuildpack.Name = cmd.NewName } - updatedBuildpack, warnings, err := cmd.Actor.UpdateBuildpackByNameAndStack( + updatedBuildpack, warnings, err := cmd.Actor.UpdateBuildpackByNameAndStackAndLifecycle( cmd.RequiredArgs.Buildpack, cmd.CurrentStack, + cmd.Lifecycle, desiredBuildpack, ) cmd.UI.DisplayWarnings(warnings) @@ -182,32 +191,36 @@ func (cmd UpdateBuildpackCommand) printInitialText(userName string) { }) } - switch { - case cmd.NewStack != "": + if cmd.NewStack != "" { cmd.UI.DisplayTextWithFlavor("Assigning stack {{.Stack}} to {{.Buildpack}} as {{.CurrentUser}}...", map[string]interface{}{ "Buildpack": buildpackName, "CurrentUser": userName, "Stack": cmd.NewStack, }) if cmd.Position.IsSet || cmd.Lock || cmd.Unlock || cmd.Enable || cmd.Disable { - cmd.UI.DisplayTextWithFlavor("\nUpdating buildpack {{.Buildpack}} with stack {{.Stack}} as {{.CurrentUser}}...", map[string]interface{}{ - "Buildpack": buildpackName, - "CurrentUser": userName, - "Stack": cmd.NewStack, - }) + cmd.UI.DisplayNewline() + cmd.displayUpdatingBuildpackMessage(buildpackName, userName, cmd.NewStack) } - case cmd.CurrentStack == "": - cmd.UI.DisplayTextWithFlavor("Updating buildpack {{.Buildpack}} as {{.CurrentUser}}...", map[string]interface{}{ - "Buildpack": buildpackName, - "CurrentUser": userName, - }) - default: - cmd.UI.DisplayTextWithFlavor("Updating buildpack {{.Buildpack}} with stack {{.Stack}} as {{.CurrentUser}}...", map[string]interface{}{ - "Buildpack": buildpackName, - "CurrentUser": userName, - "Stack": cmd.CurrentStack, - }) + } else { + cmd.displayUpdatingBuildpackMessage(buildpackName, userName, cmd.CurrentStack) + } +} + +func (cmd UpdateBuildpackCommand) displayUpdatingBuildpackMessage(buildpackName, userName, stack string) { + message := "Updating buildpack {{.Buildpack}}" + if stack != "" { + message += " with stack {{.Stack}}" } + if cmd.Lifecycle != "" { + message += " with lifecycle {{.Lifecycle}}" + } + message += " as {{.CurrentUser}}..." + cmd.UI.DisplayTextWithFlavor(message, map[string]interface{}{ + "Buildpack": buildpackName, + "CurrentUser": userName, + "Stack": stack, + "Lifecycle": cmd.Lifecycle, + }) } func (cmd UpdateBuildpackCommand) validateFlagCombinations() error { diff --git a/command/v7/update_buildpack_command_test.go b/command/v7/update_buildpack_command_test.go index 05de1f2e8a9..a5bf8dc7d03 100644 --- a/command/v7/update_buildpack_command_test.go +++ b/command/v7/update_buildpack_command_test.go @@ -3,21 +3,21 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/command/translatableerror" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/command/translatableerror" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -44,6 +44,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) fakeActor = new(v7fakes.FakeActor) fakeConfig = new(commandfakes.FakeConfig) + fakeConfig.APIVersionReturns("4.0.0") buildpackGUID = "some guid" cmd = UpdateBuildpackCommand{ @@ -173,7 +174,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("exits without updating if the path points to an empty directory", func() { Expect(executeErr).To(MatchError(emptyDirectoryError)) - Expect(fakeActor.UpdateBuildpackByNameAndStackCallCount()).To(Equal(0)) + Expect(fakeActor.UpdateBuildpackByNameAndStackAndLifecycleCallCount()).To(Equal(0)) }) }) @@ -182,7 +183,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { cmd.Path = "path/to/buildpack" fakeActor.PrepareBuildpackBitsReturns("path/to/prepared/bits", nil) expectedErr = errors.New("update-error") - fakeActor.UpdateBuildpackByNameAndStackReturns( + fakeActor.UpdateBuildpackByNameAndStackAndLifecycleReturns( resources.Buildpack{}, v7action.Warnings{"update-bp-warning1", "update-bp-warning2"}, expectedErr, @@ -204,7 +205,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the locked value to true when updating the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Locked.IsSet).To(Equal(true)) Expect(buildpack.Locked.Value).To(Equal(true)) }) @@ -217,7 +218,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the locked value to false when updating the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Locked.IsSet).To(Equal(true)) Expect(buildpack.Locked.Value).To(Equal(false)) }) @@ -230,7 +231,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the enabled value to true when updating the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Enabled.IsSet).To(Equal(true)) Expect(buildpack.Enabled.Value).To(Equal(true)) }) @@ -243,7 +244,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the enabled value to false when updating the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Enabled.IsSet).To(Equal(true)) Expect(buildpack.Enabled.Value).To(Equal(false)) }) @@ -256,7 +257,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the new buildpack order when updating the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Position.IsSet).To(Equal(true)) Expect(buildpack.Position.Value).To(Equal(99)) }) @@ -269,7 +270,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the new stack on the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(testUI.Out).ToNot(Say("Updating buildpack %s", buildpackName)) Expect(testUI.Out).To(Say("Assigning stack %s to %s as %s...", cmd.NewStack, buildpackName, userName)) Expect(buildpack.Stack).To(Equal("some-new-stack")) @@ -342,6 +343,28 @@ var _ = Describe("UpdateBuildpackCommand", func() { }) + When("the --lifecycle flag is provided", func() { + BeforeEach(func() { + cmd.Lifecycle = "some-lifecycle" + }) + It("is only used for getting the buildpack and does not update existing lifecycle", func() { + Expect(executeErr).ToNot(HaveOccurred()) + _, _, lifecycleQuery, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) + Expect(buildpack.Lifecycle).To(BeEmpty()) + Expect(lifecycleQuery).To(Equal("some-lifecycle")) + }) + It("fails when the cc version is below the minimum", func() { + fakeConfig.APIVersionReturns("3.193.0") + executeErr = cmd.Execute(nil) + + Expect(executeErr).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{ + Command: "--lifecycle", + CurrentVersion: "3.193.0", + MinimumVersion: "3.194.0", + })) + }) + }) + When("the --rename flag is provided", func() { BeforeEach(func() { cmd.NewName = "new-buildpack-name" @@ -349,7 +372,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the new name on the buildpack", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Name).To(Equal("new-buildpack-name")) Expect(testUI.Out).ToNot(Say("Updating buildpack %s", buildpackName)) @@ -365,7 +388,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { It("sets the new name/stack on the buildpack and refers to the new name going forward", func() { Expect(executeErr).ToNot(HaveOccurred()) - _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + _, _, _, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Name).To(Equal("new-buildpack-name")) Expect(buildpack.Stack).To(Equal("new-stack")) @@ -384,7 +407,7 @@ var _ = Describe("UpdateBuildpackCommand", func() { When("updating the buildpack succeeds", func() { BeforeEach(func() { - fakeActor.UpdateBuildpackByNameAndStackReturns( + fakeActor.UpdateBuildpackByNameAndStackAndLifecycleReturns( resources.Buildpack{GUID: buildpackGUID}, v7action.Warnings{"update-bp-warning1", "update-bp-warning2"}, nil, @@ -393,14 +416,15 @@ var _ = Describe("UpdateBuildpackCommand", func() { When("no arguments are specified", func() { It("makes the actor call to update the buildpack", func() { - Expect(fakeActor.UpdateBuildpackByNameAndStackCallCount()).To(Equal(1)) - _, newStack, buildpack := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + Expect(fakeActor.UpdateBuildpackByNameAndStackAndLifecycleCallCount()).To(Equal(1)) + _, newStack, lifecycle, buildpack := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpack.Name).To(Equal("")) Expect(buildpack.Stack).To(Equal("")) Expect(buildpack.Position.IsSet).To(BeFalse()) Expect(buildpack.Locked.IsSet).To(BeFalse()) Expect(buildpack.Enabled.IsSet).To(BeFalse()) Expect(newStack).To(Equal("")) + Expect(lifecycle).To(Equal("")) Expect(testUI.Err).To(Say("update-bp-warning1")) Expect(testUI.Err).To(Say("update-bp-warning2")) @@ -415,8 +439,8 @@ var _ = Describe("UpdateBuildpackCommand", func() { }) It("makes the call to update the buildpack", func() { - Expect(fakeActor.UpdateBuildpackByNameAndStackCallCount()).To(Equal(1)) - buildpackNameArg, _, _ := fakeActor.UpdateBuildpackByNameAndStackArgsForCall(0) + Expect(fakeActor.UpdateBuildpackByNameAndStackAndLifecycleCallCount()).To(Equal(1)) + buildpackNameArg, _, _, _ := fakeActor.UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(0) Expect(buildpackNameArg).To(Equal(buildpackName)) Expect(testUI.Err).To(Say("update-bp-warning1")) diff --git a/command/v7/update_destination_command.go b/command/v7/update_destination_command.go new file mode 100644 index 00000000000..ad8b9fe7ccf --- /dev/null +++ b/command/v7/update_destination_command.go @@ -0,0 +1,117 @@ +package v7 + +import ( + "errors" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" +) + +type UpdateDestinationCommand struct { + BaseCommand + + RequiredArgs flag.AppDomain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + AppProtocol string `long:"app-protocol" description:"New Protocol for the route destination (http1 or http2). Only applied to HTTP routes"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + + relatedCommands interface{} `related_commands:"routes, map-route, create-route, unmap-route"` +} + +func (cmd UpdateDestinationCommand) Usage() string { + return ` +Edit an existing HTTP route: + CF_NAME update-destination APP_NAME DOMAIN [--hostname HOSTNAME] [--app-protocol PROTOCOL] [--path PATH]` +} + +func (cmd UpdateDestinationCommand) Examples() string { + return ` +CF_NAME update-destination my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com +CF_NAME update destination my-app example.com --hostname myhost --path foo --app-protocol http2 # myhost.example.com/foo` +} + +func (cmd UpdateDestinationCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequiredArgs.Domain) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + spaceGUID := cmd.Config.TargetedSpace().GUID + app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.App, spaceGUID) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + path := cmd.Path.Path + route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) + cmd.UI.DisplayWarnings(warnings) + url := desiredURL(domain.Name, cmd.Hostname, path, 0) + if err != nil { + if _, ok := err.(actionerror.RouteNotFoundError); ok { + cmd.UI.DisplayText("Route to be updated does not exist.") + return err + } + return err + } + + dest, err := cmd.Actor.GetRouteDestinationByAppGUID(route, app.GUID) + if err != nil { + if _, ok := err.(actionerror.RouteDestinationNotFoundError); !ok { + cmd.UI.DisplayText("Route's destination to be updated does not exist.") + return err + } + } + + if cmd.AppProtocol == "" { + cmd.AppProtocol = "http1" + } + + if cmd.AppProtocol == "tcp" { + return errors.New("Destination protocol must be 'http1' or 'http2'") + } + + if dest.Protocol == cmd.AppProtocol { + cmd.UI.DisplayText(" App '{{ .AppName }}' is already using '{{ .AppProtocol }}'. Nothing has been updated", map[string]interface{}{ + "AppName": cmd.RequiredArgs.App, + "AppProtocol": cmd.AppProtocol, + }) + cmd.UI.DisplayOK() + return nil + } + + cmd.UI.DisplayTextWithFlavor("Updating destination protocol from {{.OldProtocol}} to {{.NewProtocol}} for route {{.URL}} in org {{.OrgName}} / space {{.SpaceName}} as {{.User}}...", + map[string]interface{}{ + "OldProtocol": dest.Protocol, + "NewProtocol": cmd.AppProtocol, + "URL": url, + "User": user.Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "OrgName": cmd.Config.TargetedOrganization().Name, + }) + + warnings, err = cmd.Actor.UpdateDestination( + route.GUID, + dest.GUID, + cmd.AppProtocol, + ) + + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + cmd.UI.DisplayOK() + + return nil +} diff --git a/command/v7/update_destination_command_test.go b/command/v7/update_destination_command_test.go new file mode 100644 index 00000000000..c81e32ff271 --- /dev/null +++ b/command/v7/update_destination_command_test.go @@ -0,0 +1,380 @@ +package v7_test + +import ( + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("update Command", func() { + var ( + cmd v7.UpdateDestinationCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + binaryName string + executeErr error + domainName string + appName string + appProtocol string + orgGUID string + spaceGUID string + hostname string + path string + ) + + BeforeEach(func() { + testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + + binaryName = "faceman" + fakeConfig.BinaryNameReturns(binaryName) + + domainName = "some-domain.com" + appName = "super-app" + appProtocol = "http2" + orgGUID = "some-org-guid" + spaceGUID = "some-space-guid" + hostname = "hostname" + path = "path" + + cmd = v7.UpdateDestinationCommand{ + BaseCommand: v7.BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + RequiredArgs: flag.AppDomain{App: appName, Domain: domainName}, + AppProtocol: appProtocol, + Hostname: hostname, + Path: flag.V7RoutePath{Path: path}, + } + + fakeConfig.TargetedSpaceReturns(configv3.Space{Name: "some-space", GUID: spaceGUID}) + fakeConfig.TargetedOrganizationReturns(configv3.Organization{Name: "some-org", GUID: orgGUID}) + fakeConfig.CurrentUserReturns(configv3.User{Name: "some-user"}, nil) + + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + It("checks the target", func() { + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in and targeted", func() { + When("getting the domain errors", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) + }) + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(0)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(0)) + + Expect(fakeActor.UpdateDestinationCallCount()).To(Equal(0)) + }) + }) + + When("getting the domain succeeds", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns( + resources.Domain{Name: domainName, GUID: "domain-guid"}, + v7action.Warnings{"get-domain-warnings"}, + nil, + ) + }) + + When("getting the app errors", func() { + BeforeEach(func() { + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{}, + v7action.Warnings{"get-app-warnings"}, + errors.New("get-app-error"), + ) + }) + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-app-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) + + Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) + }) + }) + + When("getting the app succeeds", func() { + BeforeEach(func() { + fakeActor.GetApplicationByNameAndSpaceReturns( + resources.Application{GUID: "app-guid", Name: appName}, + v7action.Warnings{"get-app-warnings"}, + nil, + ) + }) + + When("getting the route errors", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + errors.New("get-route-error"), + ) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-route-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.UpdateDestinationCallCount()).To(Equal(0)) + + }) + }) + + When("the requested route does not exist", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + actionerror.RouteNotFoundError{}, + ) + }) + + It("displays error message", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + }) + }) + + When("the requested route exists", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid"}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + When("getting the destination errors", func() { + BeforeEach(func() { + fakeActor.GetRouteDestinationByAppGUIDReturns( + resources.RouteDestination{}, + errors.New("get-destination-error"), + ) + }) + It("returns the error and warnings", func() { + Expect(executeErr).To(MatchError(errors.New("get-destination-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) + actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) + Expect(actualRoute.GUID).To(Equal("route-guid")) + Expect(actualAppGUID).To(Equal("app-guid")) + + Expect(fakeActor.UpdateDestinationCallCount()).To(Equal(0)) + }) + }) + When("the destination already exists", func() { + BeforeEach(func() { + fakeActor.GetRouteDestinationByAppGUIDReturns( + resources.RouteDestination{ + GUID: "route-dst-guid", + App: resources.RouteDestinationApp{ + GUID: "existing-app-guid", + }, + }, + nil, + ) + }) + + It("exits 0 with a helpful message that the destination protocol was changed", func() { + Expect(executeErr).ShouldNot(HaveOccurred()) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) + actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) + Expect(actualRoute.GUID).To(Equal("route-guid")) + Expect(actualAppGUID).To(Equal("app-guid")) + Expect(fakeActor.UpdateDestinationCallCount()).To(Equal(1)) + }) + }) + + When("the destination is not found", func() { + When("updating the destination errors", func() { + BeforeEach(func() { + fakeActor.UpdateDestinationReturns(v7action.Warnings{"update-dest-warnings"}, errors.New("map-route-error")) + fakeActor.GetRouteDestinationByAppGUIDReturns( + resources.RouteDestination{ + GUID: "route-dst-guid", + App: resources.RouteDestinationApp{ + GUID: "existing-app-guid", + }, + }, + nil, + ) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(testUI.Err).To(Say("get-app-warnings")) + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(testUI.Err).To(Say("update-dest-warnings")) + Expect(executeErr).To(MatchError(errors.New("map-route-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domainName)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) + actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) + Expect(actualAppName).To(Equal(appName)) + Expect(actualSpaceGUID).To(Equal(spaceGUID)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal(domainName)) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal(hostname)) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.UpdateDestinationCallCount()).To(Equal(1)) + actualRouteGUID, destinationGUID, protocol := fakeActor.UpdateDestinationArgsForCall(0) + Expect(actualRouteGUID).To(Equal("route-guid")) + Expect(destinationGUID).To(Equal("route-dst-guid")) + Expect(protocol).To(Equal("http2")) + }) + }) + }) + }) + }) + }) + }) +}) diff --git a/command/v7/update_org_quota_command.go b/command/v7/update_org_quota_command.go index 04a93c6a7b8..d9199ac48ab 100644 --- a/command/v7/update_org_quota_command.go +++ b/command/v7/update_org_quota_command.go @@ -1,26 +1,28 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type UpdateOrgQuotaCommand struct { BaseCommand - RequiredArgs flag.OrganizationQuota `positional-args:"Yes"` - NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` - PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` - NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` - PerProcessMemory flag.MemoryWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` - TotalMemory flag.MemoryWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` - NewName string `short:"n" description:"New name"` - TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` - TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` - TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` - usage interface{} `usage:"CF_NAME update-org-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS]"` - relatedCommands interface{} `related_commands:"org, org-quota"` + RequiredArgs flag.OrganizationQuota `positional-args:"Yes"` + NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` + PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` + NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` + PerProcessMemory flag.MegabytesWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` + TotalMemory flag.MegabytesWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` + NewName string `short:"n" description:"New name"` + TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` + TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` + TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` + TotalLogVolume flag.BytesWithUnlimited `short:"l" description:"Total log volume per second all processes can have, in bytes (e.g. 128B, 4K, 1M). -1 represents an unlimited amount."` + + usage interface{} `usage:"CF_NAME update-org-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS] [-l LOG_VOLUME]"` + relatedCommands interface{} `related_commands:"org, org-quota"` } func (cmd UpdateOrgQuotaCommand) Execute(args []string) error { @@ -61,6 +63,7 @@ func (cmd UpdateOrgQuotaCommand) Execute(args []string) error { TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), + TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), } warnings, err := cmd.Actor.UpdateOrganizationQuota(oldQuotaName, cmd.NewName, updatedQuotaLimits) diff --git a/command/v7/update_org_quota_command_test.go b/command/v7/update_org_quota_command_test.go index 4dd534d5dc2..4d4409900b3 100644 --- a/command/v7/update_org_quota_command_test.go +++ b/command/v7/update_org_quota_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/command/translatableerror" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -91,11 +91,12 @@ var _ = Describe("UpdateOrgQuotaCommand", func() { cmd.NewName = "new-org-quota-name" cmd.PaidServicePlans = true cmd.NumAppInstances = flag.IntegerLimit{IsSet: true, Value: 10} - cmd.PerProcessMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 9} - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 2048} + cmd.PerProcessMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 9} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 2048} cmd.TotalRoutes = flag.IntegerLimit{IsSet: true, Value: 7} cmd.TotalReservedPorts = flag.IntegerLimit{IsSet: true, Value: 1} cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 2} + cmd.TotalLogVolume = flag.BytesWithUnlimited{IsSet: true, Value: 8} fakeActor.UpdateOrganizationQuotaReturns( v7action.Warnings{"warning"}, nil) @@ -130,6 +131,9 @@ var _ = Describe("UpdateOrgQuotaCommand", func() { Expect(quotaLimits.TotalServiceInstances.IsSet).To(Equal(true)) Expect(quotaLimits.TotalServiceInstances.Value).To(Equal(2)) + Expect(quotaLimits.TotalLogVolume.IsSet).To(Equal(true)) + Expect(quotaLimits.TotalLogVolume.Value).To(Equal(8)) + Expect(testUI.Out).To(Say("Updating org quota %s as bob...", orgQuotaName)) Expect(testUI.Out).To(Say("OK")) }) @@ -137,7 +141,7 @@ var _ = Describe("UpdateOrgQuotaCommand", func() { When("only some org quota limits are updated", func() { BeforeEach(func() { - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 2048} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 2048} cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 2} fakeActor.UpdateOrganizationQuotaReturns( v7action.Warnings{"warning"}, @@ -169,6 +173,8 @@ var _ = Describe("UpdateOrgQuotaCommand", func() { Expect(quotaLimits.TotalReservedPorts).To(BeNil()) + Expect(quotaLimits.TotalLogVolume).To(BeNil()) + Expect(testUI.Out).To(Say("Updating org quota %s as bob...", orgQuotaName)) Expect(testUI.Out).To(Say("OK")) }) diff --git a/command/v7/update_route_command.go b/command/v7/update_route_command.go new file mode 100644 index 00000000000..1107f647a4d --- /dev/null +++ b/command/v7/update_route_command.go @@ -0,0 +1,137 @@ +package v7 + +import ( + "fmt" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" +) + +type UpdateRouteCommand struct { + BaseCommand + + RequiredArgs flag.Domain `positional-args:"yes"` + Hostname string `long:"hostname" short:"n" description:"Hostname for the HTTP route (required for shared domains)"` + Path flag.V7RoutePath `long:"path" description:"Path for the HTTP route"` + Options []string `long:"option" short:"o" description:"Set the value of a per-route option"` + RemoveOptions []string `long:"remove-option" short:"r" description:"Remove an option with the given name"` + relatedCommands interface{} `related_commands:"check-route, domains, map-route, routes, unmap-route"` +} + +func (cmd UpdateRouteCommand) Usage() string { + return ` +Update an existing HTTP route: + CF_NAME update-route DOMAIN [--hostname HOSTNAME] [--path PATH] [--option OPTION=VALUE] [--remove-option OPTION]` +} + +func (cmd UpdateRouteCommand) Examples() string { + return ` +CF_NAME update-route example.com -o loadbalancing=round-robin, +CF_NAME update-route example.com -o loadbalancing=least-connection, +CF_NAME update-route example.com -r loadbalancing, +CF_NAME update-route example.com --hostname myhost --path foo -o loadbalancing=round-robin` +} +func (cmd UpdateRouteCommand) Execute(args []string) error { + err := cmd.SharedActor.CheckTarget(true, true) + if err != nil { + return err + } + + user, err := cmd.Actor.GetCurrentUser() + if err != nil { + return err + } + + domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequiredArgs.Domain) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + + path := cmd.Path.Path + + route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0) + url := desiredURL(domain.Name, cmd.Hostname, path, 0) + cmd.UI.DisplayWarnings(warnings) + + if err != nil { + if _, ok := err.(actionerror.RouteNotFoundError); !ok { + return err + } + } + + // Update route only works for per route options. The command will fail instead instead of just + // ignoring the per-route options like it is the case for create-route and map-route. + err = cmd.validateAPIVersionForPerRouteOptions() + if err != nil { + return err + } + + if cmd.Options == nil && cmd.RemoveOptions == nil { + return actionerror.RouteOptionSupportError{ + ErrorText: fmt.Sprintf("No options were specified for the update of the Route %s", route.URL)} + } + + if len(cmd.Options) > 0 { + routeOpts, wrongOptSpec := resources.CreateRouteOptions(cmd.Options) + if wrongOptSpec != nil { + return actionerror.RouteOptionError{ + Name: *wrongOptSpec, + DomainName: domain.Name, + Path: path, + Host: cmd.Hostname, + } + } + + cmd.UI.DisplayTextWithFlavor("Updating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.User}}...", + map[string]interface{}{ + "URL": url, + "User": user.Name, + "SpaceName": cmd.Config.TargetedSpace().Name, + "OrgName": cmd.Config.TargetedOrganization().Name, + }) + route, warnings, err = cmd.Actor.UpdateRoute( + route.GUID, + routeOpts, + ) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + } + + if cmd.RemoveOptions != nil { + inputRouteOptions := resources.RemoveRouteOptions(cmd.RemoveOptions) + route, warnings, err = cmd.Actor.UpdateRoute( + route.GUID, + inputRouteOptions, + ) + cmd.UI.DisplayWarnings(warnings) + if err != nil { + return err + } + } + + cmd.UI.DisplayText("Route {{.URL}} has been updated", + map[string]interface{}{ + "URL": route.URL, + }) + cmd.UI.DisplayOK() + + return nil +} + +func (cmd UpdateRouteCommand) validateAPIVersionForPerRouteOptions() error { + err := command.MinimumCCAPIVersionCheck(cmd.Config.APIVersion(), ccversion.MinVersionPerRouteOpts) + if err != nil { + cmd.UI.DisplayWarning("Your CC API version ({{.APIVersion}}) does not support per-route options."+ + "Upgrade to a newer version of the API (minimum version {{.MinSupportedVersion}}). ", map[string]interface{}{ + "APIVersion": cmd.Config.APIVersion(), + "MinSupportedVersion": ccversion.MinVersionPerRouteOpts, + }) + } + return err +} diff --git a/command/v7/update_route_command_test.go b/command/v7/update_route_command_test.go new file mode 100644 index 00000000000..6ec367234ba --- /dev/null +++ b/command/v7/update_route_command_test.go @@ -0,0 +1,288 @@ +package v7_test + +import ( + "errors" + "fmt" + "strconv" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" +) + +var _ = Describe("update-route Command", func() { + var ( + cmd UpdateRouteCommand + testUI *ui.UI + fakeConfig *commandfakes.FakeConfig + fakeSharedActor *commandfakes.FakeSharedActor + fakeActor *v7fakes.FakeActor + input *Buffer + binaryName string + executeErr error + domain string + hostname string + path string + orgGUID string + spaceGUID string + commandOptions []string + removeOptions []string + options map[string]*string + cCAPIOldVersion string + routeGuid string + ) + + BeforeEach(func() { + input = NewBuffer() + testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) + fakeConfig = new(commandfakes.FakeConfig) + fakeSharedActor = new(commandfakes.FakeSharedActor) + fakeActor = new(v7fakes.FakeActor) + fakeConfig.APIVersionReturns(ccversion.MinVersionPerRouteOpts) + + binaryName = "faceman" + fakeConfig.BinaryNameReturns(binaryName) + domain = "some-domain.com" + hostname = "host" + path = `path` + orgGUID = "some-org-guid" + spaceGUID = "some-space-guid" + commandOptions = []string{"loadbalancing=least-connection"} + removeOptions = []string{"loadbalancing"} + lbLCVal := "least-connection" + lbLeastConnections := &lbLCVal + options = map[string]*string{"loadbalancing": lbLeastConnections} + routeGuid = "route-guid" + + cmd = UpdateRouteCommand{ + RequiredArgs: flag.Domain{Domain: domain}, + Hostname: hostname, + Path: flag.V7RoutePath{Path: path}, + Options: commandOptions, + RemoveOptions: removeOptions, + BaseCommand: BaseCommand{ + UI: testUI, + Config: fakeConfig, + SharedActor: fakeSharedActor, + Actor: fakeActor, + }, + } + + fakeConfig.TargetedOrganizationReturns(configv3.Organization{ + Name: "some-org", + GUID: orgGUID, + }) + + fakeConfig.TargetedSpaceReturns(configv3.Space{ + Name: "some-space", + GUID: spaceGUID, + }) + + fakeActor.GetCurrentUserReturns(configv3.User{Name: "steve"}, nil) + + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: routeGuid, URL: domain}, + v7action.Warnings{"get-route-warnings"}, + nil, + ) + }) + + JustBeforeEach(func() { + executeErr = cmd.Execute(nil) + }) + + When("checking target fails", func() { + BeforeEach(func() { + fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) + + Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) + checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) + Expect(checkTargetedOrg).To(BeTrue()) + Expect(checkTargetedSpace).To(BeTrue()) + }) + }) + + When("the user is not logged in", func() { + var expectedErr error + + BeforeEach(func() { + expectedErr = errors.New("some current user error") + fakeActor.GetCurrentUserReturns(configv3.User{}, expectedErr) + }) + + It("return an error", func() { + Expect(executeErr).To(Equal(expectedErr)) + }) + }) + + When("the user is logged in and targeted", func() { + When("getting the domain errors", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-domain-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) + + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) + + Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(0)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) + + Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) + + Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) + }) + }) + + When("getting the domain succeeds", func() { + BeforeEach(func() { + fakeActor.GetDomainByNameReturns( + resources.Domain{Name: "some-domain.com", GUID: "domain-guid"}, + v7action.Warnings{"get-domain-warnings"}, + nil, + ) + fakeActor.UpdateRouteReturns( + resources.Route{GUID: routeGuid, URL: domain, Options: options}, + nil, + nil, + ) + }) + When("updating the route fails when the CC API version is too old for route options", func() { + BeforeEach(func() { + cmd.Options = []string{} + cCAPIOldVersion = strconv.Itoa(1) + fakeConfig.APIVersionReturns(cCAPIOldVersion) + }) + + It("does not update a route giving the error message", func() { + Expect(executeErr).To(HaveOccurred()) + Expect(fakeActor.UpdateRouteCallCount()).To(Equal(0)) + Expect(testUI.Err).To(Say("CC API version")) + Expect(testUI.Err).To(Say("does not support per-route options")) + }) + }) + + When("the route options are not specified", func() { + BeforeEach(func() { + cmd.Options = nil + cmd.RemoveOptions = nil + }) + + It("does not update a route giving the error message", func() { + Expect(executeErr).To(MatchError(actionerror.RouteOptionSupportError{ + ErrorText: fmt.Sprintf("No options were specified for the update of the Route %s", domain)})) + Expect(fakeActor.UpdateRouteCallCount()).To(Equal(0)) + }) + }) + + When("the route options are specified incorrectly", func() { + BeforeEach(func() { + cmd.Options = []string{"loadbalancing"} + }) + It("does not update a route giving the error message", func() { + Expect(executeErr).To(MatchError(actionerror.RouteOptionError{Name: "loadbalancing", DomainName: domain, Path: path, Host: hostname})) + Expect(fakeActor.UpdateRouteCallCount()).To(Equal(0)) + }) + }) + + When("removing the options of the route succeeds", func() { + BeforeEach(func() { + cmd.RemoveOptions = []string{"loadbalancing"} + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: routeGuid, URL: domain, Options: options}, + nil, + nil, + ) + }) + + It("updates a given route", func() { + Expect(executeErr).ToNot(HaveOccurred()) + expectedRouteGuid, expectedOptions := fakeActor.UpdateRouteArgsForCall(0) + Expect(expectedRouteGuid).To(Equal(routeGuid)) + Expect(expectedOptions).To(Equal(options)) + + expectedRouteGuid, expectedOptions = fakeActor.UpdateRouteArgsForCall(1) + Expect(expectedRouteGuid).To(Equal(routeGuid)) + Expect(expectedOptions).To(Equal(map[string]*string{"loadbalancing": nil})) + Expect(fakeActor.UpdateRouteCallCount()).To(Equal(2)) + + Expect(testUI.Out).To(Say("Updating route")) + Expect(testUI.Out).To(Say("has been updated")) + Expect(testUI.Out).To(Say("OK")) + }) + }) + + When("a requested route exists", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{GUID: "route-guid", URL: domain}, + nil, + nil, + ) + }) + + It("calls update route passing the proper arguments", func() { + By("passing the expected arguments to the actor ", func() { + Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) + Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) + + Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) + actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) + Expect(actualDomain.Name).To(Equal("some-domain.com")) + Expect(actualDomain.GUID).To(Equal("domain-guid")) + Expect(actualHostname).To(Equal("host")) + Expect(actualPath).To(Equal(path)) + Expect(actualPort).To(Equal(0)) + + Expect(fakeActor.UpdateRouteCallCount()).To(Equal(2)) + actualRouteGUID, actualOptions := fakeActor.UpdateRouteArgsForCall(0) + Expect(actualRouteGUID).To(Equal("route-guid")) + Expect(actualOptions).To(Equal(options)) + + // Second update route call to remove the option + actualRouteGUID, actualOptions = fakeActor.UpdateRouteArgsForCall(1) + Expect(actualRouteGUID).To(Equal("route-guid")) + options["loadbalancing"] = nil + Expect(actualOptions).To(Equal(options)) + }) + }) + }) + }) + }) + + When("getting the route errors", func() { + BeforeEach(func() { + fakeActor.GetRouteByAttributesReturns( + resources.Route{}, + v7action.Warnings{"get-route-warnings"}, + errors.New("get-route-error"), + ) + }) + + It("returns the error and displays warnings", func() { + Expect(testUI.Err).To(Say("get-route-warnings")) + Expect(executeErr).To(MatchError(errors.New("get-route-error"))) + }) + }) + +}) diff --git a/command/v7/update_security_group_command.go b/command/v7/update_security_group_command.go index 6fdbbd3f6e2..47846ca1518 100644 --- a/command/v7/update_security_group_command.go +++ b/command/v7/update_security_group_command.go @@ -3,15 +3,15 @@ package v7 import ( "encoding/json" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" ) type UpdateSecurityGroupCommand struct { BaseCommand RequiredArgs flag.SecurityGroupArgs `positional-args:"yes"` - usage interface{} `usage:"CF_NAME update-security-group SECURITY_GROUP PATH_TO_JSON_RULES_FILE\n\n The provided path can be an absolute or relative path to a file. The file should have\n a single array with JSON objects inside describing the rules. The JSON Base Object is\n omitted and only the square brackets and associated child object are required in the file.\n\n Valid json file example:\n [\n {\n \"protocol\": \"tcp\",\n \"destination\": \"10.0.11.0/24\",\n \"ports\": \"80,443\",\n \"description\": \"Allow http and https traffic from ZoneA\"\n }\n ]\n\nTIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications."` + usage interface{} `usage:"CF_NAME update-security-group SECURITY_GROUP PATH_TO_JSON_RULES_FILE\n\n The provided path can be an absolute or relative path to a file. The file should have\n a single array with JSON objects inside describing the rules. The JSON Base Object is\n omitted and only the square brackets and associated child object are required in the file.\n\n Valid json file example:\n [\n {\n \"protocol\": \"tcp\",\n \"destination\": \"10.0.11.0/24\",\n \"ports\": \"80,443\",\n \"description\": \"Allow http and https traffic from ZoneA\"\n }\n ]\n\nTIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications."` relatedCommands interface{} `related_commands:"restage, security-groups"` } @@ -44,6 +44,6 @@ func (cmd UpdateSecurityGroupCommand) Execute(args []string) error { cmd.UI.DisplayOK() cmd.UI.DisplayNewline() - cmd.UI.DisplayText("TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications.") + cmd.UI.DisplayText("TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications.") return nil } diff --git a/command/v7/update_security_group_command_test.go b/command/v7/update_security_group_command_test.go index cc4b82fdbae..e59beea631d 100644 --- a/command/v7/update_security_group_command_test.go +++ b/command/v7/update_security_group_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "encoding/json" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/update_service_broker_command.go b/command/v7/update_service_broker_command.go index 8380755d656..15620eb0cd7 100644 --- a/command/v7/update_service_broker_command.go +++ b/command/v7/update_service_broker_command.go @@ -1,16 +1,20 @@ package v7 import ( - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" ) type UpdateServiceBrokerCommand struct { BaseCommand - RequiredArgs flag.ServiceBrokerArgs `positional-args:"yes"` - usage interface{} `usage:"CF_NAME update-service-broker SERVICE_BROKER USERNAME PASSWORD URL"` - relatedCommands interface{} `related_commands:"rename-service-broker, service-brokers"` + PositionalArgs flag.ServiceBrokerArgs `positional-args:"yes"` + usage any `usage:"CF_NAME update-service-broker SERVICE_BROKER USERNAME PASSWORD URL\n CF_NAME update-service-broker SERVICE_BROKER USERNAME URL (omit password to specify interactively or via environment variable)\n\nWARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history"` + relatedCommands any `related_commands:"rename-service-broker, service-brokers"` + + // This field is not used, it is only present to ensure we print the description as part of the usage of the command + envPassword any `environmentName:"CF_BROKER_PASSWORD" environmentDescription:"Password associated with user. Overridden if PASSWORD argument is provided" environmentDefault:"password"` //nolint:unused } func (cmd UpdateServiceBrokerCommand) Execute(args []string) error { @@ -18,7 +22,12 @@ func (cmd UpdateServiceBrokerCommand) Execute(args []string) error { return err } - serviceBroker, warnings, err := cmd.Actor.GetServiceBrokerByName(cmd.RequiredArgs.ServiceBroker) + brokerName, username, password, url, err := promptUserForBrokerPasswordIfRequired(cmd.PositionalArgs, cmd.UI) + if err != nil { + return err + } + + serviceBroker, warnings, err := cmd.Actor.GetServiceBrokerByName(brokerName) cmd.UI.DisplayWarnings(warnings) if err != nil { return err @@ -29,28 +38,32 @@ func (cmd UpdateServiceBrokerCommand) Execute(args []string) error { return err } - cmd.UI.DisplayTextWithFlavor( + return updateServiceBroker(cmd.UI, cmd.Actor, user.Name, serviceBroker.GUID, brokerName, username, password, url) +} + +func updateServiceBroker(ui command.UI, actor Actor, user, brokerGUID, brokerName, username, password, url string) error { + ui.DisplayTextWithFlavor( "Updating service broker {{.ServiceBroker}} as {{.Username}}...", - map[string]interface{}{ - "Username": user.Name, - "ServiceBroker": cmd.RequiredArgs.ServiceBroker, + map[string]any{ + "Username": user, + "ServiceBroker": brokerName, }, ) - warnings, err = cmd.Actor.UpdateServiceBroker( - serviceBroker.GUID, + warnings, err := actor.UpdateServiceBroker( + brokerGUID, resources.ServiceBroker{ - Username: cmd.RequiredArgs.Username, - Password: cmd.RequiredArgs.Password, - URL: cmd.RequiredArgs.URL, + Username: username, + Password: password, + URL: url, }, ) - cmd.UI.DisplayWarnings(warnings) + ui.DisplayWarnings(warnings) if err != nil { return err } - cmd.UI.DisplayOK() + ui.DisplayOK() return nil } diff --git a/command/v7/update_service_broker_command_test.go b/command/v7/update_service_broker_command_test.go index d3a2b658bc4..d4ab809f141 100644 --- a/command/v7/update_service_broker_command_test.go +++ b/command/v7/update_service_broker_command_test.go @@ -1,16 +1,19 @@ package v7_test import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/cf/errors" - "code.cloudfoundry.org/cli/command/commandfakes" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "fmt" + "os" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/cf/errors" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -29,13 +32,15 @@ var _ = Describe("update-service-broker command", func() { fakeUpdateServiceBrokerActor *v7fakes.FakeActor fakeSharedActor *commandfakes.FakeSharedActor fakeConfig *commandfakes.FakeConfig + input *Buffer testUI *ui.UI ) BeforeEach(func() { fakeUpdateServiceBrokerActor = &v7fakes.FakeActor{} fakeSharedActor = &commandfakes.FakeSharedActor{} - testUI = ui.NewTestUI(NewBuffer(), NewBuffer(), NewBuffer()) + input = NewBuffer() + testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) fakeConfig = &commandfakes.FakeConfig{} cmd = &v7.UpdateServiceBrokerCommand{ BaseCommand: v7.BaseCommand{ @@ -45,8 +50,6 @@ var _ = Describe("update-service-broker command", func() { Config: fakeConfig, }, } - - setPositionalFlags(cmd, serviceBrokerName, username, password, url) }) When("logged in", func() { @@ -60,6 +63,8 @@ var _ = Describe("update-service-broker command", func() { ) fakeUpdateServiceBrokerActor.GetCurrentUserReturns(configv3.User{Name: "user"}, nil) + + setPositionalFlags(cmd, serviceBrokerName, username, password, url) }) It("succeeds", func() { @@ -123,6 +128,64 @@ var _ = Describe("update-service-broker command", func() { Expect(err).To(MatchError("no user found")) }) }) + + When("password is provided as environment variable", func() { + const ( + varName = "CF_BROKER_PASSWORD" + varPassword = "var-password" + ) + + BeforeEach(func() { + setPositionalFlags(cmd, serviceBrokerName, username, url, "") + os.Setenv(varName, varPassword) + + Expect(cmd.Execute(nil)).To(Succeed()) + }) + + AfterEach(func() { + os.Unsetenv(varName) + }) + + It("passes the data to the actor layer", func() { + Expect(fakeUpdateServiceBrokerActor.UpdateServiceBrokerCallCount()).To(Equal(1)) + serviceBrokerGUID, model := fakeUpdateServiceBrokerActor.UpdateServiceBrokerArgsForCall(0) + Expect(serviceBrokerGUID).To(Equal(guid)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(varPassword)) + Expect(model.URL).To(Equal(url)) + }) + }) + + When("password is provided via prompt", func() { + const promptPassword = "prompt-password" + + BeforeEach(func() { + setPositionalFlags(cmd, serviceBrokerName, username, url, "") + + _, err := input.Write([]byte(fmt.Sprintf("%s\n", promptPassword))) + Expect(err).NotTo(HaveOccurred()) + + Expect(cmd.Execute(nil)).To(Succeed()) + }) + + It("prompts the user for credentials", func() { + Expect(testUI.Out).To(Say("Service Broker Password: ")) + }) + + It("does not echo the credentials", func() { + Expect(testUI.Out).NotTo(Say(promptPassword)) + Expect(testUI.Err).NotTo(Say(promptPassword)) + }) + + It("passes the data to the actor layer", func() { + Expect(fakeUpdateServiceBrokerActor.UpdateServiceBrokerCallCount()).To(Equal(1)) + serviceBrokerGUID, model := fakeUpdateServiceBrokerActor.UpdateServiceBrokerArgsForCall(0) + Expect(serviceBrokerGUID).To(Equal(guid)) + Expect(model.Username).To(Equal(username)) + Expect(model.Password).To(Equal(promptPassword)) + Expect(model.URL).To(Equal(url)) + }) + }) }) When("not logged in", func() { diff --git a/command/v7/update_service_command.go b/command/v7/update_service_command.go index 289cec1ed8c..2c10086cff3 100644 --- a/command/v7/update_service_command.go +++ b/command/v7/update_service_command.go @@ -4,11 +4,11 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/v7/shared" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/v7/shared" + "code.cloudfoundry.org/cli/v8/types" ) type UpdateServiceCommand struct { diff --git a/command/v7/update_service_command_test.go b/command/v7/update_service_command_test.go index 5e9a55b1f49..4d81b73ddb9 100644 --- a/command/v7/update_service_command_test.go +++ b/command/v7/update_service_command_test.go @@ -4,16 +4,16 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/update_space_quota_command.go b/command/v7/update_space_quota_command.go index c2905ecae64..03d44980937 100644 --- a/command/v7/update_space_quota_command.go +++ b/command/v7/update_space_quota_command.go @@ -1,26 +1,28 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) type UpdateSpaceQuotaCommand struct { BaseCommand - RequiredArgs flag.SpaceQuota `positional-args:"Yes"` - NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` - PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` - NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` - PerProcessMemory flag.MemoryWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` - TotalMemory flag.MemoryWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` - NewName string `short:"n" description:"New name"` - TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` - TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` - TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` - usage interface{} `usage:"CF_NAME update-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS]"` - relatedCommands interface{} `related_commands:"space, space-quota, space-quotas"` + RequiredArgs flag.SpaceQuota `positional-args:"Yes"` + NumAppInstances flag.IntegerLimit `short:"a" description:"Total number of application instances. -1 represents an unlimited amount."` + PaidServicePlans bool `long:"allow-paid-service-plans" description:"Allow provisioning instances of paid service plans."` + NoPaidServicePlans bool `long:"disallow-paid-service-plans" description:"Disallow provisioning instances of paid service plans."` + PerProcessMemory flag.MegabytesWithUnlimited `short:"i" description:"Maximum amount of memory a process can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` + TotalMemory flag.MegabytesWithUnlimited `short:"m" description:"Total amount of memory all processes can have (e.g. 1024M, 1G, 10G). -1 represents an unlimited amount."` + NewName string `short:"n" description:"New name"` + TotalRoutes flag.IntegerLimit `short:"r" description:"Total number of routes. -1 represents an unlimited amount."` + TotalReservedPorts flag.IntegerLimit `long:"reserved-route-ports" description:"Maximum number of routes that may be created with ports. -1 represents an unlimited amount."` + TotalServiceInstances flag.IntegerLimit `short:"s" description:"Total number of service instances. -1 represents an unlimited amount."` + TotalLogVolume flag.BytesWithUnlimited `short:"l" description:"Total log volume per second all processes can have, in bytes (e.g. 128B, 4K, 1M). -1 represents an unlimited amount."` + + usage interface{} `usage:"CF_NAME update-space-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [-a APP_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans] [--reserved-route-ports RESERVED_ROUTE_PORTS] [-l LOG_VOLUME]"` + relatedCommands interface{} `related_commands:"space, space-quota, space-quotas"` } func (cmd UpdateSpaceQuotaCommand) Execute(args []string) error { @@ -63,6 +65,7 @@ func (cmd UpdateSpaceQuotaCommand) Execute(args []string) error { TotalServiceInstances: convertIntegerLimitFlagToNullInt(cmd.TotalServiceInstances), TotalRoutes: convertIntegerLimitFlagToNullInt(cmd.TotalRoutes), TotalReservedPorts: convertIntegerLimitFlagToNullInt(cmd.TotalReservedPorts), + TotalLogVolume: convertBytesFlagToNullInt(cmd.TotalLogVolume), } warnings, err := cmd.Actor.UpdateSpaceQuota(oldQuotaName, orgGUID, cmd.NewName, updatedQuotaLimits) diff --git a/command/v7/update_space_quota_command_test.go b/command/v7/update_space_quota_command_test.go index 2caf0945a62..3f3ba55b810 100644 --- a/command/v7/update_space_quota_command_test.go +++ b/command/v7/update_space_quota_command_test.go @@ -3,17 +3,17 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/command/translatableerror" - - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/flag" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/flag" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -94,11 +94,12 @@ var _ = Describe("UpdateSpaceQuotaCommand", func() { cmd.NewName = "new-space-quota-name" cmd.PaidServicePlans = true cmd.NumAppInstances = flag.IntegerLimit{IsSet: true, Value: 10} - cmd.PerProcessMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 9} - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 2048} + cmd.PerProcessMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 9} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 2048} cmd.TotalRoutes = flag.IntegerLimit{IsSet: true, Value: 7} cmd.TotalReservedPorts = flag.IntegerLimit{IsSet: true, Value: 1} cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 2} + cmd.TotalLogVolume = flag.BytesWithUnlimited{IsSet: true, Value: 512} fakeActor.UpdateSpaceQuotaReturns( v7action.Warnings{"warning"}, nil) @@ -134,6 +135,9 @@ var _ = Describe("UpdateSpaceQuotaCommand", func() { Expect(quotaLimits.TotalServiceInstances.IsSet).To(Equal(true)) Expect(quotaLimits.TotalServiceInstances.Value).To(Equal(2)) + Expect(quotaLimits.TotalLogVolume.IsSet).To(Equal(true)) + Expect(quotaLimits.TotalLogVolume.Value).To(Equal(512)) + Expect(testUI.Out).To(Say("Updating space quota %s for org %s as bob...", spaceQuotaName, orgName)) Expect(testUI.Out).To(Say("OK")) }) @@ -141,7 +145,7 @@ var _ = Describe("UpdateSpaceQuotaCommand", func() { When("only some org quota limits are updated", func() { BeforeEach(func() { - cmd.TotalMemory = flag.MemoryWithUnlimited{IsSet: true, Value: 2048} + cmd.TotalMemory = flag.MegabytesWithUnlimited{IsSet: true, Value: 2048} cmd.TotalServiceInstances = flag.IntegerLimit{IsSet: true, Value: 2} fakeActor.UpdateSpaceQuotaReturns( v7action.Warnings{"warning"}, @@ -174,6 +178,8 @@ var _ = Describe("UpdateSpaceQuotaCommand", func() { Expect(quotaLimits.TotalReservedPorts).To(BeNil()) + Expect(quotaLimits.TotalLogVolume).To(BeNil()) + Expect(testUI.Out).To(Say("Updating space quota %s for org %s as bob...", spaceQuotaName, orgName)) Expect(testUI.Out).To(Say("OK")) }) diff --git a/command/v7/update_user_provided_service_command.go b/command/v7/update_user_provided_service_command.go index 71b9eb1a6e4..ce10d10fafe 100644 --- a/command/v7/update_user_provided_service_command.go +++ b/command/v7/update_user_provided_service_command.go @@ -1,11 +1,11 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" ) type UpdateUserProvidedServiceCommand struct { @@ -25,7 +25,7 @@ func (cmd *UpdateUserProvidedServiceCommand) Execute(args []string) error { return err } - if err := PromptUserForCredentialsIfRequired(&cmd.Credentials, cmd.UI); err != nil { + if err := promptUserForCredentialsIfRequired(&cmd.Credentials, cmd.UI); err != nil { return err } diff --git a/command/v7/update_user_provided_service_command_test.go b/command/v7/update_user_provided_service_command_test.go index ac55f322aa7..4679e02fe1c 100644 --- a/command/v7/update_user_provided_service_command_test.go +++ b/command/v7/update_user_provided_service_command_test.go @@ -3,20 +3,20 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccerror" + + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) diff --git a/command/v7/upgrade_service_command.go b/command/v7/upgrade_service_command.go index 81bd39a065a..fccd0133612 100644 --- a/command/v7/upgrade_service_command.go +++ b/command/v7/upgrade_service_command.go @@ -1,9 +1,10 @@ package v7 import ( - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/v7/shared" ) type UpgradeServiceCommand struct { @@ -11,6 +12,7 @@ type UpgradeServiceCommand struct { RequiredArgs flag.ServiceInstance `positional-args:"yes"` Force bool `short:"f" long:"force" description:"Force upgrade without asking for confirmation"` + Wait bool `short:"w" long:"wait" description:"Wait for the operation to complete"` relatedCommands interface{} `related_commands:"services, update-service, update-user-provided-service"` } @@ -38,7 +40,7 @@ func (cmd UpgradeServiceCommand) Execute(args []string) error { serviceInstanceName := string(cmd.RequiredArgs.ServiceInstance) - warnings, actorError := cmd.Actor.UpgradeManagedServiceInstance( + stream, warnings, actorError := cmd.Actor.UpgradeManagedServiceInstance( serviceInstanceName, cmd.Config.TargetedSpace().GUID, ) @@ -46,8 +48,6 @@ func (cmd UpgradeServiceCommand) Execute(args []string) error { switch actorError.(type) { case nil: - cmd.displayUpgradeInProgressMessage() - cmd.UI.DisplayOK() case actionerror.ServiceInstanceUpgradeNotAvailableError: cmd.UI.DisplayText(actorError.Error()) cmd.UI.DisplayOK() @@ -57,6 +57,17 @@ func (cmd UpgradeServiceCommand) Execute(args []string) error { return actorError } + complete, err := shared.WaitForResult(stream, cmd.UI, cmd.Wait) + switch { + case err != nil: + return err + case complete: + cmd.UI.DisplayTextWithFlavor("Upgrade of service instance {{.ServiceInstanceName}} complete.", cmd.serviceInstanceName()) + default: + cmd.UI.DisplayTextWithFlavor("Upgrade in progress. Use 'cf services' or 'cf service {{.ServiceInstanceName}}' to check operation status.", cmd.serviceInstanceName()) + } + + cmd.UI.DisplayOK() return nil } @@ -79,6 +90,7 @@ func (cmd UpgradeServiceCommand) displayEvent() error { "Username": user.Name, }, ) + cmd.UI.DisplayNewline() return nil } @@ -101,15 +113,8 @@ func (cmd UpgradeServiceCommand) displayPrompt() (bool, error) { return upgrade, nil } -func (cmd UpgradeServiceCommand) displayUpgradeInProgressMessage() { - cmd.UI.DisplayTextWithFlavor("Upgrade in progress. Use 'cf services' or 'cf service {{.ServiceInstance}}' to check operation status.", - map[string]interface{}{ - "ServiceInstance": cmd.RequiredArgs.ServiceInstance, - }) -} - -func (cmd UpgradeServiceCommand) serviceInstanceName() map[string]interface{} { - return map[string]interface{}{ +func (cmd UpgradeServiceCommand) serviceInstanceName() map[string]any { + return map[string]any{ "ServiceInstanceName": cmd.RequiredArgs.ServiceInstance, } } diff --git a/command/v7/upgrade_service_command_test.go b/command/v7/upgrade_service_command_test.go index bc8aa3f54fa..3c8acb319c3 100644 --- a/command/v7/upgrade_service_command_test.go +++ b/command/v7/upgrade_service_command_test.go @@ -3,15 +3,15 @@ package v7_test import ( "errors" - "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/command/v7/v7fakes" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/actor/actionerror" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/command/commandfakes" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + . "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/command/v7/v7fakes" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" ) @@ -76,6 +76,7 @@ var _ = Describe("upgrade-service command", func() { When("the service instance does not exist", func() { BeforeEach(func() { fakeActor.UpgradeManagedServiceInstanceReturns( + nil, v7action.Warnings{"upgrade warning"}, actionerror.ServiceInstanceNotFoundError{Name: serviceInstanceName}, ) @@ -89,37 +90,126 @@ var _ = Describe("upgrade-service command", func() { }) }) - When("the service instance upgrade starts successfully", func() { + When("the actor returns an unexpected error", func() { BeforeEach(func() { fakeActor.UpgradeManagedServiceInstanceReturns( + make(chan v7action.PollJobEvent), v7action.Warnings{"upgrade warning"}, - nil, + errors.New("bang"), ) }) - It("succeeds with a message", func() { - Expect(executeErr).NotTo(HaveOccurred()) + It("fails with warnings", func() { + Expect(executeErr).To(MatchError("bang")) Expect(testUI.Err).To(Say("upgrade warning")) + Expect(testUI.Out).NotTo(Say("OK")) + }) + }) + + When("stream goes to polling", func() { + BeforeEach(func() { + fakeStream := make(chan v7action.PollJobEvent) + fakeActor.UpgradeManagedServiceInstanceReturns( + fakeStream, + v7action.Warnings{"actor warning"}, + nil, + ) + + go func() { + fakeStream <- v7action.PollJobEvent{ + State: v7action.JobPolling, + Warnings: v7action.Warnings{"poll warning"}, + } + }() + }) + + It("prints messages and warnings", func() { Expect(testUI.Out).To(SatisfyAll( - Say("\n"), - Say(`Upgrade in progress. Use 'cf services' or 'cf service %s' to check operation status\.\n`, serviceInstanceName), - Say("OK\n"), + Say(`Upgrading service instance %s in org %s / space %s as %s...\n`, serviceInstanceName, orgName, spaceName, username), + Say(`\n`), + Say(`Upgrade in progress. Use 'cf services' or 'cf service %s' to check operation status\.`, serviceInstanceName), + Say(`OK\n`), + )) + + Expect(testUI.Err).To(SatisfyAll( + Say("actor warning"), + Say("poll warning"), )) }) }) - When("the actor returns an unexpected error", func() { + When("error in event stream", func() { BeforeEach(func() { + setFlag(&cmd, "--wait") + + fakeStream := make(chan v7action.PollJobEvent) fakeActor.UpgradeManagedServiceInstanceReturns( - v7action.Warnings{"upgrade warning"}, - errors.New("bang"), + fakeStream, + v7action.Warnings{"a warning"}, + nil, ) + + go func() { + fakeStream <- v7action.PollJobEvent{ + State: v7action.JobPolling, + Warnings: v7action.Warnings{"poll warning"}, + } + fakeStream <- v7action.PollJobEvent{ + State: v7action.JobFailed, + Warnings: v7action.Warnings{"failed warning"}, + Err: errors.New("boom"), + } + }() }) - It("fails with warnings", func() { - Expect(executeErr).To(MatchError("bang")) - Expect(testUI.Err).To(Say("upgrade warning")) - Expect(testUI.Out).NotTo(Say("OK")) + It("returns the error and prints warnings", func() { + Expect(executeErr).To(MatchError("boom")) + Expect(testUI.Err).To(SatisfyAll( + Say("poll warning"), + Say("failed warning"), + )) + }) + }) + + When("--wait flag specified", func() { + BeforeEach(func() { + setFlag(&cmd, "--wait") + + fakeStream := make(chan v7action.PollJobEvent) + fakeActor.UpgradeManagedServiceInstanceReturns( + fakeStream, + v7action.Warnings{"a warning"}, + nil, + ) + + go func() { + fakeStream <- v7action.PollJobEvent{ + State: v7action.JobPolling, + Warnings: v7action.Warnings{"poll warning"}, + } + fakeStream <- v7action.PollJobEvent{ + State: v7action.JobComplete, + Warnings: v7action.Warnings{"failed warning"}, + } + close(fakeStream) + }() + }) + + It("prints messages and warnings", func() { + Expect(testUI.Out).To(SatisfyAll( + Say(`Upgrading service instance %s in org %s / space %s as %s...\n`, serviceInstanceName, orgName, spaceName, username), + Say(`\n`), + Say(`Waiting for the operation to complete\.\.\n`), + Say(`\n`), + Say(`Upgrade of service instance %s complete\.\n`, serviceInstanceName), + Say(`OK\n`), + )) + + Expect(testUI.Err).To(SatisfyAll( + Say("a warning"), + Say("poll warning"), + Say("failed warning"), + )) }) }) } diff --git a/command/v7/v7_suite_test.go b/command/v7/v7_suite_test.go index 6fc2ad1cd9c..8a1af2c03a2 100644 --- a/command/v7/v7_suite_test.go +++ b/command/v7/v7_suite_test.go @@ -4,13 +4,12 @@ import ( "fmt" "reflect" "strings" + "testing" uuid "github.com/nu7hatch/gouuid" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" - - "testing" ) func TestV3(t *testing.T) { @@ -75,7 +74,7 @@ func setFlag(cmd interface{}, flag string, values ...interface{}) { case value.Type().ConvertibleTo(field.Type): val.Field(i).Set(value.Convert(field.Type)) return - case reflect.PtrTo(field.Type).Implements(reflect.TypeOf((*interface{ UnmarshalFlag(string) error })(nil)).Elem()): + case reflect.PointerTo(field.Type).Implements(reflect.TypeOf((*interface{ UnmarshalFlag(string) error })(nil)).Elem()): elem := reflect.New(field.Type) e := elem.MethodByName("UnmarshalFlag").Call([]reflect.Value{value}) if !e[0].IsNil() { diff --git a/command/v7/v7fakes/fake_actor.go b/command/v7/v7fakes/fake_actor.go index 8065bc84341..80cd8d0e79d 100644 --- a/command/v7/v7fakes/fake_actor.go +++ b/command/v7/v7fakes/fake_actor.go @@ -8,16 +8,16 @@ import ( "sync" "time" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - constanta "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/api/uaa/constant" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + constanta "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/uaa/constant" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" "github.com/SermoDigital/jose/jwt" ) @@ -128,6 +128,19 @@ type FakeActor struct { clearTargetMutex sync.RWMutex clearTargetArgsForCall []struct { } + ContinueDeploymentStub func(string) (v7action.Warnings, error) + continueDeploymentMutex sync.RWMutex + continueDeploymentArgsForCall []struct { + arg1 string + } + continueDeploymentReturns struct { + result1 v7action.Warnings + result2 error + } + continueDeploymentReturnsOnCall map[int]struct { + result1 v7action.Warnings + result2 error + } CopyPackageStub func(resources.Application, resources.Application) (resources.Package, v7action.Warnings, error) copyPackageMutex sync.RWMutex copyPackageArgsForCall []struct { @@ -222,34 +235,17 @@ type FakeActor struct { result2 v7action.Warnings result3 error } - CreateDeploymentByApplicationAndDropletStub func(string, string) (string, v7action.Warnings, error) - createDeploymentByApplicationAndDropletMutex sync.RWMutex - createDeploymentByApplicationAndDropletArgsForCall []struct { - arg1 string - arg2 string - } - createDeploymentByApplicationAndDropletReturns struct { - result1 string - result2 v7action.Warnings - result3 error - } - createDeploymentByApplicationAndDropletReturnsOnCall map[int]struct { - result1 string - result2 v7action.Warnings - result3 error - } - CreateDeploymentByApplicationAndRevisionStub func(string, string) (string, v7action.Warnings, error) - createDeploymentByApplicationAndRevisionMutex sync.RWMutex - createDeploymentByApplicationAndRevisionArgsForCall []struct { - arg1 string - arg2 string + CreateDeploymentStub func(resources.Deployment) (string, v7action.Warnings, error) + createDeploymentMutex sync.RWMutex + createDeploymentArgsForCall []struct { + arg1 resources.Deployment } - createDeploymentByApplicationAndRevisionReturns struct { + createDeploymentReturns struct { result1 string result2 v7action.Warnings result3 error } - createDeploymentByApplicationAndRevisionReturnsOnCall map[int]struct { + createDeploymentReturnsOnCall map[int]struct { result1 string result2 v7action.Warnings result3 error @@ -375,7 +371,7 @@ type FakeActor struct { result1 v7action.Warnings result2 error } - CreateRouteStub func(string, string, string, string, int) (resources.Route, v7action.Warnings, error) + CreateRouteStub func(string, string, string, string, int, map[string]*string) (resources.Route, v7action.Warnings, error) createRouteMutex sync.RWMutex createRouteArgsForCall []struct { arg1 string @@ -383,6 +379,7 @@ type FakeActor struct { arg3 string arg4 string arg5 int + arg6 map[string]*string } createRouteReturns struct { result1 resources.Route @@ -575,17 +572,18 @@ type FakeActor struct { result1 v7action.Warnings result2 error } - DeleteBuildpackByNameAndStackStub func(string, string) (v7action.Warnings, error) - deleteBuildpackByNameAndStackMutex sync.RWMutex - deleteBuildpackByNameAndStackArgsForCall []struct { + DeleteBuildpackByNameAndStackAndLifecycleStub func(string, string, string) (v7action.Warnings, error) + deleteBuildpackByNameAndStackAndLifecycleMutex sync.RWMutex + deleteBuildpackByNameAndStackAndLifecycleArgsForCall []struct { arg1 string arg2 string + arg3 string } - deleteBuildpackByNameAndStackReturns struct { + deleteBuildpackByNameAndStackAndLifecycleReturns struct { result1 v7action.Warnings result2 error } - deleteBuildpackByNameAndStackReturnsOnCall map[int]struct { + deleteBuildpackByNameAndStackAndLifecycleReturnsOnCall map[int]struct { result1 v7action.Warnings result2 error } @@ -1007,11 +1005,12 @@ type FakeActor struct { result2 v7action.Warnings result3 error } - GetAppSummariesForSpaceStub func(string, string) ([]v7action.ApplicationSummary, v7action.Warnings, error) + GetAppSummariesForSpaceStub func(string, string, bool) ([]v7action.ApplicationSummary, v7action.Warnings, error) getAppSummariesForSpaceMutex sync.RWMutex getAppSummariesForSpaceArgsForCall []struct { arg1 string arg2 string + arg3 bool } getAppSummariesForSpaceReturns struct { result1 []v7action.ApplicationSummary @@ -1118,6 +1117,22 @@ type FakeActor struct { result2 v7action.Warnings result3 error } + GetApplicationProcessReadinessHealthChecksByNameAndSpaceStub func(string, string) ([]v7action.ProcessReadinessHealthCheck, v7action.Warnings, error) + getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex sync.RWMutex + getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall []struct { + arg1 string + arg2 string + } + getApplicationProcessReadinessHealthChecksByNameAndSpaceReturns struct { + result1 []v7action.ProcessReadinessHealthCheck + result2 v7action.Warnings + result3 error + } + getApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall map[int]struct { + result1 []v7action.ProcessReadinessHealthCheck + result2 v7action.Warnings + result3 error + } GetApplicationRevisionsDeployedStub func(string) ([]resources.Revision, v7action.Warnings, error) getApplicationRevisionsDeployedMutex sync.RWMutex getApplicationRevisionsDeployedArgsForCall []struct { @@ -1164,6 +1179,21 @@ type FakeActor struct { result2 v7action.Warnings result3 error } + GetApplicationsByGUIDsStub func([]string) ([]resources.Application, v7action.Warnings, error) + getApplicationsByGUIDsMutex sync.RWMutex + getApplicationsByGUIDsArgsForCall []struct { + arg1 []string + } + getApplicationsByGUIDsReturns struct { + result1 []resources.Application + result2 v7action.Warnings + result3 error + } + getApplicationsByGUIDsReturnsOnCall map[int]struct { + result1 []resources.Application + result2 v7action.Warnings + result3 error + } GetApplicationsByNamesAndSpaceStub func([]string, string) ([]resources.Application, v7action.Warnings, error) getApplicationsByNamesAndSpaceMutex sync.RWMutex getApplicationsByNamesAndSpaceArgsForCall []struct { @@ -1180,11 +1210,12 @@ type FakeActor struct { result2 v7action.Warnings result3 error } - GetBuildpackLabelsStub func(string, string) (map[string]types.NullString, v7action.Warnings, error) + GetBuildpackLabelsStub func(string, string, string) (map[string]types.NullString, v7action.Warnings, error) getBuildpackLabelsMutex sync.RWMutex getBuildpackLabelsArgsForCall []struct { arg1 string arg2 string + arg3 string } getBuildpackLabelsReturns struct { result1 map[string]types.NullString @@ -1196,10 +1227,11 @@ type FakeActor struct { result2 v7action.Warnings result3 error } - GetBuildpacksStub func(string) ([]resources.Buildpack, v7action.Warnings, error) + GetBuildpacksStub func(string, string) ([]resources.Buildpack, v7action.Warnings, error) getBuildpacksMutex sync.RWMutex getBuildpacksArgsForCall []struct { arg1 string + arg2 string } getBuildpacksReturns struct { result1 []resources.Buildpack @@ -1331,6 +1363,23 @@ type FakeActor struct { result2 v7action.Warnings result3 error } + GetEnvironmentVariableGroupByRevisionStub func(resources.Revision) (v7action.EnvironmentVariableGroup, bool, v7action.Warnings, error) + getEnvironmentVariableGroupByRevisionMutex sync.RWMutex + getEnvironmentVariableGroupByRevisionArgsForCall []struct { + arg1 resources.Revision + } + getEnvironmentVariableGroupByRevisionReturns struct { + result1 v7action.EnvironmentVariableGroup + result2 bool + result3 v7action.Warnings + result4 error + } + getEnvironmentVariableGroupByRevisionReturnsOnCall map[int]struct { + result1 v7action.EnvironmentVariableGroup + result2 bool + result3 v7action.Warnings + result4 error + } GetEnvironmentVariablesByApplicationNameAndSpaceStub func(string, string) (v7action.EnvironmentVariableGroups, v7action.Warnings, error) getEnvironmentVariablesByApplicationNameAndSpaceMutex sync.RWMutex getEnvironmentVariablesByApplicationNameAndSpaceArgsForCall []struct { @@ -1404,6 +1453,20 @@ type FakeActor struct { result2 v7action.Warnings result3 error } + GetInfoResponseStub func() (v7action.Info, v7action.Warnings, error) + getInfoResponseMutex sync.RWMutex + getInfoResponseArgsForCall []struct { + } + getInfoResponseReturns struct { + result1 v7action.Info + result2 v7action.Warnings + result3 error + } + getInfoResponseReturnsOnCall map[int]struct { + result1 v7action.Info + result2 v7action.Warnings + result3 error + } GetIsolationSegmentByNameStub func(string) (resources.IsolationSegment, v7action.Warnings, error) getIsolationSegmentByNameMutex sync.RWMutex getIsolationSegmentByNameArgsForCall []struct { @@ -1738,17 +1801,17 @@ type FakeActor struct { result2 v7action.Warnings result3 error } - GetRootResponseStub func() (v7action.Info, v7action.Warnings, error) + GetRootResponseStub func() (v7action.Root, v7action.Warnings, error) getRootResponseMutex sync.RWMutex getRootResponseArgsForCall []struct { } getRootResponseReturns struct { - result1 v7action.Info + result1 v7action.Root result2 v7action.Warnings result3 error } getRootResponseReturnsOnCall map[int]struct { - result1 v7action.Info + result1 v7action.Root result2 v7action.Warnings result3 error } @@ -2489,6 +2552,20 @@ type FakeActor struct { result2 v7action.Warnings result3 error } + MoveRouteStub func(string, string) (v7action.Warnings, error) + moveRouteMutex sync.RWMutex + moveRouteArgsForCall []struct { + arg1 string + arg2 string + } + moveRouteReturns struct { + result1 v7action.Warnings + result2 error + } + moveRouteReturnsOnCall map[int]struct { + result1 v7action.Warnings + result2 error + } ParseAccessTokenStub func(string) (jwt.JWT, error) parseAccessTokenMutex sync.RWMutex parseAccessTokenArgsForCall []struct { @@ -2548,22 +2625,37 @@ type FakeActor struct { result1 v7action.Warnings result2 error } - PollStartForRollingStub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error) - pollStartForRollingMutex sync.RWMutex - pollStartForRollingArgsForCall []struct { + PollStartForDeploymentStub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error) + pollStartForDeploymentMutex sync.RWMutex + pollStartForDeploymentArgsForCall []struct { arg1 resources.Application arg2 string arg3 bool arg4 func(string) } - pollStartForRollingReturns struct { + pollStartForDeploymentReturns struct { result1 v7action.Warnings result2 error } - pollStartForRollingReturnsOnCall map[int]struct { + pollStartForDeploymentReturnsOnCall map[int]struct { result1 v7action.Warnings result2 error } + PollTaskStub func(resources.Task) (resources.Task, v7action.Warnings, error) + pollTaskMutex sync.RWMutex + pollTaskArgsForCall []struct { + arg1 resources.Task + } + pollTaskReturns struct { + result1 resources.Task + result2 v7action.Warnings + result3 error + } + pollTaskReturnsOnCall map[int]struct { + result1 resources.Task + result2 v7action.Warnings + result3 error + } PollUploadBuildpackJobStub func(ccv3.JobURL) (v7action.Warnings, error) pollUploadBuildpackJobMutex sync.RWMutex pollUploadBuildpackJobArgsForCall []struct { @@ -2957,6 +3049,20 @@ type FakeActor struct { result1 v7action.Warnings result2 error } + ShareRouteStub func(string, string) (v7action.Warnings, error) + shareRouteMutex sync.RWMutex + shareRouteArgsForCall []struct { + arg1 string + arg2 string + } + shareRouteReturns struct { + result1 v7action.Warnings + result2 error + } + shareRouteReturnsOnCall map[int]struct { + result1 v7action.Warnings + result2 error + } ShareServiceInstanceToSpaceAndOrgStub func(string, string, string, v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) shareServiceInstanceToSpaceAndOrgMutex sync.RWMutex shareServiceInstanceToSpaceAndOrgArgsForCall []struct { @@ -3120,6 +3226,20 @@ type FakeActor struct { result1 v7action.Warnings result2 error } + UnshareRouteStub func(string, string) (v7action.Warnings, error) + unshareRouteMutex sync.RWMutex + unshareRouteArgsForCall []struct { + arg1 string + arg2 string + } + unshareRouteReturns struct { + result1 v7action.Warnings + result2 error + } + unshareRouteReturnsOnCall map[int]struct { + result1 v7action.Warnings + result2 error + } UnshareServiceInstanceFromSpaceAndOrgStub func(string, string, string, v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) unshareServiceInstanceFromSpaceAndOrgMutex sync.RWMutex unshareServiceInstanceFromSpaceAndOrgArgsForCall []struct { @@ -3181,35 +3301,52 @@ type FakeActor struct { result1 v7action.Warnings result2 error } - UpdateBuildpackByNameAndStackStub func(string, string, resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) - updateBuildpackByNameAndStackMutex sync.RWMutex - updateBuildpackByNameAndStackArgsForCall []struct { + UpdateBuildpackByNameAndStackAndLifecycleStub func(string, string, string, resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) + updateBuildpackByNameAndStackAndLifecycleMutex sync.RWMutex + updateBuildpackByNameAndStackAndLifecycleArgsForCall []struct { arg1 string arg2 string - arg3 resources.Buildpack + arg3 string + arg4 resources.Buildpack } - updateBuildpackByNameAndStackReturns struct { + updateBuildpackByNameAndStackAndLifecycleReturns struct { result1 resources.Buildpack result2 v7action.Warnings result3 error } - updateBuildpackByNameAndStackReturnsOnCall map[int]struct { + updateBuildpackByNameAndStackAndLifecycleReturnsOnCall map[int]struct { result1 resources.Buildpack result2 v7action.Warnings result3 error } - UpdateBuildpackLabelsByBuildpackNameAndStackStub func(string, string, map[string]types.NullString) (v7action.Warnings, error) - updateBuildpackLabelsByBuildpackNameAndStackMutex sync.RWMutex - updateBuildpackLabelsByBuildpackNameAndStackArgsForCall []struct { + UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub func(string, string, string, map[string]types.NullString) (v7action.Warnings, error) + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex sync.RWMutex + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall []struct { arg1 string arg2 string - arg3 map[string]types.NullString + arg3 string + arg4 map[string]types.NullString + } + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns struct { + result1 v7action.Warnings + result2 error + } + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall map[int]struct { + result1 v7action.Warnings + result2 error + } + UpdateDestinationStub func(string, string, string) (v7action.Warnings, error) + updateDestinationMutex sync.RWMutex + updateDestinationArgsForCall []struct { + arg1 string + arg2 string + arg3 string } - updateBuildpackLabelsByBuildpackNameAndStackReturns struct { + updateDestinationReturns struct { result1 v7action.Warnings result2 error } - updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall map[int]struct { + updateDestinationReturnsOnCall map[int]struct { result1 v7action.Warnings result2 error } @@ -3286,6 +3423,22 @@ type FakeActor struct { result1 v7action.Warnings result2 error } + UpdateRouteStub func(string, map[string]*string) (resources.Route, v7action.Warnings, error) + updateRouteMutex sync.RWMutex + updateRouteArgsForCall []struct { + arg1 string + arg2 map[string]*string + } + updateRouteReturns struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + } + updateRouteReturnsOnCall map[int]struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + } UpdateRouteLabelsStub func(string, string, map[string]types.NullString) (v7action.Warnings, error) updateRouteLabelsMutex sync.RWMutex updateRouteLabelsArgsForCall []struct { @@ -3493,19 +3646,21 @@ type FakeActor struct { result1 v7action.Warnings result2 error } - UpgradeManagedServiceInstanceStub func(string, string) (v7action.Warnings, error) + UpgradeManagedServiceInstanceStub func(string, string) (chan v7action.PollJobEvent, v7action.Warnings, error) upgradeManagedServiceInstanceMutex sync.RWMutex upgradeManagedServiceInstanceArgsForCall []struct { arg1 string arg2 string } upgradeManagedServiceInstanceReturns struct { - result1 v7action.Warnings - result2 error + result1 chan v7action.PollJobEvent + result2 v7action.Warnings + result3 error } upgradeManagedServiceInstanceReturnsOnCall map[int]struct { - result1 v7action.Warnings - result2 error + result1 chan v7action.PollJobEvent + result2 v7action.Warnings + result3 error } UploadBitsPackageStub func(resources.Package, []sharedaction.V3Resource, io.Reader, int64) (resources.Package, v7action.Warnings, error) uploadBitsPackageMutex sync.RWMutex @@ -3569,15 +3724,16 @@ func (fake *FakeActor) ApplyOrganizationQuotaByName(arg1 string, arg2 string) (v arg1 string arg2 string }{arg1, arg2}) + stub := fake.ApplyOrganizationQuotaByNameStub + fakeReturns := fake.applyOrganizationQuotaByNameReturns fake.recordInvocation("ApplyOrganizationQuotaByName", []interface{}{arg1, arg2}) fake.applyOrganizationQuotaByNameMutex.Unlock() - if fake.ApplyOrganizationQuotaByNameStub != nil { - return fake.ApplyOrganizationQuotaByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.applyOrganizationQuotaByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3634,15 +3790,16 @@ func (fake *FakeActor) ApplySpaceQuotaByName(arg1 string, arg2 string, arg3 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.ApplySpaceQuotaByNameStub + fakeReturns := fake.applySpaceQuotaByNameReturns fake.recordInvocation("ApplySpaceQuotaByName", []interface{}{arg1, arg2, arg3}) fake.applySpaceQuotaByNameMutex.Unlock() - if fake.ApplySpaceQuotaByNameStub != nil { - return fake.ApplySpaceQuotaByNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.applySpaceQuotaByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3698,15 +3855,16 @@ func (fake *FakeActor) AssignIsolationSegmentToSpaceByNameAndSpace(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.AssignIsolationSegmentToSpaceByNameAndSpaceStub + fakeReturns := fake.assignIsolationSegmentToSpaceByNameAndSpaceReturns fake.recordInvocation("AssignIsolationSegmentToSpaceByNameAndSpace", []interface{}{arg1, arg2}) fake.assignIsolationSegmentToSpaceByNameAndSpaceMutex.Unlock() - if fake.AssignIsolationSegmentToSpaceByNameAndSpaceStub != nil { - return fake.AssignIsolationSegmentToSpaceByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.assignIsolationSegmentToSpaceByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3763,15 +3921,16 @@ func (fake *FakeActor) Authenticate(arg1 map[string]string, arg2 string, arg3 co arg2 string arg3 constant.GrantType }{arg1, arg2, arg3}) + stub := fake.AuthenticateStub + fakeReturns := fake.authenticateReturns fake.recordInvocation("Authenticate", []interface{}{arg1, arg2, arg3}) fake.authenticateMutex.Unlock() - if fake.AuthenticateStub != nil { - return fake.AuthenticateStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.authenticateReturns return fakeReturns.result1 } @@ -3830,15 +3989,16 @@ func (fake *FakeActor) BindSecurityGroupToSpaces(arg1 string, arg2 []resources.S arg2 []resources.Space arg3 constanta.SecurityGroupLifecycle }{arg1, arg2Copy, arg3}) + stub := fake.BindSecurityGroupToSpacesStub + fakeReturns := fake.bindSecurityGroupToSpacesReturns fake.recordInvocation("BindSecurityGroupToSpaces", []interface{}{arg1, arg2Copy, arg3}) fake.bindSecurityGroupToSpacesMutex.Unlock() - if fake.BindSecurityGroupToSpacesStub != nil { - return fake.BindSecurityGroupToSpacesStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.bindSecurityGroupToSpacesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3893,15 +4053,16 @@ func (fake *FakeActor) CancelDeployment(arg1 string) (v7action.Warnings, error) fake.cancelDeploymentArgsForCall = append(fake.cancelDeploymentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CancelDeploymentStub + fakeReturns := fake.cancelDeploymentReturns fake.recordInvocation("CancelDeployment", []interface{}{arg1}) fake.cancelDeploymentMutex.Unlock() - if fake.CancelDeploymentStub != nil { - return fake.CancelDeploymentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.cancelDeploymentReturns return fakeReturns.result1, fakeReturns.result2 } @@ -3959,15 +4120,16 @@ func (fake *FakeActor) CheckRoute(arg1 string, arg2 string, arg3 string, arg4 in arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.CheckRouteStub + fakeReturns := fake.checkRouteReturns fake.recordInvocation("CheckRoute", []interface{}{arg1, arg2, arg3, arg4}) fake.checkRouteMutex.Unlock() - if fake.CheckRouteStub != nil { - return fake.CheckRouteStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.checkRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4023,9 +4185,10 @@ func (fake *FakeActor) ClearTarget() { fake.clearTargetMutex.Lock() fake.clearTargetArgsForCall = append(fake.clearTargetArgsForCall, struct { }{}) + stub := fake.ClearTargetStub fake.recordInvocation("ClearTarget", []interface{}{}) fake.clearTargetMutex.Unlock() - if fake.ClearTargetStub != nil { + if stub != nil { fake.ClearTargetStub() } } @@ -4042,6 +4205,70 @@ func (fake *FakeActor) ClearTargetCalls(stub func()) { fake.ClearTargetStub = stub } +func (fake *FakeActor) ContinueDeployment(arg1 string) (v7action.Warnings, error) { + fake.continueDeploymentMutex.Lock() + ret, specificReturn := fake.continueDeploymentReturnsOnCall[len(fake.continueDeploymentArgsForCall)] + fake.continueDeploymentArgsForCall = append(fake.continueDeploymentArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.ContinueDeploymentStub + fakeReturns := fake.continueDeploymentReturns + fake.recordInvocation("ContinueDeployment", []interface{}{arg1}) + fake.continueDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeActor) ContinueDeploymentCallCount() int { + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() + return len(fake.continueDeploymentArgsForCall) +} + +func (fake *FakeActor) ContinueDeploymentCalls(stub func(string) (v7action.Warnings, error)) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = stub +} + +func (fake *FakeActor) ContinueDeploymentArgsForCall(i int) string { + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() + argsForCall := fake.continueDeploymentArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeActor) ContinueDeploymentReturns(result1 v7action.Warnings, result2 error) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = nil + fake.continueDeploymentReturns = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) ContinueDeploymentReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.continueDeploymentMutex.Lock() + defer fake.continueDeploymentMutex.Unlock() + fake.ContinueDeploymentStub = nil + if fake.continueDeploymentReturnsOnCall == nil { + fake.continueDeploymentReturnsOnCall = make(map[int]struct { + result1 v7action.Warnings + result2 error + }) + } + fake.continueDeploymentReturnsOnCall[i] = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeActor) CopyPackage(arg1 resources.Application, arg2 resources.Application) (resources.Package, v7action.Warnings, error) { fake.copyPackageMutex.Lock() ret, specificReturn := fake.copyPackageReturnsOnCall[len(fake.copyPackageArgsForCall)] @@ -4049,15 +4276,16 @@ func (fake *FakeActor) CopyPackage(arg1 resources.Application, arg2 resources.Ap arg1 resources.Application arg2 resources.Application }{arg1, arg2}) + stub := fake.CopyPackageStub + fakeReturns := fake.copyPackageReturns fake.recordInvocation("CopyPackage", []interface{}{arg1, arg2}) fake.copyPackageMutex.Unlock() - if fake.CopyPackageStub != nil { - return fake.CopyPackageStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.copyPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4117,15 +4345,16 @@ func (fake *FakeActor) CreateAndUploadBitsPackageByApplicationNameAndSpace(arg1 arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.CreateAndUploadBitsPackageByApplicationNameAndSpaceStub + fakeReturns := fake.createAndUploadBitsPackageByApplicationNameAndSpaceReturns fake.recordInvocation("CreateAndUploadBitsPackageByApplicationNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.createAndUploadBitsPackageByApplicationNameAndSpaceMutex.Unlock() - if fake.CreateAndUploadBitsPackageByApplicationNameAndSpaceStub != nil { - return fake.CreateAndUploadBitsPackageByApplicationNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createAndUploadBitsPackageByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4183,15 +4412,16 @@ func (fake *FakeActor) CreateApplicationDroplet(arg1 string) (resources.Droplet, fake.createApplicationDropletArgsForCall = append(fake.createApplicationDropletArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateApplicationDropletStub + fakeReturns := fake.createApplicationDropletReturns fake.recordInvocation("CreateApplicationDroplet", []interface{}{arg1}) fake.createApplicationDropletMutex.Unlock() - if fake.CreateApplicationDropletStub != nil { - return fake.CreateApplicationDropletStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationDropletReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4250,15 +4480,16 @@ func (fake *FakeActor) CreateApplicationInSpace(arg1 resources.Application, arg2 arg1 resources.Application arg2 string }{arg1, arg2}) + stub := fake.CreateApplicationInSpaceStub + fakeReturns := fake.createApplicationInSpaceReturns fake.recordInvocation("CreateApplicationInSpace", []interface{}{arg1, arg2}) fake.createApplicationInSpaceMutex.Unlock() - if fake.CreateApplicationInSpaceStub != nil { - return fake.CreateApplicationInSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createApplicationInSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4316,15 +4547,16 @@ func (fake *FakeActor) CreateBitsPackageByApplication(arg1 string) (resources.Pa fake.createBitsPackageByApplicationArgsForCall = append(fake.createBitsPackageByApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateBitsPackageByApplicationStub + fakeReturns := fake.createBitsPackageByApplicationReturns fake.recordInvocation("CreateBitsPackageByApplication", []interface{}{arg1}) fake.createBitsPackageByApplicationMutex.Unlock() - if fake.CreateBitsPackageByApplicationStub != nil { - return fake.CreateBitsPackageByApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBitsPackageByApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4382,15 +4614,16 @@ func (fake *FakeActor) CreateBuildpack(arg1 resources.Buildpack) (resources.Buil fake.createBuildpackArgsForCall = append(fake.createBuildpackArgsForCall, struct { arg1 resources.Buildpack }{arg1}) + stub := fake.CreateBuildpackStub + fakeReturns := fake.createBuildpackReturns fake.recordInvocation("CreateBuildpack", []interface{}{arg1}) fake.createBuildpackMutex.Unlock() - if fake.CreateBuildpackStub != nil { - return fake.CreateBuildpackStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4442,134 +4675,67 @@ func (fake *FakeActor) CreateBuildpackReturnsOnCall(i int, result1 resources.Bui }{result1, result2, result3} } -func (fake *FakeActor) CreateDeploymentByApplicationAndDroplet(arg1 string, arg2 string) (string, v7action.Warnings, error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - ret, specificReturn := fake.createDeploymentByApplicationAndDropletReturnsOnCall[len(fake.createDeploymentByApplicationAndDropletArgsForCall)] - fake.createDeploymentByApplicationAndDropletArgsForCall = append(fake.createDeploymentByApplicationAndDropletArgsForCall, struct { - arg1 string - arg2 string - }{arg1, arg2}) - fake.recordInvocation("CreateDeploymentByApplicationAndDroplet", []interface{}{arg1, arg2}) - fake.createDeploymentByApplicationAndDropletMutex.Unlock() - if fake.CreateDeploymentByApplicationAndDropletStub != nil { - return fake.CreateDeploymentByApplicationAndDropletStub(arg1, arg2) - } - if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - fakeReturns := fake.createDeploymentByApplicationAndDropletReturns - return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndDropletCallCount() int { - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() - return len(fake.createDeploymentByApplicationAndDropletArgsForCall) -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndDropletCalls(stub func(string, string) (string, v7action.Warnings, error)) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = stub -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndDropletArgsForCall(i int) (string, string) { - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() - argsForCall := fake.createDeploymentByApplicationAndDropletArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndDropletReturns(result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = nil - fake.createDeploymentByApplicationAndDropletReturns = struct { - result1 string - result2 v7action.Warnings - result3 error - }{result1, result2, result3} -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndDropletReturnsOnCall(i int, result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndDropletMutex.Lock() - defer fake.createDeploymentByApplicationAndDropletMutex.Unlock() - fake.CreateDeploymentByApplicationAndDropletStub = nil - if fake.createDeploymentByApplicationAndDropletReturnsOnCall == nil { - fake.createDeploymentByApplicationAndDropletReturnsOnCall = make(map[int]struct { - result1 string - result2 v7action.Warnings - result3 error - }) - } - fake.createDeploymentByApplicationAndDropletReturnsOnCall[i] = struct { - result1 string - result2 v7action.Warnings - result3 error - }{result1, result2, result3} -} - -func (fake *FakeActor) CreateDeploymentByApplicationAndRevision(arg1 string, arg2 string) (string, v7action.Warnings, error) { - fake.createDeploymentByApplicationAndRevisionMutex.Lock() - ret, specificReturn := fake.createDeploymentByApplicationAndRevisionReturnsOnCall[len(fake.createDeploymentByApplicationAndRevisionArgsForCall)] - fake.createDeploymentByApplicationAndRevisionArgsForCall = append(fake.createDeploymentByApplicationAndRevisionArgsForCall, struct { - arg1 string - arg2 string - }{arg1, arg2}) - fake.recordInvocation("CreateDeploymentByApplicationAndRevision", []interface{}{arg1, arg2}) - fake.createDeploymentByApplicationAndRevisionMutex.Unlock() - if fake.CreateDeploymentByApplicationAndRevisionStub != nil { - return fake.CreateDeploymentByApplicationAndRevisionStub(arg1, arg2) +func (fake *FakeActor) CreateDeployment(arg1 resources.Deployment) (string, v7action.Warnings, error) { + fake.createDeploymentMutex.Lock() + ret, specificReturn := fake.createDeploymentReturnsOnCall[len(fake.createDeploymentArgsForCall)] + fake.createDeploymentArgsForCall = append(fake.createDeploymentArgsForCall, struct { + arg1 resources.Deployment + }{arg1}) + stub := fake.CreateDeploymentStub + fakeReturns := fake.createDeploymentReturns + fake.recordInvocation("CreateDeployment", []interface{}{arg1}) + fake.createDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDeploymentByApplicationAndRevisionReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeActor) CreateDeploymentByApplicationAndRevisionCallCount() int { - fake.createDeploymentByApplicationAndRevisionMutex.RLock() - defer fake.createDeploymentByApplicationAndRevisionMutex.RUnlock() - return len(fake.createDeploymentByApplicationAndRevisionArgsForCall) +func (fake *FakeActor) CreateDeploymentCallCount() int { + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() + return len(fake.createDeploymentArgsForCall) } -func (fake *FakeActor) CreateDeploymentByApplicationAndRevisionCalls(stub func(string, string) (string, v7action.Warnings, error)) { - fake.createDeploymentByApplicationAndRevisionMutex.Lock() - defer fake.createDeploymentByApplicationAndRevisionMutex.Unlock() - fake.CreateDeploymentByApplicationAndRevisionStub = stub +func (fake *FakeActor) CreateDeploymentCalls(stub func(resources.Deployment) (string, v7action.Warnings, error)) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = stub } -func (fake *FakeActor) CreateDeploymentByApplicationAndRevisionArgsForCall(i int) (string, string) { - fake.createDeploymentByApplicationAndRevisionMutex.RLock() - defer fake.createDeploymentByApplicationAndRevisionMutex.RUnlock() - argsForCall := fake.createDeploymentByApplicationAndRevisionArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 +func (fake *FakeActor) CreateDeploymentArgsForCall(i int) resources.Deployment { + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() + argsForCall := fake.createDeploymentArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeActor) CreateDeploymentByApplicationAndRevisionReturns(result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndRevisionMutex.Lock() - defer fake.createDeploymentByApplicationAndRevisionMutex.Unlock() - fake.CreateDeploymentByApplicationAndRevisionStub = nil - fake.createDeploymentByApplicationAndRevisionReturns = struct { +func (fake *FakeActor) CreateDeploymentReturns(result1 string, result2 v7action.Warnings, result3 error) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = nil + fake.createDeploymentReturns = struct { result1 string result2 v7action.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeActor) CreateDeploymentByApplicationAndRevisionReturnsOnCall(i int, result1 string, result2 v7action.Warnings, result3 error) { - fake.createDeploymentByApplicationAndRevisionMutex.Lock() - defer fake.createDeploymentByApplicationAndRevisionMutex.Unlock() - fake.CreateDeploymentByApplicationAndRevisionStub = nil - if fake.createDeploymentByApplicationAndRevisionReturnsOnCall == nil { - fake.createDeploymentByApplicationAndRevisionReturnsOnCall = make(map[int]struct { +func (fake *FakeActor) CreateDeploymentReturnsOnCall(i int, result1 string, result2 v7action.Warnings, result3 error) { + fake.createDeploymentMutex.Lock() + defer fake.createDeploymentMutex.Unlock() + fake.CreateDeploymentStub = nil + if fake.createDeploymentReturnsOnCall == nil { + fake.createDeploymentReturnsOnCall = make(map[int]struct { result1 string result2 v7action.Warnings result3 error }) } - fake.createDeploymentByApplicationAndRevisionReturnsOnCall[i] = struct { + fake.createDeploymentReturnsOnCall[i] = struct { result1 string result2 v7action.Warnings result3 error @@ -4583,15 +4749,16 @@ func (fake *FakeActor) CreateDockerPackageByApplication(arg1 string, arg2 v7acti arg1 string arg2 v7action.DockerImageCredentials }{arg1, arg2}) + stub := fake.CreateDockerPackageByApplicationStub + fakeReturns := fake.createDockerPackageByApplicationReturns fake.recordInvocation("CreateDockerPackageByApplication", []interface{}{arg1, arg2}) fake.createDockerPackageByApplicationMutex.Unlock() - if fake.CreateDockerPackageByApplicationStub != nil { - return fake.CreateDockerPackageByApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDockerPackageByApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4651,15 +4818,16 @@ func (fake *FakeActor) CreateDockerPackageByApplicationNameAndSpace(arg1 string, arg2 string arg3 v7action.DockerImageCredentials }{arg1, arg2, arg3}) + stub := fake.CreateDockerPackageByApplicationNameAndSpaceStub + fakeReturns := fake.createDockerPackageByApplicationNameAndSpaceReturns fake.recordInvocation("CreateDockerPackageByApplicationNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.createDockerPackageByApplicationNameAndSpaceMutex.Unlock() - if fake.CreateDockerPackageByApplicationNameAndSpaceStub != nil { - return fake.CreateDockerPackageByApplicationNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createDockerPackageByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4717,15 +4885,16 @@ func (fake *FakeActor) CreateIsolationSegmentByName(arg1 resources.IsolationSegm fake.createIsolationSegmentByNameArgsForCall = append(fake.createIsolationSegmentByNameArgsForCall, struct { arg1 resources.IsolationSegment }{arg1}) + stub := fake.CreateIsolationSegmentByNameStub + fakeReturns := fake.createIsolationSegmentByNameReturns fake.recordInvocation("CreateIsolationSegmentByName", []interface{}{arg1}) fake.createIsolationSegmentByNameMutex.Unlock() - if fake.CreateIsolationSegmentByNameStub != nil { - return fake.CreateIsolationSegmentByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createIsolationSegmentByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -4780,15 +4949,16 @@ func (fake *FakeActor) CreateManagedServiceInstance(arg1 v7action.CreateManagedS fake.createManagedServiceInstanceArgsForCall = append(fake.createManagedServiceInstanceArgsForCall, struct { arg1 v7action.CreateManagedServiceInstanceParams }{arg1}) + stub := fake.CreateManagedServiceInstanceStub + fakeReturns := fake.createManagedServiceInstanceReturns fake.recordInvocation("CreateManagedServiceInstance", []interface{}{arg1}) fake.createManagedServiceInstanceMutex.Unlock() - if fake.CreateManagedServiceInstanceStub != nil { - return fake.CreateManagedServiceInstanceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createManagedServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4850,15 +5020,16 @@ func (fake *FakeActor) CreateOrgRole(arg1 constanta.RoleType, arg2 string, arg3 arg4 string arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.CreateOrgRoleStub + fakeReturns := fake.createOrgRoleReturns fake.recordInvocation("CreateOrgRole", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.createOrgRoleMutex.Unlock() - if fake.CreateOrgRoleStub != nil { - return fake.CreateOrgRoleStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createOrgRoleReturns return fakeReturns.result1, fakeReturns.result2 } @@ -4913,15 +5084,16 @@ func (fake *FakeActor) CreateOrganization(arg1 string) (resources.Organization, fake.createOrganizationArgsForCall = append(fake.createOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.CreateOrganizationStub + fakeReturns := fake.createOrganizationReturns fake.recordInvocation("CreateOrganization", []interface{}{arg1}) fake.createOrganizationMutex.Unlock() - if fake.CreateOrganizationStub != nil { - return fake.CreateOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -4980,15 +5152,16 @@ func (fake *FakeActor) CreateOrganizationQuota(arg1 string, arg2 v7action.QuotaL arg1 string arg2 v7action.QuotaLimits }{arg1, arg2}) + stub := fake.CreateOrganizationQuotaStub + fakeReturns := fake.createOrganizationQuotaReturns fake.recordInvocation("CreateOrganizationQuota", []interface{}{arg1, arg2}) fake.createOrganizationQuotaMutex.Unlock() - if fake.CreateOrganizationQuotaStub != nil { - return fake.CreateOrganizationQuotaStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5044,15 +5217,16 @@ func (fake *FakeActor) CreatePrivateDomain(arg1 string, arg2 string) (v7action.W arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreatePrivateDomainStub + fakeReturns := fake.createPrivateDomainReturns fake.recordInvocation("CreatePrivateDomain", []interface{}{arg1, arg2}) fake.createPrivateDomainMutex.Unlock() - if fake.CreatePrivateDomainStub != nil { - return fake.CreatePrivateDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createPrivateDomainReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5101,7 +5275,7 @@ func (fake *FakeActor) CreatePrivateDomainReturnsOnCall(i int, result1 v7action. }{result1, result2} } -func (fake *FakeActor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 string, arg5 int) (resources.Route, v7action.Warnings, error) { +func (fake *FakeActor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 string, arg5 int, arg6 map[string]*string) (resources.Route, v7action.Warnings, error) { fake.createRouteMutex.Lock() ret, specificReturn := fake.createRouteReturnsOnCall[len(fake.createRouteArgsForCall)] fake.createRouteArgsForCall = append(fake.createRouteArgsForCall, struct { @@ -5110,16 +5284,18 @@ func (fake *FakeActor) CreateRoute(arg1 string, arg2 string, arg3 string, arg4 s arg3 string arg4 string arg5 int - }{arg1, arg2, arg3, arg4, arg5}) - fake.recordInvocation("CreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5}) + arg6 map[string]*string + }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.CreateRouteStub + fakeReturns := fake.createRouteReturns + fake.recordInvocation("CreateRoute", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.createRouteMutex.Unlock() - if fake.CreateRouteStub != nil { - return fake.CreateRouteStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5129,17 +5305,17 @@ func (fake *FakeActor) CreateRouteCallCount() int { return len(fake.createRouteArgsForCall) } -func (fake *FakeActor) CreateRouteCalls(stub func(string, string, string, string, int) (resources.Route, v7action.Warnings, error)) { +func (fake *FakeActor) CreateRouteCalls(stub func(string, string, string, string, int, map[string]*string) (resources.Route, v7action.Warnings, error)) { fake.createRouteMutex.Lock() defer fake.createRouteMutex.Unlock() fake.CreateRouteStub = stub } -func (fake *FakeActor) CreateRouteArgsForCall(i int) (string, string, string, string, int) { +func (fake *FakeActor) CreateRouteArgsForCall(i int) (string, string, string, string, int, map[string]*string) { fake.createRouteMutex.RLock() defer fake.createRouteMutex.RUnlock() argsForCall := fake.createRouteArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 } func (fake *FakeActor) CreateRouteReturns(result1 resources.Route, result2 v7action.Warnings, result3 error) { @@ -5177,15 +5353,16 @@ func (fake *FakeActor) CreateRouteBinding(arg1 v7action.CreateRouteBindingParams fake.createRouteBindingArgsForCall = append(fake.createRouteBindingArgsForCall, struct { arg1 v7action.CreateRouteBindingParams }{arg1}) + stub := fake.CreateRouteBindingStub + fakeReturns := fake.createRouteBindingReturns fake.recordInvocation("CreateRouteBinding", []interface{}{arg1}) fake.createRouteBindingMutex.Unlock() - if fake.CreateRouteBindingStub != nil { - return fake.CreateRouteBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createRouteBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5244,15 +5421,16 @@ func (fake *FakeActor) CreateSecurityGroup(arg1 string, arg2 string) (v7action.W arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateSecurityGroupStub + fakeReturns := fake.createSecurityGroupReturns fake.recordInvocation("CreateSecurityGroup", []interface{}{arg1, arg2}) fake.createSecurityGroupMutex.Unlock() - if fake.CreateSecurityGroupStub != nil { - return fake.CreateSecurityGroupStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5307,15 +5485,16 @@ func (fake *FakeActor) CreateServiceAppBinding(arg1 v7action.CreateServiceAppBin fake.createServiceAppBindingArgsForCall = append(fake.createServiceAppBindingArgsForCall, struct { arg1 v7action.CreateServiceAppBindingParams }{arg1}) + stub := fake.CreateServiceAppBindingStub + fakeReturns := fake.createServiceAppBindingReturns fake.recordInvocation("CreateServiceAppBinding", []interface{}{arg1}) fake.createServiceAppBindingMutex.Unlock() - if fake.CreateServiceAppBindingStub != nil { - return fake.CreateServiceAppBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createServiceAppBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5373,15 +5552,16 @@ func (fake *FakeActor) CreateServiceBroker(arg1 resources.ServiceBroker) (v7acti fake.createServiceBrokerArgsForCall = append(fake.createServiceBrokerArgsForCall, struct { arg1 resources.ServiceBroker }{arg1}) + stub := fake.CreateServiceBrokerStub + fakeReturns := fake.createServiceBrokerReturns fake.recordInvocation("CreateServiceBroker", []interface{}{arg1}) fake.createServiceBrokerMutex.Unlock() - if fake.CreateServiceBrokerStub != nil { - return fake.CreateServiceBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5436,15 +5616,16 @@ func (fake *FakeActor) CreateServiceKey(arg1 v7action.CreateServiceKeyParams) (c fake.createServiceKeyArgsForCall = append(fake.createServiceKeyArgsForCall, struct { arg1 v7action.CreateServiceKeyParams }{arg1}) + stub := fake.CreateServiceKeyStub + fakeReturns := fake.createServiceKeyReturns fake.recordInvocation("CreateServiceKey", []interface{}{arg1}) fake.createServiceKeyMutex.Unlock() - if fake.CreateServiceKeyStub != nil { - return fake.CreateServiceKeyStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createServiceKeyReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5504,15 +5685,16 @@ func (fake *FakeActor) CreateSharedDomain(arg1 string, arg2 bool, arg3 string) ( arg2 bool arg3 string }{arg1, arg2, arg3}) + stub := fake.CreateSharedDomainStub + fakeReturns := fake.createSharedDomainReturns fake.recordInvocation("CreateSharedDomain", []interface{}{arg1, arg2, arg3}) fake.createSharedDomainMutex.Unlock() - if fake.CreateSharedDomainStub != nil { - return fake.CreateSharedDomainStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createSharedDomainReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5568,15 +5750,16 @@ func (fake *FakeActor) CreateSpace(arg1 string, arg2 string) (resources.Space, v arg1 string arg2 string }{arg1, arg2}) + stub := fake.CreateSpaceStub + fakeReturns := fake.createSpaceReturns fake.recordInvocation("CreateSpace", []interface{}{arg1, arg2}) fake.createSpaceMutex.Unlock() - if fake.CreateSpaceStub != nil { - return fake.CreateSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5636,15 +5819,16 @@ func (fake *FakeActor) CreateSpaceQuota(arg1 string, arg2 string, arg3 v7action. arg2 string arg3 v7action.QuotaLimits }{arg1, arg2, arg3}) + stub := fake.CreateSpaceQuotaStub + fakeReturns := fake.createSpaceQuotaReturns fake.recordInvocation("CreateSpaceQuota", []interface{}{arg1, arg2, arg3}) fake.createSpaceQuotaMutex.Unlock() - if fake.CreateSpaceQuotaStub != nil { - return fake.CreateSpaceQuotaStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5704,15 +5888,16 @@ func (fake *FakeActor) CreateSpaceRole(arg1 constanta.RoleType, arg2 string, arg arg5 string arg6 bool }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.CreateSpaceRoleStub + fakeReturns := fake.createSpaceRoleReturns fake.recordInvocation("CreateSpaceRole", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.createSpaceRoleMutex.Unlock() - if fake.CreateSpaceRoleStub != nil { - return fake.CreateSpaceRoleStub(arg1, arg2, arg3, arg4, arg5, arg6) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createSpaceRoleReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5769,15 +5954,16 @@ func (fake *FakeActor) CreateUser(arg1 string, arg2 string, arg3 string) (resour arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.CreateUserStub + fakeReturns := fake.createUserReturns fake.recordInvocation("CreateUser", []interface{}{arg1, arg2, arg3}) fake.createUserMutex.Unlock() - if fake.CreateUserStub != nil { - return fake.CreateUserStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createUserReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -5835,15 +6021,16 @@ func (fake *FakeActor) CreateUserProvidedServiceInstance(arg1 resources.ServiceI fake.createUserProvidedServiceInstanceArgsForCall = append(fake.createUserProvidedServiceInstanceArgsForCall, struct { arg1 resources.ServiceInstance }{arg1}) + stub := fake.CreateUserProvidedServiceInstanceStub + fakeReturns := fake.createUserProvidedServiceInstanceReturns fake.recordInvocation("CreateUserProvidedServiceInstance", []interface{}{arg1}) fake.createUserProvidedServiceInstanceMutex.Unlock() - if fake.CreateUserProvidedServiceInstanceStub != nil { - return fake.CreateUserProvidedServiceInstanceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.createUserProvidedServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5900,15 +6087,16 @@ func (fake *FakeActor) DeleteApplicationByNameAndSpace(arg1 string, arg2 string, arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.DeleteApplicationByNameAndSpaceStub + fakeReturns := fake.deleteApplicationByNameAndSpaceReturns fake.recordInvocation("DeleteApplicationByNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.deleteApplicationByNameAndSpaceMutex.Unlock() - if fake.DeleteApplicationByNameAndSpaceStub != nil { - return fake.DeleteApplicationByNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -5957,65 +6145,67 @@ func (fake *FakeActor) DeleteApplicationByNameAndSpaceReturnsOnCall(i int, resul }{result1, result2} } -func (fake *FakeActor) DeleteBuildpackByNameAndStack(arg1 string, arg2 string) (v7action.Warnings, error) { - fake.deleteBuildpackByNameAndStackMutex.Lock() - ret, specificReturn := fake.deleteBuildpackByNameAndStackReturnsOnCall[len(fake.deleteBuildpackByNameAndStackArgsForCall)] - fake.deleteBuildpackByNameAndStackArgsForCall = append(fake.deleteBuildpackByNameAndStackArgsForCall, struct { +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycle(arg1 string, arg2 string, arg3 string) (v7action.Warnings, error) { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Lock() + ret, specificReturn := fake.deleteBuildpackByNameAndStackAndLifecycleReturnsOnCall[len(fake.deleteBuildpackByNameAndStackAndLifecycleArgsForCall)] + fake.deleteBuildpackByNameAndStackAndLifecycleArgsForCall = append(fake.deleteBuildpackByNameAndStackAndLifecycleArgsForCall, struct { arg1 string arg2 string - }{arg1, arg2}) - fake.recordInvocation("DeleteBuildpackByNameAndStack", []interface{}{arg1, arg2}) - fake.deleteBuildpackByNameAndStackMutex.Unlock() - if fake.DeleteBuildpackByNameAndStackStub != nil { - return fake.DeleteBuildpackByNameAndStackStub(arg1, arg2) + arg3 string + }{arg1, arg2, arg3}) + stub := fake.DeleteBuildpackByNameAndStackAndLifecycleStub + fakeReturns := fake.deleteBuildpackByNameAndStackAndLifecycleReturns + fake.recordInvocation("DeleteBuildpackByNameAndStackAndLifecycle", []interface{}{arg1, arg2, arg3}) + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteBuildpackByNameAndStackReturns return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeActor) DeleteBuildpackByNameAndStackCallCount() int { - fake.deleteBuildpackByNameAndStackMutex.RLock() - defer fake.deleteBuildpackByNameAndStackMutex.RUnlock() - return len(fake.deleteBuildpackByNameAndStackArgsForCall) +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycleCallCount() int { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RUnlock() + return len(fake.deleteBuildpackByNameAndStackAndLifecycleArgsForCall) } -func (fake *FakeActor) DeleteBuildpackByNameAndStackCalls(stub func(string, string) (v7action.Warnings, error)) { - fake.deleteBuildpackByNameAndStackMutex.Lock() - defer fake.deleteBuildpackByNameAndStackMutex.Unlock() - fake.DeleteBuildpackByNameAndStackStub = stub +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycleCalls(stub func(string, string, string) (v7action.Warnings, error)) { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.DeleteBuildpackByNameAndStackAndLifecycleStub = stub } -func (fake *FakeActor) DeleteBuildpackByNameAndStackArgsForCall(i int) (string, string) { - fake.deleteBuildpackByNameAndStackMutex.RLock() - defer fake.deleteBuildpackByNameAndStackMutex.RUnlock() - argsForCall := fake.deleteBuildpackByNameAndStackArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycleArgsForCall(i int) (string, string, string) { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RUnlock() + argsForCall := fake.deleteBuildpackByNameAndStackAndLifecycleArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } -func (fake *FakeActor) DeleteBuildpackByNameAndStackReturns(result1 v7action.Warnings, result2 error) { - fake.deleteBuildpackByNameAndStackMutex.Lock() - defer fake.deleteBuildpackByNameAndStackMutex.Unlock() - fake.DeleteBuildpackByNameAndStackStub = nil - fake.deleteBuildpackByNameAndStackReturns = struct { +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycleReturns(result1 v7action.Warnings, result2 error) { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.DeleteBuildpackByNameAndStackAndLifecycleStub = nil + fake.deleteBuildpackByNameAndStackAndLifecycleReturns = struct { result1 v7action.Warnings result2 error }{result1, result2} } -func (fake *FakeActor) DeleteBuildpackByNameAndStackReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { - fake.deleteBuildpackByNameAndStackMutex.Lock() - defer fake.deleteBuildpackByNameAndStackMutex.Unlock() - fake.DeleteBuildpackByNameAndStackStub = nil - if fake.deleteBuildpackByNameAndStackReturnsOnCall == nil { - fake.deleteBuildpackByNameAndStackReturnsOnCall = make(map[int]struct { +func (fake *FakeActor) DeleteBuildpackByNameAndStackAndLifecycleReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.DeleteBuildpackByNameAndStackAndLifecycleStub = nil + if fake.deleteBuildpackByNameAndStackAndLifecycleReturnsOnCall == nil { + fake.deleteBuildpackByNameAndStackAndLifecycleReturnsOnCall = make(map[int]struct { result1 v7action.Warnings result2 error }) } - fake.deleteBuildpackByNameAndStackReturnsOnCall[i] = struct { + fake.deleteBuildpackByNameAndStackAndLifecycleReturnsOnCall[i] = struct { result1 v7action.Warnings result2 error }{result1, result2} @@ -6027,15 +6217,16 @@ func (fake *FakeActor) DeleteDomain(arg1 resources.Domain) (v7action.Warnings, e fake.deleteDomainArgsForCall = append(fake.deleteDomainArgsForCall, struct { arg1 resources.Domain }{arg1}) + stub := fake.DeleteDomainStub + fakeReturns := fake.deleteDomainReturns fake.recordInvocation("DeleteDomain", []interface{}{arg1}) fake.deleteDomainMutex.Unlock() - if fake.DeleteDomainStub != nil { - return fake.DeleteDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteDomainReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6093,15 +6284,16 @@ func (fake *FakeActor) DeleteInstanceByApplicationNameSpaceProcessTypeAndIndex(a arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.DeleteInstanceByApplicationNameSpaceProcessTypeAndIndexStub + fakeReturns := fake.deleteInstanceByApplicationNameSpaceProcessTypeAndIndexReturns fake.recordInvocation("DeleteInstanceByApplicationNameSpaceProcessTypeAndIndex", []interface{}{arg1, arg2, arg3, arg4}) fake.deleteInstanceByApplicationNameSpaceProcessTypeAndIndexMutex.Unlock() - if fake.DeleteInstanceByApplicationNameSpaceProcessTypeAndIndexStub != nil { - return fake.DeleteInstanceByApplicationNameSpaceProcessTypeAndIndexStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteInstanceByApplicationNameSpaceProcessTypeAndIndexReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6156,15 +6348,16 @@ func (fake *FakeActor) DeleteIsolationSegmentByName(arg1 string) (v7action.Warni fake.deleteIsolationSegmentByNameArgsForCall = append(fake.deleteIsolationSegmentByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteIsolationSegmentByNameStub + fakeReturns := fake.deleteIsolationSegmentByNameReturns fake.recordInvocation("DeleteIsolationSegmentByName", []interface{}{arg1}) fake.deleteIsolationSegmentByNameMutex.Unlock() - if fake.DeleteIsolationSegmentByNameStub != nil { - return fake.DeleteIsolationSegmentByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteIsolationSegmentByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6220,15 +6413,16 @@ func (fake *FakeActor) DeleteIsolationSegmentOrganizationByName(arg1 string, arg arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteIsolationSegmentOrganizationByNameStub + fakeReturns := fake.deleteIsolationSegmentOrganizationByNameReturns fake.recordInvocation("DeleteIsolationSegmentOrganizationByName", []interface{}{arg1, arg2}) fake.deleteIsolationSegmentOrganizationByNameMutex.Unlock() - if fake.DeleteIsolationSegmentOrganizationByNameStub != nil { - return fake.DeleteIsolationSegmentOrganizationByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteIsolationSegmentOrganizationByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6287,15 +6481,16 @@ func (fake *FakeActor) DeleteOrgRole(arg1 constanta.RoleType, arg2 string, arg3 arg4 string arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.DeleteOrgRoleStub + fakeReturns := fake.deleteOrgRoleReturns fake.recordInvocation("DeleteOrgRole", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.deleteOrgRoleMutex.Unlock() - if fake.DeleteOrgRoleStub != nil { - return fake.DeleteOrgRoleStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteOrgRoleReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6350,15 +6545,16 @@ func (fake *FakeActor) DeleteOrganization(arg1 string) (v7action.Warnings, error fake.deleteOrganizationArgsForCall = append(fake.deleteOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrganizationStub + fakeReturns := fake.deleteOrganizationReturns fake.recordInvocation("DeleteOrganization", []interface{}{arg1}) fake.deleteOrganizationMutex.Unlock() - if fake.DeleteOrganizationStub != nil { - return fake.DeleteOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteOrganizationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6413,15 +6609,16 @@ func (fake *FakeActor) DeleteOrganizationQuota(arg1 string) (v7action.Warnings, fake.deleteOrganizationQuotaArgsForCall = append(fake.deleteOrganizationQuotaArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrganizationQuotaStub + fakeReturns := fake.deleteOrganizationQuotaReturns fake.recordInvocation("DeleteOrganizationQuota", []interface{}{arg1}) fake.deleteOrganizationQuotaMutex.Unlock() - if fake.DeleteOrganizationQuotaStub != nil { - return fake.DeleteOrganizationQuotaStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6476,15 +6673,16 @@ func (fake *FakeActor) DeleteOrphanedRoutes(arg1 string) (v7action.Warnings, err fake.deleteOrphanedRoutesArgsForCall = append(fake.deleteOrphanedRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteOrphanedRoutesStub + fakeReturns := fake.deleteOrphanedRoutesReturns fake.recordInvocation("DeleteOrphanedRoutes", []interface{}{arg1}) fake.deleteOrphanedRoutesMutex.Unlock() - if fake.DeleteOrphanedRoutesStub != nil { - return fake.DeleteOrphanedRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteOrphanedRoutesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6542,15 +6740,16 @@ func (fake *FakeActor) DeleteRoute(arg1 string, arg2 string, arg3 string, arg4 i arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.DeleteRouteStub + fakeReturns := fake.deleteRouteReturns fake.recordInvocation("DeleteRoute", []interface{}{arg1, arg2, arg3, arg4}) fake.deleteRouteMutex.Unlock() - if fake.DeleteRouteStub != nil { - return fake.DeleteRouteStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6605,15 +6804,16 @@ func (fake *FakeActor) DeleteRouteBinding(arg1 v7action.DeleteRouteBindingParams fake.deleteRouteBindingArgsForCall = append(fake.deleteRouteBindingArgsForCall, struct { arg1 v7action.DeleteRouteBindingParams }{arg1}) + stub := fake.DeleteRouteBindingStub + fakeReturns := fake.deleteRouteBindingReturns fake.recordInvocation("DeleteRouteBinding", []interface{}{arg1}) fake.deleteRouteBindingMutex.Unlock() - if fake.DeleteRouteBindingStub != nil { - return fake.DeleteRouteBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteRouteBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6671,15 +6871,16 @@ func (fake *FakeActor) DeleteSecurityGroup(arg1 string) (v7action.Warnings, erro fake.deleteSecurityGroupArgsForCall = append(fake.deleteSecurityGroupArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteSecurityGroupStub + fakeReturns := fake.deleteSecurityGroupReturns fake.recordInvocation("DeleteSecurityGroup", []interface{}{arg1}) fake.deleteSecurityGroupMutex.Unlock() - if fake.DeleteSecurityGroupStub != nil { - return fake.DeleteSecurityGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6734,15 +6935,16 @@ func (fake *FakeActor) DeleteServiceAppBinding(arg1 v7action.DeleteServiceAppBin fake.deleteServiceAppBindingArgsForCall = append(fake.deleteServiceAppBindingArgsForCall, struct { arg1 v7action.DeleteServiceAppBindingParams }{arg1}) + stub := fake.DeleteServiceAppBindingStub + fakeReturns := fake.deleteServiceAppBindingReturns fake.recordInvocation("DeleteServiceAppBinding", []interface{}{arg1}) fake.deleteServiceAppBindingMutex.Unlock() - if fake.DeleteServiceAppBindingStub != nil { - return fake.DeleteServiceAppBindingStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceAppBindingReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6800,15 +7002,16 @@ func (fake *FakeActor) DeleteServiceBroker(arg1 string) (v7action.Warnings, erro fake.deleteServiceBrokerArgsForCall = append(fake.deleteServiceBrokerArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteServiceBrokerStub + fakeReturns := fake.deleteServiceBrokerReturns fake.recordInvocation("DeleteServiceBroker", []interface{}{arg1}) fake.deleteServiceBrokerMutex.Unlock() - if fake.DeleteServiceBrokerStub != nil { - return fake.DeleteServiceBrokerStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -6864,15 +7067,16 @@ func (fake *FakeActor) DeleteServiceInstance(arg1 string, arg2 string) (chan v7a arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteServiceInstanceStub + fakeReturns := fake.deleteServiceInstanceReturns fake.recordInvocation("DeleteServiceInstance", []interface{}{arg1, arg2}) fake.deleteServiceInstanceMutex.Unlock() - if fake.DeleteServiceInstanceStub != nil { - return fake.DeleteServiceInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6932,15 +7136,16 @@ func (fake *FakeActor) DeleteServiceKeyByServiceInstanceAndName(arg1 string, arg arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DeleteServiceKeyByServiceInstanceAndNameStub + fakeReturns := fake.deleteServiceKeyByServiceInstanceAndNameReturns fake.recordInvocation("DeleteServiceKeyByServiceInstanceAndName", []interface{}{arg1, arg2, arg3}) fake.deleteServiceKeyByServiceInstanceAndNameMutex.Unlock() - if fake.DeleteServiceKeyByServiceInstanceAndNameStub != nil { - return fake.DeleteServiceKeyByServiceInstanceAndNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.deleteServiceKeyByServiceInstanceAndNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -6999,15 +7204,16 @@ func (fake *FakeActor) DeleteSpaceByNameAndOrganizationName(arg1 string, arg2 st arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteSpaceByNameAndOrganizationNameStub + fakeReturns := fake.deleteSpaceByNameAndOrganizationNameReturns fake.recordInvocation("DeleteSpaceByNameAndOrganizationName", []interface{}{arg1, arg2}) fake.deleteSpaceByNameAndOrganizationNameMutex.Unlock() - if fake.DeleteSpaceByNameAndOrganizationNameStub != nil { - return fake.DeleteSpaceByNameAndOrganizationNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteSpaceByNameAndOrganizationNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7063,15 +7269,16 @@ func (fake *FakeActor) DeleteSpaceQuotaByName(arg1 string, arg2 string) (v7actio arg1 string arg2 string }{arg1, arg2}) + stub := fake.DeleteSpaceQuotaByNameStub + fakeReturns := fake.deleteSpaceQuotaByNameReturns fake.recordInvocation("DeleteSpaceQuotaByName", []interface{}{arg1, arg2}) fake.deleteSpaceQuotaByNameMutex.Unlock() - if fake.DeleteSpaceQuotaByNameStub != nil { - return fake.DeleteSpaceQuotaByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteSpaceQuotaByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7130,15 +7337,16 @@ func (fake *FakeActor) DeleteSpaceRole(arg1 constanta.RoleType, arg2 string, arg arg4 string arg5 bool }{arg1, arg2, arg3, arg4, arg5}) + stub := fake.DeleteSpaceRoleStub + fakeReturns := fake.deleteSpaceRoleReturns fake.recordInvocation("DeleteSpaceRole", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.deleteSpaceRoleMutex.Unlock() - if fake.DeleteSpaceRoleStub != nil { - return fake.DeleteSpaceRoleStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteSpaceRoleReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7193,15 +7401,16 @@ func (fake *FakeActor) DeleteUser(arg1 string) (v7action.Warnings, error) { fake.deleteUserArgsForCall = append(fake.deleteUserArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DeleteUserStub + fakeReturns := fake.deleteUserReturns fake.recordInvocation("DeleteUser", []interface{}{arg1}) fake.deleteUserMutex.Unlock() - if fake.DeleteUserStub != nil { - return fake.DeleteUserStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.deleteUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7262,15 +7471,16 @@ func (fake *FakeActor) DiffSpaceManifest(arg1 string, arg2 []byte) (resources.Ma arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.DiffSpaceManifestStub + fakeReturns := fake.diffSpaceManifestReturns fake.recordInvocation("DiffSpaceManifest", []interface{}{arg1, arg2Copy}) fake.diffSpaceManifestMutex.Unlock() - if fake.DiffSpaceManifestStub != nil { - return fake.DiffSpaceManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.diffSpaceManifestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7328,15 +7538,16 @@ func (fake *FakeActor) DisableFeatureFlag(arg1 string) (v7action.Warnings, error fake.disableFeatureFlagArgsForCall = append(fake.disableFeatureFlagArgsForCall, struct { arg1 string }{arg1}) + stub := fake.DisableFeatureFlagStub + fakeReturns := fake.disableFeatureFlagReturns fake.recordInvocation("DisableFeatureFlag", []interface{}{arg1}) fake.disableFeatureFlagMutex.Unlock() - if fake.DisableFeatureFlagStub != nil { - return fake.DisableFeatureFlagStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.disableFeatureFlagReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7394,15 +7605,16 @@ func (fake *FakeActor) DisableServiceAccess(arg1 string, arg2 string, arg3 strin arg3 string arg4 string }{arg1, arg2, arg3, arg4}) + stub := fake.DisableServiceAccessStub + fakeReturns := fake.disableServiceAccessReturns fake.recordInvocation("DisableServiceAccess", []interface{}{arg1, arg2, arg3, arg4}) fake.disableServiceAccessMutex.Unlock() - if fake.DisableServiceAccessStub != nil { - return fake.DisableServiceAccessStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.disableServiceAccessReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7461,15 +7673,16 @@ func (fake *FakeActor) DownloadCurrentDropletByAppName(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.DownloadCurrentDropletByAppNameStub + fakeReturns := fake.downloadCurrentDropletByAppNameReturns fake.recordInvocation("DownloadCurrentDropletByAppName", []interface{}{arg1, arg2}) fake.downloadCurrentDropletByAppNameMutex.Unlock() - if fake.DownloadCurrentDropletByAppNameStub != nil { - return fake.DownloadCurrentDropletByAppNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4 } - fakeReturns := fake.downloadCurrentDropletByAppNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 } @@ -7532,15 +7745,16 @@ func (fake *FakeActor) DownloadDropletByGUIDAndAppName(arg1 string, arg2 string, arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.DownloadDropletByGUIDAndAppNameStub + fakeReturns := fake.downloadDropletByGUIDAndAppNameReturns fake.recordInvocation("DownloadDropletByGUIDAndAppName", []interface{}{arg1, arg2, arg3}) fake.downloadDropletByGUIDAndAppNameMutex.Unlock() - if fake.DownloadDropletByGUIDAndAppNameStub != nil { - return fake.DownloadDropletByGUIDAndAppNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.downloadDropletByGUIDAndAppNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7598,15 +7812,16 @@ func (fake *FakeActor) EnableFeatureFlag(arg1 string) (v7action.Warnings, error) fake.enableFeatureFlagArgsForCall = append(fake.enableFeatureFlagArgsForCall, struct { arg1 string }{arg1}) + stub := fake.EnableFeatureFlagStub + fakeReturns := fake.enableFeatureFlagReturns fake.recordInvocation("EnableFeatureFlag", []interface{}{arg1}) fake.enableFeatureFlagMutex.Unlock() - if fake.EnableFeatureFlagStub != nil { - return fake.EnableFeatureFlagStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.enableFeatureFlagReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7664,15 +7879,16 @@ func (fake *FakeActor) EnableServiceAccess(arg1 string, arg2 string, arg3 string arg3 string arg4 string }{arg1, arg2, arg3, arg4}) + stub := fake.EnableServiceAccessStub + fakeReturns := fake.enableServiceAccessReturns fake.recordInvocation("EnableServiceAccess", []interface{}{arg1, arg2, arg3, arg4}) fake.enableServiceAccessMutex.Unlock() - if fake.EnableServiceAccessStub != nil { - return fake.EnableServiceAccessStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.enableServiceAccessReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7731,15 +7947,16 @@ func (fake *FakeActor) EntitleIsolationSegmentToOrganizationByName(arg1 string, arg1 string arg2 string }{arg1, arg2}) + stub := fake.EntitleIsolationSegmentToOrganizationByNameStub + fakeReturns := fake.entitleIsolationSegmentToOrganizationByNameReturns fake.recordInvocation("EntitleIsolationSegmentToOrganizationByName", []interface{}{arg1, arg2}) fake.entitleIsolationSegmentToOrganizationByNameMutex.Unlock() - if fake.EntitleIsolationSegmentToOrganizationByNameStub != nil { - return fake.EntitleIsolationSegmentToOrganizationByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.entitleIsolationSegmentToOrganizationByNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -7795,15 +8012,16 @@ func (fake *FakeActor) GetAppFeature(arg1 string, arg2 string) (resources.Applic arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetAppFeatureStub + fakeReturns := fake.getAppFeatureReturns fake.recordInvocation("GetAppFeature", []interface{}{arg1, arg2}) fake.getAppFeatureMutex.Unlock() - if fake.GetAppFeatureStub != nil { - return fake.GetAppFeatureStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getAppFeatureReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7855,22 +8073,24 @@ func (fake *FakeActor) GetAppFeatureReturnsOnCall(i int, result1 resources.Appli }{result1, result2, result3} } -func (fake *FakeActor) GetAppSummariesForSpace(arg1 string, arg2 string) ([]v7action.ApplicationSummary, v7action.Warnings, error) { +func (fake *FakeActor) GetAppSummariesForSpace(arg1 string, arg2 string, arg3 bool) ([]v7action.ApplicationSummary, v7action.Warnings, error) { fake.getAppSummariesForSpaceMutex.Lock() ret, specificReturn := fake.getAppSummariesForSpaceReturnsOnCall[len(fake.getAppSummariesForSpaceArgsForCall)] fake.getAppSummariesForSpaceArgsForCall = append(fake.getAppSummariesForSpaceArgsForCall, struct { arg1 string arg2 string - }{arg1, arg2}) - fake.recordInvocation("GetAppSummariesForSpace", []interface{}{arg1, arg2}) + arg3 bool + }{arg1, arg2, arg3}) + stub := fake.GetAppSummariesForSpaceStub + fakeReturns := fake.getAppSummariesForSpaceReturns + fake.recordInvocation("GetAppSummariesForSpace", []interface{}{arg1, arg2, arg3}) fake.getAppSummariesForSpaceMutex.Unlock() - if fake.GetAppSummariesForSpaceStub != nil { - return fake.GetAppSummariesForSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getAppSummariesForSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7880,17 +8100,17 @@ func (fake *FakeActor) GetAppSummariesForSpaceCallCount() int { return len(fake.getAppSummariesForSpaceArgsForCall) } -func (fake *FakeActor) GetAppSummariesForSpaceCalls(stub func(string, string) ([]v7action.ApplicationSummary, v7action.Warnings, error)) { +func (fake *FakeActor) GetAppSummariesForSpaceCalls(stub func(string, string, bool) ([]v7action.ApplicationSummary, v7action.Warnings, error)) { fake.getAppSummariesForSpaceMutex.Lock() defer fake.getAppSummariesForSpaceMutex.Unlock() fake.GetAppSummariesForSpaceStub = stub } -func (fake *FakeActor) GetAppSummariesForSpaceArgsForCall(i int) (string, string) { +func (fake *FakeActor) GetAppSummariesForSpaceArgsForCall(i int) (string, string, bool) { fake.getAppSummariesForSpaceMutex.RLock() defer fake.getAppSummariesForSpaceMutex.RUnlock() argsForCall := fake.getAppSummariesForSpaceArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeActor) GetAppSummariesForSpaceReturns(result1 []v7action.ApplicationSummary, result2 v7action.Warnings, result3 error) { @@ -7929,15 +8149,16 @@ func (fake *FakeActor) GetApplicationByNameAndSpace(arg1 string, arg2 string) (r arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationByNameAndSpaceStub + fakeReturns := fake.getApplicationByNameAndSpaceReturns fake.recordInvocation("GetApplicationByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationByNameAndSpaceMutex.Unlock() - if fake.GetApplicationByNameAndSpaceStub != nil { - return fake.GetApplicationByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -7996,15 +8217,16 @@ func (fake *FakeActor) GetApplicationDroplets(arg1 string, arg2 string) ([]resou arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationDropletsStub + fakeReturns := fake.getApplicationDropletsReturns fake.recordInvocation("GetApplicationDroplets", []interface{}{arg1, arg2}) fake.getApplicationDropletsMutex.Unlock() - if fake.GetApplicationDropletsStub != nil { - return fake.GetApplicationDropletsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationDropletsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8063,15 +8285,16 @@ func (fake *FakeActor) GetApplicationLabels(arg1 string, arg2 string) (map[strin arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationLabelsStub + fakeReturns := fake.getApplicationLabelsReturns fake.recordInvocation("GetApplicationLabels", []interface{}{arg1, arg2}) fake.getApplicationLabelsMutex.Unlock() - if fake.GetApplicationLabelsStub != nil { - return fake.GetApplicationLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8129,15 +8352,16 @@ func (fake *FakeActor) GetApplicationMapForRoute(arg1 resources.Route) (map[stri fake.getApplicationMapForRouteArgsForCall = append(fake.getApplicationMapForRouteArgsForCall, struct { arg1 resources.Route }{arg1}) + stub := fake.GetApplicationMapForRouteStub + fakeReturns := fake.getApplicationMapForRouteReturns fake.recordInvocation("GetApplicationMapForRoute", []interface{}{arg1}) fake.getApplicationMapForRouteMutex.Unlock() - if fake.GetApplicationMapForRouteStub != nil { - return fake.GetApplicationMapForRouteStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationMapForRouteReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8196,15 +8420,16 @@ func (fake *FakeActor) GetApplicationPackages(arg1 string, arg2 string) ([]resou arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationPackagesStub + fakeReturns := fake.getApplicationPackagesReturns fake.recordInvocation("GetApplicationPackages", []interface{}{arg1, arg2}) fake.getApplicationPackagesMutex.Unlock() - if fake.GetApplicationPackagesStub != nil { - return fake.GetApplicationPackagesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationPackagesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8263,15 +8488,16 @@ func (fake *FakeActor) GetApplicationProcessHealthChecksByNameAndSpace(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationProcessHealthChecksByNameAndSpaceStub + fakeReturns := fake.getApplicationProcessHealthChecksByNameAndSpaceReturns fake.recordInvocation("GetApplicationProcessHealthChecksByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationProcessHealthChecksByNameAndSpaceMutex.Unlock() - if fake.GetApplicationProcessHealthChecksByNameAndSpaceStub != nil { - return fake.GetApplicationProcessHealthChecksByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationProcessHealthChecksByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8323,21 +8549,90 @@ func (fake *FakeActor) GetApplicationProcessHealthChecksByNameAndSpaceReturnsOnC }{result1, result2, result3} } +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpace(arg1 string, arg2 string) ([]v7action.ProcessReadinessHealthCheck, v7action.Warnings, error) { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Lock() + ret, specificReturn := fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall[len(fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall)] + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall = append(fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.GetApplicationProcessReadinessHealthChecksByNameAndSpaceStub + fakeReturns := fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturns + fake.recordInvocation("GetApplicationProcessReadinessHealthChecksByNameAndSpace", []interface{}{arg1, arg2}) + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpaceCallCount() int { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RLock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RUnlock() + return len(fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall) +} + +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpaceCalls(stub func(string, string) ([]v7action.ProcessReadinessHealthCheck, v7action.Warnings, error)) { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Lock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Unlock() + fake.GetApplicationProcessReadinessHealthChecksByNameAndSpaceStub = stub +} + +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall(i int) (string, string) { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RLock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RUnlock() + argsForCall := fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpaceReturns(result1 []v7action.ProcessReadinessHealthCheck, result2 v7action.Warnings, result3 error) { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Lock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Unlock() + fake.GetApplicationProcessReadinessHealthChecksByNameAndSpaceStub = nil + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturns = struct { + result1 []v7action.ProcessReadinessHealthCheck + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) GetApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall(i int, result1 []v7action.ProcessReadinessHealthCheck, result2 v7action.Warnings, result3 error) { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Lock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.Unlock() + fake.GetApplicationProcessReadinessHealthChecksByNameAndSpaceStub = nil + if fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall == nil { + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall = make(map[int]struct { + result1 []v7action.ProcessReadinessHealthCheck + result2 v7action.Warnings + result3 error + }) + } + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceReturnsOnCall[i] = struct { + result1 []v7action.ProcessReadinessHealthCheck + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeActor) GetApplicationRevisionsDeployed(arg1 string) ([]resources.Revision, v7action.Warnings, error) { fake.getApplicationRevisionsDeployedMutex.Lock() ret, specificReturn := fake.getApplicationRevisionsDeployedReturnsOnCall[len(fake.getApplicationRevisionsDeployedArgsForCall)] fake.getApplicationRevisionsDeployedArgsForCall = append(fake.getApplicationRevisionsDeployedArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationRevisionsDeployedStub + fakeReturns := fake.getApplicationRevisionsDeployedReturns fake.recordInvocation("GetApplicationRevisionsDeployed", []interface{}{arg1}) fake.getApplicationRevisionsDeployedMutex.Unlock() - if fake.GetApplicationRevisionsDeployedStub != nil { - return fake.GetApplicationRevisionsDeployedStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRevisionsDeployedReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8395,15 +8690,16 @@ func (fake *FakeActor) GetApplicationRoutes(arg1 string) ([]resources.Route, v7a fake.getApplicationRoutesArgsForCall = append(fake.getApplicationRoutesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetApplicationRoutesStub + fakeReturns := fake.getApplicationRoutesReturns fake.recordInvocation("GetApplicationRoutes", []interface{}{arg1}) fake.getApplicationRoutesMutex.Unlock() - if fake.GetApplicationRoutesStub != nil { - return fake.GetApplicationRoutesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationRoutesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8462,15 +8758,16 @@ func (fake *FakeActor) GetApplicationTasks(arg1 string, arg2 v7action.SortOrder) arg1 string arg2 v7action.SortOrder }{arg1, arg2}) + stub := fake.GetApplicationTasksStub + fakeReturns := fake.getApplicationTasksReturns fake.recordInvocation("GetApplicationTasks", []interface{}{arg1, arg2}) fake.getApplicationTasksMutex.Unlock() - if fake.GetApplicationTasksStub != nil { - return fake.GetApplicationTasksStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationTasksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8522,6 +8819,78 @@ func (fake *FakeActor) GetApplicationTasksReturnsOnCall(i int, result1 []resourc }{result1, result2, result3} } +func (fake *FakeActor) GetApplicationsByGUIDs(arg1 []string) ([]resources.Application, v7action.Warnings, error) { + var arg1Copy []string + if arg1 != nil { + arg1Copy = make([]string, len(arg1)) + copy(arg1Copy, arg1) + } + fake.getApplicationsByGUIDsMutex.Lock() + ret, specificReturn := fake.getApplicationsByGUIDsReturnsOnCall[len(fake.getApplicationsByGUIDsArgsForCall)] + fake.getApplicationsByGUIDsArgsForCall = append(fake.getApplicationsByGUIDsArgsForCall, struct { + arg1 []string + }{arg1Copy}) + stub := fake.GetApplicationsByGUIDsStub + fakeReturns := fake.getApplicationsByGUIDsReturns + fake.recordInvocation("GetApplicationsByGUIDs", []interface{}{arg1Copy}) + fake.getApplicationsByGUIDsMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeActor) GetApplicationsByGUIDsCallCount() int { + fake.getApplicationsByGUIDsMutex.RLock() + defer fake.getApplicationsByGUIDsMutex.RUnlock() + return len(fake.getApplicationsByGUIDsArgsForCall) +} + +func (fake *FakeActor) GetApplicationsByGUIDsCalls(stub func([]string) ([]resources.Application, v7action.Warnings, error)) { + fake.getApplicationsByGUIDsMutex.Lock() + defer fake.getApplicationsByGUIDsMutex.Unlock() + fake.GetApplicationsByGUIDsStub = stub +} + +func (fake *FakeActor) GetApplicationsByGUIDsArgsForCall(i int) []string { + fake.getApplicationsByGUIDsMutex.RLock() + defer fake.getApplicationsByGUIDsMutex.RUnlock() + argsForCall := fake.getApplicationsByGUIDsArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeActor) GetApplicationsByGUIDsReturns(result1 []resources.Application, result2 v7action.Warnings, result3 error) { + fake.getApplicationsByGUIDsMutex.Lock() + defer fake.getApplicationsByGUIDsMutex.Unlock() + fake.GetApplicationsByGUIDsStub = nil + fake.getApplicationsByGUIDsReturns = struct { + result1 []resources.Application + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) GetApplicationsByGUIDsReturnsOnCall(i int, result1 []resources.Application, result2 v7action.Warnings, result3 error) { + fake.getApplicationsByGUIDsMutex.Lock() + defer fake.getApplicationsByGUIDsMutex.Unlock() + fake.GetApplicationsByGUIDsStub = nil + if fake.getApplicationsByGUIDsReturnsOnCall == nil { + fake.getApplicationsByGUIDsReturnsOnCall = make(map[int]struct { + result1 []resources.Application + result2 v7action.Warnings + result3 error + }) + } + fake.getApplicationsByGUIDsReturnsOnCall[i] = struct { + result1 []resources.Application + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeActor) GetApplicationsByNamesAndSpace(arg1 []string, arg2 string) ([]resources.Application, v7action.Warnings, error) { var arg1Copy []string if arg1 != nil { @@ -8534,15 +8903,16 @@ func (fake *FakeActor) GetApplicationsByNamesAndSpace(arg1 []string, arg2 string arg1 []string arg2 string }{arg1Copy, arg2}) + stub := fake.GetApplicationsByNamesAndSpaceStub + fakeReturns := fake.getApplicationsByNamesAndSpaceReturns fake.recordInvocation("GetApplicationsByNamesAndSpace", []interface{}{arg1Copy, arg2}) fake.getApplicationsByNamesAndSpaceMutex.Unlock() - if fake.GetApplicationsByNamesAndSpaceStub != nil { - return fake.GetApplicationsByNamesAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationsByNamesAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8594,22 +8964,24 @@ func (fake *FakeActor) GetApplicationsByNamesAndSpaceReturnsOnCall(i int, result }{result1, result2, result3} } -func (fake *FakeActor) GetBuildpackLabels(arg1 string, arg2 string) (map[string]types.NullString, v7action.Warnings, error) { +func (fake *FakeActor) GetBuildpackLabels(arg1 string, arg2 string, arg3 string) (map[string]types.NullString, v7action.Warnings, error) { fake.getBuildpackLabelsMutex.Lock() ret, specificReturn := fake.getBuildpackLabelsReturnsOnCall[len(fake.getBuildpackLabelsArgsForCall)] fake.getBuildpackLabelsArgsForCall = append(fake.getBuildpackLabelsArgsForCall, struct { arg1 string arg2 string - }{arg1, arg2}) - fake.recordInvocation("GetBuildpackLabels", []interface{}{arg1, arg2}) + arg3 string + }{arg1, arg2, arg3}) + stub := fake.GetBuildpackLabelsStub + fakeReturns := fake.getBuildpackLabelsReturns + fake.recordInvocation("GetBuildpackLabels", []interface{}{arg1, arg2, arg3}) fake.getBuildpackLabelsMutex.Unlock() - if fake.GetBuildpackLabelsStub != nil { - return fake.GetBuildpackLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getBuildpackLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8619,17 +8991,17 @@ func (fake *FakeActor) GetBuildpackLabelsCallCount() int { return len(fake.getBuildpackLabelsArgsForCall) } -func (fake *FakeActor) GetBuildpackLabelsCalls(stub func(string, string) (map[string]types.NullString, v7action.Warnings, error)) { +func (fake *FakeActor) GetBuildpackLabelsCalls(stub func(string, string, string) (map[string]types.NullString, v7action.Warnings, error)) { fake.getBuildpackLabelsMutex.Lock() defer fake.getBuildpackLabelsMutex.Unlock() fake.GetBuildpackLabelsStub = stub } -func (fake *FakeActor) GetBuildpackLabelsArgsForCall(i int) (string, string) { +func (fake *FakeActor) GetBuildpackLabelsArgsForCall(i int) (string, string, string) { fake.getBuildpackLabelsMutex.RLock() defer fake.getBuildpackLabelsMutex.RUnlock() argsForCall := fake.getBuildpackLabelsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeActor) GetBuildpackLabelsReturns(result1 map[string]types.NullString, result2 v7action.Warnings, result3 error) { @@ -8661,21 +9033,23 @@ func (fake *FakeActor) GetBuildpackLabelsReturnsOnCall(i int, result1 map[string }{result1, result2, result3} } -func (fake *FakeActor) GetBuildpacks(arg1 string) ([]resources.Buildpack, v7action.Warnings, error) { +func (fake *FakeActor) GetBuildpacks(arg1 string, arg2 string) ([]resources.Buildpack, v7action.Warnings, error) { fake.getBuildpacksMutex.Lock() ret, specificReturn := fake.getBuildpacksReturnsOnCall[len(fake.getBuildpacksArgsForCall)] fake.getBuildpacksArgsForCall = append(fake.getBuildpacksArgsForCall, struct { arg1 string - }{arg1}) - fake.recordInvocation("GetBuildpacks", []interface{}{arg1}) + arg2 string + }{arg1, arg2}) + stub := fake.GetBuildpacksStub + fakeReturns := fake.getBuildpacksReturns + fake.recordInvocation("GetBuildpacks", []interface{}{arg1, arg2}) fake.getBuildpacksMutex.Unlock() - if fake.GetBuildpacksStub != nil { - return fake.GetBuildpacksStub(arg1) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getBuildpacksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8685,17 +9059,17 @@ func (fake *FakeActor) GetBuildpacksCallCount() int { return len(fake.getBuildpacksArgsForCall) } -func (fake *FakeActor) GetBuildpacksCalls(stub func(string) ([]resources.Buildpack, v7action.Warnings, error)) { +func (fake *FakeActor) GetBuildpacksCalls(stub func(string, string) ([]resources.Buildpack, v7action.Warnings, error)) { fake.getBuildpacksMutex.Lock() defer fake.getBuildpacksMutex.Unlock() fake.GetBuildpacksStub = stub } -func (fake *FakeActor) GetBuildpacksArgsForCall(i int) string { +func (fake *FakeActor) GetBuildpacksArgsForCall(i int) (string, string) { fake.getBuildpacksMutex.RLock() defer fake.getBuildpacksMutex.RUnlock() argsForCall := fake.getBuildpacksArgsForCall[i] - return argsForCall.arg1 + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeActor) GetBuildpacksReturns(result1 []resources.Buildpack, result2 v7action.Warnings, result3 error) { @@ -8732,15 +9106,16 @@ func (fake *FakeActor) GetCurrentUser() (configv3.User, error) { ret, specificReturn := fake.getCurrentUserReturnsOnCall[len(fake.getCurrentUserArgsForCall)] fake.getCurrentUserArgsForCall = append(fake.getCurrentUserArgsForCall, struct { }{}) + stub := fake.GetCurrentUserStub + fakeReturns := fake.getCurrentUserReturns fake.recordInvocation("GetCurrentUser", []interface{}{}) fake.getCurrentUserMutex.Unlock() - if fake.GetCurrentUserStub != nil { - return fake.GetCurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getCurrentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -8788,15 +9163,16 @@ func (fake *FakeActor) GetDefaultDomain(arg1 string) (resources.Domain, v7action fake.getDefaultDomainArgsForCall = append(fake.getDefaultDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDefaultDomainStub + fakeReturns := fake.getDefaultDomainReturns fake.recordInvocation("GetDefaultDomain", []interface{}{arg1}) fake.getDefaultDomainMutex.Unlock() - if fake.GetDefaultDomainStub != nil { - return fake.GetDefaultDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDefaultDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8856,15 +9232,16 @@ func (fake *FakeActor) GetDetailedAppSummary(arg1 string, arg2 string, arg3 bool arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.GetDetailedAppSummaryStub + fakeReturns := fake.getDetailedAppSummaryReturns fake.recordInvocation("GetDetailedAppSummary", []interface{}{arg1, arg2, arg3}) fake.getDetailedAppSummaryMutex.Unlock() - if fake.GetDetailedAppSummaryStub != nil { - return fake.GetDetailedAppSummaryStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDetailedAppSummaryReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8922,15 +9299,16 @@ func (fake *FakeActor) GetDomain(arg1 string) (resources.Domain, v7action.Warnin fake.getDomainArgsForCall = append(fake.getDomainArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDomainStub + fakeReturns := fake.getDomainReturns fake.recordInvocation("GetDomain", []interface{}{arg1}) fake.getDomainMutex.Unlock() - if fake.GetDomainStub != nil { - return fake.GetDomainStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -8988,15 +9366,16 @@ func (fake *FakeActor) GetDomainByName(arg1 string) (resources.Domain, v7action. fake.getDomainByNameArgsForCall = append(fake.getDomainByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDomainByNameStub + fakeReturns := fake.getDomainByNameReturns fake.recordInvocation("GetDomainByName", []interface{}{arg1}) fake.getDomainByNameMutex.Unlock() - if fake.GetDomainByNameStub != nil { - return fake.GetDomainByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9054,15 +9433,16 @@ func (fake *FakeActor) GetDomainLabels(arg1 string) (map[string]types.NullString fake.getDomainLabelsArgsForCall = append(fake.getDomainLabelsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetDomainLabelsStub + fakeReturns := fake.getDomainLabelsReturns fake.recordInvocation("GetDomainLabels", []interface{}{arg1}) fake.getDomainLabelsMutex.Unlock() - if fake.GetDomainLabelsStub != nil { - return fake.GetDomainLabelsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDomainLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9121,15 +9501,16 @@ func (fake *FakeActor) GetEffectiveIsolationSegmentBySpace(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetEffectiveIsolationSegmentBySpaceStub + fakeReturns := fake.getEffectiveIsolationSegmentBySpaceReturns fake.recordInvocation("GetEffectiveIsolationSegmentBySpace", []interface{}{arg1, arg2}) fake.getEffectiveIsolationSegmentBySpaceMutex.Unlock() - if fake.GetEffectiveIsolationSegmentBySpaceStub != nil { - return fake.GetEffectiveIsolationSegmentBySpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getEffectiveIsolationSegmentBySpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9187,15 +9568,16 @@ func (fake *FakeActor) GetEnvironmentVariableGroup(arg1 constanta.EnvironmentVar fake.getEnvironmentVariableGroupArgsForCall = append(fake.getEnvironmentVariableGroupArgsForCall, struct { arg1 constanta.EnvironmentVariableGroupName }{arg1}) + stub := fake.GetEnvironmentVariableGroupStub + fakeReturns := fake.getEnvironmentVariableGroupReturns fake.recordInvocation("GetEnvironmentVariableGroup", []interface{}{arg1}) fake.getEnvironmentVariableGroupMutex.Unlock() - if fake.GetEnvironmentVariableGroupStub != nil { - return fake.GetEnvironmentVariableGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getEnvironmentVariableGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9247,6 +9629,76 @@ func (fake *FakeActor) GetEnvironmentVariableGroupReturnsOnCall(i int, result1 v }{result1, result2, result3} } +func (fake *FakeActor) GetEnvironmentVariableGroupByRevision(arg1 resources.Revision) (v7action.EnvironmentVariableGroup, bool, v7action.Warnings, error) { + fake.getEnvironmentVariableGroupByRevisionMutex.Lock() + ret, specificReturn := fake.getEnvironmentVariableGroupByRevisionReturnsOnCall[len(fake.getEnvironmentVariableGroupByRevisionArgsForCall)] + fake.getEnvironmentVariableGroupByRevisionArgsForCall = append(fake.getEnvironmentVariableGroupByRevisionArgsForCall, struct { + arg1 resources.Revision + }{arg1}) + stub := fake.GetEnvironmentVariableGroupByRevisionStub + fakeReturns := fake.getEnvironmentVariableGroupByRevisionReturns + fake.recordInvocation("GetEnvironmentVariableGroupByRevision", []interface{}{arg1}) + fake.getEnvironmentVariableGroupByRevisionMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3, ret.result4 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 +} + +func (fake *FakeActor) GetEnvironmentVariableGroupByRevisionCallCount() int { + fake.getEnvironmentVariableGroupByRevisionMutex.RLock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.RUnlock() + return len(fake.getEnvironmentVariableGroupByRevisionArgsForCall) +} + +func (fake *FakeActor) GetEnvironmentVariableGroupByRevisionCalls(stub func(resources.Revision) (v7action.EnvironmentVariableGroup, bool, v7action.Warnings, error)) { + fake.getEnvironmentVariableGroupByRevisionMutex.Lock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.Unlock() + fake.GetEnvironmentVariableGroupByRevisionStub = stub +} + +func (fake *FakeActor) GetEnvironmentVariableGroupByRevisionArgsForCall(i int) resources.Revision { + fake.getEnvironmentVariableGroupByRevisionMutex.RLock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.RUnlock() + argsForCall := fake.getEnvironmentVariableGroupByRevisionArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeActor) GetEnvironmentVariableGroupByRevisionReturns(result1 v7action.EnvironmentVariableGroup, result2 bool, result3 v7action.Warnings, result4 error) { + fake.getEnvironmentVariableGroupByRevisionMutex.Lock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.Unlock() + fake.GetEnvironmentVariableGroupByRevisionStub = nil + fake.getEnvironmentVariableGroupByRevisionReturns = struct { + result1 v7action.EnvironmentVariableGroup + result2 bool + result3 v7action.Warnings + result4 error + }{result1, result2, result3, result4} +} + +func (fake *FakeActor) GetEnvironmentVariableGroupByRevisionReturnsOnCall(i int, result1 v7action.EnvironmentVariableGroup, result2 bool, result3 v7action.Warnings, result4 error) { + fake.getEnvironmentVariableGroupByRevisionMutex.Lock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.Unlock() + fake.GetEnvironmentVariableGroupByRevisionStub = nil + if fake.getEnvironmentVariableGroupByRevisionReturnsOnCall == nil { + fake.getEnvironmentVariableGroupByRevisionReturnsOnCall = make(map[int]struct { + result1 v7action.EnvironmentVariableGroup + result2 bool + result3 v7action.Warnings + result4 error + }) + } + fake.getEnvironmentVariableGroupByRevisionReturnsOnCall[i] = struct { + result1 v7action.EnvironmentVariableGroup + result2 bool + result3 v7action.Warnings + result4 error + }{result1, result2, result3, result4} +} + func (fake *FakeActor) GetEnvironmentVariablesByApplicationNameAndSpace(arg1 string, arg2 string) (v7action.EnvironmentVariableGroups, v7action.Warnings, error) { fake.getEnvironmentVariablesByApplicationNameAndSpaceMutex.Lock() ret, specificReturn := fake.getEnvironmentVariablesByApplicationNameAndSpaceReturnsOnCall[len(fake.getEnvironmentVariablesByApplicationNameAndSpaceArgsForCall)] @@ -9254,15 +9706,16 @@ func (fake *FakeActor) GetEnvironmentVariablesByApplicationNameAndSpace(arg1 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetEnvironmentVariablesByApplicationNameAndSpaceStub + fakeReturns := fake.getEnvironmentVariablesByApplicationNameAndSpaceReturns fake.recordInvocation("GetEnvironmentVariablesByApplicationNameAndSpace", []interface{}{arg1, arg2}) fake.getEnvironmentVariablesByApplicationNameAndSpaceMutex.Unlock() - if fake.GetEnvironmentVariablesByApplicationNameAndSpaceStub != nil { - return fake.GetEnvironmentVariablesByApplicationNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getEnvironmentVariablesByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9320,15 +9773,16 @@ func (fake *FakeActor) GetFeatureFlagByName(arg1 string) (resources.FeatureFlag, fake.getFeatureFlagByNameArgsForCall = append(fake.getFeatureFlagByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetFeatureFlagByNameStub + fakeReturns := fake.getFeatureFlagByNameReturns fake.recordInvocation("GetFeatureFlagByName", []interface{}{arg1}) fake.getFeatureFlagByNameMutex.Unlock() - if fake.GetFeatureFlagByNameStub != nil { - return fake.GetFeatureFlagByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getFeatureFlagByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9385,15 +9839,16 @@ func (fake *FakeActor) GetFeatureFlags() ([]resources.FeatureFlag, v7action.Warn ret, specificReturn := fake.getFeatureFlagsReturnsOnCall[len(fake.getFeatureFlagsArgsForCall)] fake.getFeatureFlagsArgsForCall = append(fake.getFeatureFlagsArgsForCall, struct { }{}) + stub := fake.GetFeatureFlagsStub + fakeReturns := fake.getFeatureFlagsReturns fake.recordInvocation("GetFeatureFlags", []interface{}{}) fake.getFeatureFlagsMutex.Unlock() - if fake.GetFeatureFlagsStub != nil { - return fake.GetFeatureFlagsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getFeatureFlagsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9443,15 +9898,16 @@ func (fake *FakeActor) GetGlobalRunningSecurityGroups() ([]resources.SecurityGro ret, specificReturn := fake.getGlobalRunningSecurityGroupsReturnsOnCall[len(fake.getGlobalRunningSecurityGroupsArgsForCall)] fake.getGlobalRunningSecurityGroupsArgsForCall = append(fake.getGlobalRunningSecurityGroupsArgsForCall, struct { }{}) + stub := fake.GetGlobalRunningSecurityGroupsStub + fakeReturns := fake.getGlobalRunningSecurityGroupsReturns fake.recordInvocation("GetGlobalRunningSecurityGroups", []interface{}{}) fake.getGlobalRunningSecurityGroupsMutex.Unlock() - if fake.GetGlobalRunningSecurityGroupsStub != nil { - return fake.GetGlobalRunningSecurityGroupsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getGlobalRunningSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9501,15 +9957,16 @@ func (fake *FakeActor) GetGlobalStagingSecurityGroups() ([]resources.SecurityGro ret, specificReturn := fake.getGlobalStagingSecurityGroupsReturnsOnCall[len(fake.getGlobalStagingSecurityGroupsArgsForCall)] fake.getGlobalStagingSecurityGroupsArgsForCall = append(fake.getGlobalStagingSecurityGroupsArgsForCall, struct { }{}) + stub := fake.GetGlobalStagingSecurityGroupsStub + fakeReturns := fake.getGlobalStagingSecurityGroupsReturns fake.recordInvocation("GetGlobalStagingSecurityGroups", []interface{}{}) fake.getGlobalStagingSecurityGroupsMutex.Unlock() - if fake.GetGlobalStagingSecurityGroupsStub != nil { - return fake.GetGlobalStagingSecurityGroupsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getGlobalStagingSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9554,21 +10011,81 @@ func (fake *FakeActor) GetGlobalStagingSecurityGroupsReturnsOnCall(i int, result }{result1, result2, result3} } -func (fake *FakeActor) GetIsolationSegmentByName(arg1 string) (resources.IsolationSegment, v7action.Warnings, error) { - fake.getIsolationSegmentByNameMutex.Lock() - ret, specificReturn := fake.getIsolationSegmentByNameReturnsOnCall[len(fake.getIsolationSegmentByNameArgsForCall)] - fake.getIsolationSegmentByNameArgsForCall = append(fake.getIsolationSegmentByNameArgsForCall, struct { - arg1 string - }{arg1}) - fake.recordInvocation("GetIsolationSegmentByName", []interface{}{arg1}) - fake.getIsolationSegmentByNameMutex.Unlock() - if fake.GetIsolationSegmentByNameStub != nil { - return fake.GetIsolationSegmentByNameStub(arg1) +func (fake *FakeActor) GetInfoResponse() (v7action.Info, v7action.Warnings, error) { + fake.getInfoResponseMutex.Lock() + ret, specificReturn := fake.getInfoResponseReturnsOnCall[len(fake.getInfoResponseArgsForCall)] + fake.getInfoResponseArgsForCall = append(fake.getInfoResponseArgsForCall, struct { + }{}) + stub := fake.GetInfoResponseStub + fakeReturns := fake.getInfoResponseReturns + fake.recordInvocation("GetInfoResponse", []interface{}{}) + fake.getInfoResponseMutex.Unlock() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeActor) GetInfoResponseCallCount() int { + fake.getInfoResponseMutex.RLock() + defer fake.getInfoResponseMutex.RUnlock() + return len(fake.getInfoResponseArgsForCall) +} + +func (fake *FakeActor) GetInfoResponseCalls(stub func() (v7action.Info, v7action.Warnings, error)) { + fake.getInfoResponseMutex.Lock() + defer fake.getInfoResponseMutex.Unlock() + fake.GetInfoResponseStub = stub +} + +func (fake *FakeActor) GetInfoResponseReturns(result1 v7action.Info, result2 v7action.Warnings, result3 error) { + fake.getInfoResponseMutex.Lock() + defer fake.getInfoResponseMutex.Unlock() + fake.GetInfoResponseStub = nil + fake.getInfoResponseReturns = struct { + result1 v7action.Info + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) GetInfoResponseReturnsOnCall(i int, result1 v7action.Info, result2 v7action.Warnings, result3 error) { + fake.getInfoResponseMutex.Lock() + defer fake.getInfoResponseMutex.Unlock() + fake.GetInfoResponseStub = nil + if fake.getInfoResponseReturnsOnCall == nil { + fake.getInfoResponseReturnsOnCall = make(map[int]struct { + result1 v7action.Info + result2 v7action.Warnings + result3 error + }) + } + fake.getInfoResponseReturnsOnCall[i] = struct { + result1 v7action.Info + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) GetIsolationSegmentByName(arg1 string) (resources.IsolationSegment, v7action.Warnings, error) { + fake.getIsolationSegmentByNameMutex.Lock() + ret, specificReturn := fake.getIsolationSegmentByNameReturnsOnCall[len(fake.getIsolationSegmentByNameArgsForCall)] + fake.getIsolationSegmentByNameArgsForCall = append(fake.getIsolationSegmentByNameArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.GetIsolationSegmentByNameStub fakeReturns := fake.getIsolationSegmentByNameReturns + fake.recordInvocation("GetIsolationSegmentByName", []interface{}{arg1}) + fake.getIsolationSegmentByNameMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9625,15 +10142,16 @@ func (fake *FakeActor) GetIsolationSegmentSummaries() ([]v7action.IsolationSegme ret, specificReturn := fake.getIsolationSegmentSummariesReturnsOnCall[len(fake.getIsolationSegmentSummariesArgsForCall)] fake.getIsolationSegmentSummariesArgsForCall = append(fake.getIsolationSegmentSummariesArgsForCall, struct { }{}) + stub := fake.GetIsolationSegmentSummariesStub + fakeReturns := fake.getIsolationSegmentSummariesReturns fake.recordInvocation("GetIsolationSegmentSummaries", []interface{}{}) fake.getIsolationSegmentSummariesMutex.Unlock() - if fake.GetIsolationSegmentSummariesStub != nil { - return fake.GetIsolationSegmentSummariesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getIsolationSegmentSummariesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9684,15 +10202,16 @@ func (fake *FakeActor) GetIsolationSegmentsByOrganization(arg1 string) ([]resour fake.getIsolationSegmentsByOrganizationArgsForCall = append(fake.getIsolationSegmentsByOrganizationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetIsolationSegmentsByOrganizationStub + fakeReturns := fake.getIsolationSegmentsByOrganizationReturns fake.recordInvocation("GetIsolationSegmentsByOrganization", []interface{}{arg1}) fake.getIsolationSegmentsByOrganizationMutex.Unlock() - if fake.GetIsolationSegmentsByOrganizationStub != nil { - return fake.GetIsolationSegmentsByOrganizationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getIsolationSegmentsByOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9750,15 +10269,16 @@ func (fake *FakeActor) GetLatestActiveDeploymentForApp(arg1 string) (resources.D fake.getLatestActiveDeploymentForAppArgsForCall = append(fake.getLatestActiveDeploymentForAppArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetLatestActiveDeploymentForAppStub + fakeReturns := fake.getLatestActiveDeploymentForAppReturns fake.recordInvocation("GetLatestActiveDeploymentForApp", []interface{}{arg1}) fake.getLatestActiveDeploymentForAppMutex.Unlock() - if fake.GetLatestActiveDeploymentForAppStub != nil { - return fake.GetLatestActiveDeploymentForAppStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getLatestActiveDeploymentForAppReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9815,15 +10335,16 @@ func (fake *FakeActor) GetLoginPrompts() (map[string]coreconfig.AuthPrompt, erro ret, specificReturn := fake.getLoginPromptsReturnsOnCall[len(fake.getLoginPromptsArgsForCall)] fake.getLoginPromptsArgsForCall = append(fake.getLoginPromptsArgsForCall, struct { }{}) + stub := fake.GetLoginPromptsStub + fakeReturns := fake.getLoginPromptsReturns fake.recordInvocation("GetLoginPrompts", []interface{}{}) fake.getLoginPromptsMutex.Unlock() - if fake.GetLoginPromptsStub != nil { - return fake.GetLoginPromptsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getLoginPromptsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -9871,15 +10392,16 @@ func (fake *FakeActor) GetNewestReadyPackageForApplication(arg1 resources.Applic fake.getNewestReadyPackageForApplicationArgsForCall = append(fake.getNewestReadyPackageForApplicationArgsForCall, struct { arg1 resources.Application }{arg1}) + stub := fake.GetNewestReadyPackageForApplicationStub + fakeReturns := fake.getNewestReadyPackageForApplicationReturns fake.recordInvocation("GetNewestReadyPackageForApplication", []interface{}{arg1}) fake.getNewestReadyPackageForApplicationMutex.Unlock() - if fake.GetNewestReadyPackageForApplicationStub != nil { - return fake.GetNewestReadyPackageForApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getNewestReadyPackageForApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -9937,15 +10459,16 @@ func (fake *FakeActor) GetOrgUsersByRoleType(arg1 string) (map[constanta.RoleTyp fake.getOrgUsersByRoleTypeArgsForCall = append(fake.getOrgUsersByRoleTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrgUsersByRoleTypeStub + fakeReturns := fake.getOrgUsersByRoleTypeReturns fake.recordInvocation("GetOrgUsersByRoleType", []interface{}{arg1}) fake.getOrgUsersByRoleTypeMutex.Unlock() - if fake.GetOrgUsersByRoleTypeStub != nil { - return fake.GetOrgUsersByRoleTypeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrgUsersByRoleTypeReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10003,15 +10526,16 @@ func (fake *FakeActor) GetOrganizationByName(arg1 string) (resources.Organizatio fake.getOrganizationByNameArgsForCall = append(fake.getOrganizationByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationByNameStub + fakeReturns := fake.getOrganizationByNameReturns fake.recordInvocation("GetOrganizationByName", []interface{}{arg1}) fake.getOrganizationByNameMutex.Unlock() - if fake.GetOrganizationByNameStub != nil { - return fake.GetOrganizationByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10070,15 +10594,16 @@ func (fake *FakeActor) GetOrganizationDomains(arg1 string, arg2 string) ([]resou arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetOrganizationDomainsStub + fakeReturns := fake.getOrganizationDomainsReturns fake.recordInvocation("GetOrganizationDomains", []interface{}{arg1, arg2}) fake.getOrganizationDomainsMutex.Unlock() - if fake.GetOrganizationDomainsStub != nil { - return fake.GetOrganizationDomainsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationDomainsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10136,15 +10661,16 @@ func (fake *FakeActor) GetOrganizationLabels(arg1 string) (map[string]types.Null fake.getOrganizationLabelsArgsForCall = append(fake.getOrganizationLabelsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationLabelsStub + fakeReturns := fake.getOrganizationLabelsReturns fake.recordInvocation("GetOrganizationLabels", []interface{}{arg1}) fake.getOrganizationLabelsMutex.Unlock() - if fake.GetOrganizationLabelsStub != nil { - return fake.GetOrganizationLabelsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10202,15 +10728,16 @@ func (fake *FakeActor) GetOrganizationQuotaByName(arg1 string) (resources.Organi fake.getOrganizationQuotaByNameArgsForCall = append(fake.getOrganizationQuotaByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationQuotaByNameStub + fakeReturns := fake.getOrganizationQuotaByNameReturns fake.recordInvocation("GetOrganizationQuotaByName", []interface{}{arg1}) fake.getOrganizationQuotaByNameMutex.Unlock() - if fake.GetOrganizationQuotaByNameStub != nil { - return fake.GetOrganizationQuotaByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationQuotaByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10267,15 +10794,16 @@ func (fake *FakeActor) GetOrganizationQuotas() ([]resources.OrganizationQuota, v ret, specificReturn := fake.getOrganizationQuotasReturnsOnCall[len(fake.getOrganizationQuotasArgsForCall)] fake.getOrganizationQuotasArgsForCall = append(fake.getOrganizationQuotasArgsForCall, struct { }{}) + stub := fake.GetOrganizationQuotasStub + fakeReturns := fake.getOrganizationQuotasReturns fake.recordInvocation("GetOrganizationQuotas", []interface{}{}) fake.getOrganizationQuotasMutex.Unlock() - if fake.GetOrganizationQuotasStub != nil { - return fake.GetOrganizationQuotasStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationQuotasReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10326,15 +10854,16 @@ func (fake *FakeActor) GetOrganizationSpaces(arg1 string) ([]resources.Space, v7 fake.getOrganizationSpacesArgsForCall = append(fake.getOrganizationSpacesArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationSpacesStub + fakeReturns := fake.getOrganizationSpacesReturns fake.recordInvocation("GetOrganizationSpaces", []interface{}{arg1}) fake.getOrganizationSpacesMutex.Unlock() - if fake.GetOrganizationSpacesStub != nil { - return fake.GetOrganizationSpacesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationSpacesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10393,15 +10922,16 @@ func (fake *FakeActor) GetOrganizationSpacesWithLabelSelector(arg1 string, arg2 arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetOrganizationSpacesWithLabelSelectorStub + fakeReturns := fake.getOrganizationSpacesWithLabelSelectorReturns fake.recordInvocation("GetOrganizationSpacesWithLabelSelector", []interface{}{arg1, arg2}) fake.getOrganizationSpacesWithLabelSelectorMutex.Unlock() - if fake.GetOrganizationSpacesWithLabelSelectorStub != nil { - return fake.GetOrganizationSpacesWithLabelSelectorStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationSpacesWithLabelSelectorReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10459,15 +10989,16 @@ func (fake *FakeActor) GetOrganizationSummaryByName(arg1 string) (v7action.Organ fake.getOrganizationSummaryByNameArgsForCall = append(fake.getOrganizationSummaryByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationSummaryByNameStub + fakeReturns := fake.getOrganizationSummaryByNameReturns fake.recordInvocation("GetOrganizationSummaryByName", []interface{}{arg1}) fake.getOrganizationSummaryByNameMutex.Unlock() - if fake.GetOrganizationSummaryByNameStub != nil { - return fake.GetOrganizationSummaryByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationSummaryByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10525,15 +11056,16 @@ func (fake *FakeActor) GetOrganizations(arg1 string) ([]resources.Organization, fake.getOrganizationsArgsForCall = append(fake.getOrganizationsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrganizationsStub + fakeReturns := fake.getOrganizationsReturns fake.recordInvocation("GetOrganizations", []interface{}{arg1}) fake.getOrganizationsMutex.Unlock() - if fake.GetOrganizationsStub != nil { - return fake.GetOrganizationsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getOrganizationsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10592,15 +11124,16 @@ func (fake *FakeActor) GetProcessByTypeAndApplication(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetProcessByTypeAndApplicationStub + fakeReturns := fake.getProcessByTypeAndApplicationReturns fake.recordInvocation("GetProcessByTypeAndApplication", []interface{}{arg1, arg2}) fake.getProcessByTypeAndApplicationMutex.Unlock() - if fake.GetProcessByTypeAndApplicationStub != nil { - return fake.GetProcessByTypeAndApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getProcessByTypeAndApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10659,15 +11192,16 @@ func (fake *FakeActor) GetRawApplicationManifestByNameAndSpace(arg1 string, arg2 arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRawApplicationManifestByNameAndSpaceStub + fakeReturns := fake.getRawApplicationManifestByNameAndSpaceReturns fake.recordInvocation("GetRawApplicationManifestByNameAndSpace", []interface{}{arg1, arg2}) fake.getRawApplicationManifestByNameAndSpaceMutex.Unlock() - if fake.GetRawApplicationManifestByNameAndSpaceStub != nil { - return fake.GetRawApplicationManifestByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRawApplicationManifestByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10726,15 +11260,16 @@ func (fake *FakeActor) GetRecentEventsByApplicationNameAndSpace(arg1 string, arg arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRecentEventsByApplicationNameAndSpaceStub + fakeReturns := fake.getRecentEventsByApplicationNameAndSpaceReturns fake.recordInvocation("GetRecentEventsByApplicationNameAndSpace", []interface{}{arg1, arg2}) fake.getRecentEventsByApplicationNameAndSpaceMutex.Unlock() - if fake.GetRecentEventsByApplicationNameAndSpaceStub != nil { - return fake.GetRecentEventsByApplicationNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRecentEventsByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10794,15 +11329,16 @@ func (fake *FakeActor) GetRecentLogsForApplicationByNameAndSpace(arg1 string, ar arg2 string arg3 sharedaction.LogCacheClient }{arg1, arg2, arg3}) + stub := fake.GetRecentLogsForApplicationByNameAndSpaceStub + fakeReturns := fake.getRecentLogsForApplicationByNameAndSpaceReturns fake.recordInvocation("GetRecentLogsForApplicationByNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.getRecentLogsForApplicationByNameAndSpaceMutex.Unlock() - if fake.GetRecentLogsForApplicationByNameAndSpaceStub != nil { - return fake.GetRecentLogsForApplicationByNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRecentLogsForApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10861,15 +11397,16 @@ func (fake *FakeActor) GetRevisionByApplicationAndVersion(arg1 string, arg2 int) arg1 string arg2 int }{arg1, arg2}) + stub := fake.GetRevisionByApplicationAndVersionStub + fakeReturns := fake.getRevisionByApplicationAndVersionReturns fake.recordInvocation("GetRevisionByApplicationAndVersion", []interface{}{arg1, arg2}) fake.getRevisionByApplicationAndVersionMutex.Unlock() - if fake.GetRevisionByApplicationAndVersionStub != nil { - return fake.GetRevisionByApplicationAndVersionStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRevisionByApplicationAndVersionReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10928,15 +11465,16 @@ func (fake *FakeActor) GetRevisionsByApplicationNameAndSpace(arg1 string, arg2 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRevisionsByApplicationNameAndSpaceStub + fakeReturns := fake.getRevisionsByApplicationNameAndSpaceReturns fake.recordInvocation("GetRevisionsByApplicationNameAndSpace", []interface{}{arg1, arg2}) fake.getRevisionsByApplicationNameAndSpaceMutex.Unlock() - if fake.GetRevisionsByApplicationNameAndSpaceStub != nil { - return fake.GetRevisionsByApplicationNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRevisionsByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -10988,20 +11526,21 @@ func (fake *FakeActor) GetRevisionsByApplicationNameAndSpaceReturnsOnCall(i int, }{result1, result2, result3} } -func (fake *FakeActor) GetRootResponse() (v7action.Info, v7action.Warnings, error) { +func (fake *FakeActor) GetRootResponse() (v7action.Root, v7action.Warnings, error) { fake.getRootResponseMutex.Lock() ret, specificReturn := fake.getRootResponseReturnsOnCall[len(fake.getRootResponseArgsForCall)] fake.getRootResponseArgsForCall = append(fake.getRootResponseArgsForCall, struct { }{}) + stub := fake.GetRootResponseStub + fakeReturns := fake.getRootResponseReturns fake.recordInvocation("GetRootResponse", []interface{}{}) fake.getRootResponseMutex.Unlock() - if fake.GetRootResponseStub != nil { - return fake.GetRootResponseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRootResponseReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11011,36 +11550,36 @@ func (fake *FakeActor) GetRootResponseCallCount() int { return len(fake.getRootResponseArgsForCall) } -func (fake *FakeActor) GetRootResponseCalls(stub func() (v7action.Info, v7action.Warnings, error)) { +func (fake *FakeActor) GetRootResponseCalls(stub func() (v7action.Root, v7action.Warnings, error)) { fake.getRootResponseMutex.Lock() defer fake.getRootResponseMutex.Unlock() fake.GetRootResponseStub = stub } -func (fake *FakeActor) GetRootResponseReturns(result1 v7action.Info, result2 v7action.Warnings, result3 error) { +func (fake *FakeActor) GetRootResponseReturns(result1 v7action.Root, result2 v7action.Warnings, result3 error) { fake.getRootResponseMutex.Lock() defer fake.getRootResponseMutex.Unlock() fake.GetRootResponseStub = nil fake.getRootResponseReturns = struct { - result1 v7action.Info + result1 v7action.Root result2 v7action.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeActor) GetRootResponseReturnsOnCall(i int, result1 v7action.Info, result2 v7action.Warnings, result3 error) { +func (fake *FakeActor) GetRootResponseReturnsOnCall(i int, result1 v7action.Root, result2 v7action.Warnings, result3 error) { fake.getRootResponseMutex.Lock() defer fake.getRootResponseMutex.Unlock() fake.GetRootResponseStub = nil if fake.getRootResponseReturnsOnCall == nil { fake.getRootResponseReturnsOnCall = make(map[int]struct { - result1 v7action.Info + result1 v7action.Root result2 v7action.Warnings result3 error }) } fake.getRootResponseReturnsOnCall[i] = struct { - result1 v7action.Info + result1 v7action.Root result2 v7action.Warnings result3 error }{result1, result2, result3} @@ -11055,15 +11594,16 @@ func (fake *FakeActor) GetRouteByAttributes(arg1 resources.Domain, arg2 string, arg3 string arg4 int }{arg1, arg2, arg3, arg4}) + stub := fake.GetRouteByAttributesStub + fakeReturns := fake.getRouteByAttributesReturns fake.recordInvocation("GetRouteByAttributes", []interface{}{arg1, arg2, arg3, arg4}) fake.getRouteByAttributesMutex.Unlock() - if fake.GetRouteByAttributesStub != nil { - return fake.GetRouteByAttributesStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRouteByAttributesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11122,15 +11662,16 @@ func (fake *FakeActor) GetRouteDestinationByAppGUID(arg1 resources.Route, arg2 s arg1 resources.Route arg2 string }{arg1, arg2}) + stub := fake.GetRouteDestinationByAppGUIDStub + fakeReturns := fake.getRouteDestinationByAppGUIDReturns fake.recordInvocation("GetRouteDestinationByAppGUID", []interface{}{arg1, arg2}) fake.getRouteDestinationByAppGUIDMutex.Unlock() - if fake.GetRouteDestinationByAppGUIDStub != nil { - return fake.GetRouteDestinationByAppGUIDStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getRouteDestinationByAppGUIDReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11186,15 +11727,16 @@ func (fake *FakeActor) GetRouteLabels(arg1 string, arg2 string) (map[string]type arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRouteLabelsStub + fakeReturns := fake.getRouteLabelsReturns fake.recordInvocation("GetRouteLabels", []interface{}{arg1, arg2}) fake.getRouteLabelsMutex.Unlock() - if fake.GetRouteLabelsStub != nil { - return fake.GetRouteLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRouteLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11257,15 +11799,16 @@ func (fake *FakeActor) GetRouteSummaries(arg1 []resources.Route) ([]v7action.Rou fake.getRouteSummariesArgsForCall = append(fake.getRouteSummariesArgsForCall, struct { arg1 []resources.Route }{arg1Copy}) + stub := fake.GetRouteSummariesStub + fakeReturns := fake.getRouteSummariesReturns fake.recordInvocation("GetRouteSummaries", []interface{}{arg1Copy}) fake.getRouteSummariesMutex.Unlock() - if fake.GetRouteSummariesStub != nil { - return fake.GetRouteSummariesStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRouteSummariesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11322,15 +11865,16 @@ func (fake *FakeActor) GetRouterGroups() ([]v7action.RouterGroup, error) { ret, specificReturn := fake.getRouterGroupsReturnsOnCall[len(fake.getRouterGroupsArgsForCall)] fake.getRouterGroupsArgsForCall = append(fake.getRouterGroupsArgsForCall, struct { }{}) + stub := fake.GetRouterGroupsStub + fakeReturns := fake.getRouterGroupsReturns fake.recordInvocation("GetRouterGroups", []interface{}{}) fake.getRouterGroupsMutex.Unlock() - if fake.GetRouterGroupsStub != nil { - return fake.GetRouterGroupsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getRouterGroupsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11379,15 +11923,16 @@ func (fake *FakeActor) GetRoutesByOrg(arg1 string, arg2 string) ([]resources.Rou arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRoutesByOrgStub + fakeReturns := fake.getRoutesByOrgReturns fake.recordInvocation("GetRoutesByOrg", []interface{}{arg1, arg2}) fake.getRoutesByOrgMutex.Unlock() - if fake.GetRoutesByOrgStub != nil { - return fake.GetRoutesByOrgStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRoutesByOrgReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11446,15 +11991,16 @@ func (fake *FakeActor) GetRoutesBySpace(arg1 string, arg2 string) ([]resources.R arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRoutesBySpaceStub + fakeReturns := fake.getRoutesBySpaceReturns fake.recordInvocation("GetRoutesBySpace", []interface{}{arg1, arg2}) fake.getRoutesBySpaceMutex.Unlock() - if fake.GetRoutesBySpaceStub != nil { - return fake.GetRoutesBySpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRoutesBySpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11512,15 +12058,16 @@ func (fake *FakeActor) GetSSHEnabled(arg1 string) (ccv3.SSHEnabled, v7action.War fake.getSSHEnabledArgsForCall = append(fake.getSSHEnabledArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSSHEnabledStub + fakeReturns := fake.getSSHEnabledReturns fake.recordInvocation("GetSSHEnabled", []interface{}{arg1}) fake.getSSHEnabledMutex.Unlock() - if fake.GetSSHEnabledStub != nil { - return fake.GetSSHEnabledStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSSHEnabledReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11579,15 +12126,16 @@ func (fake *FakeActor) GetSSHEnabledByAppName(arg1 string, arg2 string) (ccv3.SS arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSSHEnabledByAppNameStub + fakeReturns := fake.getSSHEnabledByAppNameReturns fake.recordInvocation("GetSSHEnabledByAppName", []interface{}{arg1, arg2}) fake.getSSHEnabledByAppNameMutex.Unlock() - if fake.GetSSHEnabledByAppNameStub != nil { - return fake.GetSSHEnabledByAppNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSSHEnabledByAppNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11644,15 +12192,16 @@ func (fake *FakeActor) GetSSHPasscode() (string, error) { ret, specificReturn := fake.getSSHPasscodeReturnsOnCall[len(fake.getSSHPasscodeArgsForCall)] fake.getSSHPasscodeArgsForCall = append(fake.getSSHPasscodeArgsForCall, struct { }{}) + stub := fake.GetSSHPasscodeStub + fakeReturns := fake.getSSHPasscodeReturns fake.recordInvocation("GetSSHPasscode", []interface{}{}) fake.getSSHPasscodeMutex.Unlock() - if fake.GetSSHPasscodeStub != nil { - return fake.GetSSHPasscodeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSSHPasscodeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -11703,15 +12252,16 @@ func (fake *FakeActor) GetSecureShellConfigurationByApplicationNameSpaceProcessT arg3 string arg4 uint }{arg1, arg2, arg3, arg4}) + stub := fake.GetSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexStub + fakeReturns := fake.getSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexReturns fake.recordInvocation("GetSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndex", []interface{}{arg1, arg2, arg3, arg4}) fake.getSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexMutex.Unlock() - if fake.GetSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexStub != nil { - return fake.GetSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSecureShellConfigurationByApplicationNameSpaceProcessTypeAndIndexReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11769,15 +12319,16 @@ func (fake *FakeActor) GetSecurityGroup(arg1 string) (resources.SecurityGroup, v fake.getSecurityGroupArgsForCall = append(fake.getSecurityGroupArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSecurityGroupStub + fakeReturns := fake.getSecurityGroupReturns fake.recordInvocation("GetSecurityGroup", []interface{}{arg1}) fake.getSecurityGroupMutex.Unlock() - if fake.GetSecurityGroupStub != nil { - return fake.GetSecurityGroupStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11835,15 +12386,16 @@ func (fake *FakeActor) GetSecurityGroupSummary(arg1 string) (v7action.SecurityGr fake.getSecurityGroupSummaryArgsForCall = append(fake.getSecurityGroupSummaryArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSecurityGroupSummaryStub + fakeReturns := fake.getSecurityGroupSummaryReturns fake.recordInvocation("GetSecurityGroupSummary", []interface{}{arg1}) fake.getSecurityGroupSummaryMutex.Unlock() - if fake.GetSecurityGroupSummaryStub != nil { - return fake.GetSecurityGroupSummaryStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSecurityGroupSummaryReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11900,15 +12452,16 @@ func (fake *FakeActor) GetSecurityGroups() ([]v7action.SecurityGroupSummary, v7a ret, specificReturn := fake.getSecurityGroupsReturnsOnCall[len(fake.getSecurityGroupsArgsForCall)] fake.getSecurityGroupsArgsForCall = append(fake.getSecurityGroupsArgsForCall, struct { }{}) + stub := fake.GetSecurityGroupsStub + fakeReturns := fake.getSecurityGroupsReturns fake.recordInvocation("GetSecurityGroups", []interface{}{}) fake.getSecurityGroupsMutex.Unlock() - if fake.GetSecurityGroupsStub != nil { - return fake.GetSecurityGroupsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSecurityGroupsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -11961,15 +12514,16 @@ func (fake *FakeActor) GetServiceAccess(arg1 string, arg2 string, arg3 string) ( arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetServiceAccessStub + fakeReturns := fake.getServiceAccessReturns fake.recordInvocation("GetServiceAccess", []interface{}{arg1, arg2, arg3}) fake.getServiceAccessMutex.Unlock() - if fake.GetServiceAccessStub != nil { - return fake.GetServiceAccessStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceAccessReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12027,15 +12581,16 @@ func (fake *FakeActor) GetServiceBrokerByName(arg1 string) (resources.ServiceBro fake.getServiceBrokerByNameArgsForCall = append(fake.getServiceBrokerByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceBrokerByNameStub + fakeReturns := fake.getServiceBrokerByNameReturns fake.recordInvocation("GetServiceBrokerByName", []interface{}{arg1}) fake.getServiceBrokerByNameMutex.Unlock() - if fake.GetServiceBrokerByNameStub != nil { - return fake.GetServiceBrokerByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceBrokerByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12093,15 +12648,16 @@ func (fake *FakeActor) GetServiceBrokerLabels(arg1 string) (map[string]types.Nul fake.getServiceBrokerLabelsArgsForCall = append(fake.getServiceBrokerLabelsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceBrokerLabelsStub + fakeReturns := fake.getServiceBrokerLabelsReturns fake.recordInvocation("GetServiceBrokerLabels", []interface{}{arg1}) fake.getServiceBrokerLabelsMutex.Unlock() - if fake.GetServiceBrokerLabelsStub != nil { - return fake.GetServiceBrokerLabelsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceBrokerLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12158,15 +12714,16 @@ func (fake *FakeActor) GetServiceBrokers() ([]resources.ServiceBroker, v7action. ret, specificReturn := fake.getServiceBrokersReturnsOnCall[len(fake.getServiceBrokersArgsForCall)] fake.getServiceBrokersArgsForCall = append(fake.getServiceBrokersArgsForCall, struct { }{}) + stub := fake.GetServiceBrokersStub + fakeReturns := fake.getServiceBrokersReturns fake.recordInvocation("GetServiceBrokers", []interface{}{}) fake.getServiceBrokersMutex.Unlock() - if fake.GetServiceBrokersStub != nil { - return fake.GetServiceBrokersStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceBrokersReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12218,15 +12775,16 @@ func (fake *FakeActor) GetServiceInstanceByNameAndSpace(arg1 string, arg2 string arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceInstanceByNameAndSpaceStub + fakeReturns := fake.getServiceInstanceByNameAndSpaceReturns fake.recordInvocation("GetServiceInstanceByNameAndSpace", []interface{}{arg1, arg2}) fake.getServiceInstanceByNameAndSpaceMutex.Unlock() - if fake.GetServiceInstanceByNameAndSpaceStub != nil { - return fake.GetServiceInstanceByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12286,15 +12844,16 @@ func (fake *FakeActor) GetServiceInstanceDetails(arg1 string, arg2 string, arg3 arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.GetServiceInstanceDetailsStub + fakeReturns := fake.getServiceInstanceDetailsReturns fake.recordInvocation("GetServiceInstanceDetails", []interface{}{arg1, arg2, arg3}) fake.getServiceInstanceDetailsMutex.Unlock() - if fake.GetServiceInstanceDetailsStub != nil { - return fake.GetServiceInstanceDetailsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceDetailsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12353,15 +12912,16 @@ func (fake *FakeActor) GetServiceInstanceLabels(arg1 string, arg2 string) (map[s arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceInstanceLabelsStub + fakeReturns := fake.getServiceInstanceLabelsReturns fake.recordInvocation("GetServiceInstanceLabels", []interface{}{arg1, arg2}) fake.getServiceInstanceLabelsMutex.Unlock() - if fake.GetServiceInstanceLabelsStub != nil { - return fake.GetServiceInstanceLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12420,15 +12980,16 @@ func (fake *FakeActor) GetServiceInstanceParameters(arg1 string, arg2 string) (v arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceInstanceParametersStub + fakeReturns := fake.getServiceInstanceParametersReturns fake.recordInvocation("GetServiceInstanceParameters", []interface{}{arg1, arg2}) fake.getServiceInstanceParametersMutex.Unlock() - if fake.GetServiceInstanceParametersStub != nil { - return fake.GetServiceInstanceParametersStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstanceParametersReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12487,15 +13048,16 @@ func (fake *FakeActor) GetServiceInstancesForSpace(arg1 string, arg2 bool) ([]v7 arg1 string arg2 bool }{arg1, arg2}) + stub := fake.GetServiceInstancesForSpaceStub + fakeReturns := fake.getServiceInstancesForSpaceReturns fake.recordInvocation("GetServiceInstancesForSpace", []interface{}{arg1, arg2}) fake.getServiceInstancesForSpaceMutex.Unlock() - if fake.GetServiceInstancesForSpaceStub != nil { - return fake.GetServiceInstancesForSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceInstancesForSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12555,15 +13117,16 @@ func (fake *FakeActor) GetServiceKeyByServiceInstanceAndName(arg1 string, arg2 s arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetServiceKeyByServiceInstanceAndNameStub + fakeReturns := fake.getServiceKeyByServiceInstanceAndNameReturns fake.recordInvocation("GetServiceKeyByServiceInstanceAndName", []interface{}{arg1, arg2, arg3}) fake.getServiceKeyByServiceInstanceAndNameMutex.Unlock() - if fake.GetServiceKeyByServiceInstanceAndNameStub != nil { - return fake.GetServiceKeyByServiceInstanceAndNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceKeyByServiceInstanceAndNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12623,15 +13186,16 @@ func (fake *FakeActor) GetServiceKeyDetailsByServiceInstanceAndName(arg1 string, arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetServiceKeyDetailsByServiceInstanceAndNameStub + fakeReturns := fake.getServiceKeyDetailsByServiceInstanceAndNameReturns fake.recordInvocation("GetServiceKeyDetailsByServiceInstanceAndName", []interface{}{arg1, arg2, arg3}) fake.getServiceKeyDetailsByServiceInstanceAndNameMutex.Unlock() - if fake.GetServiceKeyDetailsByServiceInstanceAndNameStub != nil { - return fake.GetServiceKeyDetailsByServiceInstanceAndNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceKeyDetailsByServiceInstanceAndNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12690,15 +13254,16 @@ func (fake *FakeActor) GetServiceKeysByServiceInstance(arg1 string, arg2 string) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceKeysByServiceInstanceStub + fakeReturns := fake.getServiceKeysByServiceInstanceReturns fake.recordInvocation("GetServiceKeysByServiceInstance", []interface{}{arg1, arg2}) fake.getServiceKeysByServiceInstanceMutex.Unlock() - if fake.GetServiceKeysByServiceInstanceStub != nil { - return fake.GetServiceKeysByServiceInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceKeysByServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12757,15 +13322,16 @@ func (fake *FakeActor) GetServiceOfferingLabels(arg1 string, arg2 string) (map[s arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetServiceOfferingLabelsStub + fakeReturns := fake.getServiceOfferingLabelsReturns fake.recordInvocation("GetServiceOfferingLabels", []interface{}{arg1, arg2}) fake.getServiceOfferingLabelsMutex.Unlock() - if fake.GetServiceOfferingLabelsStub != nil { - return fake.GetServiceOfferingLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServiceOfferingLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12825,15 +13391,16 @@ func (fake *FakeActor) GetServicePlanByNameOfferingAndBroker(arg1 string, arg2 s arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetServicePlanByNameOfferingAndBrokerStub + fakeReturns := fake.getServicePlanByNameOfferingAndBrokerReturns fake.recordInvocation("GetServicePlanByNameOfferingAndBroker", []interface{}{arg1, arg2, arg3}) fake.getServicePlanByNameOfferingAndBrokerMutex.Unlock() - if fake.GetServicePlanByNameOfferingAndBrokerStub != nil { - return fake.GetServicePlanByNameOfferingAndBrokerStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlanByNameOfferingAndBrokerReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12893,15 +13460,16 @@ func (fake *FakeActor) GetServicePlanLabels(arg1 string, arg2 string, arg3 strin arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetServicePlanLabelsStub + fakeReturns := fake.getServicePlanLabelsReturns fake.recordInvocation("GetServicePlanLabels", []interface{}{arg1, arg2, arg3}) fake.getServicePlanLabelsMutex.Unlock() - if fake.GetServicePlanLabelsStub != nil { - return fake.GetServicePlanLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getServicePlanLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -12960,15 +13528,16 @@ func (fake *FakeActor) GetSpaceByNameAndOrganization(arg1 string, arg2 string) ( arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceByNameAndOrganizationStub + fakeReturns := fake.getSpaceByNameAndOrganizationReturns fake.recordInvocation("GetSpaceByNameAndOrganization", []interface{}{arg1, arg2}) fake.getSpaceByNameAndOrganizationMutex.Unlock() - if fake.GetSpaceByNameAndOrganizationStub != nil { - return fake.GetSpaceByNameAndOrganizationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceByNameAndOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13028,15 +13597,16 @@ func (fake *FakeActor) GetSpaceFeature(arg1 string, arg2 string, arg3 string) (b arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.GetSpaceFeatureStub + fakeReturns := fake.getSpaceFeatureReturns fake.recordInvocation("GetSpaceFeature", []interface{}{arg1, arg2, arg3}) fake.getSpaceFeatureMutex.Unlock() - if fake.GetSpaceFeatureStub != nil { - return fake.GetSpaceFeatureStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceFeatureReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13095,15 +13665,16 @@ func (fake *FakeActor) GetSpaceLabels(arg1 string, arg2 string) (map[string]type arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceLabelsStub + fakeReturns := fake.getSpaceLabelsReturns fake.recordInvocation("GetSpaceLabels", []interface{}{arg1, arg2}) fake.getSpaceLabelsMutex.Unlock() - if fake.GetSpaceLabelsStub != nil { - return fake.GetSpaceLabelsStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13162,15 +13733,16 @@ func (fake *FakeActor) GetSpaceQuotaByName(arg1 string, arg2 string) (resources. arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceQuotaByNameStub + fakeReturns := fake.getSpaceQuotaByNameReturns fake.recordInvocation("GetSpaceQuotaByName", []interface{}{arg1, arg2}) fake.getSpaceQuotaByNameMutex.Unlock() - if fake.GetSpaceQuotaByNameStub != nil { - return fake.GetSpaceQuotaByNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceQuotaByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13228,15 +13800,16 @@ func (fake *FakeActor) GetSpaceQuotasByOrgGUID(arg1 string) ([]resources.SpaceQu fake.getSpaceQuotasByOrgGUIDArgsForCall = append(fake.getSpaceQuotasByOrgGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSpaceQuotasByOrgGUIDStub + fakeReturns := fake.getSpaceQuotasByOrgGUIDReturns fake.recordInvocation("GetSpaceQuotasByOrgGUID", []interface{}{arg1}) fake.getSpaceQuotasByOrgGUIDMutex.Unlock() - if fake.GetSpaceQuotasByOrgGUIDStub != nil { - return fake.GetSpaceQuotasByOrgGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceQuotasByOrgGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13295,15 +13868,16 @@ func (fake *FakeActor) GetSpaceSummaryByNameAndOrganization(arg1 string, arg2 st arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceSummaryByNameAndOrganizationStub + fakeReturns := fake.getSpaceSummaryByNameAndOrganizationReturns fake.recordInvocation("GetSpaceSummaryByNameAndOrganization", []interface{}{arg1, arg2}) fake.getSpaceSummaryByNameAndOrganizationMutex.Unlock() - if fake.GetSpaceSummaryByNameAndOrganizationStub != nil { - return fake.GetSpaceSummaryByNameAndOrganizationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceSummaryByNameAndOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13361,15 +13935,16 @@ func (fake *FakeActor) GetSpaceUsersByRoleType(arg1 string) (map[constanta.RoleT fake.getSpaceUsersByRoleTypeArgsForCall = append(fake.getSpaceUsersByRoleTypeArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSpaceUsersByRoleTypeStub + fakeReturns := fake.getSpaceUsersByRoleTypeReturns fake.recordInvocation("GetSpaceUsersByRoleType", []interface{}{arg1}) fake.getSpaceUsersByRoleTypeMutex.Unlock() - if fake.GetSpaceUsersByRoleTypeStub != nil { - return fake.GetSpaceUsersByRoleTypeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getSpaceUsersByRoleTypeReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13427,15 +14002,16 @@ func (fake *FakeActor) GetStackByName(arg1 string) (resources.Stack, v7action.Wa fake.getStackByNameArgsForCall = append(fake.getStackByNameArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetStackByNameStub + fakeReturns := fake.getStackByNameReturns fake.recordInvocation("GetStackByName", []interface{}{arg1}) fake.getStackByNameMutex.Unlock() - if fake.GetStackByNameStub != nil { - return fake.GetStackByNameStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getStackByNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13493,15 +14069,16 @@ func (fake *FakeActor) GetStackLabels(arg1 string) (map[string]types.NullString, fake.getStackLabelsArgsForCall = append(fake.getStackLabelsArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetStackLabelsStub + fakeReturns := fake.getStackLabelsReturns fake.recordInvocation("GetStackLabels", []interface{}{arg1}) fake.getStackLabelsMutex.Unlock() - if fake.GetStackLabelsStub != nil { - return fake.GetStackLabelsStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getStackLabelsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13559,15 +14136,16 @@ func (fake *FakeActor) GetStacks(arg1 string) ([]resources.Stack, v7action.Warni fake.getStacksArgsForCall = append(fake.getStacksArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetStacksStub + fakeReturns := fake.getStacksReturns fake.recordInvocation("GetStacks", []interface{}{arg1}) fake.getStacksMutex.Unlock() - if fake.GetStacksStub != nil { - return fake.GetStacksStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getStacksReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13627,15 +14205,16 @@ func (fake *FakeActor) GetStreamingLogsForApplicationByNameAndSpace(arg1 string, arg2 string arg3 sharedaction.LogCacheClient }{arg1, arg2, arg3}) + stub := fake.GetStreamingLogsForApplicationByNameAndSpaceStub + fakeReturns := fake.getStreamingLogsForApplicationByNameAndSpaceReturns fake.recordInvocation("GetStreamingLogsForApplicationByNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.getStreamingLogsForApplicationByNameAndSpaceMutex.Unlock() - if fake.GetStreamingLogsForApplicationByNameAndSpaceStub != nil { - return fake.GetStreamingLogsForApplicationByNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4, ret.result5 } - fakeReturns := fake.getStreamingLogsForApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4, fakeReturns.result5 } @@ -13700,15 +14279,16 @@ func (fake *FakeActor) GetTaskBySequenceIDAndApplication(arg1 int, arg2 string) arg1 int arg2 string }{arg1, arg2}) + stub := fake.GetTaskBySequenceIDAndApplicationStub + fakeReturns := fake.getTaskBySequenceIDAndApplicationReturns fake.recordInvocation("GetTaskBySequenceIDAndApplication", []interface{}{arg1, arg2}) fake.getTaskBySequenceIDAndApplicationMutex.Unlock() - if fake.GetTaskBySequenceIDAndApplicationStub != nil { - return fake.GetTaskBySequenceIDAndApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getTaskBySequenceIDAndApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13765,15 +14345,16 @@ func (fake *FakeActor) GetUAAAPIVersion() (string, error) { ret, specificReturn := fake.getUAAAPIVersionReturnsOnCall[len(fake.getUAAAPIVersionArgsForCall)] fake.getUAAAPIVersionArgsForCall = append(fake.getUAAAPIVersionArgsForCall, struct { }{}) + stub := fake.GetUAAAPIVersionStub + fakeReturns := fake.getUAAAPIVersionReturns fake.recordInvocation("GetUAAAPIVersion", []interface{}{}) fake.getUAAAPIVersionMutex.Unlock() - if fake.GetUAAAPIVersionStub != nil { - return fake.GetUAAAPIVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getUAAAPIVersionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -13821,15 +14402,16 @@ func (fake *FakeActor) GetUnstagedNewestPackageGUID(arg1 string) (string, v7acti fake.getUnstagedNewestPackageGUIDArgsForCall = append(fake.getUnstagedNewestPackageGUIDArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetUnstagedNewestPackageGUIDStub + fakeReturns := fake.getUnstagedNewestPackageGUIDReturns fake.recordInvocation("GetUnstagedNewestPackageGUID", []interface{}{arg1}) fake.getUnstagedNewestPackageGUIDMutex.Unlock() - if fake.GetUnstagedNewestPackageGUIDStub != nil { - return fake.GetUnstagedNewestPackageGUIDStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getUnstagedNewestPackageGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -13888,15 +14470,16 @@ func (fake *FakeActor) GetUser(arg1 string, arg2 string) (resources.User, error) arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetUserStub + fakeReturns := fake.getUserReturns fake.recordInvocation("GetUser", []interface{}{arg1, arg2}) fake.getUserMutex.Unlock() - if fake.GetUserStub != nil { - return fake.GetUserStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -13960,15 +14543,16 @@ func (fake *FakeActor) MakeCurlRequest(arg1 string, arg2 string, arg3 []string, arg4 string arg5 bool }{arg1, arg2, arg3Copy, arg4, arg5}) + stub := fake.MakeCurlRequestStub + fakeReturns := fake.makeCurlRequestReturns fake.recordInvocation("MakeCurlRequest", []interface{}{arg1, arg2, arg3Copy, arg4, arg5}) fake.makeCurlRequestMutex.Unlock() - if fake.MakeCurlRequestStub != nil { - return fake.MakeCurlRequestStub(arg1, arg2, arg3, arg4, arg5) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.makeCurlRequestReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14028,15 +14612,16 @@ func (fake *FakeActor) MapRoute(arg1 string, arg2 string, arg3 string) (v7action arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.MapRouteStub + fakeReturns := fake.mapRouteReturns fake.recordInvocation("MapRoute", []interface{}{arg1, arg2, arg3}) fake.mapRouteMutex.Unlock() - if fake.MapRouteStub != nil { - return fake.MapRouteStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.mapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14091,15 +14676,16 @@ func (fake *FakeActor) Marketplace(arg1 v7action.MarketplaceFilter) ([]v7action. fake.marketplaceArgsForCall = append(fake.marketplaceArgsForCall, struct { arg1 v7action.MarketplaceFilter }{arg1}) + stub := fake.MarketplaceStub + fakeReturns := fake.marketplaceReturns fake.recordInvocation("Marketplace", []interface{}{arg1}) fake.marketplaceMutex.Unlock() - if fake.MarketplaceStub != nil { - return fake.MarketplaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.marketplaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14151,21 +14737,87 @@ func (fake *FakeActor) MarketplaceReturnsOnCall(i int, result1 []v7action.Servic }{result1, result2, result3} } +func (fake *FakeActor) MoveRoute(arg1 string, arg2 string) (v7action.Warnings, error) { + fake.moveRouteMutex.Lock() + ret, specificReturn := fake.moveRouteReturnsOnCall[len(fake.moveRouteArgsForCall)] + fake.moveRouteArgsForCall = append(fake.moveRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.MoveRouteStub + fakeReturns := fake.moveRouteReturns + fake.recordInvocation("MoveRoute", []interface{}{arg1, arg2}) + fake.moveRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeActor) MoveRouteCallCount() int { + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() + return len(fake.moveRouteArgsForCall) +} + +func (fake *FakeActor) MoveRouteCalls(stub func(string, string) (v7action.Warnings, error)) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = stub +} + +func (fake *FakeActor) MoveRouteArgsForCall(i int) (string, string) { + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() + argsForCall := fake.moveRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeActor) MoveRouteReturns(result1 v7action.Warnings, result2 error) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = nil + fake.moveRouteReturns = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) MoveRouteReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.moveRouteMutex.Lock() + defer fake.moveRouteMutex.Unlock() + fake.MoveRouteStub = nil + if fake.moveRouteReturnsOnCall == nil { + fake.moveRouteReturnsOnCall = make(map[int]struct { + result1 v7action.Warnings + result2 error + }) + } + fake.moveRouteReturnsOnCall[i] = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeActor) ParseAccessToken(arg1 string) (jwt.JWT, error) { fake.parseAccessTokenMutex.Lock() ret, specificReturn := fake.parseAccessTokenReturnsOnCall[len(fake.parseAccessTokenArgsForCall)] fake.parseAccessTokenArgsForCall = append(fake.parseAccessTokenArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ParseAccessTokenStub + fakeReturns := fake.parseAccessTokenReturns fake.recordInvocation("ParseAccessToken", []interface{}{arg1}) fake.parseAccessTokenMutex.Unlock() - if fake.ParseAccessTokenStub != nil { - return fake.ParseAccessTokenStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.parseAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14221,15 +14873,16 @@ func (fake *FakeActor) PollBuild(arg1 string, arg2 string) (resources.Droplet, v arg1 string arg2 string }{arg1, arg2}) + stub := fake.PollBuildStub + fakeReturns := fake.pollBuildReturns fake.recordInvocation("PollBuild", []interface{}{arg1, arg2}) fake.pollBuildMutex.Unlock() - if fake.PollBuildStub != nil { - return fake.PollBuildStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.pollBuildReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14287,15 +14940,16 @@ func (fake *FakeActor) PollPackage(arg1 resources.Package) (resources.Package, v fake.pollPackageArgsForCall = append(fake.pollPackageArgsForCall, struct { arg1 resources.Package }{arg1}) + stub := fake.PollPackageStub + fakeReturns := fake.pollPackageReturns fake.recordInvocation("PollPackage", []interface{}{arg1}) fake.pollPackageMutex.Unlock() - if fake.PollPackageStub != nil { - return fake.PollPackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.pollPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14355,15 +15009,16 @@ func (fake *FakeActor) PollStart(arg1 resources.Application, arg2 bool, arg3 fun arg2 bool arg3 func(string) }{arg1, arg2, arg3}) + stub := fake.PollStartStub + fakeReturns := fake.pollStartReturns fake.recordInvocation("PollStart", []interface{}{arg1, arg2, arg3}) fake.pollStartMutex.Unlock() - if fake.PollStartStub != nil { - return fake.PollStartStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollStartReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14412,87 +15067,156 @@ func (fake *FakeActor) PollStartReturnsOnCall(i int, result1 v7action.Warnings, }{result1, result2} } -func (fake *FakeActor) PollStartForRolling(arg1 resources.Application, arg2 string, arg3 bool, arg4 func(string)) (v7action.Warnings, error) { - fake.pollStartForRollingMutex.Lock() - ret, specificReturn := fake.pollStartForRollingReturnsOnCall[len(fake.pollStartForRollingArgsForCall)] - fake.pollStartForRollingArgsForCall = append(fake.pollStartForRollingArgsForCall, struct { +func (fake *FakeActor) PollStartForDeployment(arg1 resources.Application, arg2 string, arg3 bool, arg4 func(string)) (v7action.Warnings, error) { + fake.pollStartForDeploymentMutex.Lock() + ret, specificReturn := fake.pollStartForDeploymentReturnsOnCall[len(fake.pollStartForDeploymentArgsForCall)] + fake.pollStartForDeploymentArgsForCall = append(fake.pollStartForDeploymentArgsForCall, struct { arg1 resources.Application arg2 string arg3 bool arg4 func(string) }{arg1, arg2, arg3, arg4}) - fake.recordInvocation("PollStartForRolling", []interface{}{arg1, arg2, arg3, arg4}) - fake.pollStartForRollingMutex.Unlock() - if fake.PollStartForRollingStub != nil { - return fake.PollStartForRollingStub(arg1, arg2, arg3, arg4) + stub := fake.PollStartForDeploymentStub + fakeReturns := fake.pollStartForDeploymentReturns + fake.recordInvocation("PollStartForDeployment", []interface{}{arg1, arg2, arg3, arg4}) + fake.pollStartForDeploymentMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollStartForRollingReturns return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeActor) PollStartForRollingCallCount() int { - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() - return len(fake.pollStartForRollingArgsForCall) +func (fake *FakeActor) PollStartForDeploymentCallCount() int { + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() + return len(fake.pollStartForDeploymentArgsForCall) } -func (fake *FakeActor) PollStartForRollingCalls(stub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error)) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = stub +func (fake *FakeActor) PollStartForDeploymentCalls(stub func(resources.Application, string, bool, func(string)) (v7action.Warnings, error)) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = stub } -func (fake *FakeActor) PollStartForRollingArgsForCall(i int) (resources.Application, string, bool, func(string)) { - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() - argsForCall := fake.pollStartForRollingArgsForCall[i] +func (fake *FakeActor) PollStartForDeploymentArgsForCall(i int) (resources.Application, string, bool, func(string)) { + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() + argsForCall := fake.pollStartForDeploymentArgsForCall[i] return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } -func (fake *FakeActor) PollStartForRollingReturns(result1 v7action.Warnings, result2 error) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = nil - fake.pollStartForRollingReturns = struct { +func (fake *FakeActor) PollStartForDeploymentReturns(result1 v7action.Warnings, result2 error) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = nil + fake.pollStartForDeploymentReturns = struct { result1 v7action.Warnings result2 error }{result1, result2} } -func (fake *FakeActor) PollStartForRollingReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { - fake.pollStartForRollingMutex.Lock() - defer fake.pollStartForRollingMutex.Unlock() - fake.PollStartForRollingStub = nil - if fake.pollStartForRollingReturnsOnCall == nil { - fake.pollStartForRollingReturnsOnCall = make(map[int]struct { +func (fake *FakeActor) PollStartForDeploymentReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.pollStartForDeploymentMutex.Lock() + defer fake.pollStartForDeploymentMutex.Unlock() + fake.PollStartForDeploymentStub = nil + if fake.pollStartForDeploymentReturnsOnCall == nil { + fake.pollStartForDeploymentReturnsOnCall = make(map[int]struct { result1 v7action.Warnings result2 error }) } - fake.pollStartForRollingReturnsOnCall[i] = struct { + fake.pollStartForDeploymentReturnsOnCall[i] = struct { result1 v7action.Warnings result2 error }{result1, result2} } +func (fake *FakeActor) PollTask(arg1 resources.Task) (resources.Task, v7action.Warnings, error) { + fake.pollTaskMutex.Lock() + ret, specificReturn := fake.pollTaskReturnsOnCall[len(fake.pollTaskArgsForCall)] + fake.pollTaskArgsForCall = append(fake.pollTaskArgsForCall, struct { + arg1 resources.Task + }{arg1}) + stub := fake.PollTaskStub + fakeReturns := fake.pollTaskReturns + fake.recordInvocation("PollTask", []interface{}{arg1}) + fake.pollTaskMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeActor) PollTaskCallCount() int { + fake.pollTaskMutex.RLock() + defer fake.pollTaskMutex.RUnlock() + return len(fake.pollTaskArgsForCall) +} + +func (fake *FakeActor) PollTaskCalls(stub func(resources.Task) (resources.Task, v7action.Warnings, error)) { + fake.pollTaskMutex.Lock() + defer fake.pollTaskMutex.Unlock() + fake.PollTaskStub = stub +} + +func (fake *FakeActor) PollTaskArgsForCall(i int) resources.Task { + fake.pollTaskMutex.RLock() + defer fake.pollTaskMutex.RUnlock() + argsForCall := fake.pollTaskArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeActor) PollTaskReturns(result1 resources.Task, result2 v7action.Warnings, result3 error) { + fake.pollTaskMutex.Lock() + defer fake.pollTaskMutex.Unlock() + fake.PollTaskStub = nil + fake.pollTaskReturns = struct { + result1 resources.Task + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) PollTaskReturnsOnCall(i int, result1 resources.Task, result2 v7action.Warnings, result3 error) { + fake.pollTaskMutex.Lock() + defer fake.pollTaskMutex.Unlock() + fake.PollTaskStub = nil + if fake.pollTaskReturnsOnCall == nil { + fake.pollTaskReturnsOnCall = make(map[int]struct { + result1 resources.Task + result2 v7action.Warnings + result3 error + }) + } + fake.pollTaskReturnsOnCall[i] = struct { + result1 resources.Task + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeActor) PollUploadBuildpackJob(arg1 ccv3.JobURL) (v7action.Warnings, error) { fake.pollUploadBuildpackJobMutex.Lock() ret, specificReturn := fake.pollUploadBuildpackJobReturnsOnCall[len(fake.pollUploadBuildpackJobArgsForCall)] fake.pollUploadBuildpackJobArgsForCall = append(fake.pollUploadBuildpackJobArgsForCall, struct { arg1 ccv3.JobURL }{arg1}) + stub := fake.PollUploadBuildpackJobStub + fakeReturns := fake.pollUploadBuildpackJobReturns fake.recordInvocation("PollUploadBuildpackJob", []interface{}{arg1}) fake.pollUploadBuildpackJobMutex.Unlock() - if fake.PollUploadBuildpackJobStub != nil { - return fake.PollUploadBuildpackJobStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.pollUploadBuildpackJobReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14549,15 +15273,16 @@ func (fake *FakeActor) PrepareBuildpackBits(arg1 string, arg2 string, arg3 v7act arg2 string arg3 v7action.Downloader }{arg1, arg2, arg3}) + stub := fake.PrepareBuildpackBitsStub + fakeReturns := fake.prepareBuildpackBitsReturns fake.recordInvocation("PrepareBuildpackBits", []interface{}{arg1, arg2, arg3}) fake.prepareBuildpackBitsMutex.Unlock() - if fake.PrepareBuildpackBitsStub != nil { - return fake.PrepareBuildpackBitsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.prepareBuildpackBitsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14613,15 +15338,16 @@ func (fake *FakeActor) PurgeServiceInstance(arg1 string, arg2 string) (v7action. arg1 string arg2 string }{arg1, arg2}) + stub := fake.PurgeServiceInstanceStub + fakeReturns := fake.purgeServiceInstanceReturns fake.recordInvocation("PurgeServiceInstance", []interface{}{arg1, arg2}) fake.purgeServiceInstanceMutex.Unlock() - if fake.PurgeServiceInstanceStub != nil { - return fake.PurgeServiceInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.purgeServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14677,15 +15403,16 @@ func (fake *FakeActor) PurgeServiceOfferingByNameAndBroker(arg1 string, arg2 str arg1 string arg2 string }{arg1, arg2}) + stub := fake.PurgeServiceOfferingByNameAndBrokerStub + fakeReturns := fake.purgeServiceOfferingByNameAndBrokerReturns fake.recordInvocation("PurgeServiceOfferingByNameAndBroker", []interface{}{arg1, arg2}) fake.purgeServiceOfferingByNameAndBrokerMutex.Unlock() - if fake.PurgeServiceOfferingByNameAndBrokerStub != nil { - return fake.PurgeServiceOfferingByNameAndBrokerStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.purgeServiceOfferingByNameAndBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14739,15 +15466,16 @@ func (fake *FakeActor) RefreshAccessToken() (string, error) { ret, specificReturn := fake.refreshAccessTokenReturnsOnCall[len(fake.refreshAccessTokenArgsForCall)] fake.refreshAccessTokenArgsForCall = append(fake.refreshAccessTokenArgsForCall, struct { }{}) + stub := fake.RefreshAccessTokenStub + fakeReturns := fake.refreshAccessTokenReturns fake.recordInvocation("RefreshAccessToken", []interface{}{}) fake.refreshAccessTokenMutex.Unlock() - if fake.RefreshAccessTokenStub != nil { - return fake.RefreshAccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.refreshAccessTokenReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14797,15 +15525,16 @@ func (fake *FakeActor) RenameApplicationByNameAndSpaceGUID(arg1 string, arg2 str arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.RenameApplicationByNameAndSpaceGUIDStub + fakeReturns := fake.renameApplicationByNameAndSpaceGUIDReturns fake.recordInvocation("RenameApplicationByNameAndSpaceGUID", []interface{}{arg1, arg2, arg3}) fake.renameApplicationByNameAndSpaceGUIDMutex.Unlock() - if fake.RenameApplicationByNameAndSpaceGUIDStub != nil { - return fake.RenameApplicationByNameAndSpaceGUIDStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.renameApplicationByNameAndSpaceGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14864,15 +15593,16 @@ func (fake *FakeActor) RenameOrganization(arg1 string, arg2 string) (resources.O arg1 string arg2 string }{arg1, arg2}) + stub := fake.RenameOrganizationStub + fakeReturns := fake.renameOrganizationReturns fake.recordInvocation("RenameOrganization", []interface{}{arg1, arg2}) fake.renameOrganizationMutex.Unlock() - if fake.RenameOrganizationStub != nil { - return fake.RenameOrganizationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.renameOrganizationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -14932,15 +15662,16 @@ func (fake *FakeActor) RenameServiceInstance(arg1 string, arg2 string, arg3 stri arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.RenameServiceInstanceStub + fakeReturns := fake.renameServiceInstanceReturns fake.recordInvocation("RenameServiceInstance", []interface{}{arg1, arg2, arg3}) fake.renameServiceInstanceMutex.Unlock() - if fake.RenameServiceInstanceStub != nil { - return fake.RenameServiceInstanceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.renameServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -14997,15 +15728,16 @@ func (fake *FakeActor) RenameSpaceByNameAndOrganizationGUID(arg1 string, arg2 st arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.RenameSpaceByNameAndOrganizationGUIDStub + fakeReturns := fake.renameSpaceByNameAndOrganizationGUIDReturns fake.recordInvocation("RenameSpaceByNameAndOrganizationGUID", []interface{}{arg1, arg2, arg3}) fake.renameSpaceByNameAndOrganizationGUIDMutex.Unlock() - if fake.RenameSpaceByNameAndOrganizationGUIDStub != nil { - return fake.RenameSpaceByNameAndOrganizationGUIDStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.renameSpaceByNameAndOrganizationGUIDReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -15063,15 +15795,16 @@ func (fake *FakeActor) ResetOrganizationDefaultIsolationSegment(arg1 string) (v7 fake.resetOrganizationDefaultIsolationSegmentArgsForCall = append(fake.resetOrganizationDefaultIsolationSegmentArgsForCall, struct { arg1 string }{arg1}) + stub := fake.ResetOrganizationDefaultIsolationSegmentStub + fakeReturns := fake.resetOrganizationDefaultIsolationSegmentReturns fake.recordInvocation("ResetOrganizationDefaultIsolationSegment", []interface{}{arg1}) fake.resetOrganizationDefaultIsolationSegmentMutex.Unlock() - if fake.ResetOrganizationDefaultIsolationSegmentStub != nil { - return fake.ResetOrganizationDefaultIsolationSegmentStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.resetOrganizationDefaultIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15127,15 +15860,16 @@ func (fake *FakeActor) ResetSpaceIsolationSegment(arg1 string, arg2 string) (str arg1 string arg2 string }{arg1, arg2}) + stub := fake.ResetSpaceIsolationSegmentStub + fakeReturns := fake.resetSpaceIsolationSegmentReturns fake.recordInvocation("ResetSpaceIsolationSegment", []interface{}{arg1, arg2}) fake.resetSpaceIsolationSegmentMutex.Unlock() - if fake.ResetSpaceIsolationSegmentStub != nil { - return fake.ResetSpaceIsolationSegmentStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.resetSpaceIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -15198,15 +15932,16 @@ func (fake *FakeActor) ResourceMatch(arg1 []sharedaction.V3Resource) ([]sharedac fake.resourceMatchArgsForCall = append(fake.resourceMatchArgsForCall, struct { arg1 []sharedaction.V3Resource }{arg1Copy}) + stub := fake.ResourceMatchStub + fakeReturns := fake.resourceMatchReturns fake.recordInvocation("ResourceMatch", []interface{}{arg1Copy}) fake.resourceMatchMutex.Unlock() - if fake.ResourceMatchStub != nil { - return fake.ResourceMatchStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.resourceMatchReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -15265,15 +16000,16 @@ func (fake *FakeActor) RestartApplication(arg1 string, arg2 bool) (v7action.Warn arg1 string arg2 bool }{arg1, arg2}) + stub := fake.RestartApplicationStub + fakeReturns := fake.restartApplicationReturns fake.recordInvocation("RestartApplication", []interface{}{arg1, arg2}) fake.restartApplicationMutex.Unlock() - if fake.RestartApplicationStub != nil { - return fake.RestartApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.restartApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15327,15 +16063,16 @@ func (fake *FakeActor) RevokeAccessAndRefreshTokens() error { ret, specificReturn := fake.revokeAccessAndRefreshTokensReturnsOnCall[len(fake.revokeAccessAndRefreshTokensArgsForCall)] fake.revokeAccessAndRefreshTokensArgsForCall = append(fake.revokeAccessAndRefreshTokensArgsForCall, struct { }{}) + stub := fake.RevokeAccessAndRefreshTokensStub + fakeReturns := fake.revokeAccessAndRefreshTokensReturns fake.recordInvocation("RevokeAccessAndRefreshTokens", []interface{}{}) fake.revokeAccessAndRefreshTokensMutex.Unlock() - if fake.RevokeAccessAndRefreshTokensStub != nil { - return fake.RevokeAccessAndRefreshTokensStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.revokeAccessAndRefreshTokensReturns return fakeReturns.result1 } @@ -15381,15 +16118,16 @@ func (fake *FakeActor) RunTask(arg1 string, arg2 resources.Task) (resources.Task arg1 string arg2 resources.Task }{arg1, arg2}) + stub := fake.RunTaskStub + fakeReturns := fake.runTaskReturns fake.recordInvocation("RunTask", []interface{}{arg1, arg2}) fake.runTaskMutex.Unlock() - if fake.RunTaskStub != nil { - return fake.RunTaskStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.runTaskReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -15448,15 +16186,16 @@ func (fake *FakeActor) ScaleProcessByApplication(arg1 string, arg2 resources.Pro arg1 string arg2 resources.Process }{arg1, arg2}) + stub := fake.ScaleProcessByApplicationStub + fakeReturns := fake.scaleProcessByApplicationReturns fake.recordInvocation("ScaleProcessByApplication", []interface{}{arg1, arg2}) fake.scaleProcessByApplicationMutex.Unlock() - if fake.ScaleProcessByApplicationStub != nil { - return fake.ScaleProcessByApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.scaleProcessByApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15513,15 +16252,16 @@ func (fake *FakeActor) ScheduleTokenRefresh(arg1 func(time.Duration) <-chan time arg2 chan struct{} arg3 chan struct{} }{arg1, arg2, arg3}) + stub := fake.ScheduleTokenRefreshStub + fakeReturns := fake.scheduleTokenRefreshReturns fake.recordInvocation("ScheduleTokenRefresh", []interface{}{arg1, arg2, arg3}) fake.scheduleTokenRefreshMutex.Unlock() - if fake.ScheduleTokenRefreshStub != nil { - return fake.ScheduleTokenRefreshStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.scheduleTokenRefreshReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15577,15 +16317,16 @@ func (fake *FakeActor) SetApplicationDroplet(arg1 string, arg2 string) (v7action arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetApplicationDropletStub + fakeReturns := fake.setApplicationDropletReturns fake.recordInvocation("SetApplicationDroplet", []interface{}{arg1, arg2}) fake.setApplicationDropletMutex.Unlock() - if fake.SetApplicationDropletStub != nil { - return fake.SetApplicationDropletStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setApplicationDropletReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15642,15 +16383,16 @@ func (fake *FakeActor) SetApplicationDropletByApplicationNameAndSpace(arg1 strin arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.SetApplicationDropletByApplicationNameAndSpaceStub + fakeReturns := fake.setApplicationDropletByApplicationNameAndSpaceReturns fake.recordInvocation("SetApplicationDropletByApplicationNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.setApplicationDropletByApplicationNameAndSpaceMutex.Unlock() - if fake.SetApplicationDropletByApplicationNameAndSpaceStub != nil { - return fake.SetApplicationDropletByApplicationNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setApplicationDropletByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15711,15 +16453,16 @@ func (fake *FakeActor) SetApplicationManifest(arg1 string, arg2 []byte) (v7actio arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.SetApplicationManifestStub + fakeReturns := fake.setApplicationManifestReturns fake.recordInvocation("SetApplicationManifest", []interface{}{arg1, arg2Copy}) fake.setApplicationManifestMutex.Unlock() - if fake.SetApplicationManifestStub != nil { - return fake.SetApplicationManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setApplicationManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15779,15 +16522,16 @@ func (fake *FakeActor) SetApplicationProcessHealthCheckTypeByNameAndSpace(arg1 s arg5 string arg6 int64 }{arg1, arg2, arg3, arg4, arg5, arg6}) + stub := fake.SetApplicationProcessHealthCheckTypeByNameAndSpaceStub + fakeReturns := fake.setApplicationProcessHealthCheckTypeByNameAndSpaceReturns fake.recordInvocation("SetApplicationProcessHealthCheckTypeByNameAndSpace", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.setApplicationProcessHealthCheckTypeByNameAndSpaceMutex.Unlock() - if fake.SetApplicationProcessHealthCheckTypeByNameAndSpaceStub != nil { - return fake.SetApplicationProcessHealthCheckTypeByNameAndSpaceStub(arg1, arg2, arg3, arg4, arg5, arg6) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.setApplicationProcessHealthCheckTypeByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -15847,15 +16591,16 @@ func (fake *FakeActor) SetEnvironmentVariableByApplicationNameAndSpace(arg1 stri arg2 string arg3 v7action.EnvironmentVariablePair }{arg1, arg2, arg3}) + stub := fake.SetEnvironmentVariableByApplicationNameAndSpaceStub + fakeReturns := fake.setEnvironmentVariableByApplicationNameAndSpaceReturns fake.recordInvocation("SetEnvironmentVariableByApplicationNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.setEnvironmentVariableByApplicationNameAndSpaceMutex.Unlock() - if fake.SetEnvironmentVariableByApplicationNameAndSpaceStub != nil { - return fake.SetEnvironmentVariableByApplicationNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setEnvironmentVariableByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15911,15 +16656,16 @@ func (fake *FakeActor) SetEnvironmentVariableGroup(arg1 constanta.EnvironmentVar arg1 constanta.EnvironmentVariableGroupName arg2 resources.EnvironmentVariables }{arg1, arg2}) + stub := fake.SetEnvironmentVariableGroupStub + fakeReturns := fake.setEnvironmentVariableGroupReturns fake.recordInvocation("SetEnvironmentVariableGroup", []interface{}{arg1, arg2}) fake.setEnvironmentVariableGroupMutex.Unlock() - if fake.SetEnvironmentVariableGroupStub != nil { - return fake.SetEnvironmentVariableGroupStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setEnvironmentVariableGroupReturns return fakeReturns.result1, fakeReturns.result2 } @@ -15975,15 +16721,16 @@ func (fake *FakeActor) SetOrganizationDefaultIsolationSegment(arg1 string, arg2 arg1 string arg2 string }{arg1, arg2}) + stub := fake.SetOrganizationDefaultIsolationSegmentStub + fakeReturns := fake.setOrganizationDefaultIsolationSegmentReturns fake.recordInvocation("SetOrganizationDefaultIsolationSegment", []interface{}{arg1, arg2}) fake.setOrganizationDefaultIsolationSegmentMutex.Unlock() - if fake.SetOrganizationDefaultIsolationSegmentStub != nil { - return fake.SetOrganizationDefaultIsolationSegmentStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setOrganizationDefaultIsolationSegmentReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16044,15 +16791,16 @@ func (fake *FakeActor) SetSpaceManifest(arg1 string, arg2 []byte) (v7action.Warn arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.SetSpaceManifestStub + fakeReturns := fake.setSpaceManifestReturns fake.recordInvocation("SetSpaceManifest", []interface{}{arg1, arg2Copy}) fake.setSpaceManifestMutex.Unlock() - if fake.SetSpaceManifestStub != nil { - return fake.SetSpaceManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setSpaceManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16107,15 +16855,16 @@ func (fake *FakeActor) SetTarget(arg1 v7action.TargetSettings) (v7action.Warning fake.setTargetArgsForCall = append(fake.setTargetArgsForCall, struct { arg1 v7action.TargetSettings }{arg1}) + stub := fake.SetTargetStub + fakeReturns := fake.setTargetReturns fake.recordInvocation("SetTarget", []interface{}{arg1}) fake.setTargetMutex.Unlock() - if fake.SetTargetStub != nil { - return fake.SetTargetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setTargetReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16171,15 +16920,16 @@ func (fake *FakeActor) SharePrivateDomain(arg1 string, arg2 string) (v7action.Wa arg1 string arg2 string }{arg1, arg2}) + stub := fake.SharePrivateDomainStub + fakeReturns := fake.sharePrivateDomainReturns fake.recordInvocation("SharePrivateDomain", []interface{}{arg1, arg2}) fake.sharePrivateDomainMutex.Unlock() - if fake.SharePrivateDomainStub != nil { - return fake.SharePrivateDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.sharePrivateDomainReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16228,6 +16978,71 @@ func (fake *FakeActor) SharePrivateDomainReturnsOnCall(i int, result1 v7action.W }{result1, result2} } +func (fake *FakeActor) ShareRoute(arg1 string, arg2 string) (v7action.Warnings, error) { + fake.shareRouteMutex.Lock() + ret, specificReturn := fake.shareRouteReturnsOnCall[len(fake.shareRouteArgsForCall)] + fake.shareRouteArgsForCall = append(fake.shareRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.ShareRouteStub + fakeReturns := fake.shareRouteReturns + fake.recordInvocation("ShareRoute", []interface{}{arg1, arg2}) + fake.shareRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeActor) ShareRouteCallCount() int { + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() + return len(fake.shareRouteArgsForCall) +} + +func (fake *FakeActor) ShareRouteCalls(stub func(string, string) (v7action.Warnings, error)) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = stub +} + +func (fake *FakeActor) ShareRouteArgsForCall(i int) (string, string) { + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() + argsForCall := fake.shareRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeActor) ShareRouteReturns(result1 v7action.Warnings, result2 error) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = nil + fake.shareRouteReturns = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) ShareRouteReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.shareRouteMutex.Lock() + defer fake.shareRouteMutex.Unlock() + fake.ShareRouteStub = nil + if fake.shareRouteReturnsOnCall == nil { + fake.shareRouteReturnsOnCall = make(map[int]struct { + result1 v7action.Warnings + result2 error + }) + } + fake.shareRouteReturnsOnCall[i] = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeActor) ShareServiceInstanceToSpaceAndOrg(arg1 string, arg2 string, arg3 string, arg4 v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) { fake.shareServiceInstanceToSpaceAndOrgMutex.Lock() ret, specificReturn := fake.shareServiceInstanceToSpaceAndOrgReturnsOnCall[len(fake.shareServiceInstanceToSpaceAndOrgArgsForCall)] @@ -16237,15 +17052,16 @@ func (fake *FakeActor) ShareServiceInstanceToSpaceAndOrg(arg1 string, arg2 strin arg3 string arg4 v7action.ServiceInstanceSharingParams }{arg1, arg2, arg3, arg4}) + stub := fake.ShareServiceInstanceToSpaceAndOrgStub + fakeReturns := fake.shareServiceInstanceToSpaceAndOrgReturns fake.recordInvocation("ShareServiceInstanceToSpaceAndOrg", []interface{}{arg1, arg2, arg3, arg4}) fake.shareServiceInstanceToSpaceAndOrgMutex.Unlock() - if fake.ShareServiceInstanceToSpaceAndOrgStub != nil { - return fake.ShareServiceInstanceToSpaceAndOrgStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.shareServiceInstanceToSpaceAndOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16300,15 +17116,16 @@ func (fake *FakeActor) StageApplicationPackage(arg1 string) (resources.Build, v7 fake.stageApplicationPackageArgsForCall = append(fake.stageApplicationPackageArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StageApplicationPackageStub + fakeReturns := fake.stageApplicationPackageReturns fake.recordInvocation("StageApplicationPackage", []interface{}{arg1}) fake.stageApplicationPackageMutex.Unlock() - if fake.StageApplicationPackageStub != nil { - return fake.StageApplicationPackageStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.stageApplicationPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -16368,15 +17185,16 @@ func (fake *FakeActor) StagePackage(arg1 string, arg2 string, arg3 string) (<-ch arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.StagePackageStub + fakeReturns := fake.stagePackageReturns fake.recordInvocation("StagePackage", []interface{}{arg1, arg2, arg3}) fake.stagePackageMutex.Unlock() - if fake.StagePackageStub != nil { - return fake.StagePackageStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.stagePackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -16434,15 +17252,16 @@ func (fake *FakeActor) StartApplication(arg1 string) (v7action.Warnings, error) fake.startApplicationArgsForCall = append(fake.startApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StartApplicationStub + fakeReturns := fake.startApplicationReturns fake.recordInvocation("StartApplication", []interface{}{arg1}) fake.startApplicationMutex.Unlock() - if fake.StartApplicationStub != nil { - return fake.StartApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.startApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16497,15 +17316,16 @@ func (fake *FakeActor) StopApplication(arg1 string) (v7action.Warnings, error) { fake.stopApplicationArgsForCall = append(fake.stopApplicationArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StopApplicationStub + fakeReturns := fake.stopApplicationReturns fake.recordInvocation("StopApplication", []interface{}{arg1}) fake.stopApplicationMutex.Unlock() - if fake.StopApplicationStub != nil { - return fake.StopApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stopApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16560,15 +17380,16 @@ func (fake *FakeActor) TerminateTask(arg1 string) (resources.Task, v7action.Warn fake.terminateTaskArgsForCall = append(fake.terminateTaskArgsForCall, struct { arg1 string }{arg1}) + stub := fake.TerminateTaskStub + fakeReturns := fake.terminateTaskReturns fake.recordInvocation("TerminateTask", []interface{}{arg1}) fake.terminateTaskMutex.Unlock() - if fake.TerminateTaskStub != nil { - return fake.TerminateTaskStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.terminateTaskReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -16629,15 +17450,16 @@ func (fake *FakeActor) UnbindSecurityGroup(arg1 string, arg2 string, arg3 string arg3 string arg4 constanta.SecurityGroupLifecycle }{arg1, arg2, arg3, arg4}) + stub := fake.UnbindSecurityGroupStub + fakeReturns := fake.unbindSecurityGroupReturns fake.recordInvocation("UnbindSecurityGroup", []interface{}{arg1, arg2, arg3, arg4}) fake.unbindSecurityGroupMutex.Unlock() - if fake.UnbindSecurityGroupStub != nil { - return fake.UnbindSecurityGroupStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unbindSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16693,15 +17515,16 @@ func (fake *FakeActor) UnmapRoute(arg1 string, arg2 string) (v7action.Warnings, arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnmapRouteStub + fakeReturns := fake.unmapRouteReturns fake.recordInvocation("UnmapRoute", []interface{}{arg1, arg2}) fake.unmapRouteMutex.Unlock() - if fake.UnmapRouteStub != nil { - return fake.UnmapRouteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unmapRouteReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16758,15 +17581,16 @@ func (fake *FakeActor) UnsetEnvironmentVariableByApplicationNameAndSpace(arg1 st arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.UnsetEnvironmentVariableByApplicationNameAndSpaceStub + fakeReturns := fake.unsetEnvironmentVariableByApplicationNameAndSpaceReturns fake.recordInvocation("UnsetEnvironmentVariableByApplicationNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.unsetEnvironmentVariableByApplicationNameAndSpaceMutex.Unlock() - if fake.UnsetEnvironmentVariableByApplicationNameAndSpaceStub != nil { - return fake.UnsetEnvironmentVariableByApplicationNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unsetEnvironmentVariableByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16823,15 +17647,16 @@ func (fake *FakeActor) UnsetSpaceQuota(arg1 string, arg2 string, arg3 string) (v arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.UnsetSpaceQuotaStub + fakeReturns := fake.unsetSpaceQuotaReturns fake.recordInvocation("UnsetSpaceQuota", []interface{}{arg1, arg2, arg3}) fake.unsetSpaceQuotaMutex.Unlock() - if fake.UnsetSpaceQuotaStub != nil { - return fake.UnsetSpaceQuotaStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unsetSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16887,15 +17712,16 @@ func (fake *FakeActor) UnsharePrivateDomain(arg1 string, arg2 string) (v7action. arg1 string arg2 string }{arg1, arg2}) + stub := fake.UnsharePrivateDomainStub + fakeReturns := fake.unsharePrivateDomainReturns fake.recordInvocation("UnsharePrivateDomain", []interface{}{arg1, arg2}) fake.unsharePrivateDomainMutex.Unlock() - if fake.UnsharePrivateDomainStub != nil { - return fake.UnsharePrivateDomainStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unsharePrivateDomainReturns return fakeReturns.result1, fakeReturns.result2 } @@ -16944,6 +17770,71 @@ func (fake *FakeActor) UnsharePrivateDomainReturnsOnCall(i int, result1 v7action }{result1, result2} } +func (fake *FakeActor) UnshareRoute(arg1 string, arg2 string) (v7action.Warnings, error) { + fake.unshareRouteMutex.Lock() + ret, specificReturn := fake.unshareRouteReturnsOnCall[len(fake.unshareRouteArgsForCall)] + fake.unshareRouteArgsForCall = append(fake.unshareRouteArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + stub := fake.UnshareRouteStub + fakeReturns := fake.unshareRouteReturns + fake.recordInvocation("UnshareRoute", []interface{}{arg1, arg2}) + fake.unshareRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeActor) UnshareRouteCallCount() int { + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() + return len(fake.unshareRouteArgsForCall) +} + +func (fake *FakeActor) UnshareRouteCalls(stub func(string, string) (v7action.Warnings, error)) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = stub +} + +func (fake *FakeActor) UnshareRouteArgsForCall(i int) (string, string) { + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() + argsForCall := fake.unshareRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeActor) UnshareRouteReturns(result1 v7action.Warnings, result2 error) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = nil + fake.unshareRouteReturns = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) UnshareRouteReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.unshareRouteMutex.Lock() + defer fake.unshareRouteMutex.Unlock() + fake.UnshareRouteStub = nil + if fake.unshareRouteReturnsOnCall == nil { + fake.unshareRouteReturnsOnCall = make(map[int]struct { + result1 v7action.Warnings + result2 error + }) + } + fake.unshareRouteReturnsOnCall[i] = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + func (fake *FakeActor) UnshareServiceInstanceFromSpaceAndOrg(arg1 string, arg2 string, arg3 string, arg4 v7action.ServiceInstanceSharingParams) (v7action.Warnings, error) { fake.unshareServiceInstanceFromSpaceAndOrgMutex.Lock() ret, specificReturn := fake.unshareServiceInstanceFromSpaceAndOrgReturnsOnCall[len(fake.unshareServiceInstanceFromSpaceAndOrgArgsForCall)] @@ -16953,15 +17844,16 @@ func (fake *FakeActor) UnshareServiceInstanceFromSpaceAndOrg(arg1 string, arg2 s arg3 string arg4 v7action.ServiceInstanceSharingParams }{arg1, arg2, arg3, arg4}) + stub := fake.UnshareServiceInstanceFromSpaceAndOrgStub + fakeReturns := fake.unshareServiceInstanceFromSpaceAndOrgReturns fake.recordInvocation("UnshareServiceInstanceFromSpaceAndOrg", []interface{}{arg1, arg2, arg3, arg4}) fake.unshareServiceInstanceFromSpaceAndOrgMutex.Unlock() - if fake.UnshareServiceInstanceFromSpaceAndOrgStub != nil { - return fake.UnshareServiceInstanceFromSpaceAndOrgStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.unshareServiceInstanceFromSpaceAndOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17018,15 +17910,16 @@ func (fake *FakeActor) UpdateAppFeature(arg1 resources.Application, arg2 bool, a arg2 bool arg3 string }{arg1, arg2, arg3}) + stub := fake.UpdateAppFeatureStub + fakeReturns := fake.updateAppFeatureReturns fake.recordInvocation("UpdateAppFeature", []interface{}{arg1, arg2, arg3}) fake.updateAppFeatureMutex.Unlock() - if fake.UpdateAppFeatureStub != nil { - return fake.UpdateAppFeatureStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateAppFeatureReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17081,15 +17974,16 @@ func (fake *FakeActor) UpdateApplication(arg1 resources.Application) (resources. fake.updateApplicationArgsForCall = append(fake.updateApplicationArgsForCall, struct { arg1 resources.Application }{arg1}) + stub := fake.UpdateApplicationStub + fakeReturns := fake.updateApplicationReturns fake.recordInvocation("UpdateApplication", []interface{}{arg1}) fake.updateApplicationMutex.Unlock() - if fake.UpdateApplicationStub != nil { - return fake.UpdateApplicationStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateApplicationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -17149,15 +18043,16 @@ func (fake *FakeActor) UpdateApplicationLabelsByApplicationName(arg1 string, arg arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateApplicationLabelsByApplicationNameStub + fakeReturns := fake.updateApplicationLabelsByApplicationNameReturns fake.recordInvocation("UpdateApplicationLabelsByApplicationName", []interface{}{arg1, arg2, arg3}) fake.updateApplicationLabelsByApplicationNameMutex.Unlock() - if fake.UpdateApplicationLabelsByApplicationNameStub != nil { - return fake.UpdateApplicationLabelsByApplicationNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateApplicationLabelsByApplicationNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17206,134 +18101,204 @@ func (fake *FakeActor) UpdateApplicationLabelsByApplicationNameReturnsOnCall(i i }{result1, result2} } -func (fake *FakeActor) UpdateBuildpackByNameAndStack(arg1 string, arg2 string, arg3 resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) { - fake.updateBuildpackByNameAndStackMutex.Lock() - ret, specificReturn := fake.updateBuildpackByNameAndStackReturnsOnCall[len(fake.updateBuildpackByNameAndStackArgsForCall)] - fake.updateBuildpackByNameAndStackArgsForCall = append(fake.updateBuildpackByNameAndStackArgsForCall, struct { +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycle(arg1 string, arg2 string, arg3 string, arg4 resources.Buildpack) (resources.Buildpack, v7action.Warnings, error) { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.Lock() + ret, specificReturn := fake.updateBuildpackByNameAndStackAndLifecycleReturnsOnCall[len(fake.updateBuildpackByNameAndStackAndLifecycleArgsForCall)] + fake.updateBuildpackByNameAndStackAndLifecycleArgsForCall = append(fake.updateBuildpackByNameAndStackAndLifecycleArgsForCall, struct { arg1 string arg2 string - arg3 resources.Buildpack - }{arg1, arg2, arg3}) - fake.recordInvocation("UpdateBuildpackByNameAndStack", []interface{}{arg1, arg2, arg3}) - fake.updateBuildpackByNameAndStackMutex.Unlock() - if fake.UpdateBuildpackByNameAndStackStub != nil { - return fake.UpdateBuildpackByNameAndStackStub(arg1, arg2, arg3) + arg3 string + arg4 resources.Buildpack + }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateBuildpackByNameAndStackAndLifecycleStub + fakeReturns := fake.updateBuildpackByNameAndStackAndLifecycleReturns + fake.recordInvocation("UpdateBuildpackByNameAndStackAndLifecycle", []interface{}{arg1, arg2, arg3, arg4}) + fake.updateBuildpackByNameAndStackAndLifecycleMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateBuildpackByNameAndStackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeActor) UpdateBuildpackByNameAndStackCallCount() int { - fake.updateBuildpackByNameAndStackMutex.RLock() - defer fake.updateBuildpackByNameAndStackMutex.RUnlock() - return len(fake.updateBuildpackByNameAndStackArgsForCall) +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycleCallCount() int { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.RUnlock() + return len(fake.updateBuildpackByNameAndStackAndLifecycleArgsForCall) } -func (fake *FakeActor) UpdateBuildpackByNameAndStackCalls(stub func(string, string, resources.Buildpack) (resources.Buildpack, v7action.Warnings, error)) { - fake.updateBuildpackByNameAndStackMutex.Lock() - defer fake.updateBuildpackByNameAndStackMutex.Unlock() - fake.UpdateBuildpackByNameAndStackStub = stub +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycleCalls(stub func(string, string, string, resources.Buildpack) (resources.Buildpack, v7action.Warnings, error)) { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackByNameAndStackAndLifecycleStub = stub } -func (fake *FakeActor) UpdateBuildpackByNameAndStackArgsForCall(i int) (string, string, resources.Buildpack) { - fake.updateBuildpackByNameAndStackMutex.RLock() - defer fake.updateBuildpackByNameAndStackMutex.RUnlock() - argsForCall := fake.updateBuildpackByNameAndStackArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycleArgsForCall(i int) (string, string, string, resources.Buildpack) { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.RUnlock() + argsForCall := fake.updateBuildpackByNameAndStackAndLifecycleArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } -func (fake *FakeActor) UpdateBuildpackByNameAndStackReturns(result1 resources.Buildpack, result2 v7action.Warnings, result3 error) { - fake.updateBuildpackByNameAndStackMutex.Lock() - defer fake.updateBuildpackByNameAndStackMutex.Unlock() - fake.UpdateBuildpackByNameAndStackStub = nil - fake.updateBuildpackByNameAndStackReturns = struct { +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycleReturns(result1 resources.Buildpack, result2 v7action.Warnings, result3 error) { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackByNameAndStackAndLifecycleStub = nil + fake.updateBuildpackByNameAndStackAndLifecycleReturns = struct { result1 resources.Buildpack result2 v7action.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeActor) UpdateBuildpackByNameAndStackReturnsOnCall(i int, result1 resources.Buildpack, result2 v7action.Warnings, result3 error) { - fake.updateBuildpackByNameAndStackMutex.Lock() - defer fake.updateBuildpackByNameAndStackMutex.Unlock() - fake.UpdateBuildpackByNameAndStackStub = nil - if fake.updateBuildpackByNameAndStackReturnsOnCall == nil { - fake.updateBuildpackByNameAndStackReturnsOnCall = make(map[int]struct { +func (fake *FakeActor) UpdateBuildpackByNameAndStackAndLifecycleReturnsOnCall(i int, result1 resources.Buildpack, result2 v7action.Warnings, result3 error) { + fake.updateBuildpackByNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackByNameAndStackAndLifecycleStub = nil + if fake.updateBuildpackByNameAndStackAndLifecycleReturnsOnCall == nil { + fake.updateBuildpackByNameAndStackAndLifecycleReturnsOnCall = make(map[int]struct { result1 resources.Buildpack result2 v7action.Warnings result3 error }) } - fake.updateBuildpackByNameAndStackReturnsOnCall[i] = struct { + fake.updateBuildpackByNameAndStackAndLifecycleReturnsOnCall[i] = struct { result1 resources.Buildpack result2 v7action.Warnings result3 error }{result1, result2, result3} } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStack(arg1 string, arg2 string, arg3 map[string]types.NullString) (v7action.Warnings, error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - ret, specificReturn := fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall[len(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall)] - fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall = append(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall, struct { +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(arg1 string, arg2 string, arg3 string, arg4 map[string]types.NullString) (v7action.Warnings, error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + ret, specificReturn := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall[len(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall)] + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall = append(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall, struct { arg1 string arg2 string - arg3 map[string]types.NullString + arg3 string + arg4 map[string]types.NullString + }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub + fakeReturns := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns + fake.recordInvocation("UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle", []interface{}{arg1, arg2, arg3, arg4}) + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount() int { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() + return len(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall) +} + +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCalls(stub func(string, string, string, map[string]types.NullString) (v7action.Warnings, error)) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = stub +} + +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall(i int) (string, string, string, map[string]types.NullString) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() + argsForCall := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns(result1 v7action.Warnings, result2 error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = nil + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = nil + if fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall == nil { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall = make(map[int]struct { + result1 v7action.Warnings + result2 error + }) + } + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall[i] = struct { + result1 v7action.Warnings + result2 error + }{result1, result2} +} + +func (fake *FakeActor) UpdateDestination(arg1 string, arg2 string, arg3 string) (v7action.Warnings, error) { + fake.updateDestinationMutex.Lock() + ret, specificReturn := fake.updateDestinationReturnsOnCall[len(fake.updateDestinationArgsForCall)] + fake.updateDestinationArgsForCall = append(fake.updateDestinationArgsForCall, struct { + arg1 string + arg2 string + arg3 string }{arg1, arg2, arg3}) - fake.recordInvocation("UpdateBuildpackLabelsByBuildpackNameAndStack", []interface{}{arg1, arg2, arg3}) - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - if fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub != nil { - return fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub(arg1, arg2, arg3) + stub := fake.UpdateDestinationStub + fakeReturns := fake.updateDestinationReturns + fake.recordInvocation("UpdateDestination", []interface{}{arg1, arg2, arg3}) + fake.updateDestinationMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateBuildpackLabelsByBuildpackNameAndStackReturns return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackCallCount() int { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() - return len(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall) +func (fake *FakeActor) UpdateDestinationCallCount() int { + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() + return len(fake.updateDestinationArgsForCall) } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackCalls(stub func(string, string, map[string]types.NullString) (v7action.Warnings, error)) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = stub +func (fake *FakeActor) UpdateDestinationCalls(stub func(string, string, string) (v7action.Warnings, error)) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = stub } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackArgsForCall(i int) (string, string, map[string]types.NullString) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() - argsForCall := fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall[i] +func (fake *FakeActor) UpdateDestinationArgsForCall(i int) (string, string, string) { + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() + argsForCall := fake.updateDestinationArgsForCall[i] return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackReturns(result1 v7action.Warnings, result2 error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = nil - fake.updateBuildpackLabelsByBuildpackNameAndStackReturns = struct { +func (fake *FakeActor) UpdateDestinationReturns(result1 v7action.Warnings, result2 error) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = nil + fake.updateDestinationReturns = struct { result1 v7action.Warnings result2 error }{result1, result2} } -func (fake *FakeActor) UpdateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = nil - if fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall == nil { - fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall = make(map[int]struct { +func (fake *FakeActor) UpdateDestinationReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.updateDestinationMutex.Lock() + defer fake.updateDestinationMutex.Unlock() + fake.UpdateDestinationStub = nil + if fake.updateDestinationReturnsOnCall == nil { + fake.updateDestinationReturnsOnCall = make(map[int]struct { result1 v7action.Warnings result2 error }) } - fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall[i] = struct { + fake.updateDestinationReturnsOnCall[i] = struct { result1 v7action.Warnings result2 error }{result1, result2} @@ -17346,15 +18311,16 @@ func (fake *FakeActor) UpdateDomainLabelsByDomainName(arg1 string, arg2 map[stri arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateDomainLabelsByDomainNameStub + fakeReturns := fake.updateDomainLabelsByDomainNameReturns fake.recordInvocation("UpdateDomainLabelsByDomainName", []interface{}{arg1, arg2}) fake.updateDomainLabelsByDomainNameMutex.Unlock() - if fake.UpdateDomainLabelsByDomainNameStub != nil { - return fake.UpdateDomainLabelsByDomainNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateDomainLabelsByDomainNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17409,15 +18375,16 @@ func (fake *FakeActor) UpdateManagedServiceInstance(arg1 v7action.UpdateManagedS fake.updateManagedServiceInstanceArgsForCall = append(fake.updateManagedServiceInstanceArgsForCall, struct { arg1 v7action.UpdateManagedServiceInstanceParams }{arg1}) + stub := fake.UpdateManagedServiceInstanceStub + fakeReturns := fake.updateManagedServiceInstanceReturns fake.recordInvocation("UpdateManagedServiceInstance", []interface{}{arg1}) fake.updateManagedServiceInstanceMutex.Unlock() - if fake.UpdateManagedServiceInstanceStub != nil { - return fake.UpdateManagedServiceInstanceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.updateManagedServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -17476,15 +18443,16 @@ func (fake *FakeActor) UpdateOrganizationLabelsByOrganizationName(arg1 string, a arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateOrganizationLabelsByOrganizationNameStub + fakeReturns := fake.updateOrganizationLabelsByOrganizationNameReturns fake.recordInvocation("UpdateOrganizationLabelsByOrganizationName", []interface{}{arg1, arg2}) fake.updateOrganizationLabelsByOrganizationNameMutex.Unlock() - if fake.UpdateOrganizationLabelsByOrganizationNameStub != nil { - return fake.UpdateOrganizationLabelsByOrganizationNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateOrganizationLabelsByOrganizationNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17541,15 +18509,16 @@ func (fake *FakeActor) UpdateOrganizationQuota(arg1 string, arg2 string, arg3 v7 arg2 string arg3 v7action.QuotaLimits }{arg1, arg2, arg3}) + stub := fake.UpdateOrganizationQuotaStub + fakeReturns := fake.updateOrganizationQuotaReturns fake.recordInvocation("UpdateOrganizationQuota", []interface{}{arg1, arg2, arg3}) fake.updateOrganizationQuotaMutex.Unlock() - if fake.UpdateOrganizationQuotaStub != nil { - return fake.UpdateOrganizationQuotaStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateOrganizationQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17606,15 +18575,16 @@ func (fake *FakeActor) UpdateProcessByTypeAndApplication(arg1 string, arg2 strin arg2 string arg3 resources.Process }{arg1, arg2, arg3}) + stub := fake.UpdateProcessByTypeAndApplicationStub + fakeReturns := fake.updateProcessByTypeAndApplicationReturns fake.recordInvocation("UpdateProcessByTypeAndApplication", []interface{}{arg1, arg2, arg3}) fake.updateProcessByTypeAndApplicationMutex.Unlock() - if fake.UpdateProcessByTypeAndApplicationStub != nil { - return fake.UpdateProcessByTypeAndApplicationStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateProcessByTypeAndApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17663,6 +18633,74 @@ func (fake *FakeActor) UpdateProcessByTypeAndApplicationReturnsOnCall(i int, res }{result1, result2} } +func (fake *FakeActor) UpdateRoute(arg1 string, arg2 map[string]*string) (resources.Route, v7action.Warnings, error) { + fake.updateRouteMutex.Lock() + ret, specificReturn := fake.updateRouteReturnsOnCall[len(fake.updateRouteArgsForCall)] + fake.updateRouteArgsForCall = append(fake.updateRouteArgsForCall, struct { + arg1 string + arg2 map[string]*string + }{arg1, arg2}) + stub := fake.UpdateRouteStub + fakeReturns := fake.updateRouteReturns + fake.recordInvocation("UpdateRoute", []interface{}{arg1, arg2}) + fake.updateRouteMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeActor) UpdateRouteCallCount() int { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + return len(fake.updateRouteArgsForCall) +} + +func (fake *FakeActor) UpdateRouteCalls(stub func(string, map[string]*string) (resources.Route, v7action.Warnings, error)) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = stub +} + +func (fake *FakeActor) UpdateRouteArgsForCall(i int) (string, map[string]*string) { + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() + argsForCall := fake.updateRouteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeActor) UpdateRouteReturns(result1 resources.Route, result2 v7action.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + fake.updateRouteReturns = struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + +func (fake *FakeActor) UpdateRouteReturnsOnCall(i int, result1 resources.Route, result2 v7action.Warnings, result3 error) { + fake.updateRouteMutex.Lock() + defer fake.updateRouteMutex.Unlock() + fake.UpdateRouteStub = nil + if fake.updateRouteReturnsOnCall == nil { + fake.updateRouteReturnsOnCall = make(map[int]struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }) + } + fake.updateRouteReturnsOnCall[i] = struct { + result1 resources.Route + result2 v7action.Warnings + result3 error + }{result1, result2, result3} +} + func (fake *FakeActor) UpdateRouteLabels(arg1 string, arg2 string, arg3 map[string]types.NullString) (v7action.Warnings, error) { fake.updateRouteLabelsMutex.Lock() ret, specificReturn := fake.updateRouteLabelsReturnsOnCall[len(fake.updateRouteLabelsArgsForCall)] @@ -17671,15 +18709,16 @@ func (fake *FakeActor) UpdateRouteLabels(arg1 string, arg2 string, arg3 map[stri arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateRouteLabelsStub + fakeReturns := fake.updateRouteLabelsReturns fake.recordInvocation("UpdateRouteLabels", []interface{}{arg1, arg2, arg3}) fake.updateRouteLabelsMutex.Unlock() - if fake.UpdateRouteLabelsStub != nil { - return fake.UpdateRouteLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateRouteLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17735,15 +18774,16 @@ func (fake *FakeActor) UpdateSecurityGroup(arg1 string, arg2 string) (v7action.W arg1 string arg2 string }{arg1, arg2}) + stub := fake.UpdateSecurityGroupStub + fakeReturns := fake.updateSecurityGroupReturns fake.recordInvocation("UpdateSecurityGroup", []interface{}{arg1, arg2}) fake.updateSecurityGroupMutex.Unlock() - if fake.UpdateSecurityGroupStub != nil { - return fake.UpdateSecurityGroupStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSecurityGroupReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17800,15 +18840,16 @@ func (fake *FakeActor) UpdateSecurityGroupGloballyEnabled(arg1 string, arg2 cons arg2 constanta.SecurityGroupLifecycle arg3 bool }{arg1, arg2, arg3}) + stub := fake.UpdateSecurityGroupGloballyEnabledStub + fakeReturns := fake.updateSecurityGroupGloballyEnabledReturns fake.recordInvocation("UpdateSecurityGroupGloballyEnabled", []interface{}{arg1, arg2, arg3}) fake.updateSecurityGroupGloballyEnabledMutex.Unlock() - if fake.UpdateSecurityGroupGloballyEnabledStub != nil { - return fake.UpdateSecurityGroupGloballyEnabledStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSecurityGroupGloballyEnabledReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17864,15 +18905,16 @@ func (fake *FakeActor) UpdateServiceBroker(arg1 string, arg2 resources.ServiceBr arg1 string arg2 resources.ServiceBroker }{arg1, arg2}) + stub := fake.UpdateServiceBrokerStub + fakeReturns := fake.updateServiceBrokerReturns fake.recordInvocation("UpdateServiceBroker", []interface{}{arg1, arg2}) fake.updateServiceBrokerMutex.Unlock() - if fake.UpdateServiceBrokerStub != nil { - return fake.UpdateServiceBrokerStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceBrokerReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17928,15 +18970,16 @@ func (fake *FakeActor) UpdateServiceBrokerLabelsByServiceBrokerName(arg1 string, arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub + fakeReturns := fake.updateServiceBrokerLabelsByServiceBrokerNameReturns fake.recordInvocation("UpdateServiceBrokerLabelsByServiceBrokerName", []interface{}{arg1, arg2}) fake.updateServiceBrokerLabelsByServiceBrokerNameMutex.Unlock() - if fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub != nil { - return fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceBrokerLabelsByServiceBrokerNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -17993,15 +19036,16 @@ func (fake *FakeActor) UpdateServiceInstanceLabels(arg1 string, arg2 string, arg arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateServiceInstanceLabelsStub + fakeReturns := fake.updateServiceInstanceLabelsReturns fake.recordInvocation("UpdateServiceInstanceLabels", []interface{}{arg1, arg2, arg3}) fake.updateServiceInstanceLabelsMutex.Unlock() - if fake.UpdateServiceInstanceLabelsStub != nil { - return fake.UpdateServiceInstanceLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceInstanceLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18058,15 +19102,16 @@ func (fake *FakeActor) UpdateServiceOfferingLabels(arg1 string, arg2 string, arg arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateServiceOfferingLabelsStub + fakeReturns := fake.updateServiceOfferingLabelsReturns fake.recordInvocation("UpdateServiceOfferingLabels", []interface{}{arg1, arg2, arg3}) fake.updateServiceOfferingLabelsMutex.Unlock() - if fake.UpdateServiceOfferingLabelsStub != nil { - return fake.UpdateServiceOfferingLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceOfferingLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18124,15 +19169,16 @@ func (fake *FakeActor) UpdateServicePlanLabels(arg1 string, arg2 string, arg3 st arg3 string arg4 map[string]types.NullString }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateServicePlanLabelsStub + fakeReturns := fake.updateServicePlanLabelsReturns fake.recordInvocation("UpdateServicePlanLabels", []interface{}{arg1, arg2, arg3, arg4}) fake.updateServicePlanLabelsMutex.Unlock() - if fake.UpdateServicePlanLabelsStub != nil { - return fake.UpdateServicePlanLabelsStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServicePlanLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18190,15 +19236,16 @@ func (fake *FakeActor) UpdateSpaceFeature(arg1 string, arg2 string, arg3 bool, a arg3 bool arg4 string }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateSpaceFeatureStub + fakeReturns := fake.updateSpaceFeatureReturns fake.recordInvocation("UpdateSpaceFeature", []interface{}{arg1, arg2, arg3, arg4}) fake.updateSpaceFeatureMutex.Unlock() - if fake.UpdateSpaceFeatureStub != nil { - return fake.UpdateSpaceFeatureStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSpaceFeatureReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18255,15 +19302,16 @@ func (fake *FakeActor) UpdateSpaceLabelsBySpaceName(arg1 string, arg2 string, ar arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateSpaceLabelsBySpaceNameStub + fakeReturns := fake.updateSpaceLabelsBySpaceNameReturns fake.recordInvocation("UpdateSpaceLabelsBySpaceName", []interface{}{arg1, arg2, arg3}) fake.updateSpaceLabelsBySpaceNameMutex.Unlock() - if fake.UpdateSpaceLabelsBySpaceNameStub != nil { - return fake.UpdateSpaceLabelsBySpaceNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSpaceLabelsBySpaceNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18321,15 +19369,16 @@ func (fake *FakeActor) UpdateSpaceQuota(arg1 string, arg2 string, arg3 string, a arg3 string arg4 v7action.QuotaLimits }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateSpaceQuotaStub + fakeReturns := fake.updateSpaceQuotaReturns fake.recordInvocation("UpdateSpaceQuota", []interface{}{arg1, arg2, arg3, arg4}) fake.updateSpaceQuotaMutex.Unlock() - if fake.UpdateSpaceQuotaStub != nil { - return fake.UpdateSpaceQuotaStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSpaceQuotaReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18385,15 +19434,16 @@ func (fake *FakeActor) UpdateStackLabelsByStackName(arg1 string, arg2 map[string arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateStackLabelsByStackNameStub + fakeReturns := fake.updateStackLabelsByStackNameReturns fake.recordInvocation("UpdateStackLabelsByStackName", []interface{}{arg1, arg2}) fake.updateStackLabelsByStackNameMutex.Unlock() - if fake.UpdateStackLabelsByStackNameStub != nil { - return fake.UpdateStackLabelsByStackNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateStackLabelsByStackNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18450,15 +19500,16 @@ func (fake *FakeActor) UpdateUserPassword(arg1 string, arg2 string, arg3 string) arg2 string arg3 string }{arg1, arg2, arg3}) + stub := fake.UpdateUserPasswordStub + fakeReturns := fake.updateUserPasswordReturns fake.recordInvocation("UpdateUserPassword", []interface{}{arg1, arg2, arg3}) fake.updateUserPasswordMutex.Unlock() - if fake.UpdateUserPasswordStub != nil { - return fake.UpdateUserPasswordStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.updateUserPasswordReturns return fakeReturns.result1 } @@ -18512,15 +19563,16 @@ func (fake *FakeActor) UpdateUserProvidedServiceInstance(arg1 string, arg2 strin arg2 string arg3 resources.ServiceInstance }{arg1, arg2, arg3}) + stub := fake.UpdateUserProvidedServiceInstanceStub + fakeReturns := fake.updateUserProvidedServiceInstanceReturns fake.recordInvocation("UpdateUserProvidedServiceInstance", []interface{}{arg1, arg2, arg3}) fake.updateUserProvidedServiceInstanceMutex.Unlock() - if fake.UpdateUserProvidedServiceInstanceStub != nil { - return fake.UpdateUserProvidedServiceInstanceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateUserProvidedServiceInstanceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18569,23 +19621,24 @@ func (fake *FakeActor) UpdateUserProvidedServiceInstanceReturnsOnCall(i int, res }{result1, result2} } -func (fake *FakeActor) UpgradeManagedServiceInstance(arg1 string, arg2 string) (v7action.Warnings, error) { +func (fake *FakeActor) UpgradeManagedServiceInstance(arg1 string, arg2 string) (chan v7action.PollJobEvent, v7action.Warnings, error) { fake.upgradeManagedServiceInstanceMutex.Lock() ret, specificReturn := fake.upgradeManagedServiceInstanceReturnsOnCall[len(fake.upgradeManagedServiceInstanceArgsForCall)] fake.upgradeManagedServiceInstanceArgsForCall = append(fake.upgradeManagedServiceInstanceArgsForCall, struct { arg1 string arg2 string }{arg1, arg2}) + stub := fake.UpgradeManagedServiceInstanceStub + fakeReturns := fake.upgradeManagedServiceInstanceReturns fake.recordInvocation("UpgradeManagedServiceInstance", []interface{}{arg1, arg2}) fake.upgradeManagedServiceInstanceMutex.Unlock() - if fake.UpgradeManagedServiceInstanceStub != nil { - return fake.UpgradeManagedServiceInstanceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.upgradeManagedServiceInstanceReturns - return fakeReturns.result1, fakeReturns.result2 + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeActor) UpgradeManagedServiceInstanceCallCount() int { @@ -18594,7 +19647,7 @@ func (fake *FakeActor) UpgradeManagedServiceInstanceCallCount() int { return len(fake.upgradeManagedServiceInstanceArgsForCall) } -func (fake *FakeActor) UpgradeManagedServiceInstanceCalls(stub func(string, string) (v7action.Warnings, error)) { +func (fake *FakeActor) UpgradeManagedServiceInstanceCalls(stub func(string, string) (chan v7action.PollJobEvent, v7action.Warnings, error)) { fake.upgradeManagedServiceInstanceMutex.Lock() defer fake.upgradeManagedServiceInstanceMutex.Unlock() fake.UpgradeManagedServiceInstanceStub = stub @@ -18607,30 +19660,33 @@ func (fake *FakeActor) UpgradeManagedServiceInstanceArgsForCall(i int) (string, return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeActor) UpgradeManagedServiceInstanceReturns(result1 v7action.Warnings, result2 error) { +func (fake *FakeActor) UpgradeManagedServiceInstanceReturns(result1 chan v7action.PollJobEvent, result2 v7action.Warnings, result3 error) { fake.upgradeManagedServiceInstanceMutex.Lock() defer fake.upgradeManagedServiceInstanceMutex.Unlock() fake.UpgradeManagedServiceInstanceStub = nil fake.upgradeManagedServiceInstanceReturns = struct { - result1 v7action.Warnings - result2 error - }{result1, result2} + result1 chan v7action.PollJobEvent + result2 v7action.Warnings + result3 error + }{result1, result2, result3} } -func (fake *FakeActor) UpgradeManagedServiceInstanceReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { +func (fake *FakeActor) UpgradeManagedServiceInstanceReturnsOnCall(i int, result1 chan v7action.PollJobEvent, result2 v7action.Warnings, result3 error) { fake.upgradeManagedServiceInstanceMutex.Lock() defer fake.upgradeManagedServiceInstanceMutex.Unlock() fake.UpgradeManagedServiceInstanceStub = nil if fake.upgradeManagedServiceInstanceReturnsOnCall == nil { fake.upgradeManagedServiceInstanceReturnsOnCall = make(map[int]struct { - result1 v7action.Warnings - result2 error + result1 chan v7action.PollJobEvent + result2 v7action.Warnings + result3 error }) } fake.upgradeManagedServiceInstanceReturnsOnCall[i] = struct { - result1 v7action.Warnings - result2 error - }{result1, result2} + result1 chan v7action.PollJobEvent + result2 v7action.Warnings + result3 error + }{result1, result2, result3} } func (fake *FakeActor) UploadBitsPackage(arg1 resources.Package, arg2 []sharedaction.V3Resource, arg3 io.Reader, arg4 int64) (resources.Package, v7action.Warnings, error) { @@ -18647,15 +19703,16 @@ func (fake *FakeActor) UploadBitsPackage(arg1 resources.Package, arg2 []sharedac arg3 io.Reader arg4 int64 }{arg1, arg2Copy, arg3, arg4}) + stub := fake.UploadBitsPackageStub + fakeReturns := fake.uploadBitsPackageReturns fake.recordInvocation("UploadBitsPackage", []interface{}{arg1, arg2Copy, arg3, arg4}) fake.uploadBitsPackageMutex.Unlock() - if fake.UploadBitsPackageStub != nil { - return fake.UploadBitsPackageStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadBitsPackageReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -18715,15 +19772,16 @@ func (fake *FakeActor) UploadBuildpack(arg1 string, arg2 string, arg3 v7action.S arg2 string arg3 v7action.SimpleProgressBar }{arg1, arg2, arg3}) + stub := fake.UploadBuildpackStub + fakeReturns := fake.uploadBuildpackReturns fake.recordInvocation("UploadBuildpack", []interface{}{arg1, arg2, arg3}) fake.uploadBuildpackMutex.Unlock() - if fake.UploadBuildpackStub != nil { - return fake.UploadBuildpackStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.uploadBuildpackReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -18784,15 +19842,16 @@ func (fake *FakeActor) UploadDroplet(arg1 string, arg2 string, arg3 io.Reader, a arg3 io.Reader arg4 int64 }{arg1, arg2, arg3, arg4}) + stub := fake.UploadDropletStub + fakeReturns := fake.uploadDropletReturns fake.recordInvocation("UploadDroplet", []interface{}{arg1, arg2, arg3, arg4}) fake.uploadDropletMutex.Unlock() - if fake.UploadDropletStub != nil { - return fake.UploadDropletStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.uploadDropletReturns return fakeReturns.result1, fakeReturns.result2 } @@ -18860,6 +19919,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.checkRouteMutex.RUnlock() fake.clearTargetMutex.RLock() defer fake.clearTargetMutex.RUnlock() + fake.continueDeploymentMutex.RLock() + defer fake.continueDeploymentMutex.RUnlock() fake.copyPackageMutex.RLock() defer fake.copyPackageMutex.RUnlock() fake.createAndUploadBitsPackageByApplicationNameAndSpaceMutex.RLock() @@ -18872,10 +19933,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.createBitsPackageByApplicationMutex.RUnlock() fake.createBuildpackMutex.RLock() defer fake.createBuildpackMutex.RUnlock() - fake.createDeploymentByApplicationAndDropletMutex.RLock() - defer fake.createDeploymentByApplicationAndDropletMutex.RUnlock() - fake.createDeploymentByApplicationAndRevisionMutex.RLock() - defer fake.createDeploymentByApplicationAndRevisionMutex.RUnlock() + fake.createDeploymentMutex.RLock() + defer fake.createDeploymentMutex.RUnlock() fake.createDockerPackageByApplicationMutex.RLock() defer fake.createDockerPackageByApplicationMutex.RUnlock() fake.createDockerPackageByApplicationNameAndSpaceMutex.RLock() @@ -18918,8 +19977,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.createUserProvidedServiceInstanceMutex.RUnlock() fake.deleteApplicationByNameAndSpaceMutex.RLock() defer fake.deleteApplicationByNameAndSpaceMutex.RUnlock() - fake.deleteBuildpackByNameAndStackMutex.RLock() - defer fake.deleteBuildpackByNameAndStackMutex.RUnlock() + fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.deleteBuildpackByNameAndStackAndLifecycleMutex.RUnlock() fake.deleteDomainMutex.RLock() defer fake.deleteDomainMutex.RUnlock() fake.deleteInstanceByApplicationNameSpaceProcessTypeAndIndexMutex.RLock() @@ -18990,12 +20049,16 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.getApplicationPackagesMutex.RUnlock() fake.getApplicationProcessHealthChecksByNameAndSpaceMutex.RLock() defer fake.getApplicationProcessHealthChecksByNameAndSpaceMutex.RUnlock() + fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RLock() + defer fake.getApplicationProcessReadinessHealthChecksByNameAndSpaceMutex.RUnlock() fake.getApplicationRevisionsDeployedMutex.RLock() defer fake.getApplicationRevisionsDeployedMutex.RUnlock() fake.getApplicationRoutesMutex.RLock() defer fake.getApplicationRoutesMutex.RUnlock() fake.getApplicationTasksMutex.RLock() defer fake.getApplicationTasksMutex.RUnlock() + fake.getApplicationsByGUIDsMutex.RLock() + defer fake.getApplicationsByGUIDsMutex.RUnlock() fake.getApplicationsByNamesAndSpaceMutex.RLock() defer fake.getApplicationsByNamesAndSpaceMutex.RUnlock() fake.getBuildpackLabelsMutex.RLock() @@ -19018,6 +20081,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.getEffectiveIsolationSegmentBySpaceMutex.RUnlock() fake.getEnvironmentVariableGroupMutex.RLock() defer fake.getEnvironmentVariableGroupMutex.RUnlock() + fake.getEnvironmentVariableGroupByRevisionMutex.RLock() + defer fake.getEnvironmentVariableGroupByRevisionMutex.RUnlock() fake.getEnvironmentVariablesByApplicationNameAndSpaceMutex.RLock() defer fake.getEnvironmentVariablesByApplicationNameAndSpaceMutex.RUnlock() fake.getFeatureFlagByNameMutex.RLock() @@ -19028,6 +20093,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.getGlobalRunningSecurityGroupsMutex.RUnlock() fake.getGlobalStagingSecurityGroupsMutex.RLock() defer fake.getGlobalStagingSecurityGroupsMutex.RUnlock() + fake.getInfoResponseMutex.RLock() + defer fake.getInfoResponseMutex.RUnlock() fake.getIsolationSegmentByNameMutex.RLock() defer fake.getIsolationSegmentByNameMutex.RUnlock() fake.getIsolationSegmentSummariesMutex.RLock() @@ -19168,6 +20235,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.mapRouteMutex.RUnlock() fake.marketplaceMutex.RLock() defer fake.marketplaceMutex.RUnlock() + fake.moveRouteMutex.RLock() + defer fake.moveRouteMutex.RUnlock() fake.parseAccessTokenMutex.RLock() defer fake.parseAccessTokenMutex.RUnlock() fake.pollBuildMutex.RLock() @@ -19176,8 +20245,10 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.pollPackageMutex.RUnlock() fake.pollStartMutex.RLock() defer fake.pollStartMutex.RUnlock() - fake.pollStartForRollingMutex.RLock() - defer fake.pollStartForRollingMutex.RUnlock() + fake.pollStartForDeploymentMutex.RLock() + defer fake.pollStartForDeploymentMutex.RUnlock() + fake.pollTaskMutex.RLock() + defer fake.pollTaskMutex.RUnlock() fake.pollUploadBuildpackJobMutex.RLock() defer fake.pollUploadBuildpackJobMutex.RUnlock() fake.prepareBuildpackBitsMutex.RLock() @@ -19232,6 +20303,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.setTargetMutex.RUnlock() fake.sharePrivateDomainMutex.RLock() defer fake.sharePrivateDomainMutex.RUnlock() + fake.shareRouteMutex.RLock() + defer fake.shareRouteMutex.RUnlock() fake.shareServiceInstanceToSpaceAndOrgMutex.RLock() defer fake.shareServiceInstanceToSpaceAndOrgMutex.RUnlock() fake.stageApplicationPackageMutex.RLock() @@ -19254,6 +20327,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.unsetSpaceQuotaMutex.RUnlock() fake.unsharePrivateDomainMutex.RLock() defer fake.unsharePrivateDomainMutex.RUnlock() + fake.unshareRouteMutex.RLock() + defer fake.unshareRouteMutex.RUnlock() fake.unshareServiceInstanceFromSpaceAndOrgMutex.RLock() defer fake.unshareServiceInstanceFromSpaceAndOrgMutex.RUnlock() fake.updateAppFeatureMutex.RLock() @@ -19262,10 +20337,12 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.updateApplicationMutex.RUnlock() fake.updateApplicationLabelsByApplicationNameMutex.RLock() defer fake.updateApplicationLabelsByApplicationNameMutex.RUnlock() - fake.updateBuildpackByNameAndStackMutex.RLock() - defer fake.updateBuildpackByNameAndStackMutex.RUnlock() - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() + fake.updateBuildpackByNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackByNameAndStackAndLifecycleMutex.RUnlock() + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() + fake.updateDestinationMutex.RLock() + defer fake.updateDestinationMutex.RUnlock() fake.updateDomainLabelsByDomainNameMutex.RLock() defer fake.updateDomainLabelsByDomainNameMutex.RUnlock() fake.updateManagedServiceInstanceMutex.RLock() @@ -19276,6 +20353,8 @@ func (fake *FakeActor) Invocations() map[string][][]interface{} { defer fake.updateOrganizationQuotaMutex.RUnlock() fake.updateProcessByTypeAndApplicationMutex.RLock() defer fake.updateProcessByTypeAndApplicationMutex.RUnlock() + fake.updateRouteMutex.RLock() + defer fake.updateRouteMutex.RUnlock() fake.updateRouteLabelsMutex.RLock() defer fake.updateRouteLabelsMutex.RUnlock() fake.updateSecurityGroupMutex.RLock() diff --git a/command/v7/v7fakes/fake_actor_reloader.go b/command/v7/v7fakes/fake_actor_reloader.go index f5397aaae12..6fe66345dd7 100644 --- a/command/v7/v7fakes/fake_actor_reloader.go +++ b/command/v7/v7fakes/fake_actor_reloader.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/command" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/command" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeActorReloader struct { @@ -34,15 +34,16 @@ func (fake *FakeActorReloader) Reload(arg1 command.Config, arg2 command.UI) (v7. arg1 command.Config arg2 command.UI }{arg1, arg2}) + stub := fake.ReloadStub + fakeReturns := fake.reloadReturns fake.recordInvocation("Reload", []interface{}{arg1, arg2}) fake.reloadMutex.Unlock() - if fake.ReloadStub != nil { - return fake.ReloadStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.reloadReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/v7/v7fakes/fake_diff_displayer.go b/command/v7/v7fakes/fake_diff_displayer.go index 79bcd663deb..8911c427ce5 100644 --- a/command/v7/v7fakes/fake_diff_displayer.go +++ b/command/v7/v7fakes/fake_diff_displayer.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/resources" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeDiffDisplayer struct { @@ -37,15 +37,16 @@ func (fake *FakeDiffDisplayer) DisplayDiff(arg1 []byte, arg2 resources.ManifestD arg1 []byte arg2 resources.ManifestDiff }{arg1Copy, arg2}) + stub := fake.DisplayDiffStub + fakeReturns := fake.displayDiffReturns fake.recordInvocation("DisplayDiff", []interface{}{arg1Copy, arg2}) fake.displayDiffMutex.Unlock() - if fake.DisplayDiffStub != nil { - return fake.DisplayDiffStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.displayDiffReturns return fakeReturns.result1 } diff --git a/command/v7/v7fakes/fake_label_setter.go b/command/v7/v7fakes/fake_label_setter.go index 21b6cea3a98..1d258f1ca87 100644 --- a/command/v7/v7fakes/fake_label_setter.go +++ b/command/v7/v7fakes/fake_label_setter.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/types" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/types" ) type FakeLabelSetter struct { @@ -32,15 +32,16 @@ func (fake *FakeLabelSetter) Execute(arg1 v7.TargetResource, arg2 map[string]typ arg1 v7.TargetResource arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1, arg2}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } diff --git a/command/v7/v7fakes/fake_label_unsetter.go b/command/v7/v7fakes/fake_label_unsetter.go index 6b57278a967..298e3f121d6 100644 --- a/command/v7/v7fakes/fake_label_unsetter.go +++ b/command/v7/v7fakes/fake_label_unsetter.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/types" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/types" ) type FakeLabelUnsetter struct { @@ -32,15 +32,16 @@ func (fake *FakeLabelUnsetter) Execute(arg1 v7.TargetResource, arg2 map[string]t arg1 v7.TargetResource arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.ExecuteStub + fakeReturns := fake.executeReturns fake.recordInvocation("Execute", []interface{}{arg1, arg2}) fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeReturns return fakeReturns.result1 } diff --git a/command/v7/v7fakes/fake_manifest_locator.go b/command/v7/v7fakes/fake_manifest_locator.go index abbbbcfaf48..3360061056c 100644 --- a/command/v7/v7fakes/fake_manifest_locator.go +++ b/command/v7/v7fakes/fake_manifest_locator.go @@ -4,7 +4,7 @@ package v7fakes import ( "sync" - v7 "code.cloudfoundry.org/cli/command/v7" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeManifestLocator struct { @@ -33,15 +33,16 @@ func (fake *FakeManifestLocator) Path(arg1 string) (string, bool, error) { fake.pathArgsForCall = append(fake.pathArgsForCall, struct { arg1 string }{arg1}) + stub := fake.PathStub + fakeReturns := fake.pathReturns fake.recordInvocation("Path", []interface{}{arg1}) fake.pathMutex.Unlock() - if fake.PathStub != nil { - return fake.PathStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.pathReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/command/v7/v7fakes/fake_manifest_parser.go b/command/v7/v7fakes/fake_manifest_parser.go index 735c953053f..3acd35c1846 100644 --- a/command/v7/v7fakes/fake_manifest_parser.go +++ b/command/v7/v7fakes/fake_manifest_parser.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/manifestparser" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/manifestparser" "github.com/cloudfoundry/bosh-cli/director/template" ) @@ -74,15 +74,16 @@ func (fake *FakeManifestParser) InterpolateManifest(arg1 string, arg2 []string, arg2 []string arg3 []template.VarKV }{arg1, arg2Copy, arg3Copy}) + stub := fake.InterpolateManifestStub + fakeReturns := fake.interpolateManifestReturns fake.recordInvocation("InterpolateManifest", []interface{}{arg1, arg2Copy, arg3Copy}) fake.interpolateManifestMutex.Unlock() - if fake.InterpolateManifestStub != nil { - return fake.InterpolateManifestStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.interpolateManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -137,15 +138,16 @@ func (fake *FakeManifestParser) MarshalManifest(arg1 manifestparser.Manifest) ([ fake.marshalManifestArgsForCall = append(fake.marshalManifestArgsForCall, struct { arg1 manifestparser.Manifest }{arg1}) + stub := fake.MarshalManifestStub + fakeReturns := fake.marshalManifestReturns fake.recordInvocation("MarshalManifest", []interface{}{arg1}) fake.marshalManifestMutex.Unlock() - if fake.MarshalManifestStub != nil { - return fake.MarshalManifestStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.marshalManifestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -206,15 +208,16 @@ func (fake *FakeManifestParser) ParseManifest(arg1 string, arg2 []byte) (manifes arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.ParseManifestStub + fakeReturns := fake.parseManifestReturns fake.recordInvocation("ParseManifest", []interface{}{arg1, arg2Copy}) fake.parseManifestMutex.Unlock() - if fake.ParseManifestStub != nil { - return fake.ParseManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.parseManifestReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/v7/v7fakes/fake_network_policies_actor.go b/command/v7/v7fakes/fake_network_policies_actor.go index 79857f0c170..b59b13435d5 100644 --- a/command/v7/v7fakes/fake_network_policies_actor.go +++ b/command/v7/v7fakes/fake_network_policies_actor.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeNetworkPoliciesActor struct { @@ -50,15 +50,16 @@ func (fake *FakeNetworkPoliciesActor) NetworkPoliciesBySpace(arg1 string) ([]cfn fake.networkPoliciesBySpaceArgsForCall = append(fake.networkPoliciesBySpaceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.NetworkPoliciesBySpaceStub + fakeReturns := fake.networkPoliciesBySpaceReturns fake.recordInvocation("NetworkPoliciesBySpace", []interface{}{arg1}) fake.networkPoliciesBySpaceMutex.Unlock() - if fake.NetworkPoliciesBySpaceStub != nil { - return fake.NetworkPoliciesBySpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.networkPoliciesBySpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -117,15 +118,16 @@ func (fake *FakeNetworkPoliciesActor) NetworkPoliciesBySpaceAndAppName(arg1 stri arg1 string arg2 string }{arg1, arg2}) + stub := fake.NetworkPoliciesBySpaceAndAppNameStub + fakeReturns := fake.networkPoliciesBySpaceAndAppNameReturns fake.recordInvocation("NetworkPoliciesBySpaceAndAppName", []interface{}{arg1, arg2}) fake.networkPoliciesBySpaceAndAppNameMutex.Unlock() - if fake.NetworkPoliciesBySpaceAndAppNameStub != nil { - return fake.NetworkPoliciesBySpaceAndAppNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.networkPoliciesBySpaceAndAppNameReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/command/v7/v7fakes/fake_networking_actor.go b/command/v7/v7fakes/fake_networking_actor.go index bb42ffac9b5..3eaad12cb3c 100644 --- a/command/v7/v7fakes/fake_networking_actor.go +++ b/command/v7/v7fakes/fake_networking_actor.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeNetworkingActor struct { @@ -44,15 +44,16 @@ func (fake *FakeNetworkingActor) AddNetworkPolicy(arg1 string, arg2 string, arg3 arg6 int arg7 int }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) + stub := fake.AddNetworkPolicyStub + fakeReturns := fake.addNetworkPolicyReturns fake.recordInvocation("AddNetworkPolicy", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) fake.addNetworkPolicyMutex.Unlock() - if fake.AddNetworkPolicyStub != nil { - return fake.AddNetworkPolicyStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.addNetworkPolicyReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/v7/v7fakes/fake_progress_bar.go b/command/v7/v7fakes/fake_progress_bar.go index 9c40495632c..06fc73c008e 100644 --- a/command/v7/v7fakes/fake_progress_bar.go +++ b/command/v7/v7fakes/fake_progress_bar.go @@ -5,7 +5,7 @@ import ( "io" "sync" - v7 "code.cloudfoundry.org/cli/command/v7" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeProgressBar struct { @@ -37,9 +37,10 @@ func (fake *FakeProgressBar) Complete() { fake.completeMutex.Lock() fake.completeArgsForCall = append(fake.completeArgsForCall, struct { }{}) + stub := fake.CompleteStub fake.recordInvocation("Complete", []interface{}{}) fake.completeMutex.Unlock() - if fake.CompleteStub != nil { + if stub != nil { fake.CompleteStub() } } @@ -63,15 +64,16 @@ func (fake *FakeProgressBar) NewProgressBarWrapper(arg1 io.Reader, arg2 int64) i arg1 io.Reader arg2 int64 }{arg1, arg2}) + stub := fake.NewProgressBarWrapperStub + fakeReturns := fake.newProgressBarWrapperReturns fake.recordInvocation("NewProgressBarWrapper", []interface{}{arg1, arg2}) fake.newProgressBarWrapperMutex.Unlock() - if fake.NewProgressBarWrapperStub != nil { - return fake.NewProgressBarWrapperStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.newProgressBarWrapperReturns return fakeReturns.result1 } @@ -121,9 +123,10 @@ func (fake *FakeProgressBar) Ready() { fake.readyMutex.Lock() fake.readyArgsForCall = append(fake.readyArgsForCall, struct { }{}) + stub := fake.ReadyStub fake.recordInvocation("Ready", []interface{}{}) fake.readyMutex.Unlock() - if fake.ReadyStub != nil { + if stub != nil { fake.ReadyStub() } } diff --git a/command/v7/v7fakes/fake_push_actor.go b/command/v7/v7fakes/fake_push_actor.go index 95c137b77ba..9e749b509c7 100644 --- a/command/v7/v7fakes/fake_push_actor.go +++ b/command/v7/v7fakes/fake_push_actor.go @@ -4,10 +4,10 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - "code.cloudfoundry.org/cli/actor/v7pushaction" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/util/manifestparser" + "code.cloudfoundry.org/cli/v8/actor/v7action" + "code.cloudfoundry.org/cli/v8/actor/v7pushaction" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/util/manifestparser" ) type FakePushActor struct { @@ -41,6 +41,20 @@ type FakePushActor struct { result2 v7action.Warnings result3 error } + HandleDeploymentScaleFlagOverridesStub func(manifestparser.Manifest, v7pushaction.FlagOverrides) (manifestparser.Manifest, error) + handleDeploymentScaleFlagOverridesMutex sync.RWMutex + handleDeploymentScaleFlagOverridesArgsForCall []struct { + arg1 manifestparser.Manifest + arg2 v7pushaction.FlagOverrides + } + handleDeploymentScaleFlagOverridesReturns struct { + result1 manifestparser.Manifest + result2 error + } + handleDeploymentScaleFlagOverridesReturnsOnCall map[int]struct { + result1 manifestparser.Manifest + result2 error + } HandleFlagOverridesStub func(manifestparser.Manifest, v7pushaction.FlagOverrides) (manifestparser.Manifest, error) handleFlagOverridesMutex sync.RWMutex handleFlagOverridesArgsForCall []struct { @@ -66,15 +80,16 @@ func (fake *FakePushActor) Actualize(arg1 v7pushaction.PushPlan, arg2 v7pushacti arg1 v7pushaction.PushPlan arg2 v7pushaction.ProgressBar }{arg1, arg2}) + stub := fake.ActualizeStub + fakeReturns := fake.actualizeReturns fake.recordInvocation("Actualize", []interface{}{arg1, arg2}) fake.actualizeMutex.Unlock() - if fake.ActualizeStub != nil { - return fake.ActualizeStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.actualizeReturns return fakeReturns.result1 } @@ -129,15 +144,16 @@ func (fake *FakePushActor) CreatePushPlans(arg1 string, arg2 string, arg3 manife arg3 manifestparser.Manifest arg4 v7pushaction.FlagOverrides }{arg1, arg2, arg3, arg4}) + stub := fake.CreatePushPlansStub + fakeReturns := fake.createPushPlansReturns fake.recordInvocation("CreatePushPlans", []interface{}{arg1, arg2, arg3, arg4}) fake.createPushPlansMutex.Unlock() - if fake.CreatePushPlansStub != nil { - return fake.CreatePushPlansStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.createPushPlansReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -189,6 +205,71 @@ func (fake *FakePushActor) CreatePushPlansReturnsOnCall(i int, result1 []v7pusha }{result1, result2, result3} } +func (fake *FakePushActor) HandleDeploymentScaleFlagOverrides(arg1 manifestparser.Manifest, arg2 v7pushaction.FlagOverrides) (manifestparser.Manifest, error) { + fake.handleDeploymentScaleFlagOverridesMutex.Lock() + ret, specificReturn := fake.handleDeploymentScaleFlagOverridesReturnsOnCall[len(fake.handleDeploymentScaleFlagOverridesArgsForCall)] + fake.handleDeploymentScaleFlagOverridesArgsForCall = append(fake.handleDeploymentScaleFlagOverridesArgsForCall, struct { + arg1 manifestparser.Manifest + arg2 v7pushaction.FlagOverrides + }{arg1, arg2}) + stub := fake.HandleDeploymentScaleFlagOverridesStub + fakeReturns := fake.handleDeploymentScaleFlagOverridesReturns + fake.recordInvocation("HandleDeploymentScaleFlagOverrides", []interface{}{arg1, arg2}) + fake.handleDeploymentScaleFlagOverridesMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakePushActor) HandleDeploymentScaleFlagOverridesCallCount() int { + fake.handleDeploymentScaleFlagOverridesMutex.RLock() + defer fake.handleDeploymentScaleFlagOverridesMutex.RUnlock() + return len(fake.handleDeploymentScaleFlagOverridesArgsForCall) +} + +func (fake *FakePushActor) HandleDeploymentScaleFlagOverridesCalls(stub func(manifestparser.Manifest, v7pushaction.FlagOverrides) (manifestparser.Manifest, error)) { + fake.handleDeploymentScaleFlagOverridesMutex.Lock() + defer fake.handleDeploymentScaleFlagOverridesMutex.Unlock() + fake.HandleDeploymentScaleFlagOverridesStub = stub +} + +func (fake *FakePushActor) HandleDeploymentScaleFlagOverridesArgsForCall(i int) (manifestparser.Manifest, v7pushaction.FlagOverrides) { + fake.handleDeploymentScaleFlagOverridesMutex.RLock() + defer fake.handleDeploymentScaleFlagOverridesMutex.RUnlock() + argsForCall := fake.handleDeploymentScaleFlagOverridesArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakePushActor) HandleDeploymentScaleFlagOverridesReturns(result1 manifestparser.Manifest, result2 error) { + fake.handleDeploymentScaleFlagOverridesMutex.Lock() + defer fake.handleDeploymentScaleFlagOverridesMutex.Unlock() + fake.HandleDeploymentScaleFlagOverridesStub = nil + fake.handleDeploymentScaleFlagOverridesReturns = struct { + result1 manifestparser.Manifest + result2 error + }{result1, result2} +} + +func (fake *FakePushActor) HandleDeploymentScaleFlagOverridesReturnsOnCall(i int, result1 manifestparser.Manifest, result2 error) { + fake.handleDeploymentScaleFlagOverridesMutex.Lock() + defer fake.handleDeploymentScaleFlagOverridesMutex.Unlock() + fake.HandleDeploymentScaleFlagOverridesStub = nil + if fake.handleDeploymentScaleFlagOverridesReturnsOnCall == nil { + fake.handleDeploymentScaleFlagOverridesReturnsOnCall = make(map[int]struct { + result1 manifestparser.Manifest + result2 error + }) + } + fake.handleDeploymentScaleFlagOverridesReturnsOnCall[i] = struct { + result1 manifestparser.Manifest + result2 error + }{result1, result2} +} + func (fake *FakePushActor) HandleFlagOverrides(arg1 manifestparser.Manifest, arg2 v7pushaction.FlagOverrides) (manifestparser.Manifest, error) { fake.handleFlagOverridesMutex.Lock() ret, specificReturn := fake.handleFlagOverridesReturnsOnCall[len(fake.handleFlagOverridesArgsForCall)] @@ -196,15 +277,16 @@ func (fake *FakePushActor) HandleFlagOverrides(arg1 manifestparser.Manifest, arg arg1 manifestparser.Manifest arg2 v7pushaction.FlagOverrides }{arg1, arg2}) + stub := fake.HandleFlagOverridesStub + fakeReturns := fake.handleFlagOverridesReturns fake.recordInvocation("HandleFlagOverrides", []interface{}{arg1, arg2}) fake.handleFlagOverridesMutex.Unlock() - if fake.HandleFlagOverridesStub != nil { - return fake.HandleFlagOverridesStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.handleFlagOverridesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -260,6 +342,8 @@ func (fake *FakePushActor) Invocations() map[string][][]interface{} { defer fake.actualizeMutex.RUnlock() fake.createPushPlansMutex.RLock() defer fake.createPushPlansMutex.RUnlock() + fake.handleDeploymentScaleFlagOverridesMutex.RLock() + defer fake.handleDeploymentScaleFlagOverridesMutex.RUnlock() fake.handleFlagOverridesMutex.RLock() defer fake.handleFlagOverridesMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/command/v7/v7fakes/fake_remove_network_policy_actor.go b/command/v7/v7fakes/fake_remove_network_policy_actor.go index b2ed7ded2e3..598339350ef 100644 --- a/command/v7/v7fakes/fake_remove_network_policy_actor.go +++ b/command/v7/v7fakes/fake_remove_network_policy_actor.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/cfnetworkingaction" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/actor/cfnetworkingaction" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeRemoveNetworkPolicyActor struct { @@ -44,15 +44,16 @@ func (fake *FakeRemoveNetworkPolicyActor) RemoveNetworkPolicy(arg1 string, arg2 arg6 int arg7 int }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) + stub := fake.RemoveNetworkPolicyStub + fakeReturns := fake.removeNetworkPolicyReturns fake.recordInvocation("RemoveNetworkPolicy", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) fake.removeNetworkPolicyMutex.Unlock() - if fake.RemoveNetworkPolicyStub != nil { - return fake.RemoveNetworkPolicyStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) + if stub != nil { + return stub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.removeNetworkPolicyReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/command/v7/v7fakes/fake_revisions_actor.go b/command/v7/v7fakes/fake_revisions_actor.go index 6db96cce2c0..334ea87c604 100644 --- a/command/v7/v7fakes/fake_revisions_actor.go +++ b/command/v7/v7fakes/fake_revisions_actor.go @@ -4,9 +4,9 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/v7action" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeRevisionsActor struct { @@ -37,15 +37,16 @@ func (fake *FakeRevisionsActor) GetRevisionsByApplicationNameAndSpace(arg1 strin arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetRevisionsByApplicationNameAndSpaceStub + fakeReturns := fake.getRevisionsByApplicationNameAndSpaceReturns fake.recordInvocation("GetRevisionsByApplicationNameAndSpace", []interface{}{arg1, arg2}) fake.getRevisionsByApplicationNameAndSpaceMutex.Unlock() - if fake.GetRevisionsByApplicationNameAndSpaceStub != nil { - return fake.GetRevisionsByApplicationNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getRevisionsByApplicationNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/command/v7/v7fakes/fake_set_label_actor.go b/command/v7/v7fakes/fake_set_label_actor.go index 8eb74fcb505..6b24970d52d 100644 --- a/command/v7/v7fakes/fake_set_label_actor.go +++ b/command/v7/v7fakes/fake_set_label_actor.go @@ -4,10 +4,10 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/v7action" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/types" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/actor/v7action" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/types" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeSetLabelActor struct { @@ -38,18 +38,19 @@ type FakeSetLabelActor struct { result1 v7action.Warnings result2 error } - UpdateBuildpackLabelsByBuildpackNameAndStackStub func(string, string, map[string]types.NullString) (v7action.Warnings, error) - updateBuildpackLabelsByBuildpackNameAndStackMutex sync.RWMutex - updateBuildpackLabelsByBuildpackNameAndStackArgsForCall []struct { + UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub func(string, string, string, map[string]types.NullString) (v7action.Warnings, error) + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex sync.RWMutex + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall []struct { arg1 string arg2 string - arg3 map[string]types.NullString + arg3 string + arg4 map[string]types.NullString } - updateBuildpackLabelsByBuildpackNameAndStackReturns struct { + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns struct { result1 v7action.Warnings result2 error } - updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall map[int]struct { + updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall map[int]struct { result1 v7action.Warnings result2 error } @@ -194,15 +195,16 @@ func (fake *FakeSetLabelActor) GetCurrentUser() (configv3.User, error) { ret, specificReturn := fake.getCurrentUserReturnsOnCall[len(fake.getCurrentUserArgsForCall)] fake.getCurrentUserArgsForCall = append(fake.getCurrentUserArgsForCall, struct { }{}) + stub := fake.GetCurrentUserStub + fakeReturns := fake.getCurrentUserReturns fake.recordInvocation("GetCurrentUser", []interface{}{}) fake.getCurrentUserMutex.Unlock() - if fake.GetCurrentUserStub != nil { - return fake.GetCurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getCurrentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -252,15 +254,16 @@ func (fake *FakeSetLabelActor) UpdateApplicationLabelsByApplicationName(arg1 str arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateApplicationLabelsByApplicationNameStub + fakeReturns := fake.updateApplicationLabelsByApplicationNameReturns fake.recordInvocation("UpdateApplicationLabelsByApplicationName", []interface{}{arg1, arg2, arg3}) fake.updateApplicationLabelsByApplicationNameMutex.Unlock() - if fake.UpdateApplicationLabelsByApplicationNameStub != nil { - return fake.UpdateApplicationLabelsByApplicationNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateApplicationLabelsByApplicationNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -309,66 +312,68 @@ func (fake *FakeSetLabelActor) UpdateApplicationLabelsByApplicationNameReturnsOn }{result1, result2} } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStack(arg1 string, arg2 string, arg3 map[string]types.NullString) (v7action.Warnings, error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - ret, specificReturn := fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall[len(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall)] - fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall = append(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall, struct { +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle(arg1 string, arg2 string, arg3 string, arg4 map[string]types.NullString) (v7action.Warnings, error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + ret, specificReturn := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall[len(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall)] + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall = append(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall, struct { arg1 string arg2 string - arg3 map[string]types.NullString - }{arg1, arg2, arg3}) - fake.recordInvocation("UpdateBuildpackLabelsByBuildpackNameAndStack", []interface{}{arg1, arg2, arg3}) - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - if fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub != nil { - return fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub(arg1, arg2, arg3) + arg3 string + arg4 map[string]types.NullString + }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub + fakeReturns := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns + fake.recordInvocation("UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycle", []interface{}{arg1, arg2, arg3, arg4}) + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateBuildpackLabelsByBuildpackNameAndStackReturns return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackCallCount() int { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() - return len(fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall) +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCallCount() int { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() + return len(fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall) } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackCalls(stub func(string, string, map[string]types.NullString) (v7action.Warnings, error)) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = stub +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleCalls(stub func(string, string, string, map[string]types.NullString) (v7action.Warnings, error)) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = stub } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackArgsForCall(i int) (string, string, map[string]types.NullString) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() - argsForCall := fake.updateBuildpackLabelsByBuildpackNameAndStackArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall(i int) (string, string, string, map[string]types.NullString) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() + argsForCall := fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackReturns(result1 v7action.Warnings, result2 error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = nil - fake.updateBuildpackLabelsByBuildpackNameAndStackReturns = struct { +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns(result1 v7action.Warnings, result2 error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = nil + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturns = struct { result1 v7action.Warnings result2 error }{result1, result2} } -func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Lock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.Unlock() - fake.UpdateBuildpackLabelsByBuildpackNameAndStackStub = nil - if fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall == nil { - fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall = make(map[int]struct { +func (fake *FakeSetLabelActor) UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall(i int, result1 v7action.Warnings, result2 error) { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Lock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.Unlock() + fake.UpdateBuildpackLabelsByBuildpackNameAndStackAndLifecycleStub = nil + if fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall == nil { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall = make(map[int]struct { result1 v7action.Warnings result2 error }) } - fake.updateBuildpackLabelsByBuildpackNameAndStackReturnsOnCall[i] = struct { + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleReturnsOnCall[i] = struct { result1 v7action.Warnings result2 error }{result1, result2} @@ -381,15 +386,16 @@ func (fake *FakeSetLabelActor) UpdateDomainLabelsByDomainName(arg1 string, arg2 arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateDomainLabelsByDomainNameStub + fakeReturns := fake.updateDomainLabelsByDomainNameReturns fake.recordInvocation("UpdateDomainLabelsByDomainName", []interface{}{arg1, arg2}) fake.updateDomainLabelsByDomainNameMutex.Unlock() - if fake.UpdateDomainLabelsByDomainNameStub != nil { - return fake.UpdateDomainLabelsByDomainNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateDomainLabelsByDomainNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -445,15 +451,16 @@ func (fake *FakeSetLabelActor) UpdateOrganizationLabelsByOrganizationName(arg1 s arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateOrganizationLabelsByOrganizationNameStub + fakeReturns := fake.updateOrganizationLabelsByOrganizationNameReturns fake.recordInvocation("UpdateOrganizationLabelsByOrganizationName", []interface{}{arg1, arg2}) fake.updateOrganizationLabelsByOrganizationNameMutex.Unlock() - if fake.UpdateOrganizationLabelsByOrganizationNameStub != nil { - return fake.UpdateOrganizationLabelsByOrganizationNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateOrganizationLabelsByOrganizationNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -510,15 +517,16 @@ func (fake *FakeSetLabelActor) UpdateRouteLabels(arg1 string, arg2 string, arg3 arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateRouteLabelsStub + fakeReturns := fake.updateRouteLabelsReturns fake.recordInvocation("UpdateRouteLabels", []interface{}{arg1, arg2, arg3}) fake.updateRouteLabelsMutex.Unlock() - if fake.UpdateRouteLabelsStub != nil { - return fake.UpdateRouteLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateRouteLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -574,15 +582,16 @@ func (fake *FakeSetLabelActor) UpdateServiceBrokerLabelsByServiceBrokerName(arg1 arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub + fakeReturns := fake.updateServiceBrokerLabelsByServiceBrokerNameReturns fake.recordInvocation("UpdateServiceBrokerLabelsByServiceBrokerName", []interface{}{arg1, arg2}) fake.updateServiceBrokerLabelsByServiceBrokerNameMutex.Unlock() - if fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub != nil { - return fake.UpdateServiceBrokerLabelsByServiceBrokerNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceBrokerLabelsByServiceBrokerNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -639,15 +648,16 @@ func (fake *FakeSetLabelActor) UpdateServiceInstanceLabels(arg1 string, arg2 str arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateServiceInstanceLabelsStub + fakeReturns := fake.updateServiceInstanceLabelsReturns fake.recordInvocation("UpdateServiceInstanceLabels", []interface{}{arg1, arg2, arg3}) fake.updateServiceInstanceLabelsMutex.Unlock() - if fake.UpdateServiceInstanceLabelsStub != nil { - return fake.UpdateServiceInstanceLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceInstanceLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -704,15 +714,16 @@ func (fake *FakeSetLabelActor) UpdateServiceOfferingLabels(arg1 string, arg2 str arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateServiceOfferingLabelsStub + fakeReturns := fake.updateServiceOfferingLabelsReturns fake.recordInvocation("UpdateServiceOfferingLabels", []interface{}{arg1, arg2, arg3}) fake.updateServiceOfferingLabelsMutex.Unlock() - if fake.UpdateServiceOfferingLabelsStub != nil { - return fake.UpdateServiceOfferingLabelsStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServiceOfferingLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -770,15 +781,16 @@ func (fake *FakeSetLabelActor) UpdateServicePlanLabels(arg1 string, arg2 string, arg3 string arg4 map[string]types.NullString }{arg1, arg2, arg3, arg4}) + stub := fake.UpdateServicePlanLabelsStub + fakeReturns := fake.updateServicePlanLabelsReturns fake.recordInvocation("UpdateServicePlanLabels", []interface{}{arg1, arg2, arg3, arg4}) fake.updateServicePlanLabelsMutex.Unlock() - if fake.UpdateServicePlanLabelsStub != nil { - return fake.UpdateServicePlanLabelsStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateServicePlanLabelsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -835,15 +847,16 @@ func (fake *FakeSetLabelActor) UpdateSpaceLabelsBySpaceName(arg1 string, arg2 st arg2 string arg3 map[string]types.NullString }{arg1, arg2, arg3}) + stub := fake.UpdateSpaceLabelsBySpaceNameStub + fakeReturns := fake.updateSpaceLabelsBySpaceNameReturns fake.recordInvocation("UpdateSpaceLabelsBySpaceName", []interface{}{arg1, arg2, arg3}) fake.updateSpaceLabelsBySpaceNameMutex.Unlock() - if fake.UpdateSpaceLabelsBySpaceNameStub != nil { - return fake.UpdateSpaceLabelsBySpaceNameStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateSpaceLabelsBySpaceNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -899,15 +912,16 @@ func (fake *FakeSetLabelActor) UpdateStackLabelsByStackName(arg1 string, arg2 ma arg1 string arg2 map[string]types.NullString }{arg1, arg2}) + stub := fake.UpdateStackLabelsByStackNameStub + fakeReturns := fake.updateStackLabelsByStackNameReturns fake.recordInvocation("UpdateStackLabelsByStackName", []interface{}{arg1, arg2}) fake.updateStackLabelsByStackNameMutex.Unlock() - if fake.UpdateStackLabelsByStackNameStub != nil { - return fake.UpdateStackLabelsByStackNameStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.updateStackLabelsByStackNameReturns return fakeReturns.result1, fakeReturns.result2 } @@ -963,8 +977,8 @@ func (fake *FakeSetLabelActor) Invocations() map[string][][]interface{} { defer fake.getCurrentUserMutex.RUnlock() fake.updateApplicationLabelsByApplicationNameMutex.RLock() defer fake.updateApplicationLabelsByApplicationNameMutex.RUnlock() - fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RLock() - defer fake.updateBuildpackLabelsByBuildpackNameAndStackMutex.RUnlock() + fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RLock() + defer fake.updateBuildpackLabelsByBuildpackNameAndStackAndLifecycleMutex.RUnlock() fake.updateDomainLabelsByDomainNameMutex.RLock() defer fake.updateDomainLabelsByDomainNameMutex.RUnlock() fake.updateOrganizationLabelsByOrganizationNameMutex.RLock() diff --git a/command/v7/v7fakes/fake_shared_sshactor.go b/command/v7/v7fakes/fake_shared_sshactor.go index 0ddf9c40d68..108786b4f36 100644 --- a/command/v7/v7fakes/fake_shared_sshactor.go +++ b/command/v7/v7fakes/fake_shared_sshactor.go @@ -4,8 +4,8 @@ package v7fakes import ( "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - v7 "code.cloudfoundry.org/cli/command/v7" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + v7 "code.cloudfoundry.org/cli/v8/command/v7" ) type FakeSharedSSHActor struct { @@ -32,15 +32,16 @@ func (fake *FakeSharedSSHActor) ExecuteSecureShell(arg1 sharedaction.SecureShell arg1 sharedaction.SecureShellClient arg2 sharedaction.SSHOptions }{arg1, arg2}) + stub := fake.ExecuteSecureShellStub + fakeReturns := fake.executeSecureShellReturns fake.recordInvocation("ExecuteSecureShell", []interface{}{arg1, arg2}) fake.executeSecureShellMutex.Unlock() - if fake.ExecuteSecureShellStub != nil { - return fake.ExecuteSecureShellStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.executeSecureShellReturns return fakeReturns.result1 } diff --git a/command/v7/v7fakes/fake_v7actor_for_push.go b/command/v7/v7fakes/fake_v7actor_for_push.go index e0005d0483d..5c51cdeeabb 100644 --- a/command/v7/v7fakes/fake_v7actor_for_push.go +++ b/command/v7/v7fakes/fake_v7actor_for_push.go @@ -5,10 +5,10 @@ import ( "context" "sync" - "code.cloudfoundry.org/cli/actor/sharedaction" - "code.cloudfoundry.org/cli/actor/v7action" - v7 "code.cloudfoundry.org/cli/command/v7" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/actor/sharedaction" + "code.cloudfoundry.org/cli/v8/actor/v7action" + v7 "code.cloudfoundry.org/cli/v8/command/v7" + "code.cloudfoundry.org/cli/v8/resources" ) type FakeV7ActorForPush struct { @@ -105,15 +105,16 @@ func (fake *FakeV7ActorForPush) GetApplicationByNameAndSpace(arg1 string, arg2 s arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetApplicationByNameAndSpaceStub + fakeReturns := fake.getApplicationByNameAndSpaceReturns fake.recordInvocation("GetApplicationByNameAndSpace", []interface{}{arg1, arg2}) fake.getApplicationByNameAndSpaceMutex.Unlock() - if fake.GetApplicationByNameAndSpaceStub != nil { - return fake.GetApplicationByNameAndSpaceStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -173,15 +174,16 @@ func (fake *FakeV7ActorForPush) GetDetailedAppSummary(arg1 string, arg2 string, arg2 string arg3 bool }{arg1, arg2, arg3}) + stub := fake.GetDetailedAppSummaryStub + fakeReturns := fake.getDetailedAppSummaryReturns fake.recordInvocation("GetDetailedAppSummary", []interface{}{arg1, arg2, arg3}) fake.getDetailedAppSummaryMutex.Unlock() - if fake.GetDetailedAppSummaryStub != nil { - return fake.GetDetailedAppSummaryStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.getDetailedAppSummaryReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } @@ -241,15 +243,16 @@ func (fake *FakeV7ActorForPush) GetStreamingLogsForApplicationByNameAndSpace(arg arg2 string arg3 sharedaction.LogCacheClient }{arg1, arg2, arg3}) + stub := fake.GetStreamingLogsForApplicationByNameAndSpaceStub + fakeReturns := fake.getStreamingLogsForApplicationByNameAndSpaceReturns fake.recordInvocation("GetStreamingLogsForApplicationByNameAndSpace", []interface{}{arg1, arg2, arg3}) fake.getStreamingLogsForApplicationByNameAndSpaceMutex.Unlock() - if fake.GetStreamingLogsForApplicationByNameAndSpaceStub != nil { - return fake.GetStreamingLogsForApplicationByNameAndSpaceStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2, ret.result3, ret.result4, ret.result5 } - fakeReturns := fake.getStreamingLogsForApplicationByNameAndSpaceReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4, fakeReturns.result5 } @@ -314,15 +317,16 @@ func (fake *FakeV7ActorForPush) RestartApplication(arg1 string, arg2 bool) (v7ac arg1 string arg2 bool }{arg1, arg2}) + stub := fake.RestartApplicationStub + fakeReturns := fake.restartApplicationReturns fake.recordInvocation("RestartApplication", []interface{}{arg1, arg2}) fake.restartApplicationMutex.Unlock() - if fake.RestartApplicationStub != nil { - return fake.RestartApplicationStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.restartApplicationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -383,15 +387,16 @@ func (fake *FakeV7ActorForPush) SetSpaceManifest(arg1 string, arg2 []byte) (v7ac arg1 string arg2 []byte }{arg1, arg2Copy}) + stub := fake.SetSpaceManifestStub + fakeReturns := fake.setSpaceManifestReturns fake.recordInvocation("SetSpaceManifest", []interface{}{arg1, arg2Copy}) fake.setSpaceManifestMutex.Unlock() - if fake.SetSpaceManifestStub != nil { - return fake.SetSpaceManifestStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setSpaceManifestReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/doc/adr/0004-v7-push-refactor.md b/doc/adr/0004-v7-push-refactor.md index 3fd517cc447..29cbe7b69bc 100644 --- a/doc/adr/0004-v7-push-refactor.md +++ b/doc/adr/0004-v7-push-refactor.md @@ -127,11 +127,11 @@ for _, changeAppFunc := range actor.ChangeApplicationSequence(plan) { } ``` -This is quite similar to the loop through `actor.PreparePushPlanSequence` above. We loop through `actor.ChangeApplicationSequence(plan)`, which returns an array of functions, and we call each one with the push plan. Each one returns a push plan that then gets passed in to the next function. +This is quite similar to the loop through `actor.PreparePushPlanSequence` above. We loop through `actor.ChangeApplicationSequence(plan)`, which returns an array of functions, and we call each one with the push plan. Each one returns a push plan that then gets passed into the next function. _Note: The rest of that code uses streams to report progress, errors, and warnings, but this is not the focus of this ADR (and we may end up changing this as well)._ -The **biggest difference** from `Conceputalize` is that instead of being a static list of functions (like `actor.PreparePushPlanSequence`), `actor.ChangeApplicationSequence` is a function that takes in a push plan and returns an array of `ChangeApplicationFunc`s. This allows us to dynamically build up the sequence of actions we run based on the push plan, rather than run the same sequence every time. +The **biggest difference** from `Conceptualize` is that instead of being a static list of functions (like `actor.PreparePushPlanSequence`), `actor.ChangeApplicationSequence` is a function that takes in a push plan and returns an array of `ChangeApplicationFunc`s. This allows us to dynamically build up the sequence of actions we run based on the push plan, rather than run the same sequence every time. Let's look at how that works: diff --git a/doc/adr/0005-v7-push-transforms-manifest-before-applying.md b/doc/adr/0005-v7-push-transforms-manifest-before-applying.md index da5b0728659..35bd334fbb1 100644 --- a/doc/adr/0005-v7-push-transforms-manifest-before-applying.md +++ b/doc/adr/0005-v7-push-transforms-manifest-before-applying.md @@ -49,7 +49,7 @@ Updating app with these attributes... + instances: 3 memory: - stack: cflinuxfs3 + stack: cflinuxfs4 routes: dora.sheer-shark.lite.cli.fun ``` diff --git a/doc/adr/0007-integration-vs-command-test.md b/doc/adr/0007-integration-vs-command-test.md index 620b2589f70..6de1052d9c3 100644 --- a/doc/adr/0007-integration-vs-command-test.md +++ b/doc/adr/0007-integration-vs-command-test.md @@ -38,7 +38,7 @@ output/functionality: > Security group my-group not bound to space my-space for lifecycle phase 'running'. > OK > -> TIP: Changes require an app restart (for running) or restage (for staging) to apply to existing applications. +> TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart (for running) or restage (for staging) to apply to existing applications. > ``` To do so, we would have to make a `BeforeEach()` that creates the scenario @@ -62,7 +62,7 @@ When("the space isn't bound to the security group in any lifecycle", func() { Eventually(session).Should(Say(`Unbinding security group %s from org %s / space %s as %s\.\.\.`, securityGroupName, orgName, spaceName, username)) Eventually(session.Err).Should(Say(`Security group %s not bound to space %s for lifecycle phase 'running'\.`, securityGroupName, spaceName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -121,7 +121,7 @@ When("an error is encountered getting the provided security group", func() { ## Consequences - Since this is not a very big change, we are not expecting to lose any - converage or increase run times. This is mostly for organization + coverage or increase run times. This is mostly for organization purposes. - There are no plans to retrofit existing tests to adhere to this ADR. diff --git a/doc/adr/0012-de-version-v8-code-base.md b/doc/adr/0012-de-version-v8-code-base.md index b27e23f9ab5..a3d725914ff 100644 --- a/doc/adr/0012-de-version-v8-code-base.md +++ b/doc/adr/0012-de-version-v8-code-base.md @@ -22,7 +22,7 @@ After [PR #2180](https://github.com/cloudfoundry/cli/pull/2180) we should be in * integration/v7 => integration/tests * Makefile ivi (integration versioned isolated) command => change to ii (integration isolated) * Makefile integration versioned global (ivg) => see above -* cf/ legacy directory => maybe rename it to something like legacy-cf, and put a README descring +* cf/ legacy directory => maybe rename it to something like legacy-cf, and put a README describing ## Decision diff --git a/doc/v7-plugin-api-changes.md b/doc/v7-plugin-api-changes.md index aa3691de7a1..60a673ee9be 100644 --- a/doc/v7-plugin-api-changes.md +++ b/doc/v7-plugin-api-changes.md @@ -53,7 +53,7 @@ V6 "StagingFailedReason": "", "Stack": { "Guid": "881b268c-d234-4c08-b5c5-50099ccb02bc", - "Name": "cflinuxfs3", + "Name": "cflinuxfs4", "Description": "" }, "Instances": [ @@ -180,7 +180,7 @@ V7 "GUID": "0110f8db-f426-4aad-87d1-4106050cd129", "State": "STAGED", "CreatedAt": "2020-01-14T22:51:13Z", - "Stack": "cflinuxfs3", + "Stack": "cflinuxfs4", "Image": "", "Buildpacks": [ { @@ -439,7 +439,7 @@ V7 { "Name": "some-app", "GUID": "defbb5bb-f010-4e4c-9841-60f641dd5bd4", - "StackName": "cflinuxfs3", + "StackName": "cf4", "State": "STARTED", "LifecycleType": "buildpack", "LifecycleBuildpacks": null, diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000000..09e50bcc7c2 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:latest +RUN apk update && \ + apk add curl && \ + curl --location --silent "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=v8&source=github" | tar -zx -C /usr/local/bin && \ + cf --version diff --git a/fixtures/config/help-plugin-test-config/.cf/plugins/config.json b/fixtures/config/help-plugin-test-config/.cf/plugins/config.json index acd96407dca..d37ebc91b07 100644 --- a/fixtures/config/help-plugin-test-config/.cf/plugins/config.json +++ b/fixtures/config/help-plugin-test-config/.cf/plugins/config.json @@ -1,14 +1,14 @@ { "Plugins": { "Test1":{ - "Location":"../../fixtures/plugins/test_1.exe", + "Location":"../../fixtures/plugins/test_1/test_1.exe", "Commands":[ {"Name":"test1_cmd1","Alias":"test1_cmd1_alias","HelpText":"help text for test1 cmd1"}, {"Name":"test1_cmd2","HelpText":"help text for test1 cmd2"} ] }, "Test2":{ - "Location":"../../fixtures/plugins/test_2.exe", + "Location":"../../fixtures/plugins/test_2/test_2.exe", "Commands":[ {"Name":"test2_cmd1","Alias":"tc1","HelpText":"help text for test2 cmd1"}, {"Name":"test2_cmd2","HelpText":"help text for test2 cmd2"}, diff --git a/fixtures/config/plugin-config/.cf/plugins/config.json b/fixtures/config/plugin-config/.cf/plugins/config.json index b039625b481..b4234c8887c 100644 --- a/fixtures/config/plugin-config/.cf/plugins/config.json +++ b/fixtures/config/plugin-config/.cf/plugins/config.json @@ -1,14 +1,14 @@ { "Plugins": { "Test1":{ - "Location":"../../../fixtures/plugins/test_1.exe", + "Location":"../../../fixtures/plugins/test_1/test_1.exe", "Commands":[ {"Name":"test_1_cmd1","HelpText":"help text for test1 cmd1"}, {"Name":"test_1_cmd2","HelpText":"help text for test1 cmd2"} ] }, "Test2":{ - "Location":"../../../fixtures/plugins/test_2.exe", + "Location":"../../../fixtures/plugins/test_2/test_2.exe", "Commands":[ {"Name":"test_2_cmd1","HelpText":"help text for test2 cmd1"}, {"Name":"test_2_cmd2","HelpText":"help text for test2 cmd2"} diff --git a/fixtures/plugins/alias_conflicts.go b/fixtures/plugins/alias_conflicts/alias_conflicts.go similarity index 94% rename from fixtures/plugins/alias_conflicts.go rename to fixtures/plugins/alias_conflicts/alias_conflicts.go index 3ac44ff67d1..987b96dfeeb 100644 --- a/fixtures/plugins/alias_conflicts.go +++ b/fixtures/plugins/alias_conflicts/alias_conflicts.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type AliasConflicts struct { diff --git a/fixtures/plugins/call_core_cmd.go b/fixtures/plugins/call_core_cmd/call_core_cmd.go similarity index 99% rename from fixtures/plugins/call_core_cmd.go rename to fixtures/plugins/call_core_cmd/call_core_cmd.go index 6027c0c3a3c..ec33b213179 100644 --- a/fixtures/plugins/call_core_cmd.go +++ b/fixtures/plugins/call_core_cmd/call_core_cmd.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type CoreCmd struct{} diff --git a/fixtures/plugins/empty_plugin.go b/fixtures/plugins/empty_plugin/empty_plugin.go similarity index 87% rename from fixtures/plugins/empty_plugin.go rename to fixtures/plugins/empty_plugin/empty_plugin.go index e7d6f971e99..b88dc7e1394 100644 --- a/fixtures/plugins/empty_plugin.go +++ b/fixtures/plugins/empty_plugin/empty_plugin.go @@ -1,6 +1,6 @@ package main -import "code.cloudfoundry.org/cli/plugin" +import "code.cloudfoundry.org/cli/v8/plugin" type EmptyPlugin struct{} diff --git a/fixtures/plugins/input.go b/fixtures/plugins/input/input.go similarity index 94% rename from fixtures/plugins/input.go rename to fixtures/plugins/input/input.go index cefcd4232e5..2dd80586321 100644 --- a/fixtures/plugins/input.go +++ b/fixtures/plugins/input/input.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Input struct { diff --git a/fixtures/plugins/my_say.go b/fixtures/plugins/my_say/my_say.go similarity index 95% rename from fixtures/plugins/my_say.go rename to fixtures/plugins/my_say/my_say.go index 1859ccd4236..066f6cad221 100644 --- a/fixtures/plugins/my_say.go +++ b/fixtures/plugins/my_say/my_say.go @@ -11,7 +11,7 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type MySay struct { diff --git a/fixtures/plugins/panics.go b/fixtures/plugins/panics/panics.go similarity index 95% rename from fixtures/plugins/panics.go rename to fixtures/plugins/panics/panics.go index bb76c2a9c7e..4106d47dd21 100644 --- a/fixtures/plugins/panics.go +++ b/fixtures/plugins/panics/panics.go @@ -10,7 +10,7 @@ package main import ( "os" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Panics struct { diff --git a/fixtures/plugins/test_1.go b/fixtures/plugins/test_1/test_1.go similarity index 98% rename from fixtures/plugins/test_1.go rename to fixtures/plugins/test_1/test_1.go index 3419bc7f91d..d334df78dba 100644 --- a/fixtures/plugins/test_1.go +++ b/fixtures/plugins/test_1/test_1.go @@ -12,7 +12,7 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Test1 struct { @@ -95,7 +95,7 @@ func (c *Test1) GetMetadata() plugin.PluginMetadata { Alias: "test_1_cmd1_alias", HelpText: "help text for test_1_cmd1", UsageDetails: plugin.Usage{ - Usage: "Test plugin command\n cf test_1_cmd1 [-a] [-b] [--no-ouput]", + Usage: "Test plugin command\n cf test_1_cmd1 [-a] [-b] [--no-output]", Options: map[string]string{ "a": "flag to do nothing", "b": "another flag to do nothing", diff --git a/fixtures/plugins/test_2.go b/fixtures/plugins/test_2/test_2.go similarity index 96% rename from fixtures/plugins/test_2.go rename to fixtures/plugins/test_2/test_2.go index 3e8abdd5739..c9b60c705bc 100644 --- a/fixtures/plugins/test_2.go +++ b/fixtures/plugins/test_2/test_2.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Test2 struct{} diff --git a/fixtures/plugins/test_with_help.go b/fixtures/plugins/test_with_help/test_with_help.go similarity index 95% rename from fixtures/plugins/test_with_help.go rename to fixtures/plugins/test_with_help/test_with_help.go index a5479d68764..03224f6bfc3 100644 --- a/fixtures/plugins/test_with_help.go +++ b/fixtures/plugins/test_with_help/test_with_help.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestWithHelp struct { diff --git a/fixtures/plugins/test_with_orgs.go b/fixtures/plugins/test_with_orgs/test_with_orgs.go similarity index 95% rename from fixtures/plugins/test_with_orgs.go rename to fixtures/plugins/test_with_orgs/test_with_orgs.go index 0c34ce337a9..db5a65e0b87 100644 --- a/fixtures/plugins/test_with_orgs.go +++ b/fixtures/plugins/test_with_orgs/test_with_orgs.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestWithOrgs struct { diff --git a/fixtures/plugins/test_with_orgs_short_name.go b/fixtures/plugins/test_with_orgs_short_name/test_with_orgs_short_name.go similarity index 95% rename from fixtures/plugins/test_with_orgs_short_name.go rename to fixtures/plugins/test_with_orgs_short_name/test_with_orgs_short_name.go index 2f083b77928..30647365415 100644 --- a/fixtures/plugins/test_with_orgs_short_name.go +++ b/fixtures/plugins/test_with_orgs_short_name/test_with_orgs_short_name.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestWithOrgsShortName struct { diff --git a/fixtures/plugins/test_with_push.go b/fixtures/plugins/test_with_push/test_with_push.go similarity index 95% rename from fixtures/plugins/test_with_push.go rename to fixtures/plugins/test_with_push/test_with_push.go index b9ab37900a2..2d4afe0fedd 100644 --- a/fixtures/plugins/test_with_push.go +++ b/fixtures/plugins/test_with_push/test_with_push.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestWithPush struct { diff --git a/fixtures/plugins/test_with_push_short_name.go b/fixtures/plugins/test_with_push_short_name/test_with_push_short_name.go similarity index 95% rename from fixtures/plugins/test_with_push_short_name.go rename to fixtures/plugins/test_with_push_short_name/test_with_push_short_name.go index 9466fc94bb4..d538f5853cd 100644 --- a/fixtures/plugins/test_with_push_short_name.go +++ b/fixtures/plugins/test_with_push_short_name/test_with_push_short_name.go @@ -10,7 +10,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestWithPushShortName struct { diff --git a/go.mod b/go.mod index 4733b4ee0d6..b835788515b 100644 --- a/go.mod +++ b/go.mod @@ -1,64 +1,101 @@ -module code.cloudfoundry.org/cli +module code.cloudfoundry.org/cli/v8 -go 1.16 +go 1.25.5 require ( - code.cloudfoundry.org/bytefmt v0.0.0-20170428003108-f4415fafc561 - code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6 + code.cloudfoundry.org/bytefmt v0.62.0 code.cloudfoundry.org/cli-plugin-repo v0.0.0-20200304195157-af98c4be9b85 code.cloudfoundry.org/cli/integration/assets/hydrabroker v0.0.0-20201002233634-81722a1144e4 - code.cloudfoundry.org/clock v1.0.0 - code.cloudfoundry.org/diego-ssh v0.0.0-20170109142818-18cdb3586e7f - code.cloudfoundry.org/go-log-cache v1.0.1-0.20211011162012-ede82a99d3cc - code.cloudfoundry.org/go-loggregator/v8 v8.0.5 + code.cloudfoundry.org/clock v1.59.0 + code.cloudfoundry.org/diego-ssh v0.0.0-20230810200140-af9d79fe9c82 + code.cloudfoundry.org/go-log-cache/v2 v2.0.7 + code.cloudfoundry.org/go-loggregator/v9 v9.2.1 code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f - code.cloudfoundry.org/jsonry v1.1.3 - code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be - code.cloudfoundry.org/tlsconfig v0.0.0-20210615191307-5d92ef3894a7 + code.cloudfoundry.org/jsonry v1.1.4 + code.cloudfoundry.org/lager/v3 v3.59.0 + code.cloudfoundry.org/tlsconfig v0.44.0 code.cloudfoundry.org/ykk v0.0.0-20170424192843-e4df4ce2fd4d - github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2 - github.com/blang/semver v3.5.1+incompatible - github.com/bmatcuk/doublestar v1.3.1 // indirect - github.com/charlievieth/fs v0.0.0-20170613215519-7dc373669fa1 // indirect - github.com/cloudfoundry/bosh-cli v5.5.1+incompatible - github.com/cloudfoundry/bosh-utils v0.0.0-20180315210917-c6a922e299b8 // indirect - github.com/cppforlife/go-patch v0.1.0 // indirect - github.com/cyphar/filepath-securejoin v0.2.1 - github.com/docker/distribution v2.6.0-rc.1.0.20171109224904-e5b5e44386f7+incompatible - github.com/docker/docker v1.4.2-0.20171120205147-9de84a78d76e // indirect - github.com/fatih/color v1.5.1-0.20170926111411-5df930a27be2 - github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 - github.com/jessevdk/go-flags v1.4.1-0.20181221193153-c0795c8afcf4 - github.com/kr/pty v1.1.1 + github.com/blang/semver/v4 v4.0.0 + github.com/cloudfoundry/bosh-cli v6.4.1+incompatible + github.com/creack/pty v1.1.24 + github.com/cyphar/filepath-securejoin v0.6.1 + github.com/distribution/reference v0.6.0 + github.com/fatih/color v1.18.0 + github.com/google/go-querystring v1.2.0 + github.com/google/uuid v1.6.0 + github.com/jessevdk/go-flags v1.6.1 github.com/lunixbochs/vtclean v1.0.0 - github.com/mattn/go-colorable v0.1.0 - github.com/mattn/go-isatty v0.0.3 // indirect - github.com/mattn/go-runewidth v0.0.5-0.20181218000649-703b5e6b11ae - github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2 - github.com/moby/moby v1.4.2-0.20171120205147-9de84a78d76e + github.com/mattn/go-colorable v0.1.14 + github.com/mattn/go-runewidth v0.0.19 + github.com/maxbrunsfeld/counterfeiter/v6 v6.12.1 + github.com/moby/term v0.5.2 github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d - github.com/onsi/ginkgo v1.16.4 - github.com/onsi/gomega v1.13.0 - github.com/opencontainers/go-digest v1.0.0-rc1 // indirect + github.com/onsi/ginkgo/v2 v2.28.1 + github.com/onsi/gomega v1.39.1 github.com/pkg/errors v0.9.1 github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f github.com/sajari/fuzzy v1.0.0 - github.com/sirupsen/logrus v1.2.0 - github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00 // indirect + github.com/sirupsen/logrus v1.9.4 github.com/tedsuo/rata v1.0.1-0.20170830210128-07d200713958 github.com/vito/go-interact v0.0.0-20171111012221-fa338ed9e9ec - golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 - golang.org/x/net v0.0.0-20211013171255-e13a2654a71e - golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect - golang.org/x/text v0.3.7 - golang.org/x/tools v0.1.6-0.20210908190839-cf92b39a962c // indirect - google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4 // indirect - google.golang.org/grpc v1.41.0 // indirect + golang.org/x/crypto v0.47.0 + golang.org/x/net v0.49.0 + golang.org/x/term v0.39.0 + golang.org/x/text v0.33.0 gopkg.in/cheggaaa/pb.v1 v1.0.28 gopkg.in/yaml.v2 v2.4.0 - k8s.io/client-go v0.22.2 + k8s.io/apimachinery v0.35.0 + k8s.io/client-go v0.35.0 ) -replace gopkg.in/fsnotify.v1 v1.4.7 => github.com/fsnotify/fsnotify v1.4.7 +require ( + code.cloudfoundry.org/inigo v0.0.0-20230612153013-b300679e6ed6 // indirect + github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect + github.com/Masterminds/semver/v3 v3.4.0 // indirect + github.com/bmatcuk/doublestar v1.3.4 // indirect + github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 // indirect + github.com/charlievieth/fs v0.0.3 // indirect + github.com/clipperhouse/uax29/v2 v2.2.0 // indirect + github.com/cloudfoundry/bosh-utils v0.0.385 // indirect + github.com/cppforlife/go-patch v0.1.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kr/pty v1.1.8 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/openzipkin/zipkin-go v0.4.3 // indirect + github.com/spf13/pflag v1.0.9 // indirect + github.com/x448/float16 v0.8.4 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/mod v0.32.0 // indirect + golang.org/x/oauth2 v0.30.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/time v0.9.0 // indirect + golang.org/x/tools v0.41.0 // indirect + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect + google.golang.org/grpc v1.63.2 // indirect + google.golang.org/protobuf v1.36.8 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect +) diff --git a/go.sum b/go.sum index 6ee6cbe53b0..463471147a9 100644 --- a/go.sum +++ b/go.sum @@ -1,710 +1,395 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -code.cloudfoundry.org/bytefmt v0.0.0-20170428003108-f4415fafc561 h1:OKYHUwj6pyB9KWBoyy1yPJVWvoYV2N+9QqbvbSw8LjM= -code.cloudfoundry.org/bytefmt v0.0.0-20170428003108-f4415fafc561/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc= -code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6 h1:Yc9r1p21kEpni9WlG4mwOZw87TB2QlyS9sAEebZ3+ak= -code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6/go.mod h1:u5FovqC5GGAEbFPz+IdjycDA+gIjhUwqxnu0vbHwVeM= +code.cloudfoundry.org/bytefmt v0.62.0 h1:MeIv8SfspydaNWVmZZZGFcE2Bs1PKVfjmA0x2/WQtMU= +code.cloudfoundry.org/bytefmt v0.62.0/go.mod h1:cV5MEjJxcDcu4oGNGwb3bJK/H3yx0rXhji++YR2rPBY= code.cloudfoundry.org/cli-plugin-repo v0.0.0-20200304195157-af98c4be9b85 h1:jaHWw9opYjKPrDT19uydBBWSxl+g5F4Hv030fqMsalo= code.cloudfoundry.org/cli-plugin-repo v0.0.0-20200304195157-af98c4be9b85/go.mod h1:R1EiyOAr7lW0l/YkZNqItUNZ01Q/dYUfbTn4X4Z+82M= code.cloudfoundry.org/cli/integration/assets/hydrabroker v0.0.0-20201002233634-81722a1144e4 h1:O+j8afQWaDuxzKGcculsjgHGK+biBTn6iMjgFpBf54c= code.cloudfoundry.org/cli/integration/assets/hydrabroker v0.0.0-20201002233634-81722a1144e4/go.mod h1:dVTgo9kQbYns/QM4A1C2GtxqUnFSvJTk2Qhw+M0/uzk= -code.cloudfoundry.org/clock v1.0.0 h1:kFXWQM4bxYvdBw2X8BbBeXwQNgfoWv1vqAk2ZZyBN2o= -code.cloudfoundry.org/clock v1.0.0/go.mod h1:QD9Lzhd/ux6eNQVUDVRJX/RKTigpewimNYBi7ivZKY8= -code.cloudfoundry.org/diego-ssh v0.0.0-20170109142818-18cdb3586e7f h1:xDSTgaS6b/AkaBqvyEYfu6i1Z+y8JSCHAd/e1HGqyF4= -code.cloudfoundry.org/diego-ssh v0.0.0-20170109142818-18cdb3586e7f/go.mod h1:L2/glHnSK+wKnsG8oZZqdV2sgYY9NDo/I1aDJGhcWaM= -code.cloudfoundry.org/go-diodes v0.0.0-20180905200951-72629b5276e3/go.mod h1:Jzi+ccHgo/V/PLQUaQ6hnZcC1c4BS790gx21LRRui4g= -code.cloudfoundry.org/go-envstruct v1.5.0/go.mod h1:E2S/gzRZpZ51PZnIv7Bo7QvcgH18yio19upkrRk0xLU= -code.cloudfoundry.org/go-log-cache v1.0.1-0.20211011162012-ede82a99d3cc h1:8gj5Z08i9ZvoIGi1A/E2CEQTbvJjogYQgBQUI2/DyNE= -code.cloudfoundry.org/go-log-cache v1.0.1-0.20211011162012-ede82a99d3cc/go.mod h1:8thG6lrstlbeI44hc7QgSnX8eau68+mNt9Pp33/TEcg= -code.cloudfoundry.org/go-loggregator/v8 v8.0.2-0.20200722201844-b5130958b65d/go.mod h1:Or3cWTXwK6d3caPRBTUJv/suT+47jOltB7hYC/3ECCo= -code.cloudfoundry.org/go-loggregator/v8 v8.0.5 h1:p1rrGxTwUqLjlUVtbjTAvKOSGNmPuBja8LeQOQgRrBc= -code.cloudfoundry.org/go-loggregator/v8 v8.0.5/go.mod h1:mLlJ1ZyG6gVvBEtYypvbztRvFeCtBsTxE9tt+85tS6Y= +code.cloudfoundry.org/clock v1.59.0 h1:qH/jamlKJX5ViQSt08td9QFnZiqc+VER2pUXnluj+H8= +code.cloudfoundry.org/clock v1.59.0/go.mod h1:M0p5X+TwhnApXGzFGs/sU8aD31LEHQILD8cgpPPUJSM= +code.cloudfoundry.org/diego-ssh v0.0.0-20230810200140-af9d79fe9c82 h1:Bns1y0jSlcvfP0u8ael+TUlnyNHsNX808zuo58bf5so= +code.cloudfoundry.org/diego-ssh v0.0.0-20230810200140-af9d79fe9c82/go.mod h1:L2/glHnSK+wKnsG8oZZqdV2sgYY9NDo/I1aDJGhcWaM= +code.cloudfoundry.org/go-log-cache/v2 v2.0.7 h1:yR/JjQ/RscO1n4xVAT9HDYcpx5ET/3Cq2/RhpJml6ZU= +code.cloudfoundry.org/go-log-cache/v2 v2.0.7/go.mod h1:6KQe2FeeaqRheD5vCvpyTa80YoJojB/r21E54mT97Mc= +code.cloudfoundry.org/go-loggregator/v9 v9.2.1 h1:S6Lgg5UJbhh2bt2TGQxs6R00CF8PrUA3GFPYDxy56Fk= +code.cloudfoundry.org/go-loggregator/v9 v9.2.1/go.mod h1:FTFFruqGeOhVCDFvyLgl8EV8YW63NNwRzLhxJcporu8= code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f h1:UrKzEwTgeiff9vxdrfdqxibzpWjxLnuXDI5m6z3GJAk= code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f/go.mod h1:sk5LnIjB/nIEU7yP5sDQExVm62wu0pBh3yrElngUisI= -code.cloudfoundry.org/jsonry v1.1.3 h1:pt7JvBaoZEObO9lppoAMjpscsE2uv7OKX9JiB3oNYxE= -code.cloudfoundry.org/jsonry v1.1.3/go.mod h1:IYd9/qJOvdVQk/SEkw3zPKpJp4GNAN+LYjU9eD3pspo= -code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be h1:rnGRgbKlOPKbI9N/PscJ78Ug5Iw+o1kE7aDW01V+0FM= +code.cloudfoundry.org/inigo v0.0.0-20230612153013-b300679e6ed6 h1:lhQNfVleRMX7dsZVZViC0gI9r/rwkO+esz06+HDCSu0= +code.cloudfoundry.org/inigo v0.0.0-20230612153013-b300679e6ed6/go.mod h1:1ZB1JCh2FAp+SqX79ve6dc8YREvbsziULEOncAilX4Q= +code.cloudfoundry.org/jsonry v1.1.4 h1:P9N7IlH1/4aRCLcXLgLFj1hkcBmV7muijJzY+K6U4hE= +code.cloudfoundry.org/jsonry v1.1.4/go.mod h1:6aKilShQP7w/Ez76h1El2/n9y2OkHuU56nKSBB9Gp0A= code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be/go.mod h1:O2sS7gKP3HM2iemG+EnwvyNQK7pTSC6Foi4QiMp9sSk= -code.cloudfoundry.org/rfc5424 v0.0.0-20180905210152-236a6d29298a/go.mod h1:tkZo8GtzBjySJ7USvxm4E36lNQw1D3xM6oKHGqdaAJ4= -code.cloudfoundry.org/tlsconfig v0.0.0-20200131000646-bbe0f8da39b3/go.mod h1:eTbFJpyXRGuFVyg5+oaj9B2eIbIc+0/kZjH8ftbtdew= -code.cloudfoundry.org/tlsconfig v0.0.0-20210615191307-5d92ef3894a7 h1:5N6M1WbWH3bknkX80Q/s7eEo5odqjixLAW79Zrrbqu0= -code.cloudfoundry.org/tlsconfig v0.0.0-20210615191307-5d92ef3894a7/go.mod h1:CKI5CV+3MlfcohVSuU3FxXubFyC52lYJGMLnZ2ltvks= +code.cloudfoundry.org/lager/v3 v3.59.0 h1:3yRkiLLlrEnzODat1JfTqOEsoRcUO77wgz7yDEfbiRI= +code.cloudfoundry.org/lager/v3 v3.59.0/go.mod h1:g05wIHDapO43fHCabGb4h0+4+QlO4tYlDa4xdToxqU4= +code.cloudfoundry.org/tlsconfig v0.44.0 h1:YipP4SR67P6omv7TPOpMXjo42bN/4UR4cyjh7GpDuEw= +code.cloudfoundry.org/tlsconfig v0.44.0/go.mod h1:LGMiYZD1XmqMUkLi58MBkhlmFfQ48MRkhiLi4phAODw= code.cloudfoundry.org/ykk v0.0.0-20170424192843-e4df4ce2fd4d h1:M+zXqtXJqcsmpL76aU0tdl1ho23eYa4axYoM4gD62UA= code.cloudfoundry.org/ykk v0.0.0-20170424192843-e4df4ce2fd4d/go.mod h1:YUJiVOr5xl0N/RjMxM1tHmgSpBbi5UM+KoVR5AoejO0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= -github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.18 h1:90Y4srNYrwOtAgVo3ndrQkTYn6kf1Eg/AjTFJ8Is2aM= -github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= -github.com/Azure/go-autorest/autorest/adal v0.9.13 h1:Mp5hbtOePIzM8pJVRa3YLrWWmZtoxRXqUEzCfJt3+/Q= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= -github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= -github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= -github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2 h1:koK7z0nSsRiRiBWwa+E714Puh+DO+ZRdIyAXiXzL+lg= github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2/go.mod h1:ARgCUhI1MHQH+ONky/PAtmVHQrP5JlGY0F3poXOp/fA= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apoydence/eachers v0.0.0-20181020210610-23942921fe77/go.mod h1:bXvGk6IkT1Agy7qzJ+DjIw/SJ1AaB3AvAuMDVV+Vkoo= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/bmatcuk/doublestar v1.3.1 h1:rT8rxDPsavp9G+4ZULzqhhUSaI/OPsTZNG88Z3i0xvY= -github.com/bmatcuk/doublestar v1.3.1/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/charlievieth/fs v0.0.0-20170613215519-7dc373669fa1 h1:vTlpHKxJqykyKdW9bkrDJNWeKNuSIAJ0TP/K4lRsz/Q= -github.com/charlievieth/fs v0.0.0-20170613215519-7dc373669fa1/go.mod h1:sAoA1zHCH4FJPE2gne5iBiiVG66U7Nyp6JqlOo+FEyg= +github.com/charlievieth/fs v0.0.3 h1:3lZQXTj4PbE81CVPwALSn+JoyCNXkZgORHN6h2XHGlg= +github.com/charlievieth/fs v0.0.3/go.mod h1:hD4sRzto1Hw8zCua76tNVKZxaeZZr1RiKftjAJQRLLo= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudfoundry/bosh-cli v5.5.1+incompatible h1:a4SP5/+ZlnfrMefIhklrw7UkbujwgXPIR0/nfCigI6I= -github.com/cloudfoundry/bosh-cli v5.5.1+incompatible/go.mod h1:rzIB+e1sn7wQL/TJ54bl/FemPKRhXby5BIMS3tLuWFM= -github.com/cloudfoundry/bosh-utils v0.0.0-20180315210917-c6a922e299b8 h1:x6vZOZ7rlvGro4GKDg0DaQz2za8Q6GjhVoB7vH6BZ2I= -github.com/cloudfoundry/bosh-utils v0.0.0-20180315210917-c6a922e299b8/go.mod h1:JCrKwetZGjxbfq1U139TZuXDBfdGLtjOEAfxMWKV/QM= -github.com/cloudfoundry/dropsonde v1.0.0/go.mod h1:6zwvrWK5TpxBVYi1cdkE5WDsIO8E0n7qAJg3wR9B67c= -github.com/cloudfoundry/gosteno v0.0.0-20150423193413-0c8581caea35/go.mod h1:3YBPUR85RIrvaUTdA1dL38YSp6s3OHu1xrWLkGt2Mog= -github.com/cloudfoundry/loggregatorlib v0.0.0-20170823162133-36eddf15ef12/go.mod h1:ucj7+svyACshmxV3Zze2NAcEcdbBf9scZYR+QKCX9/w= -github.com/cloudfoundry/sonde-go v0.0.0-20171206171820-b33733203bb4/go.mod h1:GS0pCHd7onIsewbw8Ue9qa9pZPv2V88cUZDttK6KzgI= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY= +github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= +github.com/cloudfoundry/bosh-cli v6.4.1+incompatible h1:n5/+NIF9QxvGINOrjh6DmO+GTen78MoCj5+LU9L8bR4= +github.com/cloudfoundry/bosh-cli v6.4.1+incompatible/go.mod h1:rzIB+e1sn7wQL/TJ54bl/FemPKRhXby5BIMS3tLuWFM= +github.com/cloudfoundry/bosh-utils v0.0.385 h1:rOgL4fKxeLNUAYoHSfycRro29ns9bhsEyBJ8DQ5W4Rc= +github.com/cloudfoundry/bosh-utils v0.0.385/go.mod h1:vYjxd5zpxGjBKC+8voohfdXZkVk0UMOOvlMlZfxyOLM= github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0= github.com/cppforlife/go-patch v0.1.0 h1:I0fT+gFTSW4xWwvaTaUUVjr9xxjNXJ4naGc01BeQjwY= github.com/cppforlife/go-patch v0.1.0/go.mod h1:67a7aIi94FHDZdoeGSJRRFDp66l9MhaAG1yGxpUoFD8= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyphar/filepath-securejoin v0.2.1 h1:5DPkzz/0MwUpvR4fxASKzgApeq2OMFY5FfYtrX28Coo= -github.com/cyphar/filepath-securejoin v0.2.1/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= +github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE= +github.com/cyphar/filepath-securejoin v0.6.1/go.mod h1:A8hd4EnAeyujCJRrICiOWqjS1AX0a9kM5XL+NwKoYSc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/distribution v2.6.0-rc.1.0.20171109224904-e5b5e44386f7+incompatible h1:AJ5ylGRVLdpWcAw14qENVOr/M8/s7vApzMorVhyVL78= -github.com/docker/distribution v2.6.0-rc.1.0.20171109224904-e5b5e44386f7+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v1.4.2-0.20171120205147-9de84a78d76e h1:M+/1NNHE/mg+RUox/04+rZoahJVklPfs6xZFECVnxso= -github.com/docker/docker v1.4.2-0.20171120205147-9de84a78d76e/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/drewolson/testflight v1.0.0/go.mod h1:t9oKuuEohRGLb80SWX+uxJHuhX98B7HnojqtW+Ryq30= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fatih/color v1.5.1-0.20170926111411-5df930a27be2 h1:lSx4zNYRd54K1yU6E/Uak9R4GqTMt7L44QU8aT1W3Go= -github.com/fatih/color v1.5.1-0.20170926111411-5df930a27be2/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU= +github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= -github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= +github.com/gkampitakis/ciinfo v0.3.2/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= +github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= +github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= +github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE= +github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= +github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc= +github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= -github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0 h1:rgxjzoDmDXw5q8HONgyHhBas4to0/XWRo/gPpJhsUNQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0/go.mod h1:qrJPVzv9YlhsrxJc3P/Q85nr0w1lIRikTl4JlhdDH5w= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jessevdk/go-flags v0.0.0-20170926144705-f88afde2fa19/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.1-0.20181221193153-c0795c8afcf4 h1:xKkUL6QBojwguhKKetf1SocCAKqc6W7S/mGm9xEGllo= -github.com/jessevdk/go-flags v1.4.1-0.20181221193153-c0795c8afcf4/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/joefitzgerald/rainbow-reporter v0.1.0 h1:AuMG652zjdzI0YCCnXAqATtRBpGXMcAnrajcaTrSeuo= +github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4= +github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= +github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3/go.mod h1:Bvhd+E3laJ0AVkG0c9rmtZcnhV0HQ3+c3YxxqTvc/gA= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.0.0-20160504234017-7cafcd837844/go.mod h1:sjUstKUATFIcff4qlB53Kml0wQPtJVc/3fWrmuUmcfA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/loggregator/go-bindata v0.0.0-20190422223605-5f11cfb2d7d9/go.mod h1:PvsJfK9t/8OdGvSanpYlwJ1EPoJ/hwT3c52txAzqooY= github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.1.0 h1:v2XXALHHh6zHfYTJ+cSkwtyffnaOyR1MXaA91mTrb8o= -github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-runewidth v0.0.5-0.20181218000649-703b5e6b11ae h1:575usOHCDzxtuyWeSjPySew7uvoOuaCsM0uUesjgAo4= -github.com/mattn/go-runewidth v0.0.5-0.20181218000649-703b5e6b11ae/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2 h1:g+4J5sZg6osfvEfkRZxJ1em0VT95/UOZgi/l7zi1/oE= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= +github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/moby/moby v1.4.2-0.20171120205147-9de84a78d76e h1:6+Fs/ljqCOuJ4Ie4VUB/wQ/9oSpk2YvtSR5Clf13puk= -github.com/moby/moby v1.4.2-0.20171120205147-9de84a78d76e/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= +github.com/maxbrunsfeld/counterfeiter/v6 v6.12.1 h1:D4O2wLxB384TS3ohBJMfolnxb4qGmoZ1PnWNtit8LYo= +github.com/maxbrunsfeld/counterfeiter/v6 v6.12.1/go.mod h1:RuJdxo0oI6dClIaMzdl3hewq3a065RH65dofJP03h8I= +github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= +github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= +github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= +github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20171031171758-652e15c9a27e/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= -github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= +github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= +github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= github.com/onsi/gomega v0.0.0-20171105031654-1eecca0ba8e6/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= -github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= -github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= -github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= +github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= +github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg= +github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c= github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pivotal-cf/brokerapi/v7 v7.2.0/go.mod h1:5QRQ8vJmav91F+AvY5NA/QoDOq70XgBVxXKUK4N/cNE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/poy/eachers v0.0.0-20181020210610-23942921fe77/go.mod h1:x1vqpbcMW9T/KRcQ4b48diSiSVtYgvwQ5xzDByEg4WE= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f h1:FQZgA673tRGrrXIP/OPMO69g81ow4XsKlN/DLH8pSic= github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f/go.mod h1:b18R55ulyQ/h3RaWyloPyER7fWQVZvimKKhnI5OfrJQ= github.com/sajari/fuzzy v1.0.0 h1:+FmwVvJErsd0d0hAPlj4CxqxUtQY/fOoY0DwX4ykpRY= github.com/sajari/fuzzy v1.0.0/go.mod h1:OjYR6KxoWOe9+dOlXeiCJd4dIbED4Oo8wpS89o0pwOo= -github.com/sclevine/spec v1.2.0 h1:1Jwdf9jSfDl9NVmt8ndHqbTZ7XCCPbh1jI3hkDBHVYA= github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= -github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/square/certstrap v1.2.0 h1:ecgyABrbFLr8jSbOC6oTBmBek0t/HqtgrMUZCPuyfdw= -github.com/square/certstrap v1.2.0/go.mod h1:CUHqV+fxJW0Y5UQFnnbYwQ7bpKXO1AKbic9g73799yw= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= +github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= +github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= +github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/square/certstrap v1.3.0 h1:N9P0ZRA+DjT8pq5fGDj0z3FjafRKnBDypP0QHpMlaAk= +github.com/square/certstrap v1.3.0/go.mod h1:wGZo9eE1B7WX2GKBn0htJ+B3OuRl2UsdCFySNooy9hU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00 h1:mujcChM89zOHwgZBBNr5WZ77mBXP1yR+gLThGCYZgAg= -github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tedsuo/ifrit v0.0.0-20230516164442-7862c310ad26 h1:mWCRvpoEMVlslxEvvptKgIUb35va9yj9Oq5wGw/er5I= +github.com/tedsuo/ifrit v0.0.0-20230516164442-7862c310ad26/go.mod h1:0uD3VMXkZ7Bw0ojGCwDzebBBzPBXtzEZeXai+56BLX4= github.com/tedsuo/rata v1.0.1-0.20170830210128-07d200713958 h1:mueRRuRjR35dEOkHdhpoRcruNgBz0ohG659HxxmcAwA= github.com/tedsuo/rata v1.0.1-0.20170830210128-07d200713958/go.mod h1:X47ELzhOoLbfFIY0Cql9P6yo3Cdwf2CMX3FVZxRzJPc= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= +github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/unrolled/secure v0.0.0-20180416205222-a1cf62cc2159/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA= -github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ= github.com/vito/go-interact v0.0.0-20171111012221-fa338ed9e9ec h1:Klu98tQ9Z1t23gvC7p7sCmvxkZxLhBHLNyrUPsWsYFg= github.com/vito/go-interact v0.0.0-20171111012221-fa338ed9e9ec/go.mod h1:wPlfmglZmRWMYv/qJy3P+fK/UnoQB5ISk4txfNd9tDo= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.step.sm/crypto v0.76.0 h1:K23BSaeoiY7Y5dvvijTeYC9EduDBetNwQYMBwMhi1aA= +go.step.sm/crypto v0.76.0/go.mod h1:PXYJdKkK8s+GHLwLguFaLxHNAFsFL3tL1vSBrYfey5k= +go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= +go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= +golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180418062111-d41e8174641f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211013171255-e13a2654a71e h1:Xj+JO91noE97IN6F/7WZxzC5QE6yENAQPrwIYhW3bsA= -golang.org/x/net v0.0.0-20211013171255-e13a2654a71e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f h1:Qmd2pbz05z7z6lm0DrgQVVPuBm92jqujBKMHMOlOQEw= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180419222023-a2a45943ae67/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8= -golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= -golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY= +golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200609164405-eb789aa7ce50/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.6-0.20210908190839-cf92b39a962c h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY= -golang.org/x/tools v0.1.6-0.20210908190839-cf92b39a962c/go.mod h1:YD9qOF0M9xpSpdWTBbzEl5e/RnCefISl8E5Noe10jFM= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc= +golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4 h1:NBxB1XxiWpGqkPUiJ9PoBXkHV5A9+GohMOA+EmWoPbU= -google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E= -google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= +gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= @@ -712,43 +397,31 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.0.0-20171116090243-287cf08546ab/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.2.0-0.dev/go.mod h1:XtegFAyX/PfluP4921rXU5IkjkqBCDnUq4W8VCIoKvM= -k8s.io/api v0.22.2 h1:M8ZzAD0V6725Fjg53fKeTJxGsJvRbk4TEm/fexHMtfw= -k8s.io/api v0.22.2/go.mod h1:y3ydYpLJAaDI+BbSe2xmGcqxiWHmWjkEeIbiwHvnPR8= -k8s.io/apimachinery v0.22.2 h1:ejz6y/zNma8clPVfNDLnPbleBo6MpoFy/HBiBqCouVk= -k8s.io/apimachinery v0.22.2/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= -k8s.io/client-go v0.22.2 h1:DaSQgs02aCC1QcwUdkKZWOeaVsQjYvWv8ZazcZ6JcHc= -k8s.io/client-go v0.22.2/go.mod h1:sAlhrkVDf50ZHx6z4K0S40wISNTarf1r800F+RlCF6U= -k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.9.0 h1:D7HV+n1V57XeZ0m6tdRkfknthUaM06VFbWldOFh8kzM= -k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a h1:8dYfu/Fc9Gz2rNJKB9IQRGgQOh2clmRzNIPPY1xLY5g= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +honnef.co/go/tools v0.4.0-0.dev/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70= +k8s.io/api v0.35.0 h1:iBAU5LTyBI9vw3L5glmat1njFK34srdLmktWwLTprlY= +k8s.io/api v0.35.0/go.mod h1:AQ0SNTzm4ZAczM03QH42c7l3bih1TbAXYo0DkF8ktnA= +k8s.io/apimachinery v0.35.0 h1:Z2L3IHvPVv/MJ7xRxHEtk6GoJElaAqDCCU0S6ncYok8= +k8s.io/apimachinery v0.35.0/go.mod h1:jQCgFZFR1F4Ik7hvr2g84RTJSZegBc8yHgFWKn//hns= +k8s.io/client-go v0.35.0 h1:IAW0ifFbfQQwQmga0UdoH0yvdqrbwMdq9vIFEhRpxBE= +k8s.io/client-go v0.35.0/go.mod h1:q2E5AAyqcbeLGPdoRB+Nxe3KYTfPce1Dnu1myQdqz9o= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/i18n/resources/README.md b/i18n/resources/README.md index e2cfa233ddd..5c4b3d28db9 100644 --- a/i18n/resources/README.md +++ b/i18n/resources/README.md @@ -3,6 +3,6 @@ This directory will get populated by the pipeline during the `build-binaries` jo ## How this file was generated ``` -$ cd code.cloudfoundry.org/cli/i18n +$ cd code.cloudfoundry.org/cli/v8/i18n $ go-bindata -nometadata -pkg resources -ignore ".go" -o resources/i18n_resources.go resources/*.all.json ``` diff --git a/i18n/resources/i18n_resources.go b/i18n/resources/i18n_resources.go index 3ba2b2f077a..0abbe9999de 100644 --- a/i18n/resources/i18n_resources.go +++ b/i18n/resources/i18n_resources.go @@ -281,8 +281,8 @@ func resourcesZhHantAllJson() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) @@ -307,8 +307,8 @@ func MustAsset(name string) []byte { // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) @@ -345,11 +345,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error @@ -357,8 +359,8 @@ var _bindata = map[string]func() (*asset, error){ func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - cannonicalName := strings.Replace(name, "\\", "/", -1) - pathList := strings.Split(cannonicalName, "/") + canonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(canonicalName, "/") for _, p := range pathList { node = node.Children[p] if node == nil { @@ -439,6 +441,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - cannonicalName := strings.Replace(name, "\\", "/", -1) - return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) + canonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) } diff --git a/integration/README.md b/integration/README.md index de326244cb7..03ed2bfed39 100644 --- a/integration/README.md +++ b/integration/README.md @@ -7,8 +7,8 @@ These are high-level tests for the CLI that make assertions about the behavior o On most systems `cf` points to an installed version. To test the latest source (most likely source that you're changing), ensure the dev `cf` binary is in your `PATH`: ``` -[[ `which cf` = *"$GOPATH/src/code.cloudfoundry.org/cli/out"* ]] || - export PATH="$GOPATH/src/code.cloudfoundry.org/cli/out:$PATH" +[[ `which cf` = *"$GOPATH/src/code.cloudfoundry.org/cli/v8/out"* ]] || + export PATH="$GOPATH/src/code.cloudfoundry.org/cli/v8/out:$PATH" ``` You'll also need to rebuild `cf` after making any relevant changes to the source: diff --git a/integration/assets/configurable_plugin/test_plugin.go b/integration/assets/configurable_plugin/test_plugin.go index 77fc49691de..6d63413259c 100644 --- a/integration/assets/configurable_plugin/test_plugin.go +++ b/integration/assets/configurable_plugin/test_plugin.go @@ -5,8 +5,8 @@ import ( "os" "strings" - "code.cloudfoundry.org/cli/plugin" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/plugin" + "github.com/blang/semver/v4" ) var ( diff --git a/integration/assets/configurable_plugin_fails_uninstall/test_plugin_fails_uninstall.go b/integration/assets/configurable_plugin_fails_uninstall/test_plugin_fails_uninstall.go index 43c68d3adb1..0f83415ab17 100644 --- a/integration/assets/configurable_plugin_fails_uninstall/test_plugin_fails_uninstall.go +++ b/integration/assets/configurable_plugin_fails_uninstall/test_plugin_fails_uninstall.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "code.cloudfoundry.org/cli/plugin" - "github.com/blang/semver" + "code.cloudfoundry.org/cli/v8/plugin" + "github.com/blang/semver/v4" ) var ( diff --git a/integration/assets/go_calls_ruby/Gemfile.lock b/integration/assets/go_calls_ruby/Gemfile.lock index f1d8dee14cd..a3fc3337da0 100644 --- a/integration/assets/go_calls_ruby/Gemfile.lock +++ b/integration/assets/go_calls_ruby/Gemfile.lock @@ -8,4 +8,4 @@ PLATFORMS DEPENDENCIES BUNDLED WITH - 1.14.6 + 2.5.20 diff --git a/integration/assets/go_calls_ruby/Godeps/Godeps.json b/integration/assets/go_calls_ruby/Godeps/Godeps.json deleted file mode 100644 index bc04af789ec..00000000000 --- a/integration/assets/go_calls_ruby/Godeps/Godeps.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "ImportPath": "github.com/cloudfoundry/cf-acceptance-tests/assets/go_calls_ruby", - "GoVersion": "go1.*", - "GodepVersion": "v79", - "Deps": [] -} diff --git a/integration/assets/go_calls_ruby/Godeps/Readme b/integration/assets/go_calls_ruby/Godeps/Readme deleted file mode 100644 index 4cdaa53d56d..00000000000 --- a/integration/assets/go_calls_ruby/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/integration/assets/go_calls_ruby/Procfile b/integration/assets/go_calls_ruby/Procfile deleted file mode 100644 index c28efa217c5..00000000000 --- a/integration/assets/go_calls_ruby/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -web: ruby -run -e httpd . -p $PORT -console: bundle exec irb -rake: bundle exec rake diff --git a/integration/assets/go_calls_ruby/go.mod b/integration/assets/go_calls_ruby/go.mod new file mode 100644 index 00000000000..0e0fa2afb1b --- /dev/null +++ b/integration/assets/go_calls_ruby/go.mod @@ -0,0 +1,5 @@ +module github.com/cloudfoundry/cf-acceptance-tests/assets/go_calls_ruby + +go 1.23 + +toolchain go1.23.7 diff --git a/integration/assets/go_calls_ruby/site.go b/integration/assets/go_calls_ruby/site.go index 628ef302640..63cac9c15d4 100644 --- a/integration/assets/go_calls_ruby/site.go +++ b/integration/assets/go_calls_ruby/site.go @@ -11,7 +11,12 @@ import ( func main() { http.HandleFunc("/", hello) fmt.Println("listening...") - err := http.ListenAndServe(":"+os.Getenv("PORT"), nil) + + server := &http.Server{ + Addr: fmt.Sprintf(":%s", os.Getenv("PORT")), + Handler: nil, + } + err := server.ListenAndServe() if err != nil { panic(err) } @@ -20,7 +25,6 @@ func main() { func hello(res http.ResponseWriter, req *http.Request) { bundlerVersion, err := exec.Command("bundle", "--version").Output() if err != nil { - res.WriteHeader(http.StatusInternalServerError) log.Print("ERROR:", err) fmt.Fprintf(res, "ERROR: %v\n", err) } else { diff --git a/integration/assets/hydrabroker/database/database_suite_test.go b/integration/assets/hydrabroker/database/database_suite_test.go index 6b7d74ae096..1684cdaa541 100644 --- a/integration/assets/hydrabroker/database/database_suite_test.go +++ b/integration/assets/hydrabroker/database/database_suite_test.go @@ -3,7 +3,7 @@ package database_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/assets/hydrabroker/database/database_test.go b/integration/assets/hydrabroker/database/database_test.go index 00faebd56e2..bdec5be2605 100644 --- a/integration/assets/hydrabroker/database/database_test.go +++ b/integration/assets/hydrabroker/database/database_test.go @@ -5,7 +5,7 @@ import ( "sync" . "code.cloudfoundry.org/cli/integration/assets/hydrabroker/database" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/assets/hydrabroker/go.mod b/integration/assets/hydrabroker/go.mod index 07eeb84c388..25fa97597ef 100644 --- a/integration/assets/hydrabroker/go.mod +++ b/integration/assets/hydrabroker/go.mod @@ -1,12 +1,35 @@ module code.cloudfoundry.org/cli/integration/assets/hydrabroker -go 1.13 +go 1.25 + +toolchain go1.25.4 require ( - github.com/go-playground/validator/v10 v10.2.0 - github.com/gorilla/mux v1.7.4 + github.com/go-playground/validator/v10 v10.8.0 + github.com/gorilla/mux v1.8.0 github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d - github.com/onsi/ginkgo v1.14.2 - github.com/onsi/gomega v1.10.3 + github.com/onsi/ginkgo/v2 v2.27.2 + github.com/onsi/gomega v1.38.2 github.com/pivotal-cf/brokerapi/v7 v7.2.0 ) + +require ( + code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be // indirect + github.com/Masterminds/semver/v3 v3.4.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-playground/locales v0.13.0 // indirect + github.com/go-playground/universal-translator v0.17.0 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/pkg/errors v0.9.1 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/crypto v0.45.0 // indirect + golang.org/x/mod v0.29.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/tools v0.38.0 // indirect +) diff --git a/integration/assets/hydrabroker/go.sum b/integration/assets/hydrabroker/go.sum index 46fe43d0297..5b676254c33 100644 --- a/integration/assets/hydrabroker/go.sum +++ b/integration/assets/hydrabroker/go.sum @@ -1,80 +1,81 @@ code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be h1:rnGRgbKlOPKbI9N/PscJ78Ug5Iw+o1kE7aDW01V+0FM= code.cloudfoundry.org/lager v1.1.1-0.20191008172124-a9afc05ee5be/go.mod h1:O2sS7gKP3HM2iemG+EnwvyNQK7pTSC6Foi4QiMp9sSk= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/drewolson/testflight v1.0.0 h1:jgA0pHcFIPnXoBmyFzrdoR2ka4UvReMDsjYc7Jcvl80= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/drewolson/testflight v1.0.0/go.mod h1:t9oKuuEohRGLb80SWX+uxJHuhX98B7HnojqtW+Ryq30= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= +github.com/gkampitakis/ciinfo v0.3.2/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= +github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= +github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= +github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE= +github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k= +github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= -github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= +github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= +github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3/go.mod h1:Bvhd+E3laJ0AVkG0c9rmtZcnhV0HQ3+c3YxxqTvc/gA= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.0.0-20160504234017-7cafcd837844/go.mod h1:sjUstKUATFIcff4qlB53Kml0wQPtJVc/3fWrmuUmcfA= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= +github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY= +github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= +github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= -github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns= +github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34= github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= -github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= +github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A= +github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k= github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 h1:zNBQb37RGLmJybyMcs983HfUfpkw9OTFD9tbBfAViHE= github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pivotal-cf/brokerapi/v7 v7.2.0 h1:LL/OS3H2p+K30YG1ppB7Fr1YFQ669My00icLkxYqdwU= @@ -84,58 +85,68 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= +github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= +golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 h1:wBouT66WTYFXdxfVdz9sVWARVd/2vfGcmI45D2gj45M= -golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db h1:9hRk1xeL9LTT3yX/941DqeBz87XgHAQuj+TbimYJuiw= golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= +golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A= +google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -146,9 +157,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/integration/assets/hydrabroker/integrationtest/integrationtest_suite_test.go b/integration/assets/hydrabroker/integrationtest/integrationtest_suite_test.go index 4d20e0df1ca..ee9ae0bf350 100644 --- a/integration/assets/hydrabroker/integrationtest/integrationtest_suite_test.go +++ b/integration/assets/hydrabroker/integrationtest/integrationtest_suite_test.go @@ -3,7 +3,7 @@ package integrationtest_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/assets/hydrabroker/integrationtest/integrationtest_test.go b/integration/assets/hydrabroker/integrationtest/integrationtest_test.go index 5653454e801..a71bbbcc8a8 100644 --- a/integration/assets/hydrabroker/integrationtest/integrationtest_test.go +++ b/integration/assets/hydrabroker/integrationtest/integrationtest_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "net/url" @@ -16,7 +15,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" uuid2 "github.com/nu7hatch/gouuid" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" "github.com/pivotal-cf/brokerapi/v7/domain/apiresponses" @@ -57,7 +56,7 @@ var _ = Describe("Integration Test For Hydrabroker", func() { Expect(err).NotTo(HaveOccurred()) expectStatusCode(response, http.StatusBadRequest) - b, err := ioutil.ReadAll(response.Body) + b, err := io.ReadAll(response.Body) Expect(err).NotTo(HaveOccurred()) Expect(string(b)).To(ContainSubstring("Error:Field validation for 'Username' failed on the 'min' tag")) }) @@ -617,7 +616,7 @@ var _ = Describe("Integration Test For Hydrabroker", func() { func expectStatusCode(response *http.Response, statusCode int) { ExpectWithOffset(1, response.StatusCode).To(Equal(statusCode), func() string { - b, err := ioutil.ReadAll(response.Body) + b, err := io.ReadAll(response.Body) if err == nil { response.Body.Close() return "Body: " + string(b) @@ -670,7 +669,7 @@ func toJSON(input interface{}) io.Reader { } func fromJSON(input io.ReadCloser, output interface{}) { - b, err := ioutil.ReadAll(input) + b, err := io.ReadAll(input) Expect(err).NotTo(HaveOccurred()) err = input.Close() diff --git a/integration/assets/hydrabroker/store/bindings_test.go b/integration/assets/hydrabroker/store/bindings_test.go index e610eca98d9..fcc02d5ea51 100644 --- a/integration/assets/hydrabroker/store/bindings_test.go +++ b/integration/assets/hydrabroker/store/bindings_test.go @@ -7,7 +7,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" uuid "github.com/nu7hatch/gouuid" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/assets/hydrabroker/store/brokers_test.go b/integration/assets/hydrabroker/store/brokers_test.go index e57d35fac14..3f3e9fd2dbd 100644 --- a/integration/assets/hydrabroker/store/brokers_test.go +++ b/integration/assets/hydrabroker/store/brokers_test.go @@ -2,7 +2,7 @@ package store_test import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" diff --git a/integration/assets/hydrabroker/store/instances_test.go b/integration/assets/hydrabroker/store/instances_test.go index ff285be0526..f6ea556dca4 100644 --- a/integration/assets/hydrabroker/store/instances_test.go +++ b/integration/assets/hydrabroker/store/instances_test.go @@ -6,7 +6,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" uuid "github.com/nu7hatch/gouuid" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" diff --git a/integration/assets/hydrabroker/store/store_suite_test.go b/integration/assets/hydrabroker/store/store_suite_test.go index aa685e16a72..e79bb60932b 100644 --- a/integration/assets/hydrabroker/store/store_suite_test.go +++ b/integration/assets/hydrabroker/store/store_suite_test.go @@ -3,7 +3,7 @@ package store_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/assets/js-hello/index.js b/integration/assets/js-hello/index.js new file mode 100644 index 00000000000..ed10e718435 --- /dev/null +++ b/integration/assets/js-hello/index.js @@ -0,0 +1,12 @@ +const http = require('http'); + +const server = http.createServer((_req, res) => { + res.statusCode = 200; + res.setHeader('Content-Type', 'text/plain'); + res.end('Hello World\n'); +}); + +const port = process.env.PORT; +server.listen(port, "0.0.0.0", () => { + console.log(`Server running at http://0.0.0.0:${port}/`); +}); diff --git a/integration/assets/js-hello/package.json b/integration/assets/js-hello/package.json new file mode 100644 index 00000000000..5d4ef7f9cff --- /dev/null +++ b/integration/assets/js-hello/package.json @@ -0,0 +1,8 @@ +{ + "name": "js-hello", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "start": "node ./index.js" + } +} diff --git a/integration/assets/test_plugin/test_plugin.go b/integration/assets/test_plugin/test_plugin.go index e6182cf10e2..020c297c3fe 100644 --- a/integration/assets/test_plugin/test_plugin.go +++ b/integration/assets/test_plugin/test_plugin.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Test1 struct { diff --git a/integration/assets/test_plugin_fails_metadata/test_plugin.go b/integration/assets/test_plugin_fails_metadata/test_plugin.go index 14ea6c61ee6..167dff3307a 100644 --- a/integration/assets/test_plugin_fails_metadata/test_plugin.go +++ b/integration/assets/test_plugin_fails_metadata/test_plugin.go @@ -3,7 +3,7 @@ package main import ( "os" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestPluginFailsMetadata struct{} diff --git a/integration/assets/test_plugin_with_command_overrides/test_plugin.go b/integration/assets/test_plugin_with_command_overrides/test_plugin.go index a3c20408b5c..e880019c31e 100644 --- a/integration/assets/test_plugin_with_command_overrides/test_plugin.go +++ b/integration/assets/test_plugin_with_command_overrides/test_plugin.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type TestPluginWithCommandOverrides struct { diff --git a/integration/assets/test_plugin_with_panic/test_plugin.go b/integration/assets/test_plugin_with_panic/test_plugin.go index c8e96c48ca4..9eff20dc996 100644 --- a/integration/assets/test_plugin_with_panic/test_plugin.go +++ b/integration/assets/test_plugin_with_panic/test_plugin.go @@ -1,6 +1,6 @@ package main -import "code.cloudfoundry.org/cli/plugin" +import "code.cloudfoundry.org/cli/v8/plugin" type TestPluginWithPanic struct { } diff --git a/integration/helpers/app.go b/integration/helpers/app.go index df93f60ac7e..8fd54dc3eaf 100644 --- a/integration/helpers/app.go +++ b/integration/helpers/app.go @@ -4,7 +4,6 @@ import ( "archive/zip" "fmt" "io" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -40,10 +39,10 @@ func WithHelloWorldApp(f func(dir string)) { defer os.RemoveAll(dir) tempfile := filepath.Join(dir, "index.html") - err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666) + err := os.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) + err = os.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) f(dir) @@ -57,18 +56,18 @@ func WithMultiEndpointApp(f func(dir string)) { defer os.RemoveAll(dir) tempfile := filepath.Join(dir, "index.html") - err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666) + err := os.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666) Expect(err).ToNot(HaveOccurred()) tempfile = filepath.Join(dir, "other_endpoint.html") - err = ioutil.WriteFile(tempfile, []byte("other endpoint"), 0666) + err = os.WriteFile(tempfile, []byte("other endpoint"), 0666) Expect(err).ToNot(HaveOccurred()) tempfile = filepath.Join(dir, "third_endpoint.html") - err = ioutil.WriteFile(tempfile, []byte("third endpoint"), 0666) + err = os.WriteFile(tempfile, []byte("third endpoint"), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) + err = os.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) f(dir) @@ -76,7 +75,7 @@ func WithMultiEndpointApp(f func(dir string)) { func WithSidecarApp(f func(dir string), appName string) { withSidecarManifest := func(dir string) { - err := ioutil.WriteFile(filepath.Join(dir, "manifest.yml"), []byte(fmt.Sprintf(`--- + err := os.WriteFile(filepath.Join(dir, "manifest.yml"), []byte(fmt.Sprintf(`--- applications: - name: %s sidecars: @@ -94,7 +93,7 @@ applications: func WithTaskApp(f func(dir string), appName string) { withTaskManifest := func(dir string) { - err := ioutil.WriteFile(filepath.Join(dir, "manifest.yml"), []byte(fmt.Sprintf(`--- + err := os.WriteFile(filepath.Join(dir, "manifest.yml"), []byte(fmt.Sprintf(`--- applications: - name: %s processes: @@ -119,7 +118,7 @@ func WithNoResourceMatchedApp(f func(dir string)) { tempfile := filepath.Join(dir, "index.html") - err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s", strings.Repeat("a", 65*1024))), 0666) + err := os.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s", strings.Repeat("a", 65*1024))), 0666) Expect(err).ToNot(HaveOccurred()) f(dir) @@ -130,40 +129,56 @@ func WithMultiBuildpackApp(f func(dir string)) { f("../../assets/go_calls_ruby") } +// WithJSHelloWorld creates a simple JS Hello World HTTP application to use with the CF push command. +func WithJSHelloWorld(f func(dir string)) { + f("../../assets/js-hello") +} + // WithProcfileApp creates an application to use with your CLI command // that contains Procfile defining web and worker processes. func WithProcfileApp(f func(dir string)) { dir := TempDirAbsolutePath("", "simple-ruby-app") defer os.RemoveAll(dir) - err := ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- + err := os.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: ruby -run -e httpd . -p $PORT console: bundle exec irb`, ), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), []byte(`source 'http://rubygems.org' -gem 'irb'`, + //TODO: Remove the ruby version once bundler issue(https://github.com/rubygems/rubygems/issues/6280) + // is solved + err = os.WriteFile(filepath.Join(dir, "Gemfile"), []byte(`source 'http://rubygems.org' +ruby '~> 3.0' +gem 'irb' +gem 'webrick'`, ), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(`GEM + err = os.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` +GEM remote: http://rubygems.org/ specs: - io-console (0.5.6) - irb (1.2.4) - reline (>= 0.0.1) - reline (0.1.4) + io-console (0.6.0) + irb (1.6.4) + reline (>= 0.3.0) + reline (0.3.3) io-console (~> 0.5) + webrick (1.8.1) PLATFORMS ruby DEPENDENCIES irb + webrick + +RUBY VERSION + ruby 3.3.1p55 BUNDLED WITH - 2.1.4`, + 2.5.18 +`, ), 0666) Expect(err).ToNot(HaveOccurred()) @@ -176,15 +191,15 @@ func WithCrashingApp(f func(dir string)) { dir := TempDirAbsolutePath("", "crashing-ruby-app") defer os.RemoveAll(dir) - err := ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- + err := os.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: bogus bogus`, ), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) + err = os.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` + err = os.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` GEM specs: @@ -194,7 +209,7 @@ PLATFORMS DEPENDENCIES BUNDLED WITH - 1.15.0 + 2.1.4 `), 0666) Expect(err).ToNot(HaveOccurred()) @@ -210,10 +225,10 @@ func WithBananaPantsApp(f func(dir string)) { defer os.RemoveAll(dir) tempfile := filepath.Join(dir, "index.html") - err := ioutil.WriteFile(tempfile, []byte("Banana Pants"), 0666) + err := os.WriteFile(tempfile, []byte("Banana Pants"), 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) + err = os.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) f(dir) @@ -224,10 +239,10 @@ func WithEmptyFilesApp(f func(dir string)) { defer os.RemoveAll(dir) tempfile := filepath.Join(dir, "index.html") - err := ioutil.WriteFile(tempfile, nil, 0666) + err := os.WriteFile(tempfile, nil, 0666) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) + err = os.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) f(dir) @@ -252,12 +267,12 @@ func AppJSON(appName string) string { func WriteManifest(path string, manifest map[string]interface{}) { body, err := yaml.Marshal(manifest) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(path, body, 0666) + err = os.WriteFile(path, body, 0666) Expect(err).ToNot(HaveOccurred()) } func ReadManifest(path string) map[string]interface{} { - manifestBytes, err := ioutil.ReadFile(path) + manifestBytes, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) var manifest map[string]interface{} err = yaml.Unmarshal(manifestBytes, &manifest) @@ -353,7 +368,7 @@ func WaitForAppMemoryToTakeEffect(appName string, processIndex int, instanceInde Eventually(session).Should(Exit(0)) appTable := ParseV3AppProcessTable(session.Out.Contents()) return appTable.Processes[processIndex].Instances[instanceIndex].Memory - }).Should(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, expectedMemory))) + }).Should(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[BKMG]? of %s`, expectedMemory))) } func WaitForAppDiskToTakeEffect(appName string, processIndex int, instanceIndex int, shouldRestartFirst bool, expectedDisk string) { @@ -369,3 +384,17 @@ func WaitForAppDiskToTakeEffect(appName string, processIndex int, instanceIndex return appTable.Processes[processIndex].Instances[instanceIndex].Disk }).Should(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, expectedDisk))) } + +func WaitForLogRateLimitToTakeEffect(appName string, processIndex int, instanceIndex int, shouldRestartFirst bool, expectedLogRateLimit string) { + if shouldRestartFirst { + session := CF("restart", appName) + Eventually(session).Should(Exit(0)) + } + + Eventually(func() string { + session := CF("app", appName) + Eventually(session).Should(Exit(0)) + appTable := ParseV3AppProcessTable(session.Out.Contents()) + return appTable.Processes[processIndex].Instances[instanceIndex].LogRate + }).Should(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[BKMG]?/s of %s/s`, expectedLogRateLimit))) +} diff --git a/integration/helpers/app_instance_table.go b/integration/helpers/app_instance_table.go index 440d8b91bcf..3189192ffd0 100644 --- a/integration/helpers/app_instance_table.go +++ b/integration/helpers/app_instance_table.go @@ -8,13 +8,16 @@ import ( // AppInstanceRow represents an instance of a V3 app's process, // as displayed in the 'cf app' output. type AppInstanceRow struct { - Index string - State string - Since string - CPU string - Memory string - Disk string - Details string + Index string + State string + Since string + CPU string + Memory string + Disk string + LogRate string + CPUEntitlement string + Details string + Ready string } // AppProcessTable represents a process of a V3 app, as displayed in the 'cf @@ -57,19 +60,17 @@ func ParseV3AppProcessTable(input []byte) AppTable { case strings.HasPrefix(row, "#"): // instance row columns := splitColumns(row) - details := "" - if len(columns) >= 7 { - details = columns[6] - } - instanceRow := AppInstanceRow{ - Index: columns[0], - State: columns[1], - Since: columns[2], - CPU: columns[3], - Memory: columns[4], - Disk: columns[5], - Details: details, + Index: columns[0], + State: columns[1], + Since: columns[2], + CPU: columns[3], + Memory: columns[4], + Disk: columns[5], + LogRate: columns[6], + CPUEntitlement: columns[7], + Details: columns[8], + Ready: columns[9], } lastProcessIndex := len(appTable.Processes) - 1 appTable.Processes[lastProcessIndex].Instances = append( @@ -103,6 +104,23 @@ func ParseV3AppProcessTable(input []byte) AppTable { } func splitColumns(row string) []string { + s := strings.TrimSpace(row) // uses 3 spaces between columns - return regexp.MustCompile(`\s{3,}`).Split(strings.TrimSpace(row), -1) + result := regexp.MustCompile(`\s{3,}`).Split(s, -1) + + if regexp.MustCompile(`\s{31}`).MatchString(s) { + + if len(result) == 8 { + // Both cpu entitlement and details are empty + result = append(result[:len(result)-1], "", "", result[len(result)-1]) + } else { + // Only details is empty + result = append(result[:len(result)-2], result[len(result)-2], "", result[len(result)-1]) + } + + } else if regexp.MustCompile(`\s{21}`).MatchString(s) { + // cpu entitlement is empty, details is filled + result = append(result[:len(result)-2], "", result[len(result)-2], result[len(result)-1]) + } + return result } diff --git a/integration/helpers/app_instance_table_test.go b/integration/helpers/app_instance_table_test.go index 31fc921e530..1161e3c6bdc 100644 --- a/integration/helpers/app_instance_table_test.go +++ b/integration/helpers/app_instance_table_test.go @@ -1,9 +1,9 @@ package helpers_test import ( - . "code.cloudfoundry.org/cli/integration/helpers" + . "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -15,23 +15,23 @@ Showing health and status for app dora in org wut / space wut as admin... name: dora requested state: started routes: dora.bosh-lite.com -stack: cflinuxfs2 +stack: cflinuxfs4 buildpacks: ruby 1.6.44 type: web instances: 4/4 memory usage: 32M - state since cpu memory disk -#0 running 2017-08-02 17:12:10 PM 0.0% 21.2M of 32M 84.5M of 1G -#1 running 2017-08-03 09:39:25 AM 0.2% 19.3M of 32M 84.5M of 1G -#2 running 2017-08-03 03:29:25 AM 0.1% 22.8M of 32M 84.5M of 1G -#3 running 2017-08-02 17:12:10 PM 0.2% 22.9M of 32M 84.5M of 1G + state since cpu memory disk logging cpu entitlement +#0 running 2017-08-02 17:12:10 PM 0.0% 21.2M of 32M 84.5M of 1G 5B/s of 1K/s 0.0% +#1 running 2017-08-03 09:39:25 AM 0.2% 19.3M of 32M 84.5M of 1G 7B/s of 1K/s 0.4% +#2 running 2017-08-03 03:29:25 AM 0.1% 22.8M of 32M 84.5M of 1G 10B/s of 1K/s 0.2% +#3 running 2017-08-02 17:12:10 PM 0.2% 22.9M of 32M 84.5M of 1G 8B/s of 1K/s 0.4% type: worker instances: 1/1 memory usage: 32M - state since cpu memory disk -#0 stopped 2017-08-02 17:12:10 PM 0.0% 0M of 32M 0M of 1G + state since cpu memory disk logging cpu entitlement +#0 stopped 2017-08-02 17:12:10 PM 0.0% 0M of 32M 0M of 1G 0B/s of 1K/s 0.0% ` appInstanceTable := ParseV3AppProcessTable([]byte(input)) Expect(appInstanceTable).To(Equal(AppTable{ @@ -41,10 +41,10 @@ memory usage: 32M InstanceCount: "4/4", MemUsage: "32M", Instances: []AppInstanceRow{ - {Index: "#0", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "21.2M of 32M", Disk: "84.5M of 1G"}, - {Index: "#1", State: "running", Since: "2017-08-03 09:39:25 AM", CPU: "0.2%", Memory: "19.3M of 32M", Disk: "84.5M of 1G"}, - {Index: "#2", State: "running", Since: "2017-08-03 03:29:25 AM", CPU: "0.1%", Memory: "22.8M of 32M", Disk: "84.5M of 1G"}, - {Index: "#3", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.2%", Memory: "22.9M of 32M", Disk: "84.5M of 1G"}, + {Index: "#0", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "21.2M of 32M", Disk: "84.5M of 1G", LogRate: "5B/s of 1K/s", CPUEntitlement: "0.0%"}, + {Index: "#1", State: "running", Since: "2017-08-03 09:39:25 AM", CPU: "0.2%", Memory: "19.3M of 32M", Disk: "84.5M of 1G", LogRate: "7B/s of 1K/s", CPUEntitlement: "0.4%"}, + {Index: "#2", State: "running", Since: "2017-08-03 03:29:25 AM", CPU: "0.1%", Memory: "22.8M of 32M", Disk: "84.5M of 1G", LogRate: "10B/s of 1K/s", CPUEntitlement: "0.2%"}, + {Index: "#3", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.2%", Memory: "22.9M of 32M", Disk: "84.5M of 1G", LogRate: "8B/s of 1K/s", CPUEntitlement: "0.4%"}, }, }, { @@ -52,7 +52,7 @@ memory usage: 32M InstanceCount: "1/1", MemUsage: "32M", Instances: []AppInstanceRow{ - {Index: "#0", State: "stopped", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "0M of 32M", Disk: "0M of 1G"}, + {Index: "#0", State: "stopped", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "0M of 32M", Disk: "0M of 1G", LogRate: "0B/s of 1K/s", CPUEntitlement: "0.0%"}, }, }, }, @@ -66,11 +66,11 @@ Showing health and status for app dora in org wut / space wut as admin... type: web instances: 4/4 memory usage: 32M - state since cpu memory disk -#0 running 2017-08-02 17:12:10 PM 0.0% 21.2M of 32M 84.5M of 1G -#1 running 2017-08-03 09:39:25 AM 0.2% 19.3M of 32M 84.5M of 1G -#2 running 2017-08-03 03:29:25 AM 0.1% 22.8M of 32M 84.5M of 1G -#3 running 2017-08-02 17:12:10 PM 0.2% 22.9M of 32M 84.5M of 1G + state since cpu memory disk logging cpu entitlement +#0 running 2017-08-02 17:12:10 PM 0.0% 21.2M of 32M 84.5M of 1G 1.3K/s of 5K/s 0.0% +#1 running 2017-08-03 09:39:25 AM 0.2% 19.3M of 32M 84.5M of 1G 1.2K/s of 5K/s 0.4% +#2 running 2017-08-03 03:29:25 AM 0.1% 22.8M of 32M 84.5M of 1G 1.1K/s of 5K/s 0.2% +#3 running 2017-08-02 17:12:10 PM 0.2% 22.9M of 32M 84.5M of 1G 1.2K/s of 5K/s 0.4% ` appInstanceTable := ParseV3AppProcessTable([]byte(input)) Expect(appInstanceTable).To(Equal(AppTable{ @@ -80,10 +80,10 @@ memory usage: 32M InstanceCount: "4/4", MemUsage: "32M", Instances: []AppInstanceRow{ - {Index: "#0", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "21.2M of 32M", Disk: "84.5M of 1G"}, - {Index: "#1", State: "running", Since: "2017-08-03 09:39:25 AM", CPU: "0.2%", Memory: "19.3M of 32M", Disk: "84.5M of 1G"}, - {Index: "#2", State: "running", Since: "2017-08-03 03:29:25 AM", CPU: "0.1%", Memory: "22.8M of 32M", Disk: "84.5M of 1G"}, - {Index: "#3", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.2%", Memory: "22.9M of 32M", Disk: "84.5M of 1G"}, + {Index: "#0", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.0%", Memory: "21.2M of 32M", Disk: "84.5M of 1G", LogRate: "1.3K/s of 5K/s", CPUEntitlement: "0.0%"}, + {Index: "#1", State: "running", Since: "2017-08-03 09:39:25 AM", CPU: "0.2%", Memory: "19.3M of 32M", Disk: "84.5M of 1G", LogRate: "1.2K/s of 5K/s", CPUEntitlement: "0.4%"}, + {Index: "#2", State: "running", Since: "2017-08-03 03:29:25 AM", CPU: "0.1%", Memory: "22.8M of 32M", Disk: "84.5M of 1G", LogRate: "1.1K/s of 5K/s", CPUEntitlement: "0.2%"}, + {Index: "#3", State: "running", Since: "2017-08-02 17:12:10 PM", CPU: "0.2%", Memory: "22.9M of 32M", Disk: "84.5M of 1G", LogRate: "1.2K/s of 5K/s", CPUEntitlement: "0.4%"}, }, }, }, diff --git a/integration/helpers/app_test.go b/integration/helpers/app_test.go index 0954de85dd0..8e305c61d66 100644 --- a/integration/helpers/app_test.go +++ b/integration/helpers/app_test.go @@ -1,8 +1,8 @@ package helpers_test import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/helpers/buildpack.go b/integration/helpers/buildpack.go index e6f023b75b0..419fa08c898 100644 --- a/integration/helpers/buildpack.go +++ b/integration/helpers/buildpack.go @@ -1,9 +1,9 @@ package helpers import ( + "archive/tar" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" @@ -14,7 +14,7 @@ import ( // MakeBuildpackArchive makes a simple buildpack zip for a given stack. func MakeBuildpackArchive(stackName string) string { - archiveFile, err := ioutil.TempFile("", "buildpack-archive-file-") + archiveFile, err := os.CreateTemp("", "buildpack-archive-file-") Expect(err).ToNot(HaveOccurred()) err = archiveFile.Close() Expect(err).ToNot(HaveOccurred()) @@ -23,12 +23,12 @@ func MakeBuildpackArchive(stackName string) string { archiveName := archiveFile.Name() + ".zip" - dir, err := ioutil.TempDir("", "buildpack-dir-") + dir, err := os.MkdirTemp("", "buildpack-dir-") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) manifest := filepath.Join(dir, "manifest.yml") - err = ioutil.WriteFile(manifest, []byte(fmt.Sprintf("stack: %s", stackName)), 0666) + err = os.WriteFile(manifest, []byte(fmt.Sprintf("stack: %s", stackName)), 0666) Expect(err).ToNot(HaveOccurred()) err = Zipit(dir, archiveName, "") @@ -69,15 +69,66 @@ func SetupBuildpackWithoutStack(buildpackName string) { SetupBuildpackWithStack(buildpackName, "") } +// CNB makes a simple cnb (using +// MakeCNBArchive) and yields it to the given function, removing the cnb file +// at the end. +func CNB(f func(buildpackArchive string)) { + cnbArchive := MakeCNBArchive() + defer os.Remove(cnbArchive) + + f(cnbArchive) +} + +// MakeCNBArchive makes a simple buildpack cnb file for a given stack. +func MakeCNBArchive() string { + archiveDir, err := os.MkdirTemp("", "cnb-archive-file-") + Expect(err).ToNot(HaveOccurred()) + + archiveFile, err := os.Create(filepath.Join(archiveDir, "buildpack.cnb")) + Expect(err).ToNot(HaveOccurred()) + defer archiveFile.Close() + + tarWriter := tar.NewWriter(archiveFile) + defer tarWriter.Close() + + manifestBytes := []byte(`{"schemaVersion": 2,"mediaType": "application/vnd.oci.image.index.v1+json","manifests": []}`) + err = tarWriter.WriteHeader(&tar.Header{ + Name: "index.json", + Mode: 0666, + Size: int64(len(manifestBytes)), + }) + Expect(err).ToNot(HaveOccurred()) + + _, err = tarWriter.Write(manifestBytes) + Expect(err).ToNot(HaveOccurred()) + + layoutBytes := []byte(`{"imageLayoutVersion": "1.0.0"}`) + err = tarWriter.WriteHeader(&tar.Header{ + Name: "oci-layout", + Mode: 0666, + Size: int64(len(layoutBytes)), + }) + Expect(err).ToNot(HaveOccurred()) + + _, err = tarWriter.Write(layoutBytes) + Expect(err).ToNot(HaveOccurred()) + + err = tarWriter.Flush() + Expect(err).ToNot(HaveOccurred()) + + return archiveFile.Name() +} + // BuildpackFields represents a buildpack, displayed in the 'cf buildpacks' // command. type BuildpackFields struct { - Position string - Name string - Enabled string - Locked string - Filename string - Stack string + Position string + Name string + Enabled string + Locked string + Filename string + Stack string + Lifecycle string } // DeleteBuildpackIfOnOldCCAPI deletes the buildpack if the CC API targeted diff --git a/integration/helpers/client_credentials.go b/integration/helpers/client_credentials.go index 8d8a155b00a..4b027e5cb15 100644 --- a/integration/helpers/client_credentials.go +++ b/integration/helpers/client_credentials.go @@ -4,7 +4,7 @@ import ( "os" "strconv" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/helpers/command.go b/integration/helpers/command.go index f8f7cad7375..e43c451b540 100644 --- a/integration/helpers/command.go +++ b/integration/helpers/command.go @@ -8,7 +8,7 @@ import ( "regexp" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/helpers/commonisolated/common_isolated_setup.go b/integration/helpers/commonisolated/common_isolated_setup.go index 0960c1acf68..2484345e3d0 100644 --- a/integration/helpers/commonisolated/common_isolated_setup.go +++ b/integration/helpers/commonisolated/common_isolated_setup.go @@ -5,8 +5,9 @@ import ( "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -40,14 +41,18 @@ func CommonGinkgoSetup( helpers.SetupSynchronizedSuite(func() { helpers.EnableFeatureFlag("diego_docker") + helpers.EnableFeatureFlag("diego_cnb") helpers.EnableFeatureFlag("service_instance_sharing") + if helpers.IsVersionMet(ccversion.MinVersionHTTP2RoutingV3) { + helpers.EnableFeatureFlag("route_sharing") + } }) _, _ = GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each==============================")) return nil }, func(_ []byte) { - _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) // Ginkgo Globals SetDefaultEventuallyTimeout(CFEventuallyTimeout) SetDefaultConsistentlyDuration(CFConsistentlyTimeout) @@ -56,17 +61,17 @@ func CommonGinkgoSetup( helpers.TurnOffColors() *readOnlyOrg, *readOnlySpace = helpers.SetupReadOnlyOrgAndSpace() - _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = SynchronizedAfterSuite(func() { - _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) *homeDir = helpers.SetHomeDir() helpers.SetAPI() helpers.LoginCF() helpers.QuickDeleteOrg(*readOnlyOrg) helpers.DestroyHomeDir(*homeDir) - _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + _, _ = GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) }, func() {}) var _ = BeforeEach(func() { diff --git a/integration/helpers/config.go b/integration/helpers/config.go index aff1855997f..a2c6f8f582e 100644 --- a/integration/helpers/config.go +++ b/integration/helpers/config.go @@ -2,13 +2,12 @@ package helpers import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -31,7 +30,7 @@ func TurnOffExperimental() { // the created directory through GinkgoWriter. func SetHomeDir() string { var err error - homeDir, err := ioutil.TempDir("", "cli-integration-test") + homeDir, err := os.MkdirTemp("", "cli-integration-test") Expect(err).NotTo(HaveOccurred()) setHomeDirsTo(homeDir, homeDir) @@ -102,7 +101,7 @@ func SetConfig(cb func(conf *configv3.Config)) { func SetConfigContent(dir string, rawConfig string) { err := os.MkdirAll(filepath.Join(dir), 0777) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(filepath.Join(dir, "config.json"), []byte(rawConfig), 0644) + err = os.WriteFile(filepath.Join(dir, "config.json"), []byte(rawConfig), 0644) Expect(err).ToNot(HaveOccurred()) } diff --git a/integration/helpers/curl.go b/integration/helpers/curl.go index 13a089c8dff..37131bc572a 100644 --- a/integration/helpers/curl.go +++ b/integration/helpers/curl.go @@ -9,10 +9,10 @@ import ( . "github.com/onsi/gomega/gexec" ) -// Curl runs a 'cf curl' command with a URL format string, allowing props to be +// Curlf runs a 'cf curl' command with a URL format string, allowing props to be // interpolated into the URL string with fmt.Sprintf. The JSON response is // unmarshaled into given obj. -func Curl(obj interface{}, url string, props ...interface{}) { +func Curlf(obj interface{}, url string, props ...interface{}) { session := CF("curl", fmt.Sprintf(url, props...)) Eventually(session).Should(Exit(0)) rawJSON := strings.TrimSpace(string(session.Out.Contents())) diff --git a/integration/helpers/docker.go b/integration/helpers/docker.go index a17b57a34af..961653205d2 100644 --- a/integration/helpers/docker.go +++ b/integration/helpers/docker.go @@ -3,7 +3,7 @@ package helpers import ( "os" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) // SkipIfPrivateDockerInfoNotSet skips the test if CF_INT_DOCKER_IMAGE, diff --git a/integration/helpers/environment.go b/integration/helpers/environment.go index 7fc74795a0c..9ce9bfeb055 100644 --- a/integration/helpers/environment.go +++ b/integration/helpers/environment.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/helpers/fake_data.go b/integration/helpers/fake_data.go index b3740864fd9..a8ded756457 100644 --- a/integration/helpers/fake_data.go +++ b/integration/helpers/fake_data.go @@ -1,16 +1,17 @@ package helpers import ( + "embed" "fmt" - "io/ioutil" "net/http" - "os" - "path/filepath" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" ) +//go:embed fixtures +var content embed.FS + // AddFiftyOneOrgs adds a mock handler to the given server which returns // 51 orgs on GET requests to /v3/organizations?order_by=name. It also // paginates, so page 2 can be requested with /v3/organizations?page=2&per_page=50. @@ -81,9 +82,7 @@ func AddEmptyPaginatedResponse(server *ghttp.Server, path string) { } func fixtureData(name string) []byte { - wd := os.Getenv("GOPATH") - fp := filepath.Join(wd, "src", "code.cloudfoundry.org", "cli", "integration", "helpers", "fixtures", name) - b, err := ioutil.ReadFile(fp) + b, err := content.ReadFile("fixtures/" + name) Expect(err).ToNot(HaveOccurred()) return b } diff --git a/integration/helpers/file.go b/integration/helpers/file.go index 769c717f322..fe5b49a0ee3 100644 --- a/integration/helpers/file.go +++ b/integration/helpers/file.go @@ -1,7 +1,6 @@ package helpers import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -18,7 +17,7 @@ func ConvertPathToRegularExpression(path string) string { // TempFileWithContent writes a temp file with given content and return the // file name. func TempFileWithContent(contents string) string { - tempFile, err := ioutil.TempFile("", "*") + tempFile, err := os.CreateTemp("", "*") Expect(err).NotTo(HaveOccurred()) defer tempFile.Close() @@ -29,10 +28,10 @@ func TempFileWithContent(contents string) string { return tempFile.Name() } -// TempDirAbsolutePath wraps `ioutil.TempDir`, ensuring symlinks are expanded +// TempDirAbsolutePath wraps `os.MkdirTemp`, ensuring symlinks are expanded // before returning the path func TempDirAbsolutePath(dir string, prefix string) string { - tempDir, err := ioutil.TempDir(dir, prefix) + tempDir, err := os.MkdirTemp(dir, prefix) Expect(err).NotTo(HaveOccurred()) tempDir, err = filepath.EvalSymlinks(tempDir) @@ -41,7 +40,7 @@ func TempDirAbsolutePath(dir string, prefix string) string { return tempDir } -// TempFileAbsolutePath wraps `ioutil.TempFile`, ensuring symlinks are expanded +// TempFileAbsolutePath wraps `os.CreateTemp`, ensuring symlinks are expanded // before returning the path func TempFileAbsolutePath(dir string, pattern string) *os.File { var ( @@ -56,7 +55,7 @@ func TempFileAbsolutePath(dir string, pattern string) *os.File { absoluteDir, err = filepath.EvalSymlinks(dir) Expect(err).NotTo(HaveOccurred()) } - tempFile, err := ioutil.TempFile(absoluteDir, pattern) + tempFile, err := os.CreateTemp(absoluteDir, pattern) Expect(err).NotTo(HaveOccurred()) return tempFile diff --git a/integration/helpers/helpers_suite_test.go b/integration/helpers/helpers_suite_test.go index ebb490012ac..c668e16cffc 100644 --- a/integration/helpers/helpers_suite_test.go +++ b/integration/helpers/helpers_suite_test.go @@ -1,7 +1,7 @@ package helpers_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/integration/helpers/isolation_segment.go b/integration/helpers/isolation_segment.go index 6ec46996f90..6588abe689f 100644 --- a/integration/helpers/isolation_segment.go +++ b/integration/helpers/isolation_segment.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/helpers/login.go b/integration/helpers/login.go index 07e28f81d2f..939698a4ce3 100644 --- a/integration/helpers/login.go +++ b/integration/helpers/login.go @@ -7,7 +7,7 @@ import ( "strings" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -54,7 +54,7 @@ func GetAPI() string { return apiURL } -// LoginAs logs in to the CLI with 'cf auth' and the given username and password, +// LoginAs logs into the CLI with 'cf auth' and the given username and password, // retrying up to 3 times on failures. func LoginAs(username, password string) { env := map[string]string{ @@ -75,7 +75,7 @@ func LoginAs(username, password string) { Expect(session.ExitCode()).To(Equal(0)) } -// LoginCF logs in to the CLI using the username and password from the CF_INT_USERNAME +// LoginCF logs into the CLI using the username and password from the CF_INT_USERNAME // and CF_INT_PASSWORD environment variables, respectively, defaulting to "admin" for // each if either is not set. func LoginCF() string { @@ -87,7 +87,7 @@ func LoginCF() string { return username } -// LoginCFWithClientCredentials logs in to the CLI using client credentials from the CF_INT_CLIENT_ID and +// LoginCFWithClientCredentials logs into the CLI using client credentials from the CF_INT_CLIENT_ID and // CF_INT_CLIENT_SECRET environment variables and returns the client ID. If these environment variables // are not set, it skips the current test. func LoginCFWithClientCredentials() string { @@ -146,13 +146,13 @@ func TargetOrg(org string) { Eventually(CF("target", "-o", org)).Should(Exit(0)) } -// ClearTarget logs out and logs back in to the CLI using LogoutCF and LoginCF. +// ClearTarget logs out and logs back into the CLI using LogoutCF and LoginCF. func ClearTarget() { LogoutCF() LoginCF() } -// SetupCF logs in to the CLI with LoginCF, creates the given org and space, and targets that +// SetupCF logs into the CLI with LoginCF, creates the given org and space, and targets that // org and space. func SetupCF(org string, space string) { LoginCF() @@ -160,14 +160,14 @@ func SetupCF(org string, space string) { TargetOrgAndSpace(org, space) } -// SetupCFWithOrgOnly logs in to the CLI with LoginCF, creates the given org, and targets it. +// SetupCFWithOrgOnly logs into the CLI with LoginCF, creates the given org, and targets it. func SetupCFWithOrgOnly(org string) { LoginCF() CreateOrg(org) TargetOrg(org) } -// SetupCFWithGeneratedOrgAndSpaceNames logs in to the CLI with LoginCF, creates the org and +// SetupCFWithGeneratedOrgAndSpaceNames logs into the CLI with LoginCF, creates the org and // space with generated names, and targets that org and space. Returns the generated org so // that it can be deleted easily in cleanup step of the test. func SetupCFWithGeneratedOrgAndSpaceNames() string { diff --git a/integration/helpers/name_generator.go b/integration/helpers/name_generator.go index 3e54cea0a51..753e05b7b58 100644 --- a/integration/helpers/name_generator.go +++ b/integration/helpers/name_generator.go @@ -2,6 +2,7 @@ package helpers import ( "fmt" + "os" "sort" "strings" @@ -66,6 +67,13 @@ func NewOrgName() string { return PrefixedRandomName("INTEGRATION-ORG") } +func NewOptions() map[string]*string { + lbRR := "round-robin" + return map[string]*string{ + "loadbalancing": &lbRR, + } +} + // NewServiceOfferingName provides a random name prefixed with INTEGRATION-SERVICE func NewServiceOfferingName() string { return PrefixedRandomName("INTEGRATION-SERVICE") @@ -152,6 +160,10 @@ func NewPath() string { // PrefixedRandomName provides a random name with structure "namePrefix-randomstring" func PrefixedRandomName(namePrefix string) string { + testName := os.Getenv("CF_INT_TEST_NAME") + if len(testName) > 0 { + namePrefix += "-" + testName + } return namePrefix + "-" + RandomName() } diff --git a/integration/helpers/org_and_space.go b/integration/helpers/org_and_space.go index e098a3bcd16..c08150762eb 100644 --- a/integration/helpers/org_and_space.go +++ b/integration/helpers/org_and_space.go @@ -112,7 +112,7 @@ func GetSpaceGUID(spaceName string) string { } // QuickDeleteOrg deletes the org with the given name, if provided, using -// 'cf curl /v2/organizations... -X DELETE'. +// 'cf curl /v3/organizations... -X DELETE'. func QuickDeleteOrg(orgName string) { // If orgName is empty, the BeforeSuite has failed and attempting to delete // will produce a meaningless error. @@ -122,13 +122,13 @@ func QuickDeleteOrg(orgName string) { } guid := GetOrgGUID(orgName) - url := fmt.Sprintf("/v2/organizations/%s?recursive=true&async=true", guid) + url := fmt.Sprintf("/v3/organizations/%s", guid) session := CF("curl", "-X", "DELETE", url) Eventually(session).Should(Exit(0)) } // QuickDeleteOrgIfExists deletes the org with the given name, if it exists, using -// 'cf curl /v2/organizations... -X DELETE'. +// 'cf curl /v3/organizations... -X DELETE'. func QuickDeleteOrgIfExists(orgName string) { session := CF("org", "--guid", orgName) Eventually(session).Should(Exit()) @@ -136,16 +136,16 @@ func QuickDeleteOrgIfExists(orgName string) { return } guid := strings.TrimSpace(string(session.Out.Contents())) - url := fmt.Sprintf("/v2/organizations/%s?recursive=true&async=true", guid) + url := fmt.Sprintf("/v3/organizations/%s", guid) session = CF("curl", "-X", "DELETE", url) Eventually(session).Should(Exit()) } // QuickDeleteSpace deletes the space with the given name, if it exists, using -// 'cf curl /v2/spaces... -X DELETE'. +// 'cf curl /v3/spaces... -X DELETE'. func QuickDeleteSpace(spaceName string) { guid := GetSpaceGUID(spaceName) - url := fmt.Sprintf("/v2/spaces/%s?recursive=true&async=true", guid) + url := fmt.Sprintf("/v3/spaces/%s", guid) session := CF("curl", "-X", "DELETE", url) Eventually(session).Should(Exit(0)) } diff --git a/integration/helpers/os.go b/integration/helpers/os.go index f9b117e7c7d..d06014e592f 100644 --- a/integration/helpers/os.go +++ b/integration/helpers/os.go @@ -3,7 +3,7 @@ package helpers import ( "runtime" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) func IsWindows() bool { diff --git a/integration/helpers/package.go b/integration/helpers/package.go index 305b87961b9..8a9b6a72ee7 100644 --- a/integration/helpers/package.go +++ b/integration/helpers/package.go @@ -2,7 +2,6 @@ package helpers import ( "fmt" - "io/ioutil" "os" "regexp" @@ -15,7 +14,7 @@ import ( // VerifyAppPackageContentsV3 verifies the contents of a V3 app package by downloading the package zip and // verifying the zipped files match the passed files. func VerifyAppPackageContentsV3(appName string, files ...string) { - tmpZipFilepath, err := ioutil.TempFile("", "") + tmpZipFilepath, err := os.CreateTemp("", "") defer os.Remove(tmpZipFilepath.Name()) Expect(err).ToNot(HaveOccurred()) @@ -60,7 +59,7 @@ func downloadFirstAppPackage(appName string, tmpZipFilepath string) { // VerifyAppPackageContentsV2 verifies the contents of a V2 app package by downloading the package zip and // verifying the zipped files match the passed files. func VerifyAppPackageContentsV2(appName string, files ...string) { - tmpZipFilepath, err := ioutil.TempFile("", "") + tmpZipFilepath, err := os.CreateTemp("", "") defer os.Remove(tmpZipFilepath.Name()) Expect(err).ToNot(HaveOccurred()) diff --git a/integration/helpers/plugin.go b/integration/helpers/plugin.go index 2f8b1e617ac..40e4cf11370 100644 --- a/integration/helpers/plugin.go +++ b/integration/helpers/plugin.go @@ -37,7 +37,7 @@ func BuildConfigurablePlugin(pluginType string, name string, version string, plu commandHelps = append(commandHelps, command.Help) } - pluginPath, err := Build(fmt.Sprintf("code.cloudfoundry.org/cli/integration/assets/%s", pluginType), + pluginPath, err := Build(fmt.Sprintf("code.cloudfoundry.org/cli/v8/integration/assets/%s", pluginType), "-o", name, "-ldflags", diff --git a/integration/helpers/plugin_repo.go b/integration/helpers/plugin_repo.go index 57d1fdab057..d7fd29e6a4e 100644 --- a/integration/helpers/plugin_repo.go +++ b/integration/helpers/plugin_repo.go @@ -4,14 +4,13 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "log" "net/http" "os" "path/filepath" - "code.cloudfoundry.org/cli/util" - "code.cloudfoundry.org/cli/util/generic" + "code.cloudfoundry.org/cli/v8/util" + "code.cloudfoundry.org/cli/v8/util/generic" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" @@ -104,7 +103,7 @@ func (pluginRepoServer *PluginRepositoryServerWithPlugin) Init(pluginType string jsonBytes, err := json.Marshal(pluginRepo) Expect(err).ToNot(HaveOccurred()) - pluginData, err := ioutil.ReadFile(pluginPath) + pluginData, err := os.ReadFile(pluginPath) Expect(err).ToNot(HaveOccurred()) repoServer.AppendHandlers( diff --git a/integration/helpers/plugin_repo_platform_unix.go b/integration/helpers/plugin_repo_platform_unix.go index 97a8abf9a55..d600f7dfb9b 100644 --- a/integration/helpers/plugin_repo_platform_unix.go +++ b/integration/helpers/plugin_repo_platform_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package helpers diff --git a/integration/helpers/plugin_repo_platform_windows.go b/integration/helpers/plugin_repo_platform_windows.go index b0bdc0c1ee6..e23de538bd0 100644 --- a/integration/helpers/plugin_repo_platform_windows.go +++ b/integration/helpers/plugin_repo_platform_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package helpers diff --git a/integration/helpers/route.go b/integration/helpers/route.go index 53eaf9d8621..16f7a151445 100644 --- a/integration/helpers/route.go +++ b/integration/helpers/route.go @@ -2,11 +2,12 @@ package helpers import ( "fmt" + "os" "path" "regexp" "strings" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/resources" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -40,38 +41,42 @@ func FindOrCreateTCPRouterGroup(node int) string { // Route represents a route. type Route struct { - Domain string - Host string - Path string - Port int - Space string + Domain string + Host string + Path string + Port int + Space string + Options map[string]*string } // NewRoute constructs a route with given space, domain, hostname, and path. -func NewRoute(space string, domain string, hostname string, path string) Route { +func NewRoute(space string, domain string, hostname string, path string, options map[string]*string) Route { return Route{ - Space: space, - Domain: domain, - Host: hostname, - Path: path, + Space: space, + Domain: domain, + Host: hostname, + Path: path, + Options: options, } } // NewTCPRoute constructs a TCP route with given space, domain, and port. -func NewTCPRoute(space string, domain string, port int) Route { +func NewTCPRoute(space string, domain string, port int, options map[string]*string) Route { return Route{ - Space: space, - Domain: domain, - Port: port, + Space: space, + Domain: domain, + Port: port, + Options: options, } } // Create creates a route using the 'cf create-route' command. func (r Route) Create() { + r.Options = make(map[string]*string) if r.Port != 0 { - Eventually(CF("create-route", r.Space, r.Domain, "--port", fmt.Sprint(r.Port))).Should(Exit(0)) + Eventually(CF("create-route", r.Space, r.Domain, "--port", fmt.Sprint(r.Port), "--option", fmt.Sprint(r.Options))).Should(Exit(0)) } else { - Eventually(CF("create-route", r.Space, r.Domain, "--hostname", r.Host, "--path", r.Path)).Should(Exit(0)) + Eventually(CF("create-route", r.Space, r.Domain, "--hostname", r.Host, "--path", r.Path, "--option", fmt.Sprint(r.Options))).Should(Exit(0)) } } @@ -116,7 +121,7 @@ func (r Route) GUID() string { var domainReceiver struct { Domains []resources.Domain `json:"resources"` } - Curl(&domainReceiver, "/v3/domains?names=%s", r.Domain) + Curlf(&domainReceiver, "/v3/domains?names=%s", r.Domain) Expect(domainReceiver.Domains).To(HaveLen(1)) query := []string{fmt.Sprintf("domain_guids=%s", domainReceiver.Domains[0].GUID)} @@ -137,8 +142,17 @@ func (r Route) GUID() string { var routeReceiver struct { Routes []resources.Route `json:"resources"` } - Curl(&routeReceiver, "/v3/routes?%s", strings.Join(query, "&")) + Curlf(&routeReceiver, "/v3/routes?%s", strings.Join(query, "&")) Expect(routeReceiver.Routes).To(HaveLen(1)) return routeReceiver.Routes[0].GUID } + +func GetPort() int { + port := 1024 + testName := os.Getenv("CF_INT_TEST_NAME") + if testName == "cc" { + port = 1025 + } + return port +} diff --git a/integration/helpers/security_group.go b/integration/helpers/security_group.go index 893f5239677..8dcb01f9a63 100644 --- a/integration/helpers/security_group.go +++ b/integration/helpers/security_group.go @@ -3,11 +3,10 @@ package helpers import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/resources" + "code.cloudfoundry.org/cli/v8/resources" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -27,7 +26,7 @@ func NewSecurityGroup(name string, protocol string, destination string, ports *s // CreateSecurityGroup Creates a new security group on the API using the 'cf create-security-group' func CreateSecurityGroup(s resources.SecurityGroup) { - dir, err := ioutil.TempDir("", "simple-security-group") + dir, err := os.MkdirTemp("", "simple-security-group") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) @@ -36,7 +35,7 @@ func CreateSecurityGroup(s resources.SecurityGroup) { securityGroup, err := json.Marshal(s.Rules) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(tempfile, securityGroup, 0666) + err = os.WriteFile(tempfile, securityGroup, 0666) Expect(err).ToNot(HaveOccurred()) Eventually(CF("create-security-group", s.Name, tempfile)).Should(Exit(0)) } diff --git a/integration/helpers/servicebrokerstub/api.go b/integration/helpers/servicebrokerstub/api.go index 6783c28effa..4178c466633 100644 --- a/integration/helpers/servicebrokerstub/api.go +++ b/integration/helpers/servicebrokerstub/api.go @@ -3,7 +3,7 @@ package servicebrokerstub import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" ) diff --git a/integration/helpers/servicebrokerstub/app_config.go b/integration/helpers/servicebrokerstub/app_config.go index 6b5be604565..23079cec187 100644 --- a/integration/helpers/servicebrokerstub/app_config.go +++ b/integration/helpers/servicebrokerstub/app_config.go @@ -5,11 +5,10 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" . "github.com/onsi/gomega" ) @@ -55,7 +54,7 @@ func (s *ServiceBrokerStub) requestNewBrokerRoute() { resp, err := http.DefaultClient.Do(req) Expect(err).ToNot(HaveOccurred()) - responseBody, err := ioutil.ReadAll(resp.Body) + responseBody, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(resp.StatusCode).To( Equal(http.StatusCreated), diff --git a/integration/helpers/servicebrokerstub/app_deploy.go b/integration/helpers/servicebrokerstub/app_deploy.go index a411e681723..793fce2077f 100644 --- a/integration/helpers/servicebrokerstub/app_deploy.go +++ b/integration/helpers/servicebrokerstub/app_deploy.go @@ -9,26 +9,35 @@ import ( "sync" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" . "github.com/onsi/gomega" ) +var appOrg = "fakeservicebroker" + const ( appNamePrefix = "hydrabroker" - appOrg = "fakeservicebroker" appSpace = "integration" defaultMemoryLimit = "32M" pathToApp = "../../assets/hydrabroker" ) +var once sync.Once var mutex sync.Mutex +func initialize() { + testName := os.Getenv("CF_INT_TEST_NAME") + if len(testName) > 0 { + appOrg += "-" + testName + } +} + func ensureAppIsDeployed() { if !appResponds() { ensureAppIsPushed() - Eventually(appResponds).Should(BeTrue()) + Eventually(appResponds, time.Minute).Should(BeTrue()) } } @@ -73,6 +82,10 @@ func ensureAppIsPushed() { } } + once.Do(func() { + initialize() + }) + // mutex protects from goroutines, and we retry later to protect from other test processes mutex.Lock() defer mutex.Unlock() diff --git a/integration/helpers/servicebrokerstub/cf.go b/integration/helpers/servicebrokerstub/cf.go index 5f92a1a8547..53f486909e8 100644 --- a/integration/helpers/servicebrokerstub/cf.go +++ b/integration/helpers/servicebrokerstub/cf.go @@ -3,7 +3,7 @@ package servicebrokerstub import ( "encoding/json" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/helpers/set_env_command.go b/integration/helpers/set_env_command.go new file mode 100644 index 00000000000..83514ae9ba0 --- /dev/null +++ b/integration/helpers/set_env_command.go @@ -0,0 +1,19 @@ +package helpers + +import ( + "encoding/json" + + . "github.com/onsi/gomega" +) + +func GetsDefaultEnvVarValue(stream []byte) string { + envVariableJSON := struct { + Var struct { + SomeEnvVar string `json:"SOME_ENV_VAR"` + } `json:"var"` + }{} + + Expect(json.Unmarshal(stream, &envVariableJSON)).To(Succeed()) + + return envVariableJSON.Var.SomeEnvVar +} diff --git a/integration/helpers/ssh_command.go b/integration/helpers/ssh_command.go new file mode 100644 index 00000000000..560f7051cde --- /dev/null +++ b/integration/helpers/ssh_command.go @@ -0,0 +1,17 @@ +package helpers + +import ( + "encoding/json" + + . "github.com/onsi/gomega" +) + +func GetsEnablementValue(stream []byte) bool { + enablementResponse := struct { + Enabled bool `json:"enabled"` + }{} + + Expect(json.Unmarshal(stream, &enablementResponse)).To(Succeed()) + + return enablementResponse.Enabled +} diff --git a/integration/helpers/stack.go b/integration/helpers/stack.go index bc148e6c2aa..4a182700f08 100644 --- a/integration/helpers/stack.go +++ b/integration/helpers/stack.go @@ -2,7 +2,6 @@ package helpers import ( "encoding/json" - "fmt" "strings" @@ -37,17 +36,17 @@ func FetchStacks() []string { return stacks } -// PreferredStack returns the cflinuxfs3 stack name if it present, otherwise cflinuxfs2 is returned. +// PreferredStack returns the cflinuxfs4 stack name if it present, otherwise cflinuxfs3 is returned. func PreferredStack() string { stacks := FetchStacks() for _, name := range stacks { - if name == "cflinuxfs3" { + if name == "cflinuxfs4" { return name } } - return "cflinuxfs2" + return "cflinuxfs3" } // CreateStack creates a new stack with the user provided name. If a name is not provided, a random name is used diff --git a/integration/helpers/version.go b/integration/helpers/version.go index bf9dd585711..5a8fffd8f4b 100644 --- a/integration/helpers/version.go +++ b/integration/helpers/version.go @@ -4,16 +4,16 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "strconv" "strings" "sync" - "code.cloudfoundry.org/cli/actor/versioncheck" + "code.cloudfoundry.org/cli/v8/actor/versioncheck" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -43,9 +43,8 @@ func (v UAAVersion) Version() string { func IsUAAVersionAtLeast(minVersion string) bool { info := fetchAPIVersion() uaaUrl := fmt.Sprintf("%s/info", info.Links.UAA.Href) - tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: SkipSSLValidation()}, - } + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: SkipSSLValidation()} req, err := http.NewRequest("GET", uaaUrl, nil) Expect(err).ToNot(HaveOccurred()) req.Header.Add("Accept", "application/json") @@ -56,7 +55,7 @@ func IsUAAVersionAtLeast(minVersion string) bool { defer resp.Body.Close() if resp.StatusCode == http.StatusOK { - bodyBytes, err2 := ioutil.ReadAll(resp.Body) + bodyBytes, err2 := io.ReadAll(resp.Body) Expect(err2).ToNot(HaveOccurred()) version := &UAAVersion{} @@ -79,7 +78,7 @@ func SkipIfUAAVersionLessThan(version string) { } } -// SkipIfUAAVersionAtLeast is used to skip tests if the UAA varsion >= the specified version. +// SkipIfUAAVersionAtLeast is used to skip tests if the UAA version >= the specified version. func SkipIfUAAVersionAtLeast(version string) { if IsUAAVersionAtLeast(version) { Skip(fmt.Sprintf("Test requires UAA version less than %s", version)) @@ -96,10 +95,10 @@ func matchMajorAPIVersion(minVersion string) string { // GetAPIVersionV2 returns the V2 api version of the targeted API func GetAPIVersionV2() string { - return fetchAPIVersion().Links.CloudContollerV2.Meta.Version + return fetchAPIVersion().Links.CloudControllerV2.Meta.Version } -// SkipIfVersionLessThan is used to skip tests if the the API version < the specified version. If +// SkipIfVersionLessThan is used to skip tests if the API version < the specified version. If // minVersion contains the prefix 3 then the v3 version is checked, otherwise the v2 version is used. func SkipIfVersionLessThan(minVersion string) { if ignoreAPIVersion() { @@ -112,7 +111,7 @@ func SkipIfVersionLessThan(minVersion string) { } } -// SkipIfVersionLessThan is used to skip tests if the the API version >= the specified version. If +// SkipIfVersionLessThan is used to skip tests if the API version >= the specified version. If // maxVersion contains the prefix 3 then the v3 version is checked, otherwise the v2 version is used. func SkipIfVersionAtLeast(maxVersion string) { version := matchMajorAPIVersion(maxVersion) @@ -134,13 +133,13 @@ func ignoreAPIVersion() bool { type ccRoot struct { Links struct { - CloudContollerV2 struct { + CloudControllerV2 struct { Meta struct { Version string } } `json:"cloud_controller_v2"` - CloudContollerV3 struct { + CloudControllerV3 struct { Meta struct { Version string } @@ -172,7 +171,7 @@ func fetchAPIVersion() ccRoot { } func getAPIVersionV3() string { - return fetchAPIVersion().Links.CloudContollerV3.Meta.Version + return fetchAPIVersion().Links.CloudControllerV3.Meta.Version } // SkipIfNoRoutingAPI is used to skip tests if the routing API is not present @@ -181,7 +180,7 @@ func SkipIfNoRoutingAPI() { var response struct { RoutingEndpoint string `json:"routing_endpoint"` } - Curl(&response, "/v2/info") + Curlf(&response, "/v2/info") if response.RoutingEndpoint == "" { Skip("Test requires routing endpoint on /v2/info") diff --git a/integration/helpers/version_v7.go b/integration/helpers/version_v7.go index a392e8aa9b7..800ede10f5f 100644 --- a/integration/helpers/version_v7.go +++ b/integration/helpers/version_v7.go @@ -3,7 +3,7 @@ package helpers import ( "fmt" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" ) const V7 = true diff --git a/integration/shared/experimental/experimental_suite_test.go b/integration/shared/experimental/experimental_suite_test.go index 028d93b2dd4..888a5882479 100644 --- a/integration/shared/experimental/experimental_suite_test.go +++ b/integration/shared/experimental/experimental_suite_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -36,6 +36,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.SetupSynchronizedSuite(func() { helpers.EnableFeatureFlag("diego_docker") + helpers.EnableFeatureFlag("diego_cnb") helpers.EnableFeatureFlag("service_instance_sharing") }) @@ -43,7 +44,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { return nil }, func(_ []byte) { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) // Ginkgo Globals SetDefaultEventuallyTimeout(CFEventuallyTimeout) SetDefaultConsistentlyDuration(CFConsistentlyTimeout) @@ -54,16 +55,16 @@ var _ = SynchronizedBeforeSuite(func() []byte { // Enable Experimental Flag helpers.TurnOnExperimental() - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = SynchronizedAfterSuite(func() { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) suiteHomeDir := helpers.SetHomeDir() helpers.SetAPI() helpers.LoginCF() helpers.DestroyHomeDir(suiteHomeDir) - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) }, func() {}) var _ = BeforeEach(func() { diff --git a/integration/shared/global/global_suite_test.go b/integration/shared/global/global_suite_test.go index 0b5c246a056..f5d0b38b1a5 100644 --- a/integration/shared/global/global_suite_test.go +++ b/integration/shared/global/global_suite_test.go @@ -2,14 +2,13 @@ package global import ( "fmt" + "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) const ( @@ -40,6 +39,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.SetupSynchronizedSuite(func() { helpers.EnableFeatureFlag("diego_docker") + helpers.EnableFeatureFlag("diego_cnb") helpers.EnableFeatureFlag("service_instance_sharing") }) @@ -48,11 +48,11 @@ var _ = SynchronizedBeforeSuite(func() []byte { GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each==============================")) return nil }, func(_ []byte) { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) - if GinkgoParallelNode() != 1 { + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) + if GinkgoParallelProcess() != 1 { Fail("Test suite cannot run in parallel") } - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = BeforeEach(func() { diff --git a/integration/shared/global/running_environment_variable_group_command_test.go b/integration/shared/global/running_environment_variable_group_command_test.go index 9ffd173e61c..dd2fca86612 100644 --- a/integration/shared/global/running_environment_variable_group_command_test.go +++ b/integration/shared/global/running_environment_variable_group_command_test.go @@ -3,8 +3,8 @@ package global import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/shared/global/staging_environment_variable_group_command_test.go b/integration/shared/global/staging_environment_variable_group_command_test.go index fcf1f6c1780..4c156f85607 100644 --- a/integration/shared/global/staging_environment_variable_group_command_test.go +++ b/integration/shared/global/staging_environment_variable_group_command_test.go @@ -3,8 +3,8 @@ package global import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/shared/isolated/apps_command_test.go b/integration/shared/isolated/apps_command_test.go index 984898d8942..cd2a3c976d9 100644 --- a/integration/shared/isolated/apps_command_test.go +++ b/integration/shared/isolated/apps_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/isolated/config_test.go b/integration/shared/isolated/config_test.go index 2870b9ac0ba..4dfbf3d917a 100644 --- a/integration/shared/isolated/config_test.go +++ b/integration/shared/isolated/config_test.go @@ -1,11 +1,12 @@ package isolated import ( - "io/ioutil" + "os" "path/filepath" + "time" - helpers "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + helpers "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -40,9 +41,12 @@ var _ = Describe("Config", func() { When("lingering tmp files exist from previous failed attempts to write the config", func() { BeforeEach(func() { for i := 0; i < 3; i++ { - tmpFile, err := ioutil.TempFile(configDir, "temp-config") + tmpFile, err := os.CreateTemp(configDir, "temp-config") Expect(err).ToNot(HaveOccurred()) tmpFile.Close() + oldTime := time.Now().Add(-time.Minute * 10) + err = os.Chtimes(tmpFile.Name(), oldTime, oldTime) + Expect(err).ToNot(HaveOccurred()) } }) diff --git a/integration/shared/isolated/error_handling_test.go b/integration/shared/isolated/error_handling_test.go index 6e4563173f5..64e39faf43b 100644 --- a/integration/shared/isolated/error_handling_test.go +++ b/integration/shared/isolated/error_handling_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -11,7 +11,7 @@ import ( var _ = Describe("curl command", func() { It("returns the expected request", func() { session := helpers.CF("curl", "/v2/banana") - Eventually(session).Should(Say(`"error_code": "CF-NotFound"`)) + Eventually(session).Should(Say(`"error_code":"CF-NotFound"`)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/shared/isolated/internationalization_test.go b/integration/shared/isolated/internationalization_test.go index 260c061df23..4aea8f32cc1 100644 --- a/integration/shared/isolated/internationalization_test.go +++ b/integration/shared/isolated/internationalization_test.go @@ -1,9 +1,8 @@ package isolated import ( - helpers "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + helpers "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -26,26 +25,26 @@ var _ = XDescribe("internationalization", func() { return helpers.CF("push", "--help") }), - Entry("when the the config and LANG environment variable is set, it uses config", func() *Session { + Entry("when the config and LANG environment variable is set, it uses config", func() *Session { session := helpers.CF("config", "--locale", "fr-FR") Eventually(session).Should(Exit(0)) return helpers.CFWithEnv(map[string]string{"LANG": "es-ES"}, "push", "--help") }), - Entry("when the the LANG environment variable is set", func() *Session { + Entry("when the LANG environment variable is set", func() *Session { return helpers.CFWithEnv(map[string]string{"LANG": "fr-FR"}, "push", "--help") }), - Entry("when the the LC_ALL environment variable is set", func() *Session { + Entry("when the LC_ALL environment variable is set", func() *Session { return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR"}, "push", "--help") }), - Entry("when the the LC_ALL and LANG environment variables are set, it uses LC_ALL", func() *Session { + Entry("when the LC_ALL and LANG environment variables are set, it uses LC_ALL", func() *Session { return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR", "LANG": "es-ES"}, "push", "--help") }), - Entry("when the the config, LC_ALL, and LANG is set, it uses config", func() *Session { + Entry("when the config, LC_ALL, and LANG is set, it uses config", func() *Session { session := helpers.CF("config", "--locale", "fr-FR") Eventually(session).Should(Exit(0)) @@ -60,15 +59,15 @@ var _ = XDescribe("internationalization", func() { Eventually(session).Should(Exit(0)) }, - Entry("when the the LANG and LC_ALL environment variable is not set", func() *Session { + Entry("when the LANG and LC_ALL environment variable is not set", func() *Session { return helpers.CF("push", "--help") }), - Entry("when the the LANG environment variable is set to a non-supported langauge", func() *Session { + Entry("when the LANG environment variable is set to a non-supported language", func() *Session { return helpers.CFWithEnv(map[string]string{"LANG": "jj-FF"}, "push", "--help") }), - Entry("when the the LC_ALL environment variable is set to a non-supported langauge", func() *Session { + Entry("when the LC_ALL environment variable is set to a non-supported language", func() *Session { return helpers.CFWithEnv(map[string]string{"LC_ALL": "jj-FF"}, "push", "--help") }), ) diff --git a/integration/shared/isolated/isolated_suite_test.go b/integration/shared/isolated/isolated_suite_test.go index 8a01781a206..f60a8850557 100644 --- a/integration/shared/isolated/isolated_suite_test.go +++ b/integration/shared/isolated/isolated_suite_test.go @@ -3,7 +3,7 @@ package isolated import ( "testing" - "code.cloudfoundry.org/cli/integration/helpers/commonisolated" + "code.cloudfoundry.org/cli/v8/integration/helpers/commonisolated" ) var ( diff --git a/integration/shared/isolated/logs_command_test.go b/integration/shared/isolated/logs_command_test.go deleted file mode 100644 index 40ac936eea4..00000000000 --- a/integration/shared/isolated/logs_command_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package isolated - -import ( - "encoding/base64" - "fmt" - "net/http" - "runtime" - "strconv" - "time" - - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" - "github.com/onsi/gomega/ghttp" -) - -var _ = Describe("logs command", func() { - var server *ghttp.Server - - BeforeEach(func() { - server = helpers.StartAndTargetMockServerWithAPIVersions(helpers.DefaultV2Version, helpers.DefaultV3Version) - helpers.AddLoginRoutes(server) - - helpers.AddHandler(server, - http.MethodGet, - "/v3/organizations?order_by=name", - http.StatusOK, - []byte( - `{ - "total_results": 1, - "total_pages": 1, - "resources": [ - { - "guid": "f3ea75ba-ea6b-439f-8889-b07abf718e6a", - "name": "some-fake-org" - } - ]}`), - ) - - // The v6 version of this command makes the below request when logging in. - // See below for comparison with v7 version. - helpers.AddHandler(server, - http.MethodGet, - "/v3/spaces?organization_guids=f3ea75ba-ea6b-439f-8889-b07abf718e6a", - http.StatusOK, - []byte( - `{ - "total_results": 1, - "total_pages": 1, - "resources": [ - { - "guid": "1704b4e7-14bb-4b7b-bc23-0b8d23a60238", - "name": "some-fake-space" - } - ]}`), - ) - - // The v7 version of this command makes the below request when logging in, - // which is similar to the v6 version above except for the additional 'order_by' - // query parameter. Rather than split these tests across two files, we just add - // a handler for both routes (with and without 'order_by'). - helpers.AddHandler(server, - http.MethodGet, - "/v3/spaces?order_by=name&organization_guids=f3ea75ba-ea6b-439f-8889-b07abf718e6a", - http.StatusOK, - []byte( - `{ - "total_results": 1, - "total_pages": 1, - "resources": [ - { - "guid": "1704b4e7-14bb-4b7b-bc23-0b8d23a60238", - "name": "some-fake-space" - } - ]}`), - ) - - helpers.AddHandler(server, - http.MethodGet, - "/v2/apps?q=name%3Asome-fake-app&q=space_guid%3A1704b4e7-14bb-4b7b-bc23-0b8d23a60238", - http.StatusOK, - []byte( - `{ - "total_results": 1, - "total_pages": 1, - "resources": [ - { - "metadata": { - "guid": "d5d27772-315f-474b-8673-57e34ce2db2c" - }, - "entity": { - "name": "some-fake-app" - } - } - ]}`), - ) - - helpers.AddHandler(server, - http.MethodGet, - "/v3/apps?names=some-fake-app&space_guids=1704b4e7-14bb-4b7b-bc23-0b8d23a60238", - http.StatusOK, - []byte( - `{ - "total_results": 1, - "total_pages": 1, - "resources": [ - { - "guid": "d5d27772-315f-474b-8673-57e34ce2db2c", - "name": "some-fake-app" - } - ]}`), - ) - - helpers.AddHandler(server, - http.MethodGet, - "/api/v1/info", - http.StatusOK, - []byte(`{"version":"2.6.8"}`), - ) - }) - - AfterEach(func() { - server.Close() - }) - - Describe("streaming logs", func() { - - const logMessage = "hello from log-cache" - var returnEmptyEnvelope bool - - onWindows := runtime.GOOS == "windows" - - BeforeEach(func() { - latestEnvelopeTimestamp := "1581447006352020890" - latestEnvelopeTimestampMinusOneSecond := "1581447005352020890" - nextEnvelopeTimestamp := "1581447009352020890" - nextEnvelopeTimestampPlusOneNanosecond := "1581447009352020891" - - server.RouteToHandler( - http.MethodGet, - "/api/v1/read/d5d27772-315f-474b-8673-57e34ce2db2c", - func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - switch r.URL.RawQuery { - case fmt.Sprintf("descending=true&limit=1&start_time=%s", strconv.FormatInt(time.Time{}.UnixNano(), 10)): - if returnEmptyEnvelope { - _, err := w.Write([]byte(`{}`)) - Expect(err).ToNot(HaveOccurred()) - returnEmptyEnvelope = false // Allow the CLI to continue after receiving an empty envelope - } else { - _, err := w.Write([]byte(fmt.Sprintf(` - { - "envelopes": { - "batch": [ - { - "timestamp": "%s", - "source_id": "d5d27772-315f-474b-8673-57e34ce2db2c" - } - ] - } - }`, latestEnvelopeTimestamp))) - Expect(err).ToNot(HaveOccurred()) - } - case fmt.Sprintf("envelope_types=LOG&start_time=%s", latestEnvelopeTimestampMinusOneSecond): - _, err := w.Write([]byte(fmt.Sprintf(`{ - "envelopes": { - "batch": [ - { - "timestamp": "%s", - "source_id": "d5d27772-315f-474b-8673-57e34ce2db2c", - "tags": { - "__v1_type": "LogMessage" - }, - "log": { - "payload": "%s", - "type": "OUT" - } - } - ] - } - }`, nextEnvelopeTimestamp, base64.StdEncoding.EncodeToString([]byte(logMessage))))) - Expect(err).ToNot(HaveOccurred()) - case fmt.Sprintf("envelope_types=LOG&start_time=%s", nextEnvelopeTimestampPlusOneNanosecond): - _, err := w.Write([]byte("{}")) - Expect(err).ToNot(HaveOccurred()) - default: - Fail(fmt.Sprintf("Unhandled log-cache api query string: %s", r.URL.RawQuery)) - } - }) - }) - - When("there already is an envelope in the log cache", func() { - JustBeforeEach(func() { - returnEmptyEnvelope = false - }) - - It("fetches logs with a timestamp just prior to the latest log envelope", func() { - username, password := helpers.GetCredentials() - session := helpers.CF("login", "-a", server.URL(), "-u", username, "-p", password, "--skip-ssl-validation") - Eventually(session).Should(Exit(0)) - - session = helpers.CF("logs", "some-fake-app") - Eventually(session).Should(Say(logMessage)) - if onWindows { - session.Kill() - Eventually(session).Should(Exit()) - } else { - session.Interrupt() - Eventually(session).Should(Exit(0), "Interrupt should be handled and fail gracefully") - } - }) - }) - - When("there is not yet an envelope in the log cache", func() { - JustBeforeEach(func() { - returnEmptyEnvelope = true - }) - - // TODO: the case where log-cache has no envelopes yet may be "special": we may want to switch to "start from your oldest envelope" approach. - It("retries until there is an initial envelope, and then fetches logs with a timestamp just prior to the latest log envelope", func() { - username, password := helpers.GetCredentials() - session := helpers.CF("login", "-a", server.URL(), "-u", username, "-p", password, "--skip-ssl-validation") - Eventually(session).Should(Exit(0)) - - session = helpers.CF("logs", "some-fake-app") - Eventually(session).Should(Say(logMessage)) - if onWindows { - session.Kill() - Eventually(session).Should(Exit()) - } else { - session.Interrupt() - Eventually(session).Should(Exit(0)) - } - }) - }) - }) -}) diff --git a/integration/shared/isolated/restart_app_instance_command_test.go b/integration/shared/isolated/restart_app_instance_command_test.go index 20cfb37f036..5b6d275b3d7 100644 --- a/integration/shared/isolated/restart_app_instance_command_test.go +++ b/integration/shared/isolated/restart_app_instance_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/isolated/spaces_command_test.go b/integration/shared/isolated/spaces_command_test.go index 7fb2f4bea65..a67cf8c3adf 100644 --- a/integration/shared/isolated/spaces_command_test.go +++ b/integration/shared/isolated/spaces_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -30,6 +30,10 @@ var _ = Describe("spaces command", func() { helpers.TargetOrg(orgName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("there are no spaces", func() { It("displays no spaces found", func() { session := helpers.CF("spaces") diff --git a/integration/shared/isolated/version_command_test.go b/integration/shared/isolated/version_command_test.go index 3012cf7df0c..2f51b3961d3 100644 --- a/integration/shared/isolated/version_command_test.go +++ b/integration/shared/isolated/version_command_test.go @@ -3,11 +3,10 @@ package isolated import ( "strings" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - "github.com/blang/semver" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "github.com/blang/semver/v4" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/performance/performance_suite_test.go b/integration/shared/performance/performance_suite_test.go index d36919b1360..86070962f13 100644 --- a/integration/shared/performance/performance_suite_test.go +++ b/integration/shared/performance/performance_suite_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -39,7 +39,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { return nil }, func(_ []byte) { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) // Ginkgo Globals SetDefaultEventuallyTimeout(CFEventuallyTimeout) SetDefaultConsistentlyDuration(CFConsistentlyTimeout) @@ -48,17 +48,17 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.TurnOffColors() perfOrg, perfSpace = helpers.SetupReadOnlyOrgAndSpace() - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = SynchronizedAfterSuite(func() { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) homeDir = helpers.SetHomeDir() helpers.SetAPI() helpers.LoginCF() helpers.QuickDeleteOrg(perfOrg) helpers.DestroyHomeDir(homeDir) - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) }, func() {}) var _ = BeforeEach(func() { diff --git a/integration/shared/plugin/add_plugin_repo_test.go b/integration/shared/plugin/add_plugin_repo_test.go index befa5f31549..c3275aeeb77 100644 --- a/integration/shared/plugin/add_plugin_repo_test.go +++ b/integration/shared/plugin/add_plugin_repo_test.go @@ -7,8 +7,8 @@ import ( "log" "net/http" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/api_test.go b/integration/shared/plugin/api_test.go index 99bce5d40ba..09794a67db7 100644 --- a/integration/shared/plugin/api_test.go +++ b/integration/shared/plugin/api_test.go @@ -3,21 +3,26 @@ package plugin import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" ) var _ = Describe("plugin API", func() { + var orgName string BeforeEach(func() { + orgName = "" installTestPlugin() }) AfterEach(func() { + if orgName != "" { + helpers.QuickDeleteOrg(orgName) + } uninstallTestPlugin() }) @@ -63,7 +68,7 @@ var _ = Describe("plugin API", func() { Describe("GetApp", func() { var appName string BeforeEach(func() { - createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() appName = helpers.PrefixedRandomName("APP") helpers.WithHelloWorldApp(func(appDir string) { Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) @@ -78,7 +83,7 @@ var _ = Describe("plugin API", func() { Describe("GetApps", func() { var appName1, appName2 string BeforeEach(func() { - createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() appName1 = helpers.PrefixedRandomName("APP") helpers.WithHelloWorldApp(func(appDir string) { Eventually(helpers.CF("push", appName1, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) @@ -97,29 +102,35 @@ var _ = Describe("plugin API", func() { Describe("GetCurrentOrg", func() { It("gets the current targeted org", func() { - org, _ := createTargetedOrgAndSpace() - confirmTestPluginOutput("GetCurrentOrg", org) + orgName, _ = createTargetedOrgAndSpace() + confirmTestPluginOutput("GetCurrentOrg", orgName) }) }) Describe("GetCurrentSpace", func() { It("gets the current targeted Space", func() { - _, space := createTargetedOrgAndSpace() + var space string + orgName, space = createTargetedOrgAndSpace() confirmTestPluginOutput("GetCurrentSpace", space) }) }) Describe("GetOrg", func() { It("gets the given org", func() { - org, _ := createTargetedOrgAndSpace() - confirmTestPluginOutputWithArg("GetOrg", org, org) + orgName, _ = createTargetedOrgAndSpace() + confirmTestPluginOutputWithArg("GetOrg", orgName, orgName) }) }) Describe("GetOrgs", func() { + var org1, org2 string + AfterEach(func() { + helpers.QuickDeleteOrg(org1) + helpers.QuickDeleteOrg(org2) + }) It("gets information for multiple orgs", func() { - org1, _ := createTargetedOrgAndSpace() - org2, _ := createTargetedOrgAndSpace() + org1, _ = createTargetedOrgAndSpace() + org2, _ = createTargetedOrgAndSpace() orgNameRegexp := fmt.Sprintf("(?:%s|%s)", org1, org2) confirmTestPluginOutput("GetOrgs", orgNameRegexp, orgNameRegexp) }) @@ -127,17 +138,17 @@ var _ = Describe("plugin API", func() { Describe("GetOrgUsers", func() { It("returns the org users", func() { - org, _ := createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() username, _ := helpers.GetCredentials() - confirmTestPluginOutputWithArg("GetOrgUsers", org, username) + confirmTestPluginOutputWithArg("GetOrgUsers", orgName, username) }) }) Describe("GetOrgUsers", func() { It("returns the org users", func() { - org, _ := createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() username, _ := helpers.GetCredentials() - confirmTestPluginOutputWithArg("GetOrgUsers", org, username) + confirmTestPluginOutputWithArg("GetOrgUsers", orgName, username) }) }) @@ -148,7 +159,7 @@ var _ = Describe("plugin API", func() { broker *servicebrokerstub.ServiceBrokerStub ) BeforeEach(func() { - createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() serviceInstance1 = helpers.PrefixedRandomName("SI1") serviceInstance2 = helpers.PrefixedRandomName("SI2") @@ -172,7 +183,8 @@ var _ = Describe("plugin API", func() { Describe("GetSpace", func() { It("gets the given space", func() { - _, space := createTargetedOrgAndSpace() + var space string + orgName, space = createTargetedOrgAndSpace() confirmTestPluginOutputWithArg("GetSpace", space, space) }) }) @@ -181,7 +193,7 @@ var _ = Describe("plugin API", func() { var space1, space2 string BeforeEach(func() { - _, space1 = createTargetedOrgAndSpace() + orgName, space1 = createTargetedOrgAndSpace() space2 = helpers.NewSpaceName() helpers.CreateSpace(space2) }) @@ -195,8 +207,9 @@ var _ = Describe("plugin API", func() { Describe("GetSpaceUsers", func() { It("returns the space users", func() { username, _ := helpers.GetCredentials() - org, space := createTargetedOrgAndSpace() - session := helpers.CF("GetSpaceUsers", org, space) + var space string + orgName, space = createTargetedOrgAndSpace() + session := helpers.CF("GetSpaceUsers", orgName, space) Eventually(session).Should(Say(username)) Eventually(session).Should(Exit(0)) }) @@ -210,14 +223,14 @@ var _ = Describe("plugin API", func() { Describe("HasOrganization", func() { It("returns true", func() { - createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() confirmTestPluginOutput("HasOrganization", "true") }) }) Describe("HasSpace", func() { It("returns true", func() { - createTargetedOrgAndSpace() + orgName, _ = createTargetedOrgAndSpace() confirmTestPluginOutput("HasSpace", "true") }) }) diff --git a/integration/shared/plugin/help_test.go b/integration/shared/plugin/help_test.go index de5b59510f9..216c0914666 100644 --- a/integration/shared/plugin/help_test.go +++ b/integration/shared/plugin/help_test.go @@ -1,9 +1,8 @@ package plugin import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/install_plugin_command_test.go b/integration/shared/plugin/install_plugin_command_test.go index 3917214e28c..1a14289b429 100644 --- a/integration/shared/plugin/install_plugin_command_test.go +++ b/integration/shared/plugin/install_plugin_command_test.go @@ -3,15 +3,14 @@ package plugin import ( "bytes" "fmt" - "io/ioutil" "log" "net/http" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -25,7 +24,7 @@ var _ = Describe("install-plugin command", func() { ) AfterEach(func() { - pluginsHomeDirContents, err := ioutil.ReadDir(filepath.Join(homeDir, ".cf", "plugins")) + pluginsHomeDirContents, err := os.ReadDir(filepath.Join(homeDir, ".cf", "plugins")) if os.IsNotExist(err) { return } @@ -88,7 +87,7 @@ var _ = Describe("install-plugin command", func() { cfPluginHome = os.Getenv("CF_PLUGIN_HOME") var err error - newPluginHome, err = ioutil.TempDir("", "plugin-temp-dir") + newPluginHome, err = os.MkdirTemp("", "plugin-temp-dir") Expect(err).ToNot(HaveOccurred()) Expect(os.RemoveAll(newPluginHome)) @@ -231,7 +230,7 @@ var _ = Describe("install-plugin command", func() { When("the file is not an executable", func() { BeforeEach(func() { - badPlugin, err := ioutil.TempFile("", "") + badPlugin, err := os.CreateTemp("", "") Expect(err).ToNot(HaveOccurred()) pluginPath = badPlugin.Name() err = badPlugin.Close() @@ -254,7 +253,7 @@ var _ = Describe("install-plugin command", func() { When("the file is not a plugin", func() { BeforeEach(func() { var err error - pluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/non_plugin") + pluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/non_plugin") Expect(err).ToNot(HaveOccurred()) }) @@ -269,7 +268,7 @@ var _ = Describe("install-plugin command", func() { When("getting metadata from the plugin errors", func() { BeforeEach(func() { var err error - pluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/test_plugin_fails_metadata") + pluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/test_plugin_fails_metadata") Expect(err).ToNot(HaveOccurred()) }) @@ -662,7 +661,7 @@ var _ = Describe("install-plugin command", func() { ) var err error - pluginData, err = ioutil.ReadFile(pluginPath) + pluginData, err = os.ReadFile(pluginPath) Expect(err).ToNot(HaveOccurred()) server.AppendHandlers( CombineHandlers( @@ -768,10 +767,10 @@ var _ = Describe("install-plugin command", func() { When("the file is not a plugin", func() { BeforeEach(func() { var err error - pluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/non_plugin") + pluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/non_plugin") Expect(err).ToNot(HaveOccurred()) - pluginData, err := ioutil.ReadFile(pluginPath) + pluginData, err := os.ReadFile(pluginPath) Expect(err).ToNot(HaveOccurred()) server.AppendHandlers( CombineHandlers( @@ -811,7 +810,7 @@ var _ = Describe("install-plugin command", func() { ) var err error - pluginData, err = ioutil.ReadFile(pluginPath) + pluginData, err = os.ReadFile(pluginPath) Expect(err).ToNot(HaveOccurred()) server.AppendHandlers( CombineHandlers( diff --git a/integration/shared/plugin/install_plugin_command_unix_test.go b/integration/shared/plugin/install_plugin_command_unix_test.go index dafed2ebf9b..b324a3cdc74 100644 --- a/integration/shared/plugin/install_plugin_command_unix_test.go +++ b/integration/shared/plugin/install_plugin_command_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package plugin @@ -6,8 +7,8 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) diff --git a/integration/shared/plugin/install_plugin_from_repo_command_test.go b/integration/shared/plugin/install_plugin_from_repo_command_test.go index 541aa04bd11..7d41fd58f0f 100644 --- a/integration/shared/plugin/install_plugin_from_repo_command_test.go +++ b/integration/shared/plugin/install_plugin_from_repo_command_test.go @@ -4,9 +4,9 @@ import ( "net/http" "runtime" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/logs_test.go b/integration/shared/plugin/logs_test.go index 43491cfc416..c3b040b8c52 100644 --- a/integration/shared/plugin/logs_test.go +++ b/integration/shared/plugin/logs_test.go @@ -1,8 +1,8 @@ package plugin import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -60,7 +60,7 @@ var _ = Describe("logs", func() { Eventually(restageSession).Should(Exit(0)) Eventually(logSession).Should(Say("Staticfile Buildpack version")) - logSession.Kill() + logSession.Interrupt() Eventually(logSession).Should(Exit()) }) diff --git a/integration/shared/plugin/plugin_suite_test.go b/integration/shared/plugin/plugin_suite_test.go index ce67c21d879..9899a4a8a5f 100644 --- a/integration/shared/plugin/plugin_suite_test.go +++ b/integration/shared/plugin/plugin_suite_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -44,13 +44,13 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.TurnOffColors() var err error - testPluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/test_plugin") + testPluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/test_plugin") Expect(err).ToNot(HaveOccurred()) - overrideTestPluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/test_plugin_with_command_overrides") + overrideTestPluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/test_plugin_with_command_overrides") Expect(err).ToNot(HaveOccurred()) - panicTestPluginPath, err = Build("code.cloudfoundry.org/cli/integration/assets/test_plugin_with_panic") + panicTestPluginPath, err = Build("code.cloudfoundry.org/cli/v8/integration/assets/test_plugin_with_panic") Expect(err).ToNot(HaveOccurred()) }) diff --git a/integration/shared/plugin/plugins_command_test.go b/integration/shared/plugin/plugins_command_test.go index 7c596a47897..06842649b84 100644 --- a/integration/shared/plugin/plugins_command_test.go +++ b/integration/shared/plugin/plugins_command_test.go @@ -4,9 +4,9 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/runner_test.go b/integration/shared/plugin/runner_test.go index 31bdcc6c0f6..3062c5f595b 100644 --- a/integration/shared/plugin/runner_test.go +++ b/integration/shared/plugin/runner_test.go @@ -3,8 +3,8 @@ package plugin import ( "os" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/uninstall_plugin_command_test.go b/integration/shared/plugin/uninstall_plugin_command_test.go index 732b7e24aac..a076ab3f14d 100644 --- a/integration/shared/plugin/uninstall_plugin_command_test.go +++ b/integration/shared/plugin/uninstall_plugin_command_test.go @@ -4,9 +4,9 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/shared/plugin/uninstall_plugin_command_unix_test.go b/integration/shared/plugin/uninstall_plugin_command_unix_test.go index 9ad7a6e051c..4637713dc79 100644 --- a/integration/shared/plugin/uninstall_plugin_command_unix_test.go +++ b/integration/shared/plugin/uninstall_plugin_command_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package plugin @@ -6,9 +7,9 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/bind_running_security_group_command_test.go b/integration/v7/global/bind_running_security_group_command_test.go index cc294c417d6..fee39e81b6c 100644 --- a/integration/v7/global/bind_running_security_group_command_test.go +++ b/integration/v7/global/bind_running_security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/bind_security_group_command_test.go b/integration/v7/global/bind_security_group_command_test.go index 10a3a859c81..cac63d0ad92 100644 --- a/integration/v7/global/bind_security_group_command_test.go +++ b/integration/v7/global/bind_security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -36,7 +36,7 @@ var _ = Describe("bind-security-group command", func() { Eventually(session).Should(Say(`\s+bind-security-group - Bind a security group to a particular space, or all existing spaces of an org`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`\s+cf bind-security-group SECURITY_GROUP ORG \[--lifecycle \(running \| staging\)\] \[--space SPACE\]`)) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`\s+--lifecycle Lifecycle phase the group applies to\. \(Default: running\)`)) Eventually(session).Should(Say(`\s+--space Space to bind the security group to\. \(Default: all existing spaces in org\)`)) @@ -151,7 +151,7 @@ var _ = Describe("bind-security-group command", func() { Eventually(session).Should(Say("Assigning running security group %s to all spaces in org %s as %s...", secGroupName, orgName, userName)) Eventually(session).Should(Say("No spaces in org %s.", orgName)) Consistently(session).ShouldNot(Say("OK")) - Eventually(session).ShouldNot(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).ShouldNot(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -169,7 +169,7 @@ var _ = Describe("bind-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say(`Assigning running security group %s to spaces INTEGRATION-SPACE.*, INTEGRATION-SPACE.* in org %s as %s\.\.\.`, secGroupName, orgName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -181,7 +181,7 @@ var _ = Describe("bind-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say(`Assigning running security group %s to space %s in org %s as %s\.\.\.`, secGroupName, spaceName1, orgName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -193,7 +193,7 @@ var _ = Describe("bind-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say(`Assigning running security group %s to space %s in org %s as %s\.\.\.`, secGroupName, spaceName1, orgName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -206,7 +206,7 @@ var _ = Describe("bind-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say(`Assigning staging security group %s to spaces INTEGRATION-SPACE.*, INTEGRATION-SPACE.* in org %s as %s\.\.\.`, secGroupName, orgName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -217,7 +217,7 @@ var _ = Describe("bind-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say(`Assigning staging security group %s to space %s in org %s as %s\.\.\.`, secGroupName, spaceName1, orgName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/global/bind_staging_security_group_command_test.go b/integration/v7/global/bind_staging_security_group_command_test.go index 460926466bd..aaace6d40f8 100644 --- a/integration/v7/global/bind_staging_security_group_command_test.go +++ b/integration/v7/global/bind_staging_security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/create_buildpack_command_test.go b/integration/v7/global/create_buildpack_command_test.go index 3ec5cb2d6ee..5ec7d56efa9 100644 --- a/integration/v7/global/create_buildpack_command_test.go +++ b/integration/v7/global/create_buildpack_command_test.go @@ -2,14 +2,13 @@ package global import ( "bytes" - "io/ioutil" "log" "net/http" "os" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,11 +32,12 @@ var _ = Describe("create buildpack command", func() { Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Say("create-buildpack - Create a buildpack")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf create-buildpack BUILDPACK PATH POSITION \[--disable\]`)) + Eventually(session).Should(Say(`cf create-buildpack BUILDPACK PATH POSITION \[--disable\] \[--lifecycle buildpack|cnb\]`)) Eventually(session).Should(Say("TIP:")) - Eventually(session).Should(Say("Path should be a zip file, a url to a zip file, or a local directory. Position is a positive integer, sets priority, and is sorted from lowest to highest.")) + Eventually(session).Should(Say("When using the 'buildpack' lifecycle type, Path should be a zip file, a url to a zip file, or a local directory. When using the 'cnb' lifecycle, Path should be a cnb file or gzipped oci image. Position is a positive integer, sets priority, and is sorted from lowest to highest.")) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`--disable\s+Disable the buildpack from being used for staging`)) + Eventually(session).Should(Say(`--lifecycle, -l\s+Lifecycle that the buildpack will use`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("buildpacks, push")) Eventually(session).Should(Exit(0)) @@ -66,6 +66,7 @@ var _ = Describe("create buildpack command", func() { AfterEach(func() { err := os.RemoveAll(buildpackDir) Expect(err).ToNot(HaveOccurred()) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) }) When("zipping the directory errors", func() { @@ -84,9 +85,9 @@ var _ = Describe("create buildpack command", func() { When("zipping the directory succeeds", func() { BeforeEach(func() { var err error - buildpackDir, err = ioutil.TempDir("", "buildpackdir-") + buildpackDir, err = os.MkdirTemp("", "buildpackdir-") Expect(err).ToNot(HaveOccurred()) - file, err := ioutil.TempFile(buildpackDir, "myfile-") + file, err := os.CreateTemp(buildpackDir, "myfile-") Expect(err).ToNot(HaveOccurred()) defer file.Close() }) @@ -104,7 +105,7 @@ var _ = Describe("create buildpack command", func() { When("the specified directory is empty", func() { BeforeEach(func() { var err error - buildpackDir, err = ioutil.TempDir("", "empty-") + buildpackDir, err = os.MkdirTemp("", "empty-") Expect(err).ToNot(HaveOccurred()) }) @@ -118,7 +119,7 @@ var _ = Describe("create buildpack command", func() { }) }) - When("uploading from a zip", func() { + When("uploading from a zip with lifecycle 'buildpack'", func() { var stacks []string BeforeEach(func() { @@ -126,6 +127,10 @@ var _ = Describe("create buildpack command", func() { }) When("specifying a valid path", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + When("the new buildpack is unique", func() { When("the new buildpack has a nil stack", func() { It("successfully uploads a buildpack", func() { @@ -146,6 +151,10 @@ var _ = Describe("create buildpack command", func() { }) When("the new buildpack has a valid stack", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + }) + It("successfully uploads a buildpack", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -166,6 +175,10 @@ var _ = Describe("create buildpack command", func() { }) When("the new buildpack has an invalid stack", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + }) + It("returns the appropriate error", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -196,6 +209,10 @@ var _ = Describe("create buildpack command", func() { }, stacks[0]) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + }) + It("prints a warning and exits with an error", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -218,6 +235,10 @@ var _ = Describe("create buildpack command", func() { }) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + It("prints a warning and exits with an error", func() { helpers.BuildpackWithoutStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -238,6 +259,11 @@ var _ = Describe("create buildpack command", func() { }, stacks[1]) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[1], "-f")).Should(Exit(0)) + }) + It("successfully uploads a buildpack", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -265,6 +291,10 @@ var _ = Describe("create buildpack command", func() { }) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + It("prints a warning and tip, then exits with an error", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -283,6 +313,10 @@ var _ = Describe("create buildpack command", func() { }, stacks[0]) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + }) + It("prints a warning then exits with an error", func() { helpers.BuildpackWithStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1") @@ -296,15 +330,47 @@ var _ = Describe("create buildpack command", func() { }) }) }) + }) - When("specifying an invalid path", func() { - It("returns the appropriate error", func() { - session := helpers.CF("create-buildpack", buildpackName, "bogus-path", "1") + When("uploading from a cnb file with lifecycle 'buildpack'", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan("3.194.0") + }) + When("specifying a valid path", func() { + When("the new buildpack is unique", func() { + When("the new buildpack has a nil stack", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) - Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'bogus-path' does not exist")) - Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Exit(1)) + It("successfully uploads a buildpack", func() { + helpers.CNB(func(buildpackPath string) { + session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1", "--lifecycle=cnb") + Eventually(session).Should(Say(`Creating buildpack %s as %s\.\.\.`, buildpackName, username)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Say(`Uploading buildpack %s as %s\.\.\.`, buildpackName, username)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + }) + + session := helpers.CF("buildpacks") + Eventually(session).Should(Say(helpers.BuildpacksOutputRegex(helpers.BuildpackFields{ + Name: buildpackName, Position: "1"}))) + Eventually(session).Should(Exit(0)) + }) + }) }) + + }) + }) + + When("specifying an invalid path", func() { + It("returns the appropriate error", func() { + session := helpers.CF("create-buildpack", buildpackName, "bogus-path", "1") + + Eventually(session.Err).Should(Say("Incorrect Usage: The specified path 'bogus-path' does not exist")) + Eventually(session).Should(Say("USAGE:")) + Eventually(session).Should(Exit(1)) }) }) @@ -316,6 +382,10 @@ var _ = Describe("create buildpack command", func() { buildpackURL = "https://github.com/cloudfoundry/binary-buildpack/releases/download/v1.0.21/binary-buildpack-v1.0.21.zip" }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + It("successfully uploads a buildpack", func() { session := helpers.CF("create-buildpack", buildpackName, buildpackURL, "1") Eventually(session).Should(Say(`Creating buildpack %s as %s\.\.\.`, buildpackName, username)) @@ -372,6 +442,10 @@ var _ = Describe("create buildpack command", func() { When("specifying the position flag", func() { When("position is positive integer", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + It("successfully uploads buildpack in correct position", func() { helpers.BuildpackWithoutStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "3") @@ -392,6 +466,10 @@ var _ = Describe("create buildpack command", func() { }) When("specifying disable flag", func() { + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + It("disables buildpack", func() { helpers.BuildpackWithoutStack(func(buildpackPath string) { session := helpers.CF("create-buildpack", buildpackName, buildpackPath, "1", "--disable") diff --git a/integration/v7/global/create_security_group_command_test.go b/integration/v7/global/create_security_group_command_test.go index 6a171f7a36b..6c314202fbc 100644 --- a/integration/v7/global/create_security_group_command_test.go +++ b/integration/v7/global/create_security_group_command_test.go @@ -1,14 +1,13 @@ package global import ( - "io/ioutil" "os" "path/filepath" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -28,7 +27,7 @@ var _ = Describe("create-security-group command", func() { dir = helpers.TempDirAbsolutePath("", "security-group") tempPath = filepath.Join(dir, "tmpfile.json") - err := ioutil.WriteFile(tempPath, []byte(`[{ + err := os.WriteFile(tempPath, []byte(`[{ "protocol": "tcp", "destination": "10.0.11.0/24", "ports": "80,443", @@ -105,7 +104,7 @@ var _ = Describe("create-security-group command", func() { When("the security group path has invalid JSON", func() { BeforeEach(func() { - err := ioutil.WriteFile(tempPath, []byte("Invalid JSON!"), 0666) + err := os.WriteFile(tempPath, []byte("Invalid JSON!"), 0666) Expect(err).ToNot(HaveOccurred()) }) diff --git a/integration/v7/global/delete_buildpack_command_test.go b/integration/v7/global/delete_buildpack_command_test.go index 9ade0a8b247..cd74dd5c2a4 100644 --- a/integration/v7/global/delete_buildpack_command_test.go +++ b/integration/v7/global/delete_buildpack_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -31,6 +31,7 @@ var _ = Describe("delete-buildpack command", func() { Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`--force, -f\s+Force deletion without confirmation`)) Eventually(session).Should(Say(`--stack, -s\s+Specify stack to disambiguate buildpacks with the same name. Required when buildpack name is ambiguous`)) + Eventually(session).Should(Say(`--lifecycle, -l\s+Specify lifecycle to disambiguate buildpacks with the same name. Required when buildpack name is ambiguous`)) Eventually(session).Should(Say("\n")) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("buildpacks")) @@ -48,12 +49,12 @@ var _ = Describe("delete-buildpack command", func() { }) When("the buildpack doesn't exist", func() { - When("the user does not specify a stack", func() { + When("the user does not specify a stack or lifecycle", func() { It("displays a warning and exits 0", func() { session := helpers.CF("delete-buildpack", "-f", "nonexistent-buildpack") Eventually(session).Should(Say(`Deleting buildpack nonexistent-buildpack\.\.\.`)) Eventually(session).Should(Say("OK")) - Eventually(session.Err).Should(Say(`Buildpack 'nonexistent-buildpack' does not exist\.`)) + Eventually(session.Err).Should(Say(`Buildpack 'nonexistent-buildpack' not found\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -71,6 +72,33 @@ var _ = Describe("delete-buildpack command", func() { Eventually(session).Should(Exit(0)) }) }) + + When("the user specifies a lifecycle", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan("3.194.0") + }) + It("displays a warning and exits 0", func() { + session := helpers.CF("delete-buildpack", "-f", "nonexistent-buildpack", "-l", "buildpack") + Eventually(session).Should(Say(`Deleting buildpack nonexistent-buildpack with lifecycle buildpack\.\.\.`)) + Eventually(session).Should(Say("OK")) + Eventually(session.Err).Should(Say(`Buildpack 'nonexistent-buildpack' with lifecycle 'buildpack' not found\.`)) + Eventually(session).Should(Exit(0)) + }) + }) + When("the user specifies a stack and lifecycle", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan("3.194.0") + stacks = helpers.FetchStacks() + }) + + It("displays a warning and exits 0", func() { + session := helpers.CF("delete-buildpack", "-f", "nonexistent-buildpack", "-s", stacks[0], "-l", "buildpack") + Eventually(session).Should(Say(`Deleting buildpack nonexistent-buildpack with stack %s with lifecycle buildpack\.\.\.`, stacks[0])) + Eventually(session).Should(Say("OK")) + Eventually(session.Err).Should(Say(`Buildpack 'nonexistent-buildpack' with stack '%s' with lifecycle 'buildpack' does not exist\.`, stacks[0])) + Eventually(session).Should(Exit(0)) + }) + }) }) Context("there is exactly one buildpack with the specified name", func() { @@ -117,11 +145,16 @@ var _ = Describe("delete-buildpack command", func() { }, stacks[1]) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[1], "-f")).Should(Exit(0)) + }) + It("properly handles ambiguity", func() { By("failing when no stack specified") session := helpers.CF("delete-buildpack", buildpackName, "-f") - Eventually(session.Err).Should(Say("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.", buildpackName)) + Eventually(session.Err).Should(Say("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.", buildpackName)) Eventually(session).Should(Exit(1)) By("succeeding with warning when the buildpack name matches but the stack does not") @@ -158,6 +191,10 @@ var _ = Describe("delete-buildpack command", func() { Eventually(session).Should(Exit(0)) }) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) It("properly handles ambiguity", func() { By("deleting the nil stack buildpack when no stack specified") @@ -185,6 +222,10 @@ var _ = Describe("delete-buildpack command", func() { }) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + When("the user enters 'y'", func() { BeforeEach(func() { _, err := buffer.Write([]byte("y\n")) diff --git a/integration/v7/global/disable_feature_flag_command_test.go b/integration/v7/global/disable_feature_flag_command_test.go index 840fc312c41..dce622f1cbb 100644 --- a/integration/v7/global/disable_feature_flag_command_test.go +++ b/integration/v7/global/disable_feature_flag_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/enable_feature_flag_command_test.go b/integration/v7/global/enable_feature_flag_command_test.go index 05526ae8271..e9a4f94b545 100644 --- a/integration/v7/global/enable_feature_flag_command_test.go +++ b/integration/v7/global/enable_feature_flag_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/env_command_test.go b/integration/v7/global/env_command_test.go index 8b7858aa7d6..2dd17e19462 100644 --- a/integration/v7/global/env_command_test.go +++ b/integration/v7/global/env_command_test.go @@ -3,8 +3,8 @@ package global import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/global_suite_test.go b/integration/v7/global/global_suite_test.go index 0b5c246a056..f5d0b38b1a5 100644 --- a/integration/v7/global/global_suite_test.go +++ b/integration/v7/global/global_suite_test.go @@ -2,14 +2,13 @@ package global import ( "fmt" + "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) const ( @@ -40,6 +39,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.SetupSynchronizedSuite(func() { helpers.EnableFeatureFlag("diego_docker") + helpers.EnableFeatureFlag("diego_cnb") helpers.EnableFeatureFlag("service_instance_sharing") }) @@ -48,11 +48,11 @@ var _ = SynchronizedBeforeSuite(func() []byte { GinkgoWriter.Write([]byte("==============================End of Global FIRST Node Synchronized Before Each==============================")) return nil }, func(_ []byte) { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) - if GinkgoParallelNode() != 1 { + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) + if GinkgoParallelProcess() != 1 { Fail("Test suite cannot run in parallel") } - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = BeforeEach(func() { diff --git a/integration/v7/global/org_quota_command_test.go b/integration/v7/global/org_quota_command_test.go index 7161c979982..8886b56cca6 100644 --- a/integration/v7/global/org_quota_command_test.go +++ b/integration/v7/global/org_quota_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -70,6 +70,7 @@ var _ = Describe("org-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+allowed`)) Eventually(session).Should(Say(`app instances:\s+unlimited`)) Eventually(session).Should(Say(`route ports:\s+100`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/global/org_quotas_command_test.go b/integration/v7/global/org_quotas_command_test.go index f264c4ea438..c6aab764af3 100644 --- a/integration/v7/global/org_quotas_command_test.go +++ b/integration/v7/global/org_quotas_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -60,8 +60,8 @@ var _ = Describe("org-quotas command", func() { It("lists the org quotas", func() { session := helpers.CF("org-quotas") - Eventually(session).Should(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, quotaName, totalMemory, instanceMemory, routes, serviceInstances, "allowed", appInstances, reservedRoutePorts)) + Eventually(session).Should(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, quotaName, totalMemory, instanceMemory, routes, serviceInstances, "allowed", appInstances, reservedRoutePorts, "unlimited")) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/global/running_environment_variable_group_command_test.go b/integration/v7/global/running_environment_variable_group_command_test.go index 892f0ddb873..958b713f1b5 100644 --- a/integration/v7/global/running_environment_variable_group_command_test.go +++ b/integration/v7/global/running_environment_variable_group_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/running_security_groups_command_test.go b/integration/v7/global/running_security_groups_command_test.go index 8fcb31b45cb..47ec71a743d 100644 --- a/integration/v7/global/running_security_groups_command_test.go +++ b/integration/v7/global/running_security_groups_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -70,6 +70,7 @@ var _ = Describe("running-security-groups command", func() { AfterEach(func() { helpers.DeleteSecurityGroup(securityGroup) + helpers.QuickDeleteOrg(orgName) }) It("displays the globally enabled running security groups exits 0", func() { diff --git a/integration/v7/global/security_group_command_test.go b/integration/v7/global/security_group_command_test.go index 5b12514f659..64b831f4c49 100644 --- a/integration/v7/global/security_group_command_test.go +++ b/integration/v7/global/security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/set_org_role_command_test.go b/integration/v7/global/set_org_role_command_test.go index 843581fcdb9..353dc3445c8 100644 --- a/integration/v7/global/set_org_role_command_test.go +++ b/integration/v7/global/set_org_role_command_test.go @@ -1,12 +1,12 @@ package global import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" ) var _ = Describe("set-org-role command", func() { diff --git a/integration/v7/global/set_running_environment_variable_group_command_test.go b/integration/v7/global/set_running_environment_variable_group_command_test.go index bc433f82c4b..a1cbc8fa9bc 100644 --- a/integration/v7/global/set_running_environment_variable_group_command_test.go +++ b/integration/v7/global/set_running_environment_variable_group_command_test.go @@ -3,8 +3,8 @@ package global import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/set_space_role_command_test.go b/integration/v7/global/set_space_role_command_test.go index 49423502bf1..3a24e82484c 100644 --- a/integration/v7/global/set_space_role_command_test.go +++ b/integration/v7/global/set_space_role_command_test.go @@ -1,12 +1,12 @@ package global import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" ) var _ = Describe("set-space-role command", func() { @@ -26,6 +26,7 @@ var _ = Describe("set-space-role command", func() { AfterEach(func() { helpers.EnableFeatureFlag("set_roles_by_username") + helpers.QuickDeleteOrg(orgName) }) When("the user does not exist", func() { diff --git a/integration/v7/global/set_staging_environment_variable_group_command_test.go b/integration/v7/global/set_staging_environment_variable_group_command_test.go index 44f406f1147..a83b0283473 100644 --- a/integration/v7/global/set_staging_environment_variable_group_command_test.go +++ b/integration/v7/global/set_staging_environment_variable_group_command_test.go @@ -3,8 +3,8 @@ package global import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/staging_environment_variable_group_command_test.go b/integration/v7/global/staging_environment_variable_group_command_test.go index de2192dfde5..a503c847e00 100644 --- a/integration/v7/global/staging_environment_variable_group_command_test.go +++ b/integration/v7/global/staging_environment_variable_group_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/global/staging_security_groups_command_test.go b/integration/v7/global/staging_security_groups_command_test.go index 05145368cf7..16415abf1ce 100644 --- a/integration/v7/global/staging_security_groups_command_test.go +++ b/integration/v7/global/staging_security_groups_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -70,6 +70,7 @@ var _ = Describe("staging-security-groups command", func() { AfterEach(func() { helpers.DeleteSecurityGroup(securityGroup) + helpers.QuickDeleteOrg(orgName) }) It("displays the globally enabled staging security groups exits 0", func() { diff --git a/integration/v7/global/unbind_running_security_group_command_test.go b/integration/v7/global/unbind_running_security_group_command_test.go index 8bcdebb916d..359d2b69dfb 100644 --- a/integration/v7/global/unbind_running_security_group_command_test.go +++ b/integration/v7/global/unbind_running_security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +27,7 @@ var _ = Describe("unbind-running-security-group command", func() { Eventually(session).Should(Say(`\s+unbind-running-security-group - Unbind a security group from the set of security groups for running applications globally`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`\s+cf unbind-running-security-group SECURITY_GROUP`)) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say(`\s+apps, restart, running-security-groups, security-groups`)) Eventually(session).Should(Exit(0)) @@ -84,13 +84,13 @@ var _ = Describe("unbind-running-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say("Unbinding security group %s from defaults for running as %s...", secGroupName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) session = helpers.CF("unbind-running-security-group", secGroupName) Eventually(session).Should(Say("Unbinding security group %s from defaults for running as %s...", secGroupName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/global/unbind_security_group_command_test.go b/integration/v7/global/unbind_security_group_command_test.go index 5c29ace218f..bb002c43b73 100644 --- a/integration/v7/global/unbind_security_group_command_test.go +++ b/integration/v7/global/unbind_security_group_command_test.go @@ -1,8 +1,8 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -31,7 +31,7 @@ var _ = Describe("unbind-security-group command", func() { Eventually(session).Should(Say(`\s+unbind-security-group - Unbind a security group from a space`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`\s+cf unbind-security-group SECURITY_GROUP ORG SPACE \[--lifecycle \(running \| staging\)\]`)) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`\s+--lifecycle Lifecycle phase the group applies to \(Default: running\)`)) Eventually(session).Should(Say("SEE ALSO:")) @@ -153,7 +153,7 @@ var _ = Describe("unbind-security-group command", func() { Eventually(session).Should(Say(`Unbinding running security group %s from org %s / space %s as %s\.\.\.`, securityGroupName, orgName, spaceName, username)) Eventually(session.Err).Should(Say(`Security group %s not bound to space %s for lifecycle phase 'running'\.`, securityGroupName, spaceName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -172,7 +172,7 @@ var _ = Describe("unbind-security-group command", func() { session := helpers.CF("unbind-security-group", securityGroupName, orgName, spaceName) Eventually(session).Should(Say(`Unbinding running security group %s from org %s / space %s as %s\.\.\.`, securityGroupName, orgName, spaceName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -186,7 +186,7 @@ var _ = Describe("unbind-security-group command", func() { session := helpers.CF("unbind-security-group", securityGroupName, orgName, spaceName, "--lifecycle", "running") Eventually(session).Should(Say(`Unbinding running security group %s from org %s / space %s as %s\.\.\.`, securityGroupName, orgName, spaceName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) @@ -248,7 +248,7 @@ var _ = Describe("unbind-security-group command", func() { session := helpers.CF("unbind-security-group", securityGroupName, orgName, spaceName, "--lifecycle", "staging") Eventually(session).Should(Say(`Unbinding staging security group %s from org %s / space %s as %s\.\.\.`, securityGroupName, orgName, spaceName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/global/unbind_staging_security_group_command_test.go b/integration/v7/global/unbind_staging_security_group_command_test.go index d32c232716c..dc7262e851b 100644 --- a/integration/v7/global/unbind_staging_security_group_command_test.go +++ b/integration/v7/global/unbind_staging_security_group_command_test.go @@ -1,9 +1,9 @@ package global import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +27,7 @@ var _ = Describe("unbind-staging-security-group command", func() { Eventually(session).Should(Say(`\s+unbind-staging-security-group - Unbind a security group from the set of security groups for staging applications globally`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`\s+cf unbind-staging-security-group SECURITY_GROUP`)) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say(`\s+apps, restart, security-groups, staging-security-groups`)) Eventually(session).Should(Exit(0)) @@ -84,13 +84,13 @@ var _ = Describe("unbind-staging-security-group command", func() { userName, _ := helpers.GetCredentials() Eventually(session).Should(Say("Unbinding security group %s from defaults for staging as %s...", secGroupName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) session = helpers.CF("unbind-staging-security-group", secGroupName) Eventually(session).Should(Say("Unbinding security group %s from defaults for staging as %s...", secGroupName, userName)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/global/update_buildpack_command_test.go b/integration/v7/global/update_buildpack_command_test.go index e3dbfda1828..6004b9bb1ab 100644 --- a/integration/v7/global/update_buildpack_command_test.go +++ b/integration/v7/global/update_buildpack_command_test.go @@ -2,14 +2,13 @@ package global import ( "bytes" - "io/ioutil" "log" "net/http" "os" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -35,7 +34,7 @@ var _ = Describe("update-buildpack command", func() { Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(regexp.QuoteMeta(`cf update-buildpack BUILDPACK [-p PATH | -s STACK | --assign-stack NEW_STACK] [-i POSITION] [--rename NEW_NAME] [--enable|--disable] [--lock|--unlock]`))) Eventually(session).Should(Say("TIP:")) - Eventually(session).Should(Say("Path should be a zip file, a url to a zip file, or a local directory. Position is a positive integer, sets priority, and is sorted from lowest to highest.\n\n")) + Eventually(session).Should(Say("When using the 'buildpack' lifecycle type, Path should be a zip file, a url to a zip file, or a local directory. When using the 'cnb' lifecycle, Path should be a cnb file or gzipped oci image. Position is a positive integer, sets priority, and is sorted from lowest to highest.\n\n")) Eventually(session).Should(Say("Use '--assign-stack' with caution. Associating a buildpack with a stack that it does not support may result in undefined behavior. Additionally, changing this association once made may require a local copy of the buildpack.\n\n")) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`--assign-stack\s+Assign a stack to a buildpack that does not have a stack association`)) @@ -46,6 +45,7 @@ var _ = Describe("update-buildpack command", func() { Eventually(session).Should(Say(`--position, -i\s+The order in which the buildpacks are checked during buildpack auto-detection`)) Eventually(session).Should(Say(`--rename\s+Rename an existing buildpack`)) Eventually(session).Should(Say(`--stack, -s\s+Specify stack to disambiguate buildpacks with the same name`)) + Eventually(session).Should(Say(`--lifecycle, -l\s+Specify lifecycle to disambiguate buildpacks with the same name`)) Eventually(session).Should(Say(`--unlock\s+Unlock the buildpack to enable updates`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("buildpacks, create-buildpack, delete-buildpack")) @@ -66,6 +66,7 @@ var _ = Describe("update-buildpack command", func() { AfterEach(func() { helpers.DeleteBuildpackIfOnOldCCAPI(buildpackName) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) }) When("the buildpack is not provided", func() { @@ -106,13 +107,18 @@ var _ = Describe("update-buildpack command", func() { Eventually(createSession).Should(Exit(0)) }) - listSession := helpers.CF("buildpacks") + listSession := helpers.CF("buildpacks").Wait() Eventually(listSession).Should(Say(helpers.BuildpacksOutputRegex(helpers.BuildpackFields{ Name: buildpackName, Stack: stacks[0]}))) Eventually(listSession).Should(Say(helpers.BuildpacksOutputRegex(helpers.BuildpackFields{Name: buildpackName}))) Eventually(listSession).Should(Exit(0)) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + When("no stack association is specified", func() { It("acts on the buildpack with the nil stack", func() { session := helpers.CF("update-buildpack", buildpackName) @@ -167,11 +173,16 @@ var _ = Describe("update-buildpack command", func() { Eventually(listSession).Should(Exit(0)) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[1], "-f")).Should(Exit(0)) + }) + When("no stack association is specified", func() { It("displays an error saying that multiple buildpacks were found", func() { session := helpers.CF("update-buildpack", buildpackName) - Eventually(session.Err).Should(Say(`Multiple buildpacks named %s found\. Specify a stack name by using a '-s' flag\.`, buildpackName)) + Eventually(session.Err).Should(Say(`Multiple buildpacks named %s found\. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag\.`, buildpackName)) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -214,6 +225,10 @@ var _ = Describe("update-buildpack command", func() { Eventually(listSession).Should(Exit(0)) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-s", stacks[0], "-f")).Should(Exit(0)) + }) + When("no stack association is specified", func() { It("updates the only buildpack with that name", func() { session := helpers.CF("update-buildpack", buildpackName) @@ -250,6 +265,10 @@ var _ = Describe("update-buildpack command", func() { Eventually(listSession).Should(Exit(0)) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + When("only a name is provided", func() { It("prints a success message", func() { session := helpers.CF("update-buildpack", buildpackName) @@ -293,7 +312,7 @@ var _ = Describe("update-buildpack command", func() { When("the buildpack path is an empty directory", func() { BeforeEach(func() { var err error - buildpackPath, err = ioutil.TempDir("", "create-buildpack-test-") + buildpackPath, err = os.MkdirTemp("", "create-buildpack-test-") Expect(err).ToNot(HaveOccurred()) }) @@ -312,9 +331,9 @@ var _ = Describe("update-buildpack command", func() { When("the path is a buildpack directory", func() { BeforeEach(func() { var err error - buildpackPath, err = ioutil.TempDir("", "create-buildpack-test-") + buildpackPath, err = os.MkdirTemp("", "create-buildpack-test-") Expect(err).ToNot(HaveOccurred()) - file, err := ioutil.TempFile(buildpackPath, "") + file, err := os.CreateTemp(buildpackPath, "") Expect(err).ToNot(HaveOccurred()) defer file.Close() }) @@ -542,6 +561,10 @@ var _ = Describe("update-buildpack command", func() { newBuildpackName = helpers.NewBuildpackName() }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", newBuildpackName, "-f")).Should(Exit(0)) + }) + When("a buildpack with the new name does not already exist", func() { It("renames the buildpack", func() { session := helpers.CF("update-buildpack", buildpackName, "--rename", newBuildpackName) @@ -568,6 +591,10 @@ var _ = Describe("update-buildpack command", func() { Eventually(listSession).Should(Exit(0)) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", newBuildpackName, "-f")).Should(Exit(0)) + }) + It("fails to rename the buildpack", func() { session := helpers.CF("update-buildpack", buildpackName, "--rename", newBuildpackName) Eventually(session.Err).Should(Say("Buildpack with name '%s' and an unassigned stack already exists", newBuildpackName)) @@ -586,6 +613,10 @@ var _ = Describe("update-buildpack command", func() { }) }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + When("specifying enable flag", func() { It("enables buildpack", func() { session := helpers.CF("update-buildpack", buildpackName, "--enable") @@ -613,6 +644,10 @@ var _ = Describe("update-buildpack command", func() { buildpackURL = "https://github.com/cloudfoundry/binary-buildpack/releases/download/v1.0.21/binary-buildpack-v1.0.21.zip" }) + AfterEach(func() { + Eventually(helpers.CF("delete-buildpack", buildpackName, "-f")).Should(Exit(0)) + }) + Context("specifying -p argument", func() { It("fails to update buildpack", func() { session := helpers.CF("update-buildpack", buildpackName, "-p", buildpackURL) diff --git a/integration/v7/global/update_security_group_command_test.go b/integration/v7/global/update_security_group_command_test.go index 9954cddef82..e3fef975584 100644 --- a/integration/v7/global/update_security_group_command_test.go +++ b/integration/v7/global/update_security_group_command_test.go @@ -2,13 +2,12 @@ package global import ( "encoding/json" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -56,7 +55,7 @@ var _ = Describe("update-security-group command", func() { }, } - tmpRulesDir, err = ioutil.TempDir("", "spam-security-group") + tmpRulesDir, err = os.MkdirTemp("", "spam-security-group") Expect(err).ToNot(HaveOccurred()) updatedRulesPath = filepath.Join(tmpRulesDir, "spam-security-group.json") @@ -64,7 +63,7 @@ var _ = Describe("update-security-group command", func() { securityGroup, err := json.Marshal(updatedSecurityGroupRules) Expect(err).ToNot(HaveOccurred()) - err = ioutil.WriteFile(updatedRulesPath, securityGroup, 0666) + err = os.WriteFile(updatedRulesPath, securityGroup, 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -78,7 +77,7 @@ var _ = Describe("update-security-group command", func() { session := helpers.CF("update-security-group", securityGroupName, updatedRulesPath) Eventually(session).Should(Say(`Updating security group %s as %s`, securityGroupName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) session = helpers.CF("security-group", securityGroupName) @@ -121,7 +120,7 @@ var _ = Describe("update-security-group command", func() { When("the JSON file with the security group's rules is not JSON", func() { BeforeEach(func() { - err = ioutil.WriteFile(updatedRulesPath, []byte("I'm definitely not JSON"), 0666) + err = os.WriteFile(updatedRulesPath, []byte("I'm definitely not JSON"), 0666) Expect(err).ToNot(HaveOccurred()) }) It("displays a an incorrect JSON format message and fails", func() { @@ -160,7 +159,7 @@ func displaysUpdateSecurityGroupHelpText(session *Session) { Eventually(session).Should(Say(`"description": "Allow http and https traffic from ZoneA"`)) Eventually(session).Should(Say("}")) Eventually(session).Should(Say("]")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("restage, security-groups")) } diff --git a/integration/v7/isolated/add_network_policy_command_test.go b/integration/v7/isolated/add_network_policy_command_test.go index 7accd458416..9e4148d32ea 100644 --- a/integration/v7/isolated/add_network_policy_command_test.go +++ b/integration/v7/isolated/add_network_policy_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/allow_space_ssh_command_test.go b/integration/v7/isolated/allow_space_ssh_command_test.go index d80a460f386..ac74ed37a6f 100644 --- a/integration/v7/isolated/allow_space_ssh_command_test.go +++ b/integration/v7/isolated/allow_space_ssh_command_test.go @@ -1,10 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/api_command_test.go b/integration/v7/isolated/api_command_test.go index b3339b84679..fc3c244af30 100644 --- a/integration/v7/isolated/api_command_test.go +++ b/integration/v7/isolated/api_command_test.go @@ -2,20 +2,16 @@ package isolated import ( "encoding/json" - "io/ioutil" - "net/http" "os" "os/exec" "path/filepath" - "strings" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" - "github.com/onsi/gomega/ghttp" ) var _ = Describe("api command", func() { @@ -106,7 +102,7 @@ var _ = Describe("api command", func() { Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig @@ -134,25 +130,17 @@ var _ = Describe("api command", func() { When("Skip SSL Validation is required", func() { Context("API has SSL", func() { - var server *ghttp.Server - - BeforeEach(func() { + It("warns about skip SSL", func() { cliVersion := "1.0.0" - server = helpers.StartMockServerWithMinimumCLIVersion(cliVersion) + server := helpers.StartMockServerWithMinimumCLIVersion(cliVersion) apiURL = server.URL() - }) - - AfterEach(func() { - server.Close() - }) - - It("warns about skip SSL", func() { session := helpers.CF("api", apiURL) Eventually(session).Should(Say("Setting API endpoint to %s...", apiURL)) Eventually(session.Err).Should(Say("x509: certificate has expired or is not yet valid|SSL Certificate Error x509: certificate is valid for|Invalid SSL Cert for %s", apiURL)) Eventually(session.Err).Should(Say("TIP: Use 'cf api --skip-ssl-validation' to continue with an insecure API endpoint")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) + defer server.Close() }) It("sets the API endpoint", func() { @@ -165,85 +153,13 @@ var _ = Describe("api command", func() { }) }) - Context("API does not have SSL", func() { - var server *ghttp.Server - - BeforeEach(func() { - server = ghttp.NewServer() - serverAPIURL := server.URL()[7:] - - response := `{ - "links":{ - "self":{ - "href":"http://APISERVER" - }, - "bits_service":null, - "cloud_controller_v2":{ - "href":"http://APISERVER/v2", - "meta":{ - "version":"2.146.0" - } - }, - "cloud_controller_v3":{ - "href":"http://APISERVER/v3", - "meta":{ - "version":"3.81.0" - } - } - } -}` - response = strings.Replace(response, "APISERVER", serverAPIURL, -1) - server.AppendHandlers( - ghttp.CombineHandlers( - ghttp.VerifyRequest("GET", "/"), - ghttp.RespondWith(http.StatusOK, response), - ), - ) - - response2 := `{ - "links":{ - "self":{ - "href":"http://APISERVER/v3" - } - } -}` - response2 = strings.Replace(response2, "APISERVER", serverAPIURL, -1) - server.AppendHandlers( - ghttp.CombineHandlers( - ghttp.VerifyRequest("GET", "/v3"), - ghttp.RespondWith(http.StatusOK, response2), - ), - ) - - server.AppendHandlers( - ghttp.CombineHandlers( - ghttp.VerifyRequest("GET", "/"), - ghttp.RespondWith(http.StatusOK, response), - ), - ) - }) - - AfterEach(func() { - server.Close() - }) - - It("falls back to http and gives a warning", func() { - session := helpers.CF("api", server.URL(), "--skip-ssl-validation") - Eventually(session).Should(Say("Setting API endpoint to %s...", server.URL())) - Eventually(session).Should(Say("Warning: Insecure http API endpoint detected: secure https API endpoints are recommended")) - Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say("Not logged in. Use 'cf login' or 'cf login --sso' to log in.")) - Eventually(session).Should(Exit(0)) - }) - }) - It("sets SSL Disabled in the config file to true", func() { command := exec.Command("cf", "api", apiURL, "--skip-ssl-validation") session, err := Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig @@ -274,7 +190,7 @@ var _ = Describe("api command", func() { session := helpers.CF("api", apiURL) Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig @@ -296,7 +212,7 @@ var _ = Describe("api command", func() { Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig @@ -316,7 +232,7 @@ var _ = Describe("api command", func() { } Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig diff --git a/integration/v7/isolated/app_command_test.go b/integration/v7/isolated/app_command_test.go index 7eed60c44ce..033cc750372 100644 --- a/integration/v7/isolated/app_command_test.go +++ b/integration/v7/isolated/app_command_test.go @@ -2,14 +2,14 @@ package isolated import ( "fmt" - "io/ioutil" - "path/filepath" - + "os" "path" + "path/filepath" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -105,7 +105,7 @@ applications: - route: %s.%s `, appName, appName, domainName)) manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) + err := os.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) // Create manifest @@ -131,7 +131,7 @@ applications: Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+\d/2`)) Eventually(session).Should(Say(`memory usage:\s+128M`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details`)) Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) Eventually(session).Should(Exit(0)) @@ -216,7 +216,7 @@ applications: } `json:"resources"` } - helpers.Curl(&AppInfo, "/v3/apps?names=%s", appName) + helpers.Curlf(&AppInfo, "/v3/apps?names=%s", appName) appGUID = AppInfo.Resources[0].GUID }) @@ -254,6 +254,72 @@ applications: Eventually(session).Should(Exit(0)) }) }) + + When("there is an active deployment", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0)) + }) + }) + + When("the deployment strategy is rolling", func() { + When("the deployment is in progress", func() { + It("displays the message", func() { + restartSession := helpers.CF("restart", appName, "--strategy", "rolling") + + Eventually(func(g Gomega) { + session := helpers.CF("app", appName).Wait() + g.Expect(session).Should(Say("Active deployment with status DEPLOYING")) + g.Expect(session).Should(Say("strategy: rolling")) + g.Expect(session).Should(Exit(0)) + }).Should(Succeed()) + Eventually(restartSession).Should(Exit(0)) + }) + }) + }) + + When("the deployment strategy is canary", func() { + When("the deployment is paused", func() { + It("displays the message", func() { + Eventually(helpers.CF("restart", appName, "--strategy", "canary")).Should(Exit(0)) + + session1 := helpers.CF("app", appName) + Eventually(session1).Should(Say("Active deployment with status PAUSED")) + Eventually(session1).Should(Say("strategy: canary")) + Expect(session1).To(Say("canary-steps: 1/1")) + Eventually(session1).Should(Exit(0)) + }) + }) + + When("the deployment is cancelled after it is paused", func() { + It("displays the message", func() { + Eventually(helpers.CF("restart", appName, "--strategy", "canary")).Should(Exit(0)) + Eventually(helpers.CF("cancel-deployment", appName)).Should(Exit(0)) + + Eventually(func(g Gomega) { + session := helpers.CF("app", appName).Wait() + g.Expect(session).Should(Say("instances:\\s+1/1")) + g.Expect(session).ShouldNot(Say("instances:\\s+1/1")) + g.Expect(session).Should(Exit(0)) + }).Should(Succeed()) + }) + }) + }) + }) + + When("there is no active deployment", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0)) + }) + }) + + It("does not display the message", func() { + session := helpers.CF("app", appName) + Eventually(session).Should(Exit(0)) + Eventually(session).ShouldNot(Say(`Active deployment with status \w+`)) + }) + }) }) Describe("version independent display", func() { @@ -290,7 +356,7 @@ applications: }) When("the app exists", func() { - When("isolation segments are available", func() { + XWhen("isolation segments are available", func() { BeforeEach(func() { Eventually(helpers.CF("create-isolation-segment", RealIsolationSegment)).Should(Exit(0)) Eventually(helpers.CF("enable-org-isolation", orgName, RealIsolationSegment)).Should(Exit(0)) @@ -343,12 +409,27 @@ applications: }) }) + When("the app is a CNB app", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionCNB) + helpers.WithJSHelloWorld(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "--lifecycle", "cnb", "-b", "docker://docker.io/paketobuildpacks/nodejs:latest")).Should(Exit()) + }) + }) + + It("displays the app buildpacks", func() { + session := helpers.CF("app", appName) + Eventually(session).Should(Say(`paketobuildpacks\/nodejs`)) + Eventually(session).Should(Exit(0)) + }) + }) + When("the app has tcp routes", func() { var tcpDomain helpers.Domain BeforeEach(func() { tcpDomain = helpers.NewDomain(orgName, helpers.NewDomainName("tcp")) - tcpDomain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode())) + tcpDomain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelProcess())) helpers.WithHelloWorldApp(func(appDir string) { manifestContents := []byte(fmt.Sprintf(` --- @@ -358,7 +439,7 @@ applications: - route: %s:1024 `, appName, tcpDomain.Name)) manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) + err := os.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) // Create manifest diff --git a/integration/v7/isolated/apply_manifest_command_test.go b/integration/v7/isolated/apply_manifest_command_test.go index 194aec66d00..b04974d0e00 100644 --- a/integration/v7/isolated/apply_manifest_command_test.go +++ b/integration/v7/isolated/apply_manifest_command_test.go @@ -2,14 +2,13 @@ package isolated import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -266,6 +265,41 @@ var _ = Describe("apply-manifest command", func() { }) }) }) + When("--redact-env flag is provided", func() { + var ( + tempDir string + pathToManifest string + ) + + BeforeEach(func() { + var err error + tempDir, err = os.MkdirTemp("", "simple-manifest-test") + Expect(err).ToNot(HaveOccurred()) + pathToManifest = filepath.Join(tempDir, "manifest.yml") + helpers.WriteManifest(pathToManifest, map[string]interface{}{ + "applications": []map[string]interface{}{ + { + "name": appName, + "env": map[string]interface{}{ + "key1": "((var1))", + "key4": "((var2))", + }, + }, + }, + }) + }) + + It("uses the manifest with substituted variables", func() { + helpers.WithHelloWorldApp(func(dir string) { + session := helpers.CF("apply-manifest", "--redact-env", "-f", pathToManifest, "--var=var1=secret-key", "--var=var2=foobar") + Eventually(session).Should(Exit(0)) + Eventually(session).Should(Say(`key1: `)) + Consistently(session).ShouldNot(Say(`foobar`)) + Consistently(session).ShouldNot(Say(`secret-key`)) + }) + + }) + }) When("--vars are provided", func() { var ( @@ -275,7 +309,7 @@ var _ = Describe("apply-manifest command", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ diff --git a/integration/v7/isolated/apps_command_test.go b/integration/v7/isolated/apps_command_test.go index 727621e8d8c..cfe9f822dde 100644 --- a/integration/v7/isolated/apps_command_test.go +++ b/integration/v7/isolated/apps_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/auth_command_test.go b/integration/v7/isolated/auth_command_test.go index e83633edb40..ad5c879c73c 100644 --- a/integration/v7/isolated/auth_command_test.go +++ b/integration/v7/isolated/auth_command_test.go @@ -2,13 +2,13 @@ package isolated import ( "encoding/json" - "io/ioutil" + "os" "path/filepath" - "code.cloudfoundry.org/cli/api/uaa/uaaversion" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/uaa/uaaversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,11 +27,13 @@ var _ = Describe("auth command", func() { Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say("cf auth USERNAME PASSWORD\n")) - Eventually(session).Should(Say("cf auth CLIENT_ID CLIENT_SECRET --client-credentials\n\n")) + Eventually(session).Should(Say("cf auth CLIENT_ID CLIENT_SECRET --client-credentials\n")) + Eventually(session).Should(Say("cf auth CLIENT_ID CLIENT_SECRET --assertion ID-TOKEN\n")) + Eventually(session).Should(Say("cf auth CLIENT_ID --client-credentials --assertion ACCESS-TOKEN\n")) Eventually(session).Should(Say("ENVIRONMENT VARIABLES:")) Eventually(session).Should(Say(`CF_USERNAME=user\s+Authenticating user. Overridden if USERNAME argument is provided.`)) - Eventually(session).Should(Say(`CF_PASSWORD=password\s+Password associated with user. Overriden if PASSWORD argument is provided.`)) + Eventually(session).Should(Say(`CF_PASSWORD=password\s+Password associated with user. Overridden if PASSWORD argument is provided.`)) Eventually(session).Should(Say("WARNING:")) Eventually(session).Should(Say("Providing your password as a command line option is highly discouraged")) @@ -44,7 +46,8 @@ var _ = Describe("auth command", func() { Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say("--client-credentials\\s+Use \\(non-user\\) service account \\(also called client credentials\\)\n")) - Eventually(session).Should(Say("--origin\\s+Indicates the identity provider to be used for authentication\n\n")) + Eventually(session).Should(Say("--origin\\s+Indicates the identity provider to be used for authentication\n")) + Eventually(session).Should(Say("--assertion\\s+Token based authentication with assertion \\(user\\) or in combination with client-credentials \\(non-user\\)\n")) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("api, login, target")) @@ -234,7 +237,7 @@ var _ = Describe("auth command", func() { session := helpers.CF("auth", clientID, clientSecret, "--client-credentials") Eventually(session).Should(Exit(0)) - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) Expect(string(rawConfig)).ToNot(ContainSubstring(clientSecret)) @@ -276,7 +279,7 @@ var _ = Describe("auth command", func() { helpers.SkipIfUAAVersionAtLeast(uaaversion.MinUAAClientVersion) }) It("prints an error message", func() { - session := helpers.CF("auth", "some-username", "some-password", "--client-credentials", "--origin", "garbaje") + session := helpers.CF("auth", "some-username", "some-password", "--client-credentials", "--origin", "garbage") Eventually(session.Err).Should(Say("Option '--origin' requires UAA API version 4.19.0 or higher. Update your Cloud Foundry instance.")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) @@ -289,7 +292,7 @@ var _ = Describe("auth command", func() { }) When("--client-credentials is also set", func() { It("displays the appropriate error message", func() { - session := helpers.CF("auth", "some-username", "some-password", "--client-credentials", "--origin", "garbaje") + session := helpers.CF("auth", "some-username", "some-password", "--client-credentials", "--origin", "garbage") Eventually(session.Err).Should(Say("Incorrect Usage: The following arguments cannot be used together: --client-credentials, --origin")) Eventually(session).Should(Exit(1)) @@ -306,7 +309,7 @@ var _ = Describe("auth command", func() { username, password = helpers.SkipIfOIDCCredentialsNotSet() }) - It("authenticates the user", func() { + It("authenticates the user", FlakeAttempts(3), func() { session := helpers.CF("auth", username, password, "--origin", "cli-oidc-provider") Eventually(session).Should(Say("API endpoint: %s", helpers.GetAPI())) diff --git a/integration/v7/isolated/bind_route_service_command_test.go b/integration/v7/isolated/bind_route_service_command_test.go index 42895584933..a88495a0efa 100644 --- a/integration/v7/isolated/bind_route_service_command_test.go +++ b/integration/v7/isolated/bind_route_service_command_test.go @@ -4,10 +4,10 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -119,7 +119,7 @@ var _ = Describe("bind-route-service command", func() { var receiver struct { Resources []resources.RouteBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) Expect(receiver.Resources).To(HaveLen(1)) return string(receiver.Resources[0].LastOperation.State) @@ -232,11 +232,11 @@ var _ = Describe("bind-route-service command", func() { var receiver struct { Resources []resources.RouteBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) Expect(receiver.Resources).To(HaveLen(1)) var parametersReceiver map[string]interface{} - helpers.Curl(¶metersReceiver, `/v3/service_route_bindings/%s/parameters`, receiver.Resources[0].GUID) + helpers.Curlf(¶metersReceiver, `/v3/service_route_bindings/%s/parameters`, receiver.Resources[0].GUID) Expect(parametersReceiver).To(Equal(map[string]interface{}{"foo": "bar"})) }) }) diff --git a/integration/v7/isolated/bind_service_command_test.go b/integration/v7/isolated/bind_service_command_test.go index 46c3473376d..5b81facd088 100644 --- a/integration/v7/isolated/bind_service_command_test.go +++ b/integration/v7/isolated/bind_service_command_test.go @@ -4,10 +4,10 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -41,6 +41,10 @@ var _ = Describe("bind-service command", func() { Say(`\n`), Say(`\s+cf bind-service APP_NAME SERVICE_INSTANCE --binding-name BINDING_NAME\n`), Say(`\n`), + Say(`\s+Optionally provide the binding strategy type. Valid options are 'single' \(default\) and 'multiple'. The 'multiple' strategy allows multiple bindings between the same app and service instance.\n`), + Say(`\s+This is useful for credential rotation scenarios.\n`), + Say(`\n`), + Say(`\s+cf bind-service APP_NAME SERVICE_INSTANCE --strategy multiple\n`), Say(`EXAMPLES:\n`), Say(`\s+Linux/Mac:\n`), Say(`\s+cf bind-service myapp mydb -c '\{"permissions":"read-only"\}'\n`), @@ -59,6 +63,7 @@ var _ = Describe("bind-service command", func() { Say(`OPTIONS:\n`), Say(`\s+--binding-name\s+Name to expose service instance to app process with \(Default: service instance name\)\n`), Say(`\s+-c\s+Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.\n`), + Say(`\s+--strategy\s+Service binding strategy. Valid values are 'single' \(default\) and 'multiple'.\n`), Say(`\s+--wait, -w\s+Wait for the operation to complete\n`), Say(`\n`), Say(`SEE ALSO:\n`), @@ -132,7 +137,7 @@ var _ = Describe("bind-service command", func() { When("the environment is not setup correctly", func() { It("fails with the appropriate errors", func() { - helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "bind-service", "app-name", "service-name") + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, command, "app-name", "service-name") }) }) @@ -147,14 +152,14 @@ var _ = Describe("bind-service command", func() { var receiver struct { Resources []resources.ServiceCredentialBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) Expect(receiver.Resources).To(HaveLen(1)) return receiver.Resources[0] } getParameters := func(serviceInstanceName string) (receiver map[string]interface{}) { binding := getBinding(serviceInstanceName) - helpers.Curl(&receiver, "/v3/service_credential_bindings/%s/parameters", binding.GUID) + helpers.Curlf(&receiver, "/v3/service_credential_bindings/%s/parameters", binding.GUID) return } diff --git a/integration/v7/isolated/buildpacks_command_test.go b/integration/v7/isolated/buildpacks_command_test.go index 4366190137b..2946c18923e 100644 --- a/integration/v7/isolated/buildpacks_command_test.go +++ b/integration/v7/isolated/buildpacks_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -32,7 +32,7 @@ var _ = Describe("buildpacks command", func() { Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`--labels\s+Selector to filter buildpacks by labels`)) Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say("create-buildpack, delete-buildpack, rename-buildpack, update-buildpack")) + Eventually(session).Should(Say("create-buildpack, delete-buildpack, update-buildpack")) Eventually(session).Should(Exit(0)) }) }) @@ -53,33 +53,36 @@ var _ = Describe("buildpacks command", func() { username, _ := helpers.GetCredentials() Eventually(session).Should(Say("Getting buildpacks as %s...", username)) - Eventually(session).Should(Say(`position\s+name\s+stack\s+enabled\s+locked\s+filename`)) + Eventually(session).Should(Say(`position\s+name\s+stack\s+enabled\s+locked\s+state\s+filename`)) positionRegex := `\d+` enabledRegex := `true` lockedRegex := `false` - stackRegex := `(cflinuxfs[23]|windows.+)` + stackRegex := `(cflinuxfs[234]|windows.+)` + stateRegex := `READY` staticfileNameRegex := `staticfile_buildpack` // staticfileFileRegex := `staticfile[-_]buildpack-\S+` staticfileFileRegex := "" - Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s`, + Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, positionRegex, staticfileNameRegex, stackRegex, enabledRegex, lockedRegex, + stateRegex, staticfileFileRegex)) binaryNameRegex := `binary_buildpack` // binaryFileRegex := `binary[-_]buildpack-\S+` binaryFileRegex := "" - Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s`, + Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, positionRegex, binaryNameRegex, stackRegex, enabledRegex, lockedRegex, + stateRegex, binaryFileRegex)) Eventually(session).Should(Exit(0)) }) @@ -118,7 +121,7 @@ var _ = Describe("buildpacks command", func() { username, _ := helpers.GetCredentials() Expect(session).Should(Say("Getting buildpacks as %s...", username)) - Expect(session).Should(Say(`position\s+name\s+stack\s+enabled\s+locked\s+filename`)) + Expect(session).Should(Say(`position\s+name\s+stack\s+enabled\s+locked\s+state\s+filename`)) re := regexp.MustCompile(`(?:\n|\r)\d+\s+\w{8}`) buildpackMatches := re.FindAll(session.Out.Contents(), -1) @@ -128,13 +131,15 @@ var _ = Describe("buildpacks command", func() { enabledRegex := `true` lockedRegex := `false` stackRegex := `` + stateRegex := `READY` - Expect(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s`, + Expect(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, positionRegex, buildpack2, stackRegex, enabledRegex, lockedRegex, + stateRegex, "")) }) }) diff --git a/integration/v7/isolated/cancel_deployment_test.go b/integration/v7/isolated/cancel_deployment_test.go index 12f5e8d5ea3..5c342bd0ba5 100644 --- a/integration/v7/isolated/cancel_deployment_test.go +++ b/integration/v7/isolated/cancel_deployment_test.go @@ -3,11 +3,11 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -90,16 +90,32 @@ var _ = Describe("Cancel Deployment", func() { }) }) - It("succeeds", func() { - helpers.WithHelloWorldApp(func(appDir string) { - Eventually(helpers.CF("push", appName, "-p", appDir, "--strategy=rolling", "--no-wait")).Should(Exit(0)) + When("There is a rolling deployment", func() { + It("succeeds", func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "--strategy=rolling", "--no-wait")).Should(Exit(0)) + }) + + session := helpers.CF("cancel-deployment", appName) + Eventually(session).Should(Say(fmt.Sprintf("Canceling deployment for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Say(fmt.Sprintf(`TIP: Run 'cf app %s' to view app status.`, appName))) + Eventually(session).Should(Exit(0)) }) + }) - session := helpers.CF("cancel-deployment", appName) - Eventually(session).Should(Say(fmt.Sprintf("Canceling deployment for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) - Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(fmt.Sprintf(`TIP: Run 'cf app %s' to view app status.`, appName))) - Eventually(session).Should(Exit(0)) + When("There is a canary deployment", func() { + It("succeeds", func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "--strategy=canary", "--no-wait")).Should(Exit(0)) + }) + + session := helpers.CF("cancel-deployment", appName) + Eventually(session).Should(Say(fmt.Sprintf("Canceling deployment for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Say(fmt.Sprintf(`TIP: Run 'cf app %s' to view app status.`, appName))) + Eventually(session).Should(Exit(0)) + }) }) }) }) diff --git a/integration/v7/isolated/check_route_command_test.go b/integration/v7/isolated/check_route_command_test.go index 21d2915e221..4be88117516 100644 --- a/integration/v7/isolated/check_route_command_test.go +++ b/integration/v7/isolated/check_route_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/config_command_test.go b/integration/v7/isolated/config_command_test.go index f01c21d5da8..b69979e9eb2 100644 --- a/integration/v7/isolated/config_command_test.go +++ b/integration/v7/isolated/config_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "strings" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/config_test.go b/integration/v7/isolated/config_test.go index caf5c0aff5f..357cb6edad4 100644 --- a/integration/v7/isolated/config_test.go +++ b/integration/v7/isolated/config_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/v7/isolated/continue_deployment_test.go b/integration/v7/isolated/continue_deployment_test.go new file mode 100644 index 00000000000..eae66d32d62 --- /dev/null +++ b/integration/v7/isolated/continue_deployment_test.go @@ -0,0 +1,121 @@ +package isolated + +import ( + "fmt" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("Continue Deployment", func() { + Context("Help", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("continue-deployment", "APPS", "Continue the most recent deployment for an app.")) + }) + + It("displays the help information", func() { + session := helpers.CF("continue-deployment", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say(`continue-deployment - Continue the most recent deployment for an app.\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`cf continue-deployment APP_NAME \[--no-wait\]\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf continue-deployment my-app\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`app, push`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + Context("when the environment is not set up correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "continue-deployment", "appName") + }) + }) + + Context("When the environment is set up correctly", func() { + var ( + orgName string + spaceName string + appName string + userName string + ) + + BeforeEach(func() { + appName = helpers.NewAppName() + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + userName, _ = helpers.GetCredentials() + + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "-b", "staticfile_buildpack", "-i", "3", "--strategy", "canary")).Should(Exit(0)) + }) + }) + + AfterEach(func() { + Eventually(helpers.CF("delete", appName, "-f")).Should(Exit(0)) + }) + + Context("when there are no deployments", func() { + It("errors with a no deployments found error", func() { + session := helpers.CF("continue-deployment", appName) + Eventually(session).Should(Say(fmt.Sprintf("Continuing deployment for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) + Eventually(session.Err).Should(Say(`No active deployment found for app\.`)) + Eventually(session).Should(Say("FAILED")) + Eventually(session).Should(Exit(1)) + }) + }) + + Context("when the continue is successful", func() { + When("There is a canary deployment", func() { + When("instance steps are provided", func() { + It("displays the number of steps", func() { + helpers.WithHelloWorldApp(func(appDir string) { + helpers.CF("push", appName, "-p", appDir, "--strategy=canary", "--instance-steps", "10,20,30,70", "-i", "5").Wait() + }) + + session := helpers.CF("app", appName) + Eventually(session).Should(Say("canary-steps: 1/4")) + session = helpers.CF("continue-deployment", appName) + Eventually(session).Should(Say("canary-steps: 2/4")) + Eventually(session).Should(Exit(0)) + }) + }) + + When("instance steps are NOT provided", func() { + It("succeeds", func() { + helpers.WithHelloWorldApp(func(appDir string) { + helpers.CF("push", appName, "-p", appDir, "--strategy=canary").Wait() + }) + + session := helpers.CF("continue-deployment", appName) + Eventually(session).Should(Say(fmt.Sprintf("Continuing deployment for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) + Eventually(session).Should(Say(fmt.Sprintf(`TIP: Run 'cf app %s' to view app status.`, appName))) + Eventually(session).Should(Exit(0)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/copy_source_command_test.go b/integration/v7/isolated/copy_source_command_test.go index 4fb385cf4a5..a3ac06c5272 100644 --- a/integration/v7/isolated/copy_source_command_test.go +++ b/integration/v7/isolated/copy_source_command_test.go @@ -2,12 +2,12 @@ package isolated import ( "fmt" - "io/ioutil" + "io" "net/http" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -73,7 +73,7 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -147,7 +147,7 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -194,7 +194,7 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -312,7 +312,7 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -353,7 +353,76 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(string(body)).To(MatchRegexp("hello world")) + }) + }) + + Describe("command behavior when the --strategy flag is set to canary", func() { + BeforeEach(func() { + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + sourceAppName = helpers.PrefixedRandomName("hello") + targetAppName = helpers.PrefixedRandomName("banana") + + helpers.SetupCF(orgName, spaceName) + + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", sourceAppName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) + }) + + helpers.WithBananaPantsApp(func(appDir string) { + Eventually(helpers.CF("push", targetAppName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0)) + }) + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + It("copies the app to the provided space using a canary deploy", func() { + username, _ := helpers.GetCredentials() + session := helpers.CF("copy-source", sourceAppName, targetAppName, "--strategy", "canary", "--instance-steps", "20,60") + Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username)) + Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username)) + Eventually(session).Should(Say("Waiting for app to deploy...")) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 1")) + Eventually(session).Should(Say("canary-steps: 1/2")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName)) + Eventually(session).Should(Exit(0)) + + Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0)) + Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0)) + + resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) + Expect(err).ToNot(HaveOccurred()) + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(string(body)).To(MatchRegexp("hello world")) + }) + + It("displays max-in-flight when it is not the default value", func() { + username, _ := helpers.GetCredentials() + session := helpers.CF("copy-source", sourceAppName, targetAppName, "--strategy", "canary", "--max-in-flight", "2") + Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username)) + Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username)) + Eventually(session).Should(Say("Waiting for app to deploy...")) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 2")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName)) + Eventually(session).Should(Exit(0)) + + Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0)) + resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) + Expect(err).ToNot(HaveOccurred()) + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -394,7 +463,7 @@ var _ = Describe("copy-source command", func() { resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain())) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(MatchRegexp("hello world")) }) @@ -407,11 +476,13 @@ func helpText(session *Session) { Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`cf copy-source SOURCE_APP DESTINATION_APP \[-s TARGET_SPACE \[-o TARGET_ORG\]\] \[--no-restart\] \[--strategy STRATEGY\] \[--no-wait\]`)) Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say(`--strategy\s+Deployment strategy, either rolling or null`)) + Eventually(session).Should(Say(`--instance-steps`)) + Eventually(session).Should(Say(`--max-in-flight\s+Defines the maximum number of instances`)) Eventually(session).Should(Say(`--no-wait\s+ Exit when the first instance of the web process is healthy`)) Eventually(session).Should(Say(`--no-restart\s+Do not restage the destination application`)) Eventually(session).Should(Say(`--organization, -o\s+Org that contains the destination application`)) Eventually(session).Should(Say(`--space, -s\s+Space that contains the destination application`)) + Eventually(session).Should(Say(`--strategy\s+Deployment strategy can be canary, rolling or null`)) Eventually(session).Should(Say("ENVIRONMENT:")) Eventually(session).Should(Say(`CF_STAGING_TIMEOUT=15\s+Max wait time for staging, in minutes`)) Eventually(session).Should(Say(`CF_STARTUP_TIMEOUT=5\s+Max wait time for app instance startup, in minutes`)) diff --git a/integration/v7/isolated/create_app_command_test.go b/integration/v7/isolated/create_app_command_test.go index d51842fb4dd..8bca69565b3 100644 --- a/integration/v7/isolated/create_app_command_test.go +++ b/integration/v7/isolated/create_app_command_test.go @@ -1,9 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -59,7 +60,7 @@ var _ = Describe("create-app command", func() { It("tells the user that the app type is incorrect, prints help text, and exits 1", func() { session := helpers.CF("create-app", appName, "--app-type", "unknown-app-type") - Eventually(session.Err).Should(Say("Incorrect Usage: Invalid value `unknown-app-type' for option `--app-type'. Allowed values are: buildpack or docker")) + Eventually(session.Err).Should(Say("Incorrect Usage: Invalid value `unknown-app-type' for option `--app-type'. Allowed values are: buildpack, docker or cnb")) Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Exit(1)) }) @@ -105,6 +106,19 @@ var _ = Describe("create-app command", func() { Eventually(session).Should(Say("docker image:")) Eventually(session).Should(Exit(0)) }) + + It("creates the app with the cnb app type", func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionCNB) + session := helpers.CF("create-app", appName, "--app-type", "cnb", "-b", "docker://foobar.test") + userName, _ := helpers.GetCredentials() + Eventually(session).Should(Say("Creating app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("app", appName) + Eventually(session).ShouldNot(Say("docker image:")) + Eventually(session).Should(Exit(0)) + }) }) }) diff --git a/integration/v7/isolated/create_app_manifest_command_test.go b/integration/v7/isolated/create_app_manifest_command_test.go index 6c0782e2c86..c6ed633ceac 100644 --- a/integration/v7/isolated/create_app_manifest_command_test.go +++ b/integration/v7/isolated/create_app_manifest_command_test.go @@ -2,15 +2,14 @@ package isolated import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -118,7 +117,7 @@ var _ = Describe("create-app-manifest command", func() { Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) - createdFile, err := ioutil.ReadFile(manifestFilePath) + createdFile, err := os.ReadFile(manifestFilePath) Expect(err).ToNot(HaveOccurred()) Expect(createdFile).To(MatchRegexp("---")) Expect(createdFile).To(MatchRegexp("applications:")) @@ -163,7 +162,7 @@ var _ = Describe("create-app-manifest command", func() { Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) - createdFile, err := ioutil.ReadFile(newFile) + createdFile, err := os.ReadFile(newFile) Expect(err).ToNot(HaveOccurred()) Expect(createdFile).To(MatchRegexp("---")) Expect(createdFile).To(MatchRegexp("applications:")) @@ -188,7 +187,7 @@ var _ = Describe("create-app-manifest command", func() { Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) - createdFile, err := ioutil.ReadFile(existingFile) + createdFile, err := os.ReadFile(existingFile) Expect(err).ToNot(HaveOccurred()) Expect(createdFile).To(MatchRegexp("---")) Expect(createdFile).To(MatchRegexp("applications:")) diff --git a/integration/v7/isolated/create_isolation_segment_command_test.go b/integration/v7/isolated/create_isolation_segment_command_test.go index e74d5ae44da..c9daa222707 100644 --- a/integration/v7/isolated/create_isolation_segment_command_test.go +++ b/integration/v7/isolated/create_isolation_segment_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/create_org_command_test.go b/integration/v7/isolated/create_org_command_test.go index bcf40ecb8d6..fb7f999068d 100644 --- a/integration/v7/isolated/create_org_command_test.go +++ b/integration/v7/isolated/create_org_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/create_org_quota_command_test.go b/integration/v7/isolated/create_org_quota_command_test.go index d9c858d695f..f39d9adede8 100644 --- a/integration/v7/isolated/create_org_quota_command_test.go +++ b/integration/v7/isolated/create_org_quota_command_test.go @@ -1,9 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -32,7 +33,7 @@ var _ = Describe("create-org-quota command", func() { Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Say("create-org-quota - Define a new quota for an organization")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf create-org-quota ORG_QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\]`)) + Eventually(session).Should(Say(`cf create-org-quota ORG_QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\] \[-l LOG_VOLUME\]`)) Eventually(session).Should(Say("ALIAS:")) Eventually(session).Should(Say("create-quota")) Eventually(session).Should(Say("OPTIONS:")) @@ -43,6 +44,7 @@ var _ = Describe("create-org-quota command", func() { Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount. \(Default: 0\)`)) Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount. \(Default: 0\)`)) Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount. \(Default: 0\)`)) + Eventually(session).Should(Say(`-l\s+Total log volume per second all processes can have, in bytes \(e.g. 128B, 4K, 1M\). -1 represents an unlimited amount. \(Default: -1\)`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("create-org, org-quotas, set-org-quota")) Eventually(session).Should(Exit(0)) @@ -119,7 +121,8 @@ var _ = Describe("create-org-quota command", func() { "-m", "4M", "-r", "6", "--reserved-route-ports", "5", - "-s", "7") + "-s", "7", + ) Eventually(session).Should(Say("Creating org quota %s as %s...", orgQuotaName, userName)) Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) @@ -133,8 +136,30 @@ var _ = Describe("create-org-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+allowed`)) Eventually(session).Should(Say(`app instances:\s+2`)) Eventually(session).Should(Say(`route ports:\s+5`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) + + When("CAPI supports log rate limits", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("creates the quota with the specified values", func() { + + userName, _ := helpers.GetCredentials() + session := helpers.CF("create-org-quota", orgQuotaName, + "-l", "32K", + ) + Eventually(session).Should(Say("Creating org quota %s as %s...", orgQuotaName, userName)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("org-quota", orgQuotaName) + Eventually(session).Should(Say(`log volume per second:\s+32K`)) + Eventually(session).Should(Exit(0)) + }) + }) }) When("The flags are all set to -1", func() { @@ -146,7 +171,8 @@ var _ = Describe("create-org-quota command", func() { "-m", "-1", "-r", "-1", "-s", "-1", - "--reserved-route-ports", "-1") + "--reserved-route-ports", "-1", + ) Eventually(session).Should(Say("Creating org quota %s as %s...", orgQuotaName, userName)) Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) @@ -158,8 +184,29 @@ var _ = Describe("create-org-quota command", func() { Eventually(session).Should(Say(`service instances:\s+unlimited`)) Eventually(session).Should(Say(`app instances:\s+unlimited`)) Eventually(session).Should(Say(`route ports:\s+unlimited`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) + + When("CAPI supports log rate limits", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("creates the quota with the specified values", func() { + userName, _ := helpers.GetCredentials() + session := helpers.CF("create-org-quota", orgQuotaName, + "-l", "-1", + ) + Eventually(session).Should(Say("Creating org quota %s as %s...", orgQuotaName, userName)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("org-quota", orgQuotaName) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) + Eventually(session).Should(Exit(0)) + }) + }) }) }) diff --git a/integration/v7/isolated/create_package_cfignore_test.go b/integration/v7/isolated/create_package_cfignore_test.go index d9b00745b0f..342af75b3d4 100644 --- a/integration/v7/isolated/create_package_cfignore_test.go +++ b/integration/v7/isolated/create_package_cfignore_test.go @@ -1,12 +1,11 @@ package isolated import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -35,43 +34,43 @@ var _ = Describe("create-package with .cfignore", func() { It("pushes all the files except .cfignore and files ignored by default", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, nil, 0666) + err = os.WriteFile(cfIgnoreFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) darcsFile := filepath.Join(appDir, "_darcs") - err = ioutil.WriteFile(darcsFile, nil, 0666) + err = os.WriteFile(darcsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) dsFile := filepath.Join(appDir, ".DS_Store") - err = ioutil.WriteFile(dsFile, nil, 0666) + err = os.WriteFile(dsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitFile := filepath.Join(appDir, ".git") - err = ioutil.WriteFile(gitFile, nil, 0666) + err = os.WriteFile(gitFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitIgnoreFile := filepath.Join(appDir, ".gitignore") - err = ioutil.WriteFile(gitIgnoreFile, nil, 0666) + err = os.WriteFile(gitIgnoreFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) hgFile := filepath.Join(appDir, ".hg") - err = ioutil.WriteFile(hgFile, nil, 0666) + err = os.WriteFile(hgFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) manifestFile := filepath.Join(appDir, "manifest.yml") - err = ioutil.WriteFile(manifestFile, nil, 0666) + err = os.WriteFile(manifestFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) svnFile := filepath.Join(appDir, ".svn") - err = ioutil.WriteFile(svnFile, nil, 0666) + err = os.WriteFile(svnFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "create-app", appName)).Should(Exit(0)) @@ -88,15 +87,15 @@ var _ = Describe("create-package with .cfignore", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "create-app", appName)).Should(Exit(0)) @@ -112,15 +111,15 @@ var _ = Describe("create-package with .cfignore", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "create-app", appName)).Should(Exit(0)) @@ -137,18 +136,18 @@ var _ = Describe("create-package with .cfignore", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) - tmpfile, err := ioutil.TempFile("", "push-archive-integration") + tmpfile, err := os.CreateTemp("", "push-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()) @@ -183,7 +182,7 @@ var _ = Describe("create-package with .cfignore", func() { It("does not push it", func() { helpers.WithHelloWorldApp(func(appDir string) { traceFilePath := filepath.Join(appDir, "i-am-trace.txt") - err := ioutil.WriteFile(traceFilePath, nil, 0666) + err := os.WriteFile(traceFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) previousEnv = os.Getenv("CF_TRACE") @@ -203,39 +202,39 @@ var _ = Describe("create-package with .cfignore", func() { It("pushes all the files except for the files ignored by default", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) darcsFile := filepath.Join(appDir, "_darcs") - err = ioutil.WriteFile(darcsFile, nil, 0666) + err = os.WriteFile(darcsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) dsFile := filepath.Join(appDir, ".DS_Store") - err = ioutil.WriteFile(dsFile, nil, 0666) + err = os.WriteFile(dsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitFile := filepath.Join(appDir, ".git") - err = ioutil.WriteFile(gitFile, nil, 0666) + err = os.WriteFile(gitFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitIgnoreFile := filepath.Join(appDir, ".gitignore") - err = ioutil.WriteFile(gitIgnoreFile, nil, 0666) + err = os.WriteFile(gitIgnoreFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) hgFile := filepath.Join(appDir, ".hg") - err = ioutil.WriteFile(hgFile, nil, 0666) + err = os.WriteFile(hgFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) manifestFile := filepath.Join(appDir, "manifest.yml") - err = ioutil.WriteFile(manifestFile, nil, 0666) + err = os.WriteFile(manifestFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) svnFile := filepath.Join(appDir, ".svn") - err = ioutil.WriteFile(svnFile, nil, 0666) + err = os.WriteFile(svnFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "create-app", appName)).Should(Exit(0)) diff --git a/integration/v7/isolated/create_package_command_test.go b/integration/v7/isolated/create_package_command_test.go index 891934d5d6c..8344d40d256 100644 --- a/integration/v7/isolated/create_package_command_test.go +++ b/integration/v7/isolated/create_package_command_test.go @@ -1,14 +1,13 @@ package isolated import ( - "io/ioutil" "os" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -142,7 +141,7 @@ var _ = Describe("create-package command", func() { BeforeEach(func() { var err error - emptyDir, err = ioutil.TempDir("", "integration-push-path-empty") + emptyDir, err = os.MkdirTemp("", "integration-push-path-empty") Expect(err).ToNot(HaveOccurred()) }) @@ -172,7 +171,7 @@ var _ = Describe("create-package command", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "package-archive-integration") + tmpfile, err := os.CreateTemp("", "package-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()) @@ -203,7 +202,7 @@ var _ = Describe("create-package command", func() { var symlinkPath string BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "symlink-") + tempFile, err := os.CreateTemp("", "symlink-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) @@ -239,7 +238,7 @@ var _ = Describe("create-package command", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "package-archive-integration") + tmpfile, err := os.CreateTemp("", "package-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()) @@ -248,7 +247,7 @@ var _ = Describe("create-package command", func() { Expect(err).ToNot(HaveOccurred()) }) - tempFile, err := ioutil.TempFile("", "symlink-to-archive-") + tempFile, err := os.CreateTemp("", "symlink-to-archive-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).To(Succeed()) diff --git a/integration/v7/isolated/create_private_domain_test.go b/integration/v7/isolated/create_private_domain_test.go index 5e24d16b4d3..cfbbf411306 100644 --- a/integration/v7/isolated/create_private_domain_test.go +++ b/integration/v7/isolated/create_private_domain_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -100,18 +100,18 @@ var _ = Describe("create-private-domain command", func() { }) }) - When("pre-existing domain", func() { + When("preexisting domain", func() { var privateDomain1 helpers.Domain BeforeEach(func() { privateDomain1 = helpers.NewDomain(orgName, helpers.NewDomainName()) privateDomain1.Create() }) - It("should fail and return an error", func() { + It("succeeds", func() { session := helpers.CF("create-private-domain", orgName, privateDomain1.Name) Eventually(session.Err).Should(Say("The domain name \"%s\" is already in use", privateDomain1.Name)) - Eventually(session).Should(Say("FAILED")) - Eventually(session).Should(Exit(1)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) }) }) }) diff --git a/integration/v7/isolated/create_route_command_test.go b/integration/v7/isolated/create_route_command_test.go index 7c1a97dcf4d..4708d43466c 100644 --- a/integration/v7/isolated/create_route_command_test.go +++ b/integration/v7/isolated/create_route_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,9 +27,9 @@ var _ = Describe("create-route command", func() { Eventually(session).Should(Say(`USAGE:`)) Eventually(session).Should(Say(`Create an HTTP route:\n`)) - Eventually(session).Should(Say(`cf create-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\]\n`)) + Eventually(session).Should(Say(`cf create-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] \[--option OPTION=VALUE\]\n`)) Eventually(session).Should(Say(`Create a TCP route:\n`)) - Eventually(session).Should(Say(`cf create-route DOMAIN \[--port PORT\]\n`)) + Eventually(session).Should(Say(`cf create-route DOMAIN \[--port PORT\] \[--option OPTION=VALUE\]\n`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`EXAMPLES:`)) @@ -37,16 +37,18 @@ var _ = Describe("create-route command", func() { Eventually(session).Should(Say(`cf create-route example.com --hostname myapp\s+# myapp.example.com`)) Eventually(session).Should(Say(`cf create-route example.com --hostname myapp --path foo\s+# myapp.example.com/foo`)) Eventually(session).Should(Say(`cf create-route example.com --port 5000\s+# example.com:5000`)) + Eventually(session).Should(Say(`cf create-route example.com --hostname myapp -o loadbalancing=least-connection\s+# myapp.example.com with a per-route option`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`OPTIONS:`)) Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) Eventually(session).Should(Say(`--port\s+Port for the TCP route \(default: random port\)`)) + Eventually(session).Should(Say(`--option, -o\s+Set the value of a per-route option`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`SEE ALSO:`)) - Eventually(session).Should(Say(`check-route, domains, map-route, routes, unmap-route`)) + Eventually(session).Should(Say(`check-route, domains, map-route, routes, unmap-route, update-route`)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/create_service_broker_command_test.go b/integration/v7/isolated/create_service_broker_command_test.go index 7c5faf3e1e5..f50f7994023 100644 --- a/integration/v7/isolated/create_service_broker_command_test.go +++ b/integration/v7/isolated/create_service_broker_command_test.go @@ -3,11 +3,11 @@ package isolated import ( "io" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -28,22 +28,9 @@ var _ = Describe("create-service-broker command", func() { When("--help flag is set", func() { It("displays command usage to output", func() { session := helpers.CF("create-service-broker", "--help") - Eventually(session).Should(Say("NAME:")) - Eventually(session).Should(Say("\\s+create-service-broker - Create a service broker")) - - Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say("\\s+cf create-service-broker SERVICE_BROKER USERNAME PASSWORD URL \\[--space-scoped\\]")) - - Eventually(session).Should(Say("ALIAS:")) - Eventually(session).Should(Say("\\s+csb")) - - Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say("\\s+--space-scoped Make the broker's service plans only visible within the targeted space")) - - Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say("\\s+enable-service-access, service-brokers, target")) - Eventually(session).Should(Exit(0)) + + expectToRenderCreateServiceBrokerHelp(session) }) }) }) @@ -164,6 +151,55 @@ var _ = Describe("create-service-broker command", func() { }) }) }) + + When("the broker already exists", func() { + var ( + org string + cfUsername string + broker *servicebrokerstub.ServiceBrokerStub + newBroker *servicebrokerstub.ServiceBrokerStub + ) + + BeforeEach(func() { + org = helpers.SetupCFWithGeneratedOrgAndSpaceNames() + cfUsername, _ = helpers.GetCredentials() + broker = servicebrokerstub.Register() + newBroker = servicebrokerstub.Create() + }) + + AfterEach(func() { + broker.Forget() + newBroker.Forget() + helpers.QuickDeleteOrg(org) + }) + + It("fails", func() { + session := helpers.CF("create-service-broker", broker.Name, newBroker.Username, newBroker.Password, newBroker.URL) + Eventually(session).Should(Exit(1), "expected duplicate create-service-broker to fail") + + Expect(session.Out).To(SatisfyAll( + Say(`Creating service broker %s as %s...\n`, broker.Name, cfUsername), + Say(`FAILED\n`), + )) + Expect(session.Err).To(Say("Name must be unique")) + }) + + When("the --update-if-exists flag is passed", func() { + It("updates the existing broker", func() { + session := helpers.CF("create-service-broker", broker.Name, newBroker.Username, newBroker.Password, newBroker.URL, "--update-if-exists") + Eventually(session).Should(Exit(0)) + + Expect(session.Out).To(SatisfyAll( + Say("Updating service broker %s as %s...", broker.Name, cfUsername), + Say("OK"), + )) + + By("checking the URL has been updated") + session = helpers.CF("service-brokers") + Eventually(session.Out).Should(Say("%s[[:space:]]+%s", broker.Name, newBroker.URL)) + }) + }) + }) }) }) @@ -185,24 +221,37 @@ var _ = Describe("create-service-broker command", func() { When("no arguments are provided", func() { It("displays an error, naming each of the missing args and the help text", func() { session := helpers.CF("create-service-broker") - Eventually(session.Err).Should(Say("Incorrect Usage: the required arguments `SERVICE_BROKER`, `USERNAME`, `PASSWORD` and `URL` were not provided")) + Eventually(session).Should(Exit(1)) - Eventually(session).Should(Say("NAME:")) - Eventually(session).Should(Say("\\s+create-service-broker - Create a service broker")) + expectToRenderCreateServiceBrokerHelp(session) + }) + }) +}) - Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say("\\s+cf create-service-broker SERVICE_BROKER USERNAME PASSWORD URL \\[--space-scoped\\]")) +func expectToRenderCreateServiceBrokerHelp(s *Session) { + Expect(s).To(SatisfyAll( + Say(`NAME:`), + Say(`\s+create-service-broker - Create a service broker`), - Eventually(session).Should(Say("ALIAS:")) - Eventually(session).Should(Say("\\s+csb")) + Say(`USAGE:`), + Say(`\s+cf create-service-broker SERVICE_BROKER USERNAME PASSWORD URL \[--space-scoped\]`), + Say(`\s+cf create-service-broker SERVICE_BROKER USERNAME URL \[--space-scoped\]`), - Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say("\\s+--space-scoped Make the broker's service plans only visible within the targeted space")) + Say(`WARNING:`), + Say(`\s+Providing your password as a command line option is highly discouraged`), + Say(`\s+Your password may be visible to others and may be recorded in your shell history`), - Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say("\\s+enable-service-access, service-brokers, target")) + Say(`ALIAS:`), + Say(`\s+csb`), - Eventually(session).Should(Exit(1)) - }) - }) -}) + Say(`OPTIONS:`), + Say(`\s+--space-scoped\s+Make the broker's service plans only visible within the targeted space`), + Say(`\s+--update-if-exists\s+If the broker already exists, update it rather than failing. Ignores --space-scoped.`), + + Say(`ENVIRONMENT:`), + Say(`\s+CF_BROKER_PASSWORD=password\s+Password associated with user. Overridden if PASSWORD argument is provided`), + + Say(`SEE ALSO:`), + Say(`\s+enable-service-access, service-brokers, target`), + )) +} diff --git a/integration/v7/isolated/create_service_command_test.go b/integration/v7/isolated/create_service_command_test.go index 986fafe22a7..5fa3810f27c 100644 --- a/integration/v7/isolated/create_service_command_test.go +++ b/integration/v7/isolated/create_service_command_test.go @@ -1,14 +1,13 @@ package isolated import ( - "io/ioutil" "os" "path/filepath" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -347,7 +346,7 @@ var _ = Describe("create-service command", func() { BeforeEach(func() { var err error - emptyDir, err = ioutil.TempDir("", "") + emptyDir, err = os.MkdirTemp("", "") Expect(err).NotTo(HaveOccurred()) }) @@ -356,7 +355,7 @@ var _ = Describe("create-service command", func() { }) It("displays an informative message and exits 1", func() { - session := helpers.CF("create-service", "foo", "bar", serviceInstanceName, "-c", filepath.Join(emptyDir, "non-existent-file")) + session := helpers.CF("create-service", "foo", "bar", serviceInstanceName, "-c", filepath.Join(emptyDir, "nonexistent-file")) Eventually(session.Err).Should(Say("Invalid configuration provided for -c flag. Please provide a valid JSON object or path to a file containing a valid JSON object.")) Eventually(session).Should(Exit(1)) }) diff --git a/integration/v7/isolated/create_service_key_command_test.go b/integration/v7/isolated/create_service_key_command_test.go index 5101a60998d..43fc747a822 100644 --- a/integration/v7/isolated/create_service_key_command_test.go +++ b/integration/v7/isolated/create_service_key_command_test.go @@ -4,10 +4,10 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -192,11 +192,11 @@ var _ = Describe("create-service-key command", func() { var receiver struct { Resources []resources.ServiceCredentialBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) Expect(receiver.Resources).To(HaveLen(1)) var parametersReceiver map[string]interface{} - helpers.Curl(¶metersReceiver, `/v3/service_credential_bindings/%s/parameters`, receiver.Resources[0].GUID) + helpers.Curlf(¶metersReceiver, `/v3/service_credential_bindings/%s/parameters`, receiver.Resources[0].GUID) Expect(parametersReceiver).To(Equal(params)) } diff --git a/integration/v7/isolated/create_shared_domain_test.go b/integration/v7/isolated/create_shared_domain_test.go index 0d38e1ebc40..3716a355d79 100644 --- a/integration/v7/isolated/create_shared_domain_test.go +++ b/integration/v7/isolated/create_shared_domain_test.go @@ -4,9 +4,9 @@ import ( "fmt" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/create_space_command_test.go b/integration/v7/isolated/create_space_command_test.go index 55af227a89e..ad8ffcf234b 100644 --- a/integration/v7/isolated/create_space_command_test.go +++ b/integration/v7/isolated/create_space_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/create_space_quota_command_test.go b/integration/v7/isolated/create_space_quota_command_test.go index 969a2a540dd..9c4a3538d28 100644 --- a/integration/v7/isolated/create_space_quota_command_test.go +++ b/integration/v7/isolated/create_space_quota_command_test.go @@ -1,9 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -29,7 +30,7 @@ var _ = Describe("create-space-quota command", func() { Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Say("create-space-quota - Define a new quota for a space")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf create-space-quota QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\]`)) + Eventually(session).Should(Say(`cf create-space-quota QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\] \[-l LOG_VOLUME\]`)) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`-a\s+Total number of application instances. \(Default: unlimited\)`)) Eventually(session).Should(Say(`--allow-paid-service-plans\s+Allow provisioning instances of paid service plans. \(Default: disallowed\)`)) @@ -38,6 +39,7 @@ var _ = Describe("create-space-quota command", func() { Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount. \(Default: 0\)`)) Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount. \(Default: 0\)`)) Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount. \(Default: 0\)`)) + Eventually(session).Should(Say(`-l\s+Total log volume per second all processes can have, in bytes \(e.g. 128B, 4K, 1M\). -1 represents an unlimited amount. \(Default: -1\).`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("create-space, set-space-quota, space-quotas")) Eventually(session).Should(Exit(0)) @@ -58,6 +60,10 @@ var _ = Describe("create-space-quota command", func() { spaceQuotaName = helpers.QuotaName() }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("the quota name is not provided", func() { It("tells the user that the quota name is required, prints help text, and exits 1", func() { session := helpers.CF("create-space-quota") @@ -95,6 +101,7 @@ var _ = Describe("create-space-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+disallowed`)) Eventually(session).Should(Say(`app instances:\s+unlimited`)) Eventually(session).Should(Say(`route ports:\s+0`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) }) @@ -122,8 +129,26 @@ var _ = Describe("create-space-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+allowed`)) Eventually(session).Should(Say(`app instances:\s+2`)) Eventually(session).Should(Say(`route ports:\s+6`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) + + When("CAPI supports log rate limits", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("creates the quota with the specified values", func() { + session := helpers.CF("create-space-quota", spaceQuotaName, "-l", "2K") + Eventually(session).Should(Say("Creating space quota %s for org %s as %s...", spaceQuotaName, orgName, userName)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("space-quota", spaceQuotaName) + Eventually(session).Should(Say(`log volume per second:\s+2K`)) + Eventually(session).Should(Exit(0)) + }) + }) }) }) diff --git a/integration/v7/isolated/create_user_command_test.go b/integration/v7/isolated/create_user_command_test.go index 2123fb70d7a..405de9ac3ae 100644 --- a/integration/v7/isolated/create_user_command_test.go +++ b/integration/v7/isolated/create_user_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/create_user_provided_service_command_test.go b/integration/v7/isolated/create_user_provided_service_command_test.go index 50253055cba..0775f7f8258 100644 --- a/integration/v7/isolated/create_user_provided_service_command_test.go +++ b/integration/v7/isolated/create_user_provided_service_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "os" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -67,7 +67,7 @@ var _ = Describe("create-user-provided-service command", func() { }) }) - When("an superflous argument is provided", func() { + When("an superfluous argument is provided", func() { It("fails and displays command usage", func() { session := helpers.CF("create-user-provided-service", "name", "extraparam") Eventually(session).Should(Exit(1)) @@ -94,7 +94,7 @@ var _ = Describe("create-user-provided-service command", func() { }) }) - When("targetting a space", func() { + When("targeting a space", func() { var ( userName string orgName string diff --git a/integration/v7/isolated/curl_command_test.go b/integration/v7/isolated/curl_command_test.go index 600d9b12608..b0651895f35 100644 --- a/integration/v7/isolated/curl_command_test.go +++ b/integration/v7/isolated/curl_command_test.go @@ -2,15 +2,14 @@ package isolated import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -28,7 +27,7 @@ var _ = Describe("curl command", func() { Eventually(session).Should(Say(`\s+is provided via -d, a POST will be performed instead, and the Content-Type\n`)) Eventually(session).Should(Say(`\s+will be set to application/json. You may override headers with -H and the\n`)) Eventually(session).Should(Say(`\s+request method with -X.\n`)) - Eventually(session).Should(Say(`\s+For API documentation, please visit http://apidocs.cloudfoundry.org.\n`)) + Eventually(session).Should(Say(`\s+For API documentation, please visit http://v2-apidocs.cloudfoundry.org.\n`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`EXAMPLES:\n`)) @@ -60,7 +59,6 @@ var _ = Describe("curl command", func() { Eventually(session).Should(Say(`Content-Length: .+`)) Eventually(session).Should(Say(`Content-Type: .+`)) Eventually(session).Should(Say(`Date: .+`)) - Eventually(session).Should(Say(`Server: .+`)) Eventually(session).Should(Say(`X-Content-Type-Options: .+`)) Eventually(session).Should(Say(`X-Vcap-Request-Id: .+`)) } @@ -320,7 +318,7 @@ var _ = Describe("curl command", func() { BeforeEach(func() { var err error - dir, err = ioutil.TempDir("", "curl-command") + dir, err = os.MkdirTemp("", "curl-command") Expect(err).ToNot(HaveOccurred()) filePath = filepath.Join(dir, "request_body.json") @@ -328,7 +326,7 @@ var _ = Describe("curl command", func() { spaceName = helpers.NewSpaceName() jsonBody := fmt.Sprintf(`{"name":"%s", "organization_guid":"%s"}`, spaceName, orgGUID) - err = ioutil.WriteFile(filePath, []byte(jsonBody), 0666) + err = os.WriteFile(filePath, []byte(jsonBody), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -385,13 +383,13 @@ var _ = Describe("curl command", func() { When("--output is passed with a file name", func() { It("writes the response headers and body to the file", func() { - outFile, err := ioutil.TempFile("", "output*.json") + outFile, err := os.CreateTemp("", "output*.json") Expect(err).ToNot(HaveOccurred()) session := helpers.CF("curl", "/v2/apps", "-i", "--output", outFile.Name()) Eventually(session).Should(Exit(0)) Eventually(session).Should(Say("OK")) - body, err := ioutil.ReadFile(outFile.Name()) + body, err := os.ReadFile(outFile.Name()) Expect(err).ToNot(HaveOccurred()) contents := string(body) @@ -401,7 +399,6 @@ var _ = Describe("curl command", func() { Expect(contents).To(MatchRegexp(`Content-Length: .+`)) Expect(contents).To(MatchRegexp(`Content-Type: .+`)) Expect(contents).To(MatchRegexp(`Date: .+`)) - Expect(contents).To(MatchRegexp(`Server: .+`)) Expect(contents).To(MatchRegexp(`X-Content-Type-Options: .+`)) Expect(contents).To(MatchRegexp(`X-Vcap-Request-Id: .+`)) @@ -413,7 +410,7 @@ var _ = Describe("curl command", func() { var tempDir, traceFile, outFile string BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "") + tempDir, err = os.MkdirTemp("", "") Expect(err).ToNot(HaveOccurred()) traceFile = filepath.Join(tempDir, "trace.log") outFile = filepath.Join(tempDir, "output") @@ -427,11 +424,11 @@ var _ = Describe("curl command", func() { session := helpers.CFWithEnv(map[string]string{"CF_TRACE": traceFile}, "curl", "/v2/apps", "--output", outFile) Eventually(session).Should(Exit(0)) - outBytes, err := ioutil.ReadFile(outFile) + outBytes, err := os.ReadFile(outFile) Expect(err).ToNot(HaveOccurred()) Expect(string(outBytes)).To(MatchJSON(expectedJSON)) - traceBytes, err := ioutil.ReadFile(traceFile) + traceBytes, err := os.ReadFile(traceFile) Expect(err).ToNot(HaveOccurred()) Expect(traceBytes).To(ContainSubstring("REQUEST: ")) Expect(traceBytes).To(ContainSubstring("HTTP/1.1 200 OK")) @@ -467,7 +464,7 @@ var _ = Describe("curl command", func() { BeforeEach(func() { var err error - dir, err = ioutil.TempDir("", "curl-command") + dir, err = os.MkdirTemp("", "curl-command") Expect(err).ToNot(HaveOccurred()) filePath = filepath.Join(dir, "request_body.json") @@ -475,7 +472,7 @@ var _ = Describe("curl command", func() { spaceName = helpers.NewSpaceName() jsonBody = fmt.Sprintf(`{"name":"%s", "organization_guid":"%s"}`, spaceName, orgGUID) - err = ioutil.WriteFile(filePath, []byte(jsonBody), 0666) + err = os.WriteFile(filePath, []byte(jsonBody), 0666) Expect(err).ToNot(HaveOccurred()) }) diff --git a/integration/v7/isolated/delete_command_test.go b/integration/v7/isolated/delete_command_test.go index 896ae58fb35..52189edd100 100644 --- a/integration/v7/isolated/delete_command_test.go +++ b/integration/v7/isolated/delete_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -94,7 +94,7 @@ var _ = Describe("delete command", func() { Expect(err).ToNot(HaveOccurred()) }) - It("shows more information when confiriming", func() { + It("shows more information when confirming", func() { username, _ := helpers.GetCredentials() session := helpers.CFWithStdin(buffer, "delete", "-r", appName) Eventually(session).Should(Say( diff --git a/integration/v7/isolated/delete_isolation_segment_command_test.go b/integration/v7/isolated/delete_isolation_segment_command_test.go index 7c34c92ece6..d5e36161153 100644 --- a/integration/v7/isolated/delete_isolation_segment_command_test.go +++ b/integration/v7/isolated/delete_isolation_segment_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_org_command_test.go b/integration/v7/isolated/delete_org_command_test.go index 231d3e7155f..794fd1f1924 100644 --- a/integration/v7/isolated/delete_org_command_test.go +++ b/integration/v7/isolated/delete_org_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_org_quota_command_test.go b/integration/v7/isolated/delete_org_quota_command_test.go index 7ff2af4ae67..93030427381 100644 --- a/integration/v7/isolated/delete_org_quota_command_test.go +++ b/integration/v7/isolated/delete_org_quota_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_orphaned_routes_command_test.go b/integration/v7/isolated/delete_orphaned_routes_command_test.go index 6079739c767..112260f9c99 100644 --- a/integration/v7/isolated/delete_orphaned_routes_command_test.go +++ b/integration/v7/isolated/delete_orphaned_routes_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -34,7 +34,7 @@ var _ = Describe("delete-orphaned-routes command", func() { Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`SEE ALSO:`)) - Eventually(session).Should(Say(`delete-routes, routes`)) + Eventually(session).Should(Say(`delete-route, routes`)) Eventually(session).Should(Exit(0)) }) @@ -114,7 +114,7 @@ var _ = Describe("delete-orphaned-routes command", func() { }) }) - When("the user's inpiut is invalud", func() { + When("the user's input is invalid", func() { BeforeEach(func() { _, err := buffer.Write([]byte("abc\n")) Expect(err).ToNot(HaveOccurred()) diff --git a/integration/v7/isolated/delete_private_domain_command_test.go b/integration/v7/isolated/delete_private_domain_command_test.go index 36aa68854c6..e3a274dbfb4 100644 --- a/integration/v7/isolated/delete_private_domain_command_test.go +++ b/integration/v7/isolated/delete_private_domain_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -124,8 +124,8 @@ var _ = Describe("delete-private-domain command", func() { When("the domain doesn't exist", func() { It("displays OK and returns successfully", func() { - session := helpers.CFWithStdin(buffer, "delete-private-domain", "non-existent.com", "-f") - Eventually(session.Err).Should(Say(`Domain 'non-existent\.com' does not exist\.`)) + session := helpers.CFWithStdin(buffer, "delete-private-domain", "nonexistent.com", "-f") + Eventually(session.Err).Should(Say(`Domain 'nonexistent\.com' does not exist\.`)) Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/delete_route_command_test.go b/integration/v7/isolated/delete_route_command_test.go index 5d3848cfd81..151efc80ac6 100644 --- a/integration/v7/isolated/delete_route_command_test.go +++ b/integration/v7/isolated/delete_route_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_security_group_command_test.go b/integration/v7/isolated/delete_security_group_command_test.go index cfab73cda10..2356fbcf56d 100644 --- a/integration/v7/isolated/delete_security_group_command_test.go +++ b/integration/v7/isolated/delete_security_group_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -18,7 +18,7 @@ var _ = Describe("delete-security-group command", func() { Eventually(session).Should(Say(`\s+delete-security-group - Deletes a security group`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`\s+cf delete-security-group SECURITY_GROUP \[-f\]`)) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`\s+--force, -f\s+Force deletion without confirmation`)) Eventually(session).Should(Say("SEE ALSO:")) @@ -110,7 +110,7 @@ var _ = Describe("delete-security-group command", func() { Eventually(session).Should(Say(`Really delete the security group %s?`, securityGroupName)) Eventually(session).Should(Say("Deleting security group %s as %s", securityGroupName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) Eventually(helpers.CF("security-group", securityGroupName)).Should(Exit(1)) }) @@ -179,7 +179,7 @@ var _ = Describe("delete-security-group command", func() { session := helpers.CF("delete-security-group", securityGroupName, "-f") Eventually(session).Should(Say("Deleting security group %s as %s", securityGroupName, username)) Eventually(session).Should(Say("OK")) - Eventually(session).Should(Say(`TIP: Changes require an app restart \(for running\) or restage \(for staging\) to apply to existing applications.`)) + Eventually(session).Should(Say(`TIP: If Dynamic ASG's are enabled, changes will automatically apply for running and staging applications. Otherwise, changes will require an app restart \(for running\) or restage \(for staging\) to apply to existing applications\.`)) Eventually(session).Should(Exit(0)) Eventually(helpers.CF("security-group", securityGroupName)).Should(Exit(1)) }) diff --git a/integration/v7/isolated/delete_service_broker_command_test.go b/integration/v7/isolated/delete_service_broker_command_test.go index fb078ba3a59..550fb08f84c 100644 --- a/integration/v7/isolated/delete_service_broker_command_test.go +++ b/integration/v7/isolated/delete_service_broker_command_test.go @@ -1,10 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_service_command_test.go b/integration/v7/isolated/delete_service_command_test.go index b2281a327f7..3a9b0d7221c 100644 --- a/integration/v7/isolated/delete_service_command_test.go +++ b/integration/v7/isolated/delete_service_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_service_key_command_test.go b/integration/v7/isolated/delete_service_key_command_test.go index 4a055a2254b..dc33e368bf3 100644 --- a/integration/v7/isolated/delete_service_key_command_test.go +++ b/integration/v7/isolated/delete_service_key_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_shared_domain_command_test.go b/integration/v7/isolated/delete_shared_domain_command_test.go index e24f174c642..e87b6c0ba85 100644 --- a/integration/v7/isolated/delete_shared_domain_command_test.go +++ b/integration/v7/isolated/delete_shared_domain_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_space_command_test.go b/integration/v7/isolated/delete_space_command_test.go index ef7a33caa86..bc802432bf1 100644 --- a/integration/v7/isolated/delete_space_command_test.go +++ b/integration/v7/isolated/delete_space_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -194,7 +194,7 @@ var _ = Describe("delete-space command", func() { }) }) - When("the -o organzation does not exist", func() { + When("the -o organization does not exist", func() { BeforeEach(func() { helpers.LoginCF() }) diff --git a/integration/v7/isolated/delete_space_quota_command_test.go b/integration/v7/isolated/delete_space_quota_command_test.go index 6874a03544e..3eed3ed7d41 100644 --- a/integration/v7/isolated/delete_space_quota_command_test.go +++ b/integration/v7/isolated/delete_space_quota_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/delete_user_command_test.go b/integration/v7/isolated/delete_user_command_test.go index 6e4912632c9..09681834dc7 100644 --- a/integration/v7/isolated/delete_user_command_test.go +++ b/integration/v7/isolated/delete_user_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -106,8 +106,8 @@ var _ = Describe("delete-user command", func() { When("the user does not exist", func() { It("does not error but prints a message letting the user know it never existed", func() { - session := helpers.CF("delete-user", "non-existent-user", "-f") - Eventually(session).Should(Say("User 'non-existent-user' does not exist.")) + session := helpers.CF("delete-user", "nonexistent-user", "-f") + Eventually(session).Should(Say("User 'nonexistent-user' does not exist.")) Eventually(session).Should(Say("OK")) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/disable_org_isolation_command_test.go b/integration/v7/isolated/disable_org_isolation_command_test.go index 943ef2e2f33..2caf3aaf185 100644 --- a/integration/v7/isolated/disable_org_isolation_command_test.go +++ b/integration/v7/isolated/disable_org_isolation_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/disable_service_access_command_test.go b/integration/v7/isolated/disable_service_access_command_test.go index 579cf4de727..949648e6283 100644 --- a/integration/v7/isolated/disable_service_access_command_test.go +++ b/integration/v7/isolated/disable_service_access_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/disable_ssh_command_test.go b/integration/v7/isolated/disable_ssh_command_test.go index ba5563fa693..b15c334af86 100644 --- a/integration/v7/isolated/disable_ssh_command_test.go +++ b/integration/v7/isolated/disable_ssh_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -104,8 +104,13 @@ var _ = Describe("disable-ssh command", func() { Eventually(session).Should(Exit(0)) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/ssh_enabled", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"enabled": %s`, "false")) + Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnablementValue := helpers.GetsEnablementValue(bytes) + Expect(actualEnablementValue).To(Equal(false)) }) }) @@ -123,8 +128,12 @@ var _ = Describe("disable-ssh command", func() { Eventually(session).Should(Say("OK")) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/ssh_enabled", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"enabled": %s`, "false")) Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnablementValue := helpers.GetsEnablementValue(bytes) + Expect(actualEnablementValue).To(Equal(false)) }) }) }) diff --git a/integration/v7/isolated/disallow_space_ssh_command_test.go b/integration/v7/isolated/disallow_space_ssh_command_test.go index 9fad10a6263..27e35b50301 100644 --- a/integration/v7/isolated/disallow_space_ssh_command_test.go +++ b/integration/v7/isolated/disallow_space_ssh_command_test.go @@ -1,10 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/domains_command_test.go b/integration/v7/isolated/domains_command_test.go index 1fe17725ad2..b00ba1b20c9 100644 --- a/integration/v7/isolated/domains_command_test.go +++ b/integration/v7/isolated/domains_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/download_droplet_command_test.go b/integration/v7/isolated/download_droplet_command_test.go index 8f302b22792..80e5d322fd1 100644 --- a/integration/v7/isolated/download_droplet_command_test.go +++ b/integration/v7/isolated/download_droplet_command_test.go @@ -1,15 +1,14 @@ package isolated import ( - "io/ioutil" "os" "path/filepath" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -129,7 +128,7 @@ var _ = Describe("download-droplet command", func() { When("a path to a directory is provided", func() { BeforeEach(func() { - tmpDir, err := ioutil.TempDir("", "droplets") + tmpDir, err := os.MkdirTemp("", "droplets") Expect(err).NotTo(HaveOccurred()) dropletPath = tmpDir }) @@ -148,7 +147,7 @@ var _ = Describe("download-droplet command", func() { When("a path to a file is provided", func() { BeforeEach(func() { - tmpDir, err := ioutil.TempDir("", "droplets") + tmpDir, err := os.MkdirTemp("", "droplets") Expect(err).NotTo(HaveOccurred()) dropletPath = filepath.Join(tmpDir, "my-droplet.tgz") }) diff --git a/integration/v7/isolated/droplets_command_test.go b/integration/v7/isolated/droplets_command_test.go index f9bc0d39d10..6fb879ee56b 100644 --- a/integration/v7/isolated/droplets_command_test.go +++ b/integration/v7/isolated/droplets_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/enable_org_isolation_command_test.go b/integration/v7/isolated/enable_org_isolation_command_test.go index c295d97e567..d5073490b3f 100644 --- a/integration/v7/isolated/enable_org_isolation_command_test.go +++ b/integration/v7/isolated/enable_org_isolation_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/enable_service_access_command_test.go b/integration/v7/isolated/enable_service_access_command_test.go index 90b62be2e0b..f0aa4a6ce66 100644 --- a/integration/v7/isolated/enable_service_access_command_test.go +++ b/integration/v7/isolated/enable_service_access_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/enable_ssh_command_test.go b/integration/v7/isolated/enable_ssh_command_test.go index cfaa89bb3dc..4e44c8fba53 100644 --- a/integration/v7/isolated/enable_ssh_command_test.go +++ b/integration/v7/isolated/enable_ssh_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -104,8 +104,12 @@ var _ = Describe("enable-ssh command", func() { Eventually(session).Should(Exit(0)) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/ssh_enabled", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"enabled": %s`, "true")) Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnablementValue := helpers.GetsEnablementValue(bytes) + Expect(actualEnablementValue).To(Equal(true)) }) }) @@ -121,10 +125,15 @@ var _ = Describe("enable-ssh command", func() { Eventually(session).Should(Say("ssh support for app '%s' is already enabled.", appName)) Eventually(session).Should(Say("OK")) + Eventually(session).Should(Say("An app restart may be required for the change to take effect.")) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/ssh_enabled", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"enabled": %s`, "true")) Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnablementValue := helpers.GetsEnablementValue(bytes) + Expect(actualEnablementValue).To(Equal(true)) }) }) diff --git a/integration/v7/isolated/error_on_extra_arguments_test.go b/integration/v7/isolated/error_on_extra_arguments_test.go index 1f437759cbe..84cb4e44c00 100644 --- a/integration/v7/isolated/error_on_extra_arguments_test.go +++ b/integration/v7/isolated/error_on_extra_arguments_test.go @@ -1,8 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/events_command_test.go b/integration/v7/isolated/events_command_test.go index d8f7aafe8f6..90b3a72691a 100644 --- a/integration/v7/isolated/events_command_test.go +++ b/integration/v7/isolated/events_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -75,7 +75,7 @@ var _ = Describe("events command", func() { It("displays events in the list", func() { - // Order of output is hard to assert here so we will just asseert we output only the events we expect and then rely on the unit + // Order of output is hard to assert here so we will just assert we output only the events we expect and then rely on the unit // tests to validate we are passing the `order_by=-created_at` query param to CAPI. The actual ordering is CAPIs concern. session := helpers.CF("events", appName) diff --git a/integration/v7/isolated/feature_flag_command_test.go b/integration/v7/isolated/feature_flag_command_test.go index ae1b10fd07c..10a42dab0c0 100644 --- a/integration/v7/isolated/feature_flag_command_test.go +++ b/integration/v7/isolated/feature_flag_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/feature_flags_command_test.go b/integration/v7/isolated/feature_flags_command_test.go index 171d4628c5f..ea599be8116 100644 --- a/integration/v7/isolated/feature_flags_command_test.go +++ b/integration/v7/isolated/feature_flags_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/get_health_check_command_test.go b/integration/v7/isolated/get_health_check_command_test.go index d3fcf3a680a..ab834cae200 100644 --- a/integration/v7/isolated/get_health_check_command_test.go +++ b/integration/v7/isolated/get_health_check_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/get_readiness_health_check_command_test.go b/integration/v7/isolated/get_readiness_health_check_command_test.go new file mode 100644 index 00000000000..1a111cfe107 --- /dev/null +++ b/integration/v7/isolated/get_readiness_health_check_command_test.go @@ -0,0 +1,197 @@ +package isolated + +import ( + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("get-readiness-health-check command", func() { + var ( + orgName string + spaceName string + appName string + ) + + BeforeEach(func() { + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + appName = helpers.PrefixedRandomName("app") + }) + + Describe("help", func() { + When("--help flag is set", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("get-readiness-health-check", "APPS", "Show the type of readiness health check performed on an app")) + }) + + It("Displays command usage to output", func() { + session := helpers.CF("get-readiness-health-check", "--help") + + Eventually(session).Should(Say("NAME:")) + Eventually(session).Should(Say("get-readiness-health-check - Show the type of readiness health check performed on an app")) + Eventually(session).Should(Say("USAGE:")) + Eventually(session).Should(Say("cf get-readiness-health-check APP_NAME")) + + Eventually(session).Should(Exit(0)) + }) + }) + }) + + When("the app name is not provided", func() { + It("tells the user that the app name is required, prints help text, and exits 1", func() { + session := helpers.CF("get-health-check") + + Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided")) + Eventually(session).Should(Say("NAME:")) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "get-readiness-health-check", appName) + }) + }) + + When("the environment is set up correctly", func() { + var username string + + BeforeEach(func() { + helpers.SetupCF(orgName, spaceName) + username, _ = helpers.GetCredentials() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the input is invalid", func() { + When("there are not enough arguments", func() { + It("outputs the usage and exits 1", func() { + session := helpers.CF("get-readiness-health-check") + + Eventually(session.Err).Should(Say("Incorrect Usage:")) + Eventually(session).Should(Say("NAME:")) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the app exists", func() { + BeforeEach(func() { + helpers.WithProcfileApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName, "--no-start")).Should(Exit(0)) + }) + }) + + It("displays the readiness health check types for each process", func() { + session := helpers.CF("get-readiness-health-check", appName) + + Eventually(session).Should(Say(`Getting readiness health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + Eventually(session).Should(Say(`process\s+type\s+endpoint \(for http\)\s+invocation timeout\s+interval\n`)) + Eventually(session).Should(Say(`web\s+process\s+\n`)) + + Eventually(session).Should(Exit(0)) + }) + + // TODO: Implement these when the set-readiness-health-check-command is implemented + // When("the health check type is http", func() { + // BeforeEach(func() { + // Eventually(helpers.CF("set-health-check", appName, "http")).Should(Exit(0)) + // }) + + // It("shows the health check type is http with an endpoint of `/`", func() { + // session := helpers.CF("get-health-check", appName) + + // Eventually(session).Should(Say(`Getting health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + // Eventually(session).Should(Say(`process\s+health check\s+endpoint \(for http\)\s+invocation timeout\n`)) + // Eventually(session).Should(Say(`web\s+http\s+/\s+1\n`)) + + // Eventually(session).Should(Exit(0)) + // }) + // }) + + // When("the health check type is http with a custom endpoint", func() { + // BeforeEach(func() { + // Eventually(helpers.CF("set-health-check", appName, "http", "--endpoint", "/some-endpoint")).Should(Exit(0)) + // }) + + // It("shows the health check type is http with the custom endpoint", func() { + // session := helpers.CF("get-health-check", appName) + + // Eventually(session).Should(Say(`Getting health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + // Eventually(session).Should(Say(`process\s+health check\s+endpoint \(for http\)\s+invocation timeout\n`)) + // Eventually(session).Should(Say(`web\s+http\s+/some-endpoint\s+1\n`)) + + // Eventually(session).Should(Exit(0)) + // }) + // }) + + // When("the health check type is port", func() { + // BeforeEach(func() { + // Eventually(helpers.CF("set-health-check", appName, "port")).Should(Exit(0)) + // }) + + // It("shows that the health check type is port", func() { + // session := helpers.CF("get-health-check", appName) + + // Eventually(session).Should(Say(`Getting health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + // Eventually(session).Should(Say(`web\s+port\s+\d+`)) + + // Eventually(session).Should(Exit(0)) + // }) + // }) + + // When("the health check type is process", func() { + // BeforeEach(func() { + // Eventually(helpers.CF("set-health-check", appName, "process")).Should(Exit(0)) + // }) + + // It("shows that the health check type is process", func() { + // session := helpers.CF("get-health-check", appName) + + // Eventually(session).Should(Say(`Getting health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + // Eventually(session).Should(Say(`web\s+process\s+\d+`)) + + // Eventually(session).Should(Exit(0)) + // }) + // }) + + // When("the health check type changes from http to another type", func() { + // BeforeEach(func() { + // Eventually(helpers.CF("set-health-check", appName, "http", "--endpoint", "/some-endpoint")).Should(Exit(0)) + // Eventually(helpers.CF("set-health-check", appName, "process")).Should(Exit(0)) + // }) + + // It("does not show an endpoint", func() { + // session := helpers.CF("get-health-check", appName) + + // Consistently(session).ShouldNot(Say("/some-endpoint")) + // Eventually(session).Should(Say(`Getting health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + // Eventually(session).Should(Say("\n\n")) + // Eventually(session).Should(Say(`web\s+process\s+\d+`)) + + // Eventually(session).Should(Exit(0)) + // }) + // }) + }) + + When("the app does not exist", func() { + It("displays app not found and exits 1", func() { + session := helpers.CF("get-readiness-health-check", appName) + + Eventually(session).Should(Say(`Getting readiness health check type for app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, username)) + Eventually(session.Err).Should(Say("App '%s' not found", appName)) + Eventually(session).Should(Say("FAILED")) + + Eventually(session).Should(Exit(1)) + }) + }) + }) +}) diff --git a/integration/v7/isolated/help_command_test.go b/integration/v7/isolated/help_command_test.go index 46db19f9a9b..52dd5752e41 100644 --- a/integration/v7/isolated/help_command_test.go +++ b/integration/v7/isolated/help_command_test.go @@ -4,10 +4,10 @@ import ( "os/exec" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/isolated_suite_test.go b/integration/v7/isolated/isolated_suite_test.go index dc376ee9eff..caac57a4da9 100644 --- a/integration/v7/isolated/isolated_suite_test.go +++ b/integration/v7/isolated/isolated_suite_test.go @@ -3,7 +3,7 @@ package isolated import ( "testing" - "code.cloudfoundry.org/cli/integration/helpers/commonisolated" + "code.cloudfoundry.org/cli/v8/integration/helpers/commonisolated" ) const ( diff --git a/integration/v7/isolated/isolation_segments_command_test.go b/integration/v7/isolated/isolation_segments_command_test.go index 7a598102eea..3b9765546d3 100644 --- a/integration/v7/isolated/isolation_segments_command_test.go +++ b/integration/v7/isolated/isolation_segments_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/labels_command_test.go b/integration/v7/isolated/labels_command_test.go index 03d10e16c64..abb955a7b45 100644 --- a/integration/v7/isolated/labels_command_test.go +++ b/integration/v7/isolated/labels_command_test.go @@ -4,11 +4,11 @@ import ( "fmt" "regexp" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -32,7 +32,7 @@ var _ = Describe("labels command", func() { Eventually(session).Should(Say("EXAMPLES:")) Eventually(session).Should(Say(`\s+cf labels app dora`)) Eventually(session).Should(Say(`\s+cf labels org business`)) - Eventually(session).Should(Say(`\s+cf labels buildpack go_buildpack --stack cflinuxfs3`)) + Eventually(session).Should(Say(`\s+cf labels buildpack go_buildpack --stack cflinuxfs4`)) Eventually(session).Should(Say("RESOURCES:")) Eventually(session).Should(Say(`\s+app`)) Eventually(session).Should(Say(`\s+buildpack`)) @@ -111,9 +111,9 @@ var _ = Describe("labels command", func() { When("the app does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "app", "non-existent-app") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for app non-existent-app in org %s / space %s as %s...\n"), orgName, spaceName, username)) - Eventually(session.Err).Should(Say("App 'non-existent-app' not found")) + session := helpers.CF("labels", "app", "nonexistent-app") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for app nonexistent-app in org %s / space %s as %s...\n"), orgName, spaceName, username)) + Eventually(session.Err).Should(Say("App 'nonexistent-app' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -135,7 +135,7 @@ var _ = Describe("labels command", func() { Eventually(session).Should(Exit(0)) }) - It("fails if a non-existent stack is specified", func() { + It("fails if a nonexistent stack is specified", func() { session := helpers.CF("labels", "buildpack", buildpackName, "-s", "bogus-stack") Eventually(session.Err).Should(Say("Buildpack '%s' with stack 'bogus-stack' not found", buildpackName)) Eventually(session).Should(Say("FAILED")) @@ -184,12 +184,12 @@ var _ = Describe("labels command", func() { When("the buildpack is bound to a stack", func() { BeforeEach(func() { - helpers.SetupBuildpackWithStack(buildpackName, "cflinuxfs3") - session := helpers.CF("set-label", "buildpack", buildpackName, "-s", "cflinuxfs3", "some-other-key=some-other-value", "some-key=some-value") + helpers.SetupBuildpackWithStack(buildpackName, "cflinuxfs4") + session := helpers.CF("set-label", "buildpack", buildpackName, "-s", "cflinuxfs4", "some-other-key=some-other-value", "some-key=some-value") Eventually(session).Should(Exit(0)) }) AfterEach(func() { - session := helpers.CF("delete-buildpack", buildpackName, "-f", "-s", "cflinuxfs3") + session := helpers.CF("delete-buildpack", buildpackName, "-f", "-s", "cflinuxfs4") Eventually(session).Should(Exit(0)) }) @@ -203,15 +203,15 @@ var _ = Describe("labels command", func() { }) It("lists the labels when the stack is specified", func() { - session := helpers.CF("labels", "buildpack", buildpackName, "-s", "cflinuxfs3") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for buildpack %s with stack %s as %s...\n\n"), buildpackName, "cflinuxfs3", username)) + session := helpers.CF("labels", "buildpack", buildpackName, "-s", "cflinuxfs4") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for buildpack %s with stack %s as %s...\n\n"), buildpackName, "cflinuxfs4", username)) Eventually(session).Should(Say(`key\s+value`)) Eventually(session).Should(Say(`some-key\s+some-value`)) Eventually(session).Should(Say(`some-other-key\s+some-other-value`)) Eventually(session).Should(Exit(0)) }) - It("fails if a non-existent stack is specified", func() { + It("fails if a nonexistent stack is specified", func() { session := helpers.CF("labels", "buildpack", buildpackName, "-s", "bogus-stack") Eventually(session.Err).Should(Say("Buildpack '%s' with stack 'bogus-stack' not found", buildpackName)) Eventually(session).Should(Say("FAILED")) @@ -229,16 +229,16 @@ var _ = Describe("labels command", func() { newStackName = helpers.NewStackName() helpers.CreateStack(newStackName) helpers.SetupBuildpackWithStack(buildpackName, newStackName) - helpers.SetupBuildpackWithStack(buildpackName, "cflinuxfs3") + helpers.SetupBuildpackWithStack(buildpackName, "cflinuxfs4") session := helpers.CF("set-label", "buildpack", buildpackName, "-s", newStackName, "my-stack-some-other-key=some-other-value", "some-key=some-value") Eventually(session).Should(Exit(0)) - session = helpers.CF("set-label", "buildpack", buildpackName, "--stack", "cflinuxfs3", + session = helpers.CF("set-label", "buildpack", buildpackName, "--stack", "cflinuxfs4", "cfl2=var2", "cfl1=var1") Eventually(session).Should(Exit(0)) }) AfterEach(func() { - session := helpers.CF("delete-buildpack", buildpackName, "-f", "-s", "cflinuxfs3") + session := helpers.CF("delete-buildpack", buildpackName, "-f", "-s", "cflinuxfs4") Eventually(session).Should(Exit(0)) session = helpers.CF("delete-buildpack", buildpackName, "-f", "-s", newStackName) Eventually(session).Should(Exit(0)) @@ -247,19 +247,19 @@ var _ = Describe("labels command", func() { It("fails when no stack is given", func() { session := helpers.CF("labels", "buildpack", buildpackName) - Eventually(session.Err).Should(Say(fmt.Sprintf(`Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.`, buildpackName))) + Eventually(session.Err).Should(Say(fmt.Sprintf(`Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.`, buildpackName))) Eventually(session).Should(Say(`FAILED`)) Eventually(session).Should(Exit(1)) }) It("fails when an empty-string stack is given", func() { session := helpers.CF("labels", "buildpack", buildpackName, "--stack", "") - Eventually(session.Err).Should(Say(fmt.Sprintf(`Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.`, buildpackName))) + Eventually(session.Err).Should(Say(fmt.Sprintf(`Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.`, buildpackName))) Eventually(session).Should(Say(`FAILED`)) Eventually(session).Should(Exit(1)) }) - It("fails when a non-existent stack is given", func() { + It("fails when a nonexistent stack is given", func() { session := helpers.CF("labels", "buildpack", buildpackName, "-s", "bogus-stack") Eventually(session.Err).Should(Say("Buildpack '%s' with stack 'bogus-stack' not found", buildpackName)) Eventually(session).Should(Say("FAILED")) @@ -275,9 +275,9 @@ var _ = Describe("labels command", func() { Eventually(session).Should(Exit(0)) }) - It("lists the labels for buildpackName/cflinuxfs3", func() { - session := helpers.CF("labels", "buildpack", buildpackName, "--stack", "cflinuxfs3") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for buildpack %s with stack cflinuxfs3 as %s...\n\n"), buildpackName, username)) + It("lists the labels for buildpackName/cflinuxfs4", func() { + session := helpers.CF("labels", "buildpack", buildpackName, "--stack", "cflinuxfs4") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for buildpack %s with stack cflinuxfs4 as %s...\n\n"), buildpackName, username)) Eventually(session).Should(Say(`key\s+value`)) Eventually(session).Should(Say(`cfl1\s+var1`)) Eventually(session).Should(Say(`cfl2\s+var2`)) @@ -306,7 +306,7 @@ var _ = Describe("labels command", func() { Eventually(session).Should(Exit(0)) }) - It("fails if a non-existent stack is specified", func() { + It("fails if a nonexistent stack is specified", func() { session := helpers.CF("labels", "buildpack", buildpackName, "-s", "bogus-stack") Eventually(session.Err).Should(Say("Buildpack '%s' with stack 'bogus-stack' not found", buildpackName)) Eventually(session).Should(Say("FAILED")) @@ -363,10 +363,10 @@ var _ = Describe("labels command", func() { When("the domain does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "domain", "non-existent-domain") + session := helpers.CF("labels", "domain", "nonexistent-domain") Eventually(session).Should(Exit(1)) - Expect(session).To(Say(regexp.QuoteMeta("Getting labels for domain non-existent-domain as %s...\n\n"), username)) - Expect(session.Err).To(Say("Domain 'non-existent-domain' not found")) + Expect(session).To(Say(regexp.QuoteMeta("Getting labels for domain nonexistent-domain as %s...\n\n"), username)) + Expect(session.Err).To(Say("Domain 'nonexistent-domain' not found")) Expect(session).To(Say("FAILED")) }) }) @@ -407,9 +407,9 @@ var _ = Describe("labels command", func() { When("the org does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "org", "non-existent-org") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for org %s as %s...\n\n"), "non-existent-org", username)) - Eventually(session.Err).Should(Say("Organization 'non-existent-org' not found")) + session := helpers.CF("labels", "org", "nonexistent-org") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for org %s as %s...\n\n"), "nonexistent-org", username)) + Eventually(session.Err).Should(Say("Organization 'nonexistent-org' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -469,9 +469,9 @@ var _ = Describe("labels command", func() { When("the route does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "route", "non-existent-route.example.com") + session := helpers.CF("labels", "route", "nonexistent-route.example.com") Eventually(session).Should(Exit(1)) - Expect(session).Should(Say(regexp.QuoteMeta("Getting labels for route non-existent-route.example.com in org %s / space %s as %s...\n"), orgName, spaceName, username)) + Expect(session).Should(Say(regexp.QuoteMeta("Getting labels for route nonexistent-route.example.com in org %s / space %s as %s...\n"), orgName, spaceName, username)) Expect(session.Err).To(Say("Domain 'example.com' not found")) Expect(session).To(Say("FAILED")) }) @@ -522,9 +522,9 @@ var _ = Describe("labels command", func() { When("the service broker does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "service-broker", "non-existent-broker") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-broker %s as %s...\n\n"), "non-existent-broker", username)) - Eventually(session.Err).Should(Say("Service broker 'non-existent-broker' not found")) + session := helpers.CF("labels", "service-broker", "nonexistent-broker") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-broker %s as %s...\n\n"), "nonexistent-broker", username)) + Eventually(session.Err).Should(Say("Service broker 'nonexistent-broker' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -574,9 +574,9 @@ var _ = Describe("labels command", func() { When("does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "service-instance", "non-existent-app") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-instance non-existent-app in org %s / space %s as %s...\n"), orgName, spaceName, username)) - Eventually(session.Err).Should(Say("Service instance 'non-existent-app' not found")) + session := helpers.CF("labels", "service-instance", "nonexistent-app") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-instance nonexistent-app in org %s / space %s as %s...\n"), orgName, spaceName, username)) + Eventually(session.Err).Should(Say("Service instance 'nonexistent-app' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -641,9 +641,9 @@ var _ = Describe("labels command", func() { When("the service offering does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "service-offering", "non-existent-offering") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-offering non-existent-offering as %s...\n"), username)) - Eventually(session.Err).Should(Say("Service offering 'non-existent-offering' not found")) + session := helpers.CF("labels", "service-offering", "nonexistent-offering") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-offering nonexistent-offering as %s...\n"), username)) + Eventually(session.Err).Should(Say("Service offering 'nonexistent-offering' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -709,9 +709,9 @@ var _ = Describe("labels command", func() { When("the service plan does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "service-plan", "non-existent-plan") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-plan non-existent-plan as %s...\n"), username)) - Eventually(session.Err).Should(Say("Service plan 'non-existent-plan' not found")) + session := helpers.CF("labels", "service-plan", "nonexistent-plan") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for service-plan nonexistent-plan as %s...\n"), username)) + Eventually(session.Err).Should(Say("Service plan 'nonexistent-plan' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -758,9 +758,9 @@ var _ = Describe("labels command", func() { When("the stack does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "stack", "non-existent-stack") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for stack %s as %s...\n\n"), "non-existent-stack", username)) - Eventually(session.Err).Should(Say("Stack 'non-existent-stack' not found")) + session := helpers.CF("labels", "stack", "nonexistent-stack") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for stack %s as %s...\n\n"), "nonexistent-stack", username)) + Eventually(session.Err).Should(Say("Stack 'nonexistent-stack' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -803,9 +803,9 @@ var _ = Describe("labels command", func() { When("the space does not exist", func() { It("displays an error", func() { - session := helpers.CF("labels", "space", "non-existent-space") - Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for space %s in org %s as %s...\n"), "non-existent-space", orgName, username)) - Eventually(session.Err).Should(Say("Space 'non-existent-space' not found")) + session := helpers.CF("labels", "space", "nonexistent-space") + Eventually(session).Should(Say(regexp.QuoteMeta("Getting labels for space %s in org %s as %s...\n"), "nonexistent-space", orgName, username)) + Eventually(session.Err).Should(Say("Space 'nonexistent-space' not found")) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) diff --git a/integration/v7/isolated/login_command_test.go b/integration/v7/isolated/login_command_test.go index 70004c90b57..8df76815d3e 100644 --- a/integration/v7/isolated/login_command_test.go +++ b/integration/v7/isolated/login_command_test.go @@ -3,19 +3,17 @@ package isolated import ( "encoding/json" "fmt" - "io/ioutil" - "net/http" "net/url" + "os" "path/filepath" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" - "github.com/onsi/gomega/ghttp" ) var _ = Describe("login command", func() { @@ -114,7 +112,7 @@ var _ = Describe("login command", func() { Eventually(session).Should(Exit(0)) }) It("writes fields to the config file when targeting an API", func() { - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig @@ -223,7 +221,7 @@ var _ = Describe("login command", func() { }) When("the API endpoint's scheme is https", func() { - // This test is somewhat redundant because the integration test setup will have alreayd logged in successfully with certificates at this point + // This test is somewhat redundant because the integration test setup will have already logged in successfully with certificates at this point // In the interest of test coverage however, we have decided to keep it in. When("the OS provides a valid SSL Certificate (Unix: SSL_CERT_FILE or SSL_CERT_DIR Environment variables) (Windows: Import-Certificate call)", func() { BeforeEach(func() { @@ -243,63 +241,6 @@ var _ = Describe("login command", func() { Expect(session).Should(Say("API endpoint: %s", apiURL)) }) }) - - When("the SSL Certificate is invalid", func() { - var server *ghttp.Server - - BeforeEach(func() { - cliVersion := "1.0.0" - server = helpers.StartMockServerWithMinimumCLIVersion(cliVersion) - fakeTokenResponse := map[string]string{ - "access_token": "", - "token_type": "bearer", - } - server.RouteToHandler(http.MethodPost, "/oauth/token", - ghttp.RespondWithJSONEncoded(http.StatusOK, fakeTokenResponse)) - server.RouteToHandler(http.MethodGet, "/v3/organizations", - ghttp.RespondWith(http.StatusOK, `{ - "total_results": 0, - "total_pages": 1, - "resources": []}`)) - }) - - AfterEach(func() { - server.Close() - }) - - It("errors when --skip-ssl-validation is not provided", func() { - session := helpers.CF("login", "-a", server.URL()) - Eventually(session).Should(Say("API endpoint: %s", server.URL())) - Eventually(session).Should(Say("FAILED")) - Eventually(session.Err).Should(Say("Invalid SSL Cert for %s", server.URL())) - Eventually(session.Err).Should(Say("TIP: Use 'cf login --skip-ssl-validation' to continue with an insecure API endpoint")) - Eventually(session).Should(Exit(1)) - }) - - It("doesn't complain about an invalid cert when we specify --skip-ssl-validation", func() { - session := helpers.CF("login", "-a", server.URL(), "--skip-ssl-validation") - Eventually(session).Should(Exit(0)) - - Expect(string(session.Err.Contents())).Should(Not(ContainSubstring("Invalid SSL Cert for %s", server.URL()))) - }) - - When("targeted with --skip-ssl-validation", func() { - BeforeEach(func() { - Eventually(helpers.CF("api", server.URL(), "--skip-ssl-validation")).Should(Exit(0)) - }) - - When("logging in without --skip-ssl-validation", func() { - It("displays a helpful error message and exits 1", func() { - session := helpers.CF("login", "-a", server.URL()) - Eventually(session).Should(Say("API endpoint: %s", server.URL())) - Eventually(session).Should(Say("FAILED")) - Eventually(session.Err).Should(Say("Invalid SSL Cert for %s", server.URL())) - Eventually(session.Err).Should(Say("TIP: Use 'cf login --skip-ssl-validation' to continue with an insecure API endpoint")) - Eventually(session).Should(Exit(1)) - }) - }) - }) - }) }) }) @@ -318,7 +259,12 @@ var _ = Describe("login command", func() { input := NewBuffer() _, err := input.Write([]byte("bad-passcode-again\nbad-passcode-strikes-back\n")) Expect(err).ToNot(HaveOccurred()) - session := helpers.CFWithStdin(input, "login", "--sso-passcode", "some-passcode") + var session *Session + if skipSSLValidation { + session = helpers.CFWithStdin(input, "login", "--sso-passcode", "some-passcode", "--skip-ssl-validation") + } else { + session = helpers.CFWithStdin(input, "login", "--sso-passcode", "some-passcode") + } Eventually(session).Should(Say("API endpoint:\\s+" + helpers.GetAPI())) Eventually(session).Should(Say(`Authenticating\.\.\.`)) Eventually(session.Err).Should(Say(`Invalid passcode`)) @@ -352,7 +298,12 @@ var _ = Describe("login command", func() { When("the user provides the --origin flag", func() { It("logs in successfully", func() { username, password := helpers.GetCredentials() - session := helpers.CF("login", "-u", username, "-p", password, "--origin", "uaa") + var session *Session + if skipSSLValidation { + session = helpers.CF("login", "-u", username, "-p", password, "--origin", "uaa", "--skip-ssl-validation") + } else { + session = helpers.CF("login", "-u", username, "-p", password, "--origin", "uaa") + } Eventually(session).Should(Say("API endpoint:\\s+" + helpers.GetAPI())) Eventually(session).Should(Say(`Authenticating\.\.\.`)) Eventually(session).Should(Say(`OK`)) @@ -461,7 +412,12 @@ var _ = Describe("login command", func() { When("the user provides the -p and -u flags", func() { Context("and the credentials are correct", func() { It("logs in successfully", func() { - session := helpers.CF("login", "-p", password, "-u", username) + var session *Session + if skipSSLValidation { + session = helpers.CF("login", "-p", password, "-u", username, "--skip-ssl-validation") + } else { + session = helpers.CF("login", "-p", password, "-u", username) + } Eventually(session).Should(Say("API endpoint:\\s+" + helpers.GetAPI())) Eventually(session).Should(Say(`Authenticating\.\.\.`)) Eventually(session).Should(Say(`OK`)) @@ -513,72 +469,6 @@ var _ = Describe("login command", func() { }) }) }) - - When("MFA is enabled", func() { - var ( - mfaCode string - server *ghttp.Server - ) - - BeforeEach(func() { - password = "some-password" - mfaCode = "123456" - server = helpers.StartAndTargetMockServerWithAPIVersions(helpers.DefaultV2Version, helpers.DefaultV3Version) - helpers.AddMfa(server, password, mfaCode) - }) - - AfterEach(func() { - server.Close() - }) - - When("correct MFA code and credentials are provided", func() { - BeforeEach(func() { - fakeTokenResponse := map[string]string{ - "access_token": "", - "token_type": "bearer", - } - server.RouteToHandler(http.MethodPost, "/oauth/token", - ghttp.RespondWithJSONEncoded(http.StatusOK, fakeTokenResponse)) - server.RouteToHandler(http.MethodGet, "/v3/organizations", - ghttp.RespondWith(http.StatusOK, `{ - "total_results": 0, - "total_pages": 1, - "resources": []}`)) - }) - - It("logs in the user", func() { - input := NewBuffer() - _, err := input.Write([]byte(username + "\n" + password + "\n" + mfaCode + "\n")) - Expect(err).ToNot(HaveOccurred()) - session := helpers.CFWithStdin(input, "login") - Eventually(session).Should(Say("Email: ")) - Eventually(session).Should(Say("\n")) - Eventually(session).Should(Say("Password:")) - Eventually(session).Should(Say("\n")) - Eventually(session).Should(Say("MFA Code \\( Register at %[1]s \\)", server.URL())) - Eventually(session).Should(Exit(0)) - }) - }) - - When("incorrect MFA code and credentials are provided", func() { - It("fails", func() { - input := NewBuffer() - wrongMfaCode := mfaCode + "foo" - _, err := input.Write([]byte(username + "\n" + password + "\n" + wrongMfaCode + "\n" + password + "\n" + wrongMfaCode + "\n")) - Expect(err).ToNot(HaveOccurred()) - session := helpers.CFWithStdin(input, "login") - Eventually(session).Should(Say("Password: ")) - Eventually(session).Should(Say("MFA Code \\( Register at %[1]s \\)", server.URL())) - Eventually(session).Should(Say("Password: ")) - Eventually(session).Should(Say("MFA Code \\( Register at %[1]s \\)", server.URL())) - Eventually(session).Should(Say("Not logged in. Use 'cf login' or 'cf login --sso' to log in.")) - Eventually(session).Should(Say("FAILED")) - Eventually(session.Err).Should(Say("Unable to authenticate.")) - - Eventually(session).Should(Exit(1)) - }) - }) - }) }) Describe("Client Credentials", func() { @@ -667,38 +557,6 @@ var _ = Describe("login command", func() { Eventually(setOrgRoleSession).Should(Exit(0)) }) - When("there are more than 50 orgs", func() { - var server *ghttp.Server - - BeforeEach(func() { - server = helpers.StartAndTargetMockServerWithAPIVersions(helpers.DefaultV2Version, helpers.DefaultV3Version) - helpers.AddLoginRoutes(server) - helpers.AddFiftyOneOrgs(server) - // handle request for spaces under "org20" - helpers.AddEmptyPaginatedResponse(server, "/v3/spaces?order_by=name&organization_guids=f6653aac-938e-4469-9a66-56a02796412b") - }) - - AfterEach(func() { - server.Close() - }) - - It("displays a message and prompts the user for the org name", func() { - input := NewBuffer() - _, wErr := input.Write([]byte(fmt.Sprintf("%s\n", "org20"))) // "org20" is one of the orgs in the test fixture - Expect(wErr).ToNot(HaveOccurred()) - - session := helpers.CFWithStdin(input, "login", "-u", username, "-p", password, "--skip-ssl-validation") - - Eventually(session).Should(Say("Select an org:")) - Eventually(session).Should(Say("There are too many options to display; please type in the name.")) - Eventually(session).Should(Say("\n\n")) - Eventually(session).Should(Say(regexp.QuoteMeta(`Org (enter to skip):`))) - Eventually(session).Should(Say(`Targeted org org20\.`)) - - Eventually(session).Should(Exit(0)) - }) - }) - When("user selects an organization by using numbered list", func() { It("prompts the user for org and targets the selected org", func() { input := NewBuffer() @@ -724,7 +582,12 @@ var _ = Describe("login command", func() { _, err := input.Write([]byte("3\n")) Expect(err).ToNot(HaveOccurred()) - session := helpers.CFWithStdin(input, "login", "-u", username, "-p", password) + var session *Session + if skipSSLValidation { + session = helpers.CFWithStdin(input, "login", "-u", username, "-p", password, "--skip-ssl-validation") + } else { + session = helpers.CFWithStdin(input, "login", "-u", username, "-p", password) + } Eventually(session).Should(Say(regexp.QuoteMeta("Select an org:"))) Eventually(session).Should(Say(regexp.QuoteMeta(`Org (enter to skip):`))) @@ -753,7 +616,7 @@ var _ = Describe("login command", func() { }) When("user does not select an organization", func() { - It("succesfully logs in but does not target any org", func() { + It("successfully logs in but does not target any org", func() { input := NewBuffer() _, err := input.Write([]byte("\n")) Expect(err).ToNot(HaveOccurred()) @@ -1113,35 +976,6 @@ var _ = Describe("login command", func() { Eventually(targetSession).Should(Say("No space targeted, use 'cf target -s SPACE'")) }) }) - - When("there are more than 50 spaces", func() { - var server *ghttp.Server - BeforeEach(func() { - server = helpers.StartAndTargetMockServerWithAPIVersions(helpers.DefaultV2Version, helpers.DefaultV3Version) - helpers.AddLoginRoutes(server) - helpers.AddFiftyOneSpaces(server) - }) - - AfterEach(func() { - server.Close() - }) - - It("displays a message and prompts the user for the space name", func() { - input := NewBuffer() - _, wErr := input.Write([]byte(fmt.Sprintf("%s\n", "test-space-1"))) - Expect(wErr).ToNot(HaveOccurred()) - - session := helpers.CFWithStdin(input, "login", "-u", username, "-p", password, "--skip-ssl-validation") - - Eventually(session).Should(Say("Select a space:")) - Eventually(session).Should(Say("There are too many options to display; please type in the name.")) - Eventually(session).Should(Say("\n\n")) - Eventually(session).Should(Say(regexp.QuoteMeta(`Space (enter to skip):`))) - Eventually(session).Should(Say(`Targeted space test-space-1\.`)) - - Eventually(session).Should(Exit(0)) - }) - }) }) }) }) diff --git a/integration/v7/isolated/logout_command_test.go b/integration/v7/isolated/logout_command_test.go index fb8ab630ac3..45709ccf380 100644 --- a/integration/v7/isolated/logout_command_test.go +++ b/integration/v7/isolated/logout_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/logs_command_test.go b/integration/v7/isolated/logs_command_test.go index 73cc08eac5f..6331e89fa0a 100644 --- a/integration/v7/isolated/logs_command_test.go +++ b/integration/v7/isolated/logs_command_test.go @@ -6,10 +6,10 @@ import ( "os/exec" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/map_route_command_test.go b/integration/v7/isolated/map_route_command_test.go index 3aaec9b04e5..4d0804e7641 100644 --- a/integration/v7/isolated/map_route_command_test.go +++ b/integration/v7/isolated/map_route_command_test.go @@ -3,11 +3,11 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -29,17 +29,18 @@ var _ = Describe("map-route command", func() { Eventually(session).Should(Say(`USAGE:`)) Eventually(session).Should(Say(`Map an HTTP route:\n`)) - Eventually(session).Should(Say(`cf map-route APP_NAME DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] \[--app-protocol PROTOCOL\]\n`)) + Eventually(session).Should(Say(`cf map-route APP_NAME DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] \[--app-protocol PROTOCOL\] \[--option OPTION=VALUE\]\n`)) Eventually(session).Should(Say(`Map a TCP route:\n`)) - Eventually(session).Should(Say(`cf map-route APP_NAME DOMAIN \[--port PORT]\n`)) + Eventually(session).Should(Say(`cf map-route APP_NAME DOMAIN \[--port PORT] \[--option OPTION=VALUE\]\n`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`EXAMPLES:`)) - Eventually(session).Should(Say(`cf map-route my-app example.com # example.com`)) - Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost # myhost.example.com`)) - Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --path foo # myhost.example.com/foo`)) - Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com`)) - Eventually(session).Should(Say(`cf map-route my-app example.com --port 5000 # example.com:5000`)) + Eventually(session).Should(Say(`cf map-route my-app example.com # example.com`)) + Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost # myhost.example.com`)) + Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost -o loadbalancing=least-connection # myhost.example.com with a per-route option`)) + Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --path foo # myhost.example.com/foo`)) + Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com`)) + Eventually(session).Should(Say(`cf map-route my-app example.com --port 5000 # example.com:5000`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`OPTIONS:`)) @@ -47,11 +48,12 @@ var _ = Describe("map-route command", func() { Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) Eventually(session).Should(Say(`--port\s+Port for the TCP route \(default: random port\)`)) Eventually(session).Should(Say(`--app-protocol\s+\[Beta flag, subject to change\] Protocol for the route destination \(default: http1\). Only applied to HTTP routes`)) + Eventually(session).Should(Say(`--option, -o\s+Set the value of a per-route option`)) Eventually(session).Should(Say(`\n`)) Eventually(session).Should(Say(`SEE ALSO:`)) - Eventually(session).Should(Say(`create-route, routes, unmap-route`)) + Eventually(session).Should(Say(`create-route, routes, unmap-route, update-route`)) Eventually(session).Should(Exit(0)) }) @@ -72,12 +74,14 @@ var _ = Describe("map-route command", func() { path string userName string appName string + options map[string]*string ) BeforeEach(func() { appName = helpers.NewAppName() hostName = helpers.NewHostName() path = helpers.NewPath() + options = helpers.NewOptions() orgName = helpers.NewOrgName() spaceName = helpers.NewSpaceName() helpers.SetupCF(orgName, spaceName) @@ -96,7 +100,7 @@ var _ = Describe("map-route command", func() { BeforeEach(func() { domainName = helpers.DefaultSharedDomain() - route = helpers.NewRoute(spaceName, domainName, hostName, path) + route = helpers.NewRoute(spaceName, domainName, hostName, path, options) route.V7Create() }) @@ -160,7 +164,7 @@ var _ = Describe("map-route command", func() { routerGroup.Create() domain.CreateWithRouterGroup(routerGroup.Name) - route = helpers.NewTCPRoute(spaceName, domainName, 1082) + route = helpers.NewTCPRoute(spaceName, domainName, 1082, options) }) AfterEach(func() { diff --git a/integration/v7/isolated/marketplace_command_test.go b/integration/v7/isolated/marketplace_command_test.go index 288a59e9f2f..50d3e082e1b 100644 --- a/integration/v7/isolated/marketplace_command_test.go +++ b/integration/v7/isolated/marketplace_command_test.go @@ -4,9 +4,9 @@ import ( "fmt" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -140,7 +140,7 @@ var _ = Describe("marketplace command", func() { Unit: "MONTHLY", }, { - Amount: map[string]float64{"usd": 0.999}, + Amount: map[string]float64{"usd": 1.00}, Unit: "1GB of messages over 20GB", }, } @@ -393,7 +393,7 @@ var _ = Describe("marketplace command", func() { // Available - //When("a plan has cost information", func() { + // When("a plan has cost information", func() { // var brokerWithCosts *servicebrokerstub.ServiceBrokerStub // // BeforeEach(func() { @@ -438,7 +438,7 @@ var _ = Describe("marketplace command", func() { // Say(`%s\s+%s\s+%s\s+\n`, brokerWithCosts.Services[0].Plans[3].Name, brokerWithCosts.Services[0].Plans[3].Description, "free"), // )) // }) - //}) + // }) }) }) diff --git a/integration/v7/isolated/move_route_command_test.go b/integration/v7/isolated/move_route_command_test.go new file mode 100644 index 00000000000..a53908e9860 --- /dev/null +++ b/integration/v7/isolated/move_route_command_test.go @@ -0,0 +1,206 @@ +package isolated + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("move route command", func() { + Context("Help", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("move-route", "ROUTES", "Assign a route to a different space")) + }) + + It("displays the help information", func() { + session := helpers.CF("move-route", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say("move-route - Assign a route to a different space")) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`Transfers the ownership of a route to a another space:`)) + Eventually(session).Should(Say(`cf move-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] -s OTHER_SPACE \[-o OTHER_ORG\]`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf move-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo`)) + Eventually(session).Should(Say(`cf move-route example.com --hostname myHost -s TargetSpace # myhost.example.com`)) + Eventually(session).Should(Say(`cf move-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) + Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) + Eventually(session).Should(Say(`-o\s+The org of the destination app \(Default: targeted org\)`)) + Eventually(session).Should(Say(`-s\s+The space of the destination app \(Default: targeted space\)`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`create-route, map-route, routes, unmap-route`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "move-route", "some-domain", "-s SOME_SPACE") + }) + }) + + When("the environment is set up correctly", func() { + var ( + userName string + orgName string + spaceName string + ) + + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionHTTP2RoutingV3) + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + userName, _ = helpers.GetCredentials() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the domain exists", func() { + var ( + domainName string + targetSpaceName string + ) + + BeforeEach(func() { + domainName = helpers.NewDomainName() + }) + + When("the route exists", func() { + var ( + domain helpers.Domain + hostname string + ) + When("the target space exists in targeted org", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.CreateShared() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.DeleteShared() + }) + + It("transfers the route to the destination space", func() { + session := helpers.CF("move-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say(`Move ownership of route %s.%s to space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the target organization does not exist", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + targetOrgName = helpers.NewOrgName() + domain.CreateShared() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 and an error message", func() { + session := helpers.CF("move-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not transfer ownership of route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the target space exists in another existing org", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + targetOrgName = helpers.NewOrgName() + targetSpaceName = helpers.NewSpaceName() + helpers.CreateOrgAndSpace(targetOrgName, targetSpaceName) + helpers.SetupCF(orgName, spaceName) + domain.CreateShared() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.DeleteShared() + helpers.QuickDeleteOrg(targetOrgName) + helpers.QuickDeleteOrg(orgName) + }) + + It("Transfers ownership of the route to the destination space", func() { + session := helpers.CF("move-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say(`Move ownership of route %s.%s to space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the space does not exist", func() { + var destinationSpaceName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + destinationSpaceName = "doesNotExistSpace" + domain.CreateShared() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 with an error", func() { + session := helpers.CF("move-route", domainName, "--hostname", hostname, "-s", destinationSpaceName) + Eventually(session).Should(Say("Can not transfer ownership of route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the route does not exist", func() { + var ( + domain helpers.Domain + hostname string + ) + + When("the target space exists", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.CreateShared() + }) + + It("exits with 1 with an error message", func() { + session := helpers.CF("move-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not transfer ownership of route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/network_policies_command_test.go b/integration/v7/isolated/network_policies_command_test.go index 22fdba973dc..3d8c66f944a 100644 --- a/integration/v7/isolated/network_policies_command_test.go +++ b/integration/v7/isolated/network_policies_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -175,7 +175,7 @@ var _ = Describe("network-policies command", func() { }) }) - When("policies are filtered by a non-existent source app", func() { + When("policies are filtered by a nonexistent source app", func() { It("returns an error", func() { session := helpers.CF("network-policies", "--source", "pineapple") diff --git a/integration/v7/isolated/oauth_client_test.go b/integration/v7/isolated/oauth_client_test.go index 5cdeb54cb82..171fbca9a5a 100644 --- a/integration/v7/isolated/oauth_client_test.go +++ b/integration/v7/isolated/oauth_client_test.go @@ -1,21 +1,20 @@ package isolated import ( - "io/ioutil" "os" "path/filepath" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" ) func fileAsString(path string) string { - configBytes, err := ioutil.ReadFile(path) + configBytes, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) return string(configBytes) @@ -24,7 +23,7 @@ func fileAsString(path string) string { func replaceConfig(path string, old string, new string) { r := regexp.MustCompile(old) newConfig := r.ReplaceAllString(fileAsString(path), new) - err := ioutil.WriteFile(path, []byte(newConfig), 0600) + err := os.WriteFile(path, []byte(newConfig), 0600) Expect(err).ToNot(HaveOccurred()) } diff --git a/integration/v7/isolated/oauth_token_command_test.go b/integration/v7/isolated/oauth_token_command_test.go index 38490c5322e..705ec53cbe9 100644 --- a/integration/v7/isolated/oauth_token_command_test.go +++ b/integration/v7/isolated/oauth_token_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -93,7 +93,7 @@ var _ = Describe("oauth-token command", func() { When("the oauth client ID and secret combination is invalid", func() { BeforeEach(func() { helpers.SetConfig(func(conf *configv3.Config) { - conf.ConfigFile.UAAOAuthClient = "non-existent-client" + conf.ConfigFile.UAAOAuthClient = "nonexistent-client" conf.ConfigFile.UAAOAuthClientSecret = "some-secret" }) }) @@ -151,7 +151,7 @@ var _ = Describe("oauth-token command", func() { When("the oauth client ID and secret combination is invalid", func() { BeforeEach(func() { helpers.SetConfig(func(conf *configv3.Config) { - conf.ConfigFile.UAAOAuthClient = "non-existent-client" + conf.ConfigFile.UAAOAuthClient = "nonexistent-client" conf.ConfigFile.UAAOAuthClientSecret = "some-secret" }) }) diff --git a/integration/v7/isolated/org_command_test.go b/integration/v7/isolated/org_command_test.go index d970a12074f..e4e3eeda040 100644 --- a/integration/v7/isolated/org_command_test.go +++ b/integration/v7/isolated/org_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "sort" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/org_users_command_test.go b/integration/v7/isolated/org_users_command_test.go index d2dfe13b272..01cb0359da6 100644 --- a/integration/v7/isolated/org_users_command_test.go +++ b/integration/v7/isolated/org_users_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -40,6 +40,10 @@ var _ = Describe("org-users command", func() { helpers.CreateOrg(orgName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("the target org has multiple users with different roles", func() { var ( orgManagerUser string diff --git a/integration/v7/isolated/orgs_command_test.go b/integration/v7/isolated/orgs_command_test.go index 2ff94fb174a..d5a4039f0b4 100644 --- a/integration/v7/isolated/orgs_command_test.go +++ b/integration/v7/isolated/orgs_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/packages_command_test.go b/integration/v7/isolated/packages_command_test.go index 83d65b59d7c..f3ddd3e11f0 100644 --- a/integration/v7/isolated/packages_command_test.go +++ b/integration/v7/isolated/packages_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/passwd_command_test.go b/integration/v7/isolated/passwd_command_test.go index 30181f64574..5d654d6a823 100644 --- a/integration/v7/isolated/passwd_command_test.go +++ b/integration/v7/isolated/passwd_command_test.go @@ -5,9 +5,9 @@ import ( "io" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/proxy_connection_test.go b/integration/v7/isolated/proxy_connection_test.go index ca2f8eb17e6..073775f02aa 100644 --- a/integration/v7/isolated/proxy_connection_test.go +++ b/integration/v7/isolated/proxy_connection_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/purge_service_instance_command_test.go b/integration/v7/isolated/purge_service_instance_command_test.go index 09cc600fcb7..f1b6b3ab216 100644 --- a/integration/v7/isolated/purge_service_instance_command_test.go +++ b/integration/v7/isolated/purge_service_instance_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/purge_service_offering_command_test.go b/integration/v7/isolated/purge_service_offering_command_test.go index 142a3c75878..47124b63648 100644 --- a/integration/v7/isolated/purge_service_offering_command_test.go +++ b/integration/v7/isolated/purge_service_offering_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/remove_network_policy_command_test.go b/integration/v7/isolated/remove_network_policy_command_test.go index ffeb9369944..92891d65b78 100644 --- a/integration/v7/isolated/remove_network_policy_command_test.go +++ b/integration/v7/isolated/remove_network_policy_command_test.go @@ -4,8 +4,8 @@ import ( "fmt" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/rename_command_test.go b/integration/v7/isolated/rename_command_test.go index bdcf63054f2..2a2b8f97468 100644 --- a/integration/v7/isolated/rename_command_test.go +++ b/integration/v7/isolated/rename_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/rename_org_command_test.go b/integration/v7/isolated/rename_org_command_test.go index ecbda727b18..08d1a8ad2ea 100644 --- a/integration/v7/isolated/rename_org_command_test.go +++ b/integration/v7/isolated/rename_org_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -107,6 +107,10 @@ var _ = Describe("rename-org command", func() { helpers.CreateOrg(orgNameNew) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgNameNew) + }) + It("fails to rename the org", func() { session := helpers.CF("rename-org", orgName, orgNameNew) userName, _ := helpers.GetCredentials() diff --git a/integration/v7/isolated/rename_service_broker_command_test.go b/integration/v7/isolated/rename_service_broker_command_test.go index dc0e1a9fead..05db1856ca9 100644 --- a/integration/v7/isolated/rename_service_broker_command_test.go +++ b/integration/v7/isolated/rename_service_broker_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/rename_service_command_test.go b/integration/v7/isolated/rename_service_command_test.go index 69d46920891..dc26857e0ad 100644 --- a/integration/v7/isolated/rename_service_command_test.go +++ b/integration/v7/isolated/rename_service_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/rename_space_command_test.go b/integration/v7/isolated/rename_space_command_test.go index 1896018d980..fc082895c69 100644 --- a/integration/v7/isolated/rename_space_command_test.go +++ b/integration/v7/isolated/rename_space_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/reset_org_default_isolation_segment_command_test.go b/integration/v7/isolated/reset_org_default_isolation_segment_command_test.go index 181ede0e070..33bde2dc535 100644 --- a/integration/v7/isolated/reset_org_default_isolation_segment_command_test.go +++ b/integration/v7/isolated/reset_org_default_isolation_segment_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/reset_space_isolation_segment_test.go b/integration/v7/isolated/reset_space_isolation_segment_test.go index 5891bfe2ae8..3ecaaef669b 100644 --- a/integration/v7/isolated/reset_space_isolation_segment_test.go +++ b/integration/v7/isolated/reset_space_isolation_segment_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/restage_command_test.go b/integration/v7/isolated/restage_command_test.go index eee7355cb49..5de0aba7cc4 100644 --- a/integration/v7/isolated/restage_command_test.go +++ b/integration/v7/isolated/restage_command_test.go @@ -2,12 +2,11 @@ package isolated import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -24,16 +23,18 @@ var _ = Describe("restage command", func() { Eventually(session).ShouldNot(Say(`This action will cause app downtime.`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say("cf restage APP_NAME")) - Eventually(session).Should(Say("This command will cause downtime unless you use '--strategy rolling'.")) + Eventually(session).Should(Say("This command will cause downtime unless you use '--strategy")) Eventually(session).Should(Say("EXAMPLES:")) Eventually(session).Should(Say("cf restage APP_NAME")) Eventually(session).Should(Say("cf restage APP_NAME --strategy rolling")) - Eventually(session).Should(Say("cf restage APP_NAME --strategy rolling --no-wait")) + Eventually(session).Should(Say("cf restage APP_NAME --strategy canary --no-wait")) Eventually(session).Should(Say("ALIAS:")) Eventually(session).Should(Say("rg")) Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say("--strategy Deployment strategy, either rolling or null")) - Eventually(session).Should(Say("--no-wait Exit when the first instance of the web process is healthy")) + Eventually(session).Should(Say("--instance-steps")) + Eventually(session).Should(Say("--max-in-flight")) + Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`)) + Eventually(session).Should(Say(`--strategy\s+Deployment strategy can be canary, rolling or null`)) Eventually(session).Should(Say("ENVIRONMENT:")) Eventually(session).Should(Say(`CF_STAGING_TIMEOUT=15\s+Max wait time for staging, in minutes`)) Eventually(session).Should(Say(`CF_STARTUP_TIMEOUT=5\s+Max wait time for app instance startup, in minutes`)) @@ -116,7 +117,7 @@ var _ = Describe("restage command", func() { session := helpers.CF("restage", appName) Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) - // The staticfile_buildback does compile an index.html file. However, it requires a "Staticfile" during buildpack detection. + // The staticfile_buildpack does compile an index.html file. However, it requires a "Staticfile" during buildpack detection. Eventually(session.Err).Should(Say("Error staging application: NoAppDetectedError - An app was not successfully detected by any available buildpack")) Eventually(session.Err).Should(Say(`TIP: Use 'cf buildpacks' to see a list of supported buildpacks.`)) Eventually(session).Should(Exit(1)) @@ -141,12 +142,12 @@ var _ = Describe("restage command", func() { Eventually(session).Should(Exit(1)) }) - When("strategy rolling is given", func() { + When("a deployment strategy is used", func() { It("fails and displays the deployment failure message", func() { userName, _ := helpers.GetCredentials() session := helpers.CustomCF(helpers.CFEnv{ EnvVars: map[string]string{"CF_STARTUP_TIMEOUT": "0.1"}, - }, "restage", appName, "--strategy", "rolling") + }, "restage", appName, "--strategy", "canary", "--max-in-flight", "3") Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`)) Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) @@ -155,6 +156,13 @@ var _ = Describe("restage command", func() { Eventually(session.Err).Should(Say(`TIP: Application must be listening on the right port\.`)) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) + + appGUID := helpers.AppGUID(appName) + Eventually(func() *Buffer { + session_deployment := helpers.CF("curl", fmt.Sprintf("/v3/deployments?app_guids=%s", appGUID)) + Eventually(session_deployment).Should(Exit(0)) + return session_deployment.Out + }).Should(Say(`"reason":\s*"CANCELED"`)) }) }) }) @@ -175,7 +183,7 @@ applications: - route: %s.%s `, appName, appName, domainName)) manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) + err := os.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CF("push", appName, "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) @@ -201,7 +209,7 @@ applications: Eventually(session).Should(Say(`sidecars:`)) Eventually(session).Should(Say(`instances:\s+\d/2`)) Eventually(session).Should(Say(`memory usage:\s+128M`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement`)) Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) Eventually(session).Should(Exit(0)) }) @@ -225,13 +233,45 @@ applications: Eventually(session).Should(Say(`sidecars:`)) Eventually(session).Should(Say(`instances:\s+\d/2`)) Eventually(session).Should(Say(`memory usage:\s+128M`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement`)) Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) Eventually(session).Should(Exit(0)) }) }) - When("isolation segments are available", func() { + When("strategy canary is given without the max-in-flight flag", func() { + It("restages successfully and notes the max-in-flight value", func() { + userName, _ := helpers.GetCredentials() + session := helpers.CF("restage", appName, "--strategy", "canary") + Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`)) + Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) + Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 1")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("strategy canary is given with a non-default max-in-flight value and instance-steps", func() { + It("restages successfully and notes the max-in-flight value", func() { + userName, _ := helpers.GetCredentials() + session := helpers.CF("restage", appName, "--strategy", "canary", "--max-in-flight", "2", "--instance-steps", "1,20") + Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`)) + Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) + Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 2")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Eventually(session).Should(Exit(0)) + }) + }) + + XWhen("isolation segments are available", func() { BeforeEach(func() { Eventually(helpers.CF("create-isolation-segment", RealIsolationSegment)).Should(Exit(0)) Eventually(helpers.CF("enable-org-isolation", orgName, RealIsolationSegment)).Should(Exit(0)) diff --git a/integration/v7/isolated/restart_app_instance_command_test.go b/integration/v7/isolated/restart_app_instance_command_test.go index d9102949725..aefdffdc9c1 100644 --- a/integration/v7/isolated/restart_app_instance_command_test.go +++ b/integration/v7/isolated/restart_app_instance_command_test.go @@ -3,11 +3,11 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -30,13 +30,13 @@ var _ = Describe("restart-app-instance command", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") Eventually(session).Should(Exit(0)) - Expect(session).To(HaveCommandInCategoryWithDescription("restart-app-instance", "APPS", "Terminate, then instantiate an app instance")) + Expect(session).To(HaveCommandInCategoryWithDescription("restart-app-instance", "APPS", "Stop, then start application instance without updating application environment")) }) It("Displays command usage to output", func() { session := helpers.CF("restart-app-instance", "--help") Eventually(session).Should(Say("NAME:")) - Eventually(session).Should(Say("restart-app-instance - Terminate, then instantiate an app instance")) + Eventually(session).Should(Say("restart-app-instance - Stop, then start application instance without updating application environment")) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(`cf restart-app-instance APP_NAME INDEX [--process PROCESS]`)) Eventually(session).Should(Say(`OPTIONS:`)) diff --git a/integration/v7/isolated/restart_command_test.go b/integration/v7/isolated/restart_command_test.go index 42bbd23c7a2..4c2c95ce67a 100644 --- a/integration/v7/isolated/restart_command_test.go +++ b/integration/v7/isolated/restart_command_test.go @@ -3,15 +3,21 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" ) var _ = Describe("restart command", func() { + + const ( + instanceStatsTitles = `\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details` + instanceStatsValues = `#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z` + ) + var ( orgName string spaceName string @@ -39,14 +45,15 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`restart - Stop all instances of the app, then start them again\.`)) Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say("cf restart APP_NAME")) - Eventually(session).Should(Say("This command will cause downtime unless you use '--strategy rolling'.")) + Eventually(session).Should(Say("This command will cause downtime unless you use '--strategy")) Eventually(session).Should(Say("If the app's most recent package is unstaged, restarting the app will stage and run that package.")) Eventually(session).Should(Say("Otherwise, the app's current droplet will be run.")) Eventually(session).Should(Say("ALIAS:")) Eventually(session).Should(Say("rs")) Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say("--strategy Deployment strategy, either rolling or null")) - Eventually(session).Should(Say("--no-wait Exit when the first instance of the web process is healthy")) + Eventually(session).Should(Say("--max-in-flight")) + Eventually(session).Should(Say(`--strategy\s+Deployment strategy can be canary, rolling or null.`)) + Eventually(session).Should(Say(`--no-wait\s+Exit when the first instance of the web process is healthy`)) Eventually(session).Should(Say("ENVIRONMENT:")) Eventually(session).Should(Say(`CF_STAGING_TIMEOUT=15\s+Max wait time for staging, in minutes`)) Eventually(session).Should(Say(`CF_STARTUP_TIMEOUT=5\s+Max wait time for app instance startup, in minutes`)) @@ -95,7 +102,29 @@ var _ = Describe("restart command", func() { }) }) It("creates a deploy", func() { - session := helpers.CF("restart", appName, "--strategy=rolling") + session := helpers.CF("restart", appName, "--strategy=rolling", "--max-in-flight=3") + Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) + Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) + Eventually(session).Should(Say(`name:\s+%s`, appName)) + Eventually(session).Should(Say(`requested state:\s+started`)) + Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) + Eventually(session).Should(Say(`type:\s+web`)) + Eventually(session).Should(Say(`instances:\s+1/1`)) + Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) + }) + }) + + When("strategy canary is given without the max-in-flight flag", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0)) + }) + }) + It("creates a deploy and notes the max-in-flight value", func() { + session := helpers.CF("restart", appName, "--strategy=canary") Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) @@ -105,8 +134,40 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) - Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 1")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("strategy canary is given with a non-default max-in-flight value", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0)) + }) + }) + It("creates a deploy and notes the max-in-flight value", func() { + session := helpers.CF("restart", appName, "--strategy=canary", "--max-in-flight", "3") + Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName)) + Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) + Eventually(session).Should(Say(`name:\s+%s`, appName)) + Eventually(session).Should(Say(`requested state:\s+started`)) + Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) + Eventually(session).Should(Say(`type:\s+web`)) + Eventually(session).Should(Say(`instances:\s+1/1`)) + Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) + Eventually(session).Should(Say("Active deployment with status PAUSED")) + Eventually(session).Should(Say("strategy: canary")) + Eventually(session).Should(Say("max-in-flight: 3")) + Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Eventually(session).Should(Exit(0)) }) }) @@ -128,8 +189,8 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) - Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) Expect(session.Out.Contents()).NotTo(ContainSubstring("Staging app and tracing logs...")) @@ -165,8 +226,8 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) - Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) Eventually(session).Should(Exit(0)) Expect(session.Err).ToNot(Say(`timeout connecting to log server, no log will be shown`)) @@ -193,8 +254,8 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) - Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) Expect(session.Out.Contents()).NotTo(ContainSubstring("Staging app and tracing logs...")) Expect(session.Out.Contents()).NotTo(ContainSubstring("Stopping app...")) @@ -222,8 +283,8 @@ var _ = Describe("restart command", func() { Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) - Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) + Eventually(session).Should(Say(instanceStatsTitles)) + Eventually(session).Should(Say(instanceStatsValues)) Expect(session.Out.Contents()).NotTo(ContainSubstring("Stopping app...")) diff --git a/integration/v7/isolated/revision_command_test.go b/integration/v7/isolated/revision_command_test.go index 3daac4c21c4..82116d79781 100644 --- a/integration/v7/isolated/revision_command_test.go +++ b/integration/v7/isolated/revision_command_test.go @@ -1,21 +1,41 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "bytes" + "encoding/json" + "fmt" + "os/exec" + "strings" + + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" ) var _ = Describe("revision command", func() { + var ( + orgName string + spaceName string + appName string + username string + ) + + BeforeEach(func() { + username, _ = helpers.GetCredentials() + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + appName = helpers.PrefixedRandomName("app") + }) + Describe("help", func() { When("--help flag is set", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") Eventually(session).Should(Exit(0)) - Expect(session).To(HaveCommandInCategoryWithDescription("revision", "EXPERIMENTAL COMMANDS", "Show details for a specific app revision")) + Expect(session).To(HaveCommandInCategoryWithDescription("revision", "APPS", "Show details for a specific app revision")) }) It("Displays revision command usage to output", func() { @@ -34,4 +54,157 @@ var _ = Describe("revision command", func() { }) }) }) + + When("targetting and org and space", func() { + BeforeEach(func() { + helpers.SetupCF(orgName, spaceName) + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the requested revision version does not exist", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("create-app", appName)).Should(Exit(0)) + Eventually(helpers.CF("set-env", appName, "foo", "bar1")).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0)) + }) + }) + It("displays revision not found", func() { + session := helpers.CF("revision", appName, "--version", "125") + Eventually(session).Should(Exit(1)) + + Expect(session).Should(Say( + fmt.Sprintf("Showing revision 125 for app %s in org %s / space %s as %s...", appName, orgName, spaceName, username), + )) + Expect(session.Err).Should(Say("Revision '125' not found")) + }) + }) + + When("the requested app and revision both exist", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("create-app", appName)).Should(Exit(0)) + Eventually(helpers.CF("set-env", appName, "foo", "bar1")).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0)) + }) + }) + + It("shows details about the revision", func() { + cmd := exec.Command("bash", "-c", "cf revision "+appName+" --version 1 | grep \"revision GUID\" | sed -e 's/.*:\\s*//' -e 's/^[ \\t]*//'") + var stdout bytes.Buffer + cmd.Stdout = &stdout + err := cmd.Run() + if err != nil { + return + } + revisionGUID := strings.TrimSpace(stdout.String()) + data := map[string]interface{}{ + "metadata": map[string]interface{}{ + "labels": map[string]string{ + "label": "foo3", + }, + "annotations": map[string]string{ + "annotation": "foo3", + }, + }, + } + metadata, err := json.Marshal(data) + Expect(err).NotTo(HaveOccurred()) + + url := "/v3/revisions/" + string(revisionGUID) + Eventually(helpers.CF("curl", "-X", "PATCH", url, "-d", string(metadata))).Should(Exit(0)) + + session := helpers.CF("revision", appName, "--version", "1") + Eventually(session).Should(Exit(0)) + + Expect(session).Should(Say( + fmt.Sprintf("Showing revision 1 for app %s in org %s / space %s as %s...", appName, orgName, spaceName, username), + )) + Expect(session).Should(Say(`revision: 1`)) + Expect(session).Should(Say(`deployed: false`)) + Expect(session).Should(Say(`description: Initial revision`)) + Expect(session).Should(Say(`deployable: true`)) + Expect(session).Should(Say(`revision GUID: \S+\n`)) + Expect(session).Should(Say(`droplet GUID: \S+\n`)) + Expect(session).Should(Say(`created on: \S+\n`)) + + Expect(session).Should(Say(`labels:`)) + Expect(session).Should(Say(`label: foo3`)) + + Expect(session).Should(Say(`annotations:`)) + Expect(session).Should(Say(`annotation: foo3`)) + + Expect(session).Should(Say(`application environment variables:`)) + Expect(session).Should(Say(`foo: bar1`)) + + session = helpers.CF("revision", appName, "--version", "2") + Eventually(session).Should(Exit(0)) + Expect(session).Should(Say( + fmt.Sprintf("Showing revision 2 for app %s in org %s / space %s as %s...", appName, orgName, spaceName, username), + )) + Expect(session).Should(Say(`revision: 2`)) + Expect(session).Should(Say(`deployed: true`)) + Expect(session).Should(Say(`description: New droplet deployed`)) + Expect(session).Should(Say(`deployable: true`)) + Expect(session).Should(Say(`revision GUID: \S+\n`)) + Expect(session).Should(Say(`droplet GUID: \S+\n`)) + Expect(session).Should(Say(`created on: \S+\n`)) + + Expect(session).Should(Say(`labels:`)) + Expect(session).Should(Say(`annotations:`)) + + Expect(session).Should(Say(`application environment variables:`)) + Expect(session).Should(Say(`foo: bar1`)) + }) + }) + + When("the revision version is not mentioned", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("create-app", appName)).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir)).Should(Exit(0)) + Eventually(helpers.CF("push", appName, "-p", appDir, "--strategy", "canary")).Should(Exit(0)) + }) + }) + + It("shows all the deployed revisions", func() { + session := helpers.CF("revision", appName) + Eventually(session).Should(Exit(0)) + + Expect(session).Should(Say( + fmt.Sprintf("Showing revisions for app %s in org %s / space %s as %s...", appName, orgName, spaceName, username), + )) + Expect(session).Should(Say(`revision: 2`)) + Expect(session).Should(Say(`deployed: true`)) + Expect(session).Should(Say(`description: New droplet deployed`)) + Expect(session).Should(Say(`deployable: true`)) + Expect(session).Should(Say(`revision GUID: \S+\n`)) + Expect(session).Should(Say(`droplet GUID: \S+\n`)) + Expect(session).Should(Say(`created on: \S+\n`)) + + Expect(session).Should(Say(`labels:`)) + Expect(session).Should(Say(`annotations:`)) + Expect(session).Should(Say(`application environment variables:`)) + + Expect(session).Should(Say(`revision: 3`)) + Expect(session).Should(Say(`deployed: true`)) + Expect(session).Should(Say(`description: New droplet deployed`)) + Expect(session).Should(Say(`deployable: true`)) + Expect(session).Should(Say(`revision GUID: \S+\n`)) + Expect(session).Should(Say(`droplet GUID: \S+\n`)) + Expect(session).Should(Say(`created on: \S+\n`)) + + Expect(session).Should(Say(`labels:`)) + Expect(session).Should(Say(`annotations:`)) + Expect(session).Should(Say(`application environment variables:`)) + + Expect(session).ShouldNot(Say(`revision: 1`)) + }) + }) + }) }) diff --git a/integration/v7/isolated/revisions_command_test.go b/integration/v7/isolated/revisions_command_test.go index ee014778750..b3d5aecfeb1 100644 --- a/integration/v7/isolated/revisions_command_test.go +++ b/integration/v7/isolated/revisions_command_test.go @@ -5,9 +5,9 @@ import ( "fmt" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,7 +33,7 @@ var _ = Describe("revisions command", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") Eventually(session).Should(Exit(0)) - Expect(session).To(HaveCommandInCategoryWithDescription("revisions", "EXPERIMENTAL COMMANDS", "List revisions of an app")) + Expect(session).To(HaveCommandInCategoryWithDescription("revisions", "APPS", "List revisions of an app")) }) It("Displays command usage to output", func() { @@ -43,13 +43,13 @@ var _ = Describe("revisions command", func() { Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say("cf revisions APP_NAME")) Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say("rollback")) + Eventually(session).Should(Say("revision, rollback")) Eventually(session).Should(Exit(0)) }) }) }) - When("targetting and org and space", func() { + When("targeting and org and space", func() { BeforeEach(func() { helpers.SetupCF(orgName, spaceName) }) diff --git a/integration/v7/isolated/rollback_command_test.go b/integration/v7/isolated/rollback_command_test.go index 458f3799274..33c8f503bd7 100644 --- a/integration/v7/isolated/rollback_command_test.go +++ b/integration/v7/isolated/rollback_command_test.go @@ -2,12 +2,12 @@ package isolated import ( "fmt" - "io/ioutil" + "os" "path/filepath" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -21,7 +21,7 @@ var _ = Describe("rollback command", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") Eventually(session).Should(Exit(0)) - Expect(session).To(HaveCommandInCategoryWithDescription("rollback", "EXPERIMENTAL COMMANDS", "Rollback to the specified revision of an app")) + Expect(session).To(HaveCommandInCategoryWithDescription("rollback", "APPS", "Rollback to the specified revision of an app")) }) It("Displays rollback command usage to output", func() { @@ -34,10 +34,13 @@ var _ = Describe("rollback command", func() { Expect(session).To(Say("USAGE:")) Expect(session).To(Say(`cf rollback APP_NAME \[--version VERSION\]`)) Expect(session).To(Say("OPTIONS:")) - Expect(session).To(Say("-f Force rollback without confirmation")) - Expect(session).To(Say("--version Roll back to the specified revision")) + Expect(session).To(Say(`-f\s+Force rollback without confirmation`)) + Expect(session).To(Say("--instance-steps")) + Expect(session).To(Say("--max-in-flight")) + Expect(session).To(Say(`--strategy\s+Deployment strategy can be canary or rolling. When not specified, it defaults to rolling.`)) + Expect(session).To(Say(`--version\s+Roll back to the specified revision`)) Expect(session).To(Say("SEE ALSO:")) - Expect(session).To(Say("revisions")) + Expect(session).To(Say("revision, revisions")) }) }) }) @@ -92,7 +95,7 @@ applications: - route: %s.%s `, appName, appName, domainName)) manifestPath := filepath.Join(appDir, "manifest.yml") - err := ioutil.WriteFile(manifestPath, manifestContents, 0666) + err := os.WriteFile(manifestPath, manifestContents, 0666) Expect(err).ToNot(HaveOccurred()) Eventually(helpers.CF("push", appName, "-p", appDir, "-f", manifestPath, "-b", "staticfile_buildpack")).Should(Exit(0)) @@ -112,7 +115,7 @@ applications: When("the -f flag is provided", func() { It("does not prompt the user, and just rolls back", func() { - session := helpers.CF("rollback", appName, "--version", "1", "-f") + session := helpers.CF("rollback", appName, "--version", "1", "-f", "--max-in-flight", "3") Eventually(session).Should(Exit(0)) Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName)) @@ -148,6 +151,46 @@ applications: Expect(session).To(Say(`3\(deployed\)\s+New droplet deployed.`)) }) + + When("the strategy flag is provided without the max-in-flight flag", func() { + BeforeEach(func() { + _, err := buffer.Write([]byte("y\n")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("uses the given strategy to rollback and notes the max-in-flight value", func() { + session := helpers.CFWithStdin(buffer, "rollback", appName, "--version", "1", "--strategy", "canary", "--instance-steps", "10,50") + Eventually(session).Should(Exit(0)) + + Expect(session).To(HaveRollbackPrompt()) + Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName)) + Expect(session).To(Say("Active deployment with status PAUSED")) + Expect(session).To(Say("strategy: canary")) + Expect(session).To(Say("max-in-flight: 1")) + Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Expect(session).To(Say("OK")) + }) + }) + + When("the strategy flag is provided with a non-default max-in-flight value", func() { + BeforeEach(func() { + _, err := buffer.Write([]byte("y\n")) + Expect(err).ToNot(HaveOccurred()) + }) + + It("uses the given strategy to rollback and notes the max-in-flight value", func() { + session := helpers.CFWithStdin(buffer, "rollback", appName, "--version", "1", "--strategy", "canary", "--max-in-flight", "2") + Eventually(session).Should(Exit(0)) + + Expect(session).To(HaveRollbackPrompt()) + Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName)) + Expect(session).To(Say("Active deployment with status PAUSED")) + Expect(session).To(Say("strategy: canary")) + Expect(session).To(Say("max-in-flight: 2")) + Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Expect(session).To(Say("OK")) + }) + }) }) When("the user enters n", func() { diff --git a/integration/v7/isolated/route_command_test.go b/integration/v7/isolated/route_command_test.go index 85d50275c44..a552ca83136 100644 --- a/integration/v7/isolated/route_command_test.go +++ b/integration/v7/isolated/route_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/router_groups_command_test.go b/integration/v7/isolated/router_groups_command_test.go index f4b5d3cd964..28d93036a8d 100644 --- a/integration/v7/isolated/router_groups_command_test.go +++ b/integration/v7/isolated/router_groups_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/routes_command_test.go b/integration/v7/isolated/routes_command_test.go index 73813867368..08a6ed35aa7 100644 --- a/integration/v7/isolated/routes_command_test.go +++ b/integration/v7/isolated/routes_command_test.go @@ -3,11 +3,11 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -16,7 +16,7 @@ import ( var _ = Describe("routes command", func() { appProtocolValue := "http1" - const tableHeaders = `space\s+host\s+domain\s+port\s+path\s+protocol\s+app-protocol\s+apps\s+service instance` + const tableHeaders = `space\s+host\s+domain\s+port\s+path\s+protocol\s+app-protocol\s+apps\s+service instance\s+options` Context("Help", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") @@ -122,7 +122,7 @@ var _ = Describe("routes command", func() { Eventually(session).Should(Exit(0)) Expect(session).To(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) Expect(session).To(Say(tableHeaders)) - Expect(session).To(Say(`%s\s+route1\s+%s\s+http\s+%s\s+%s\s+%s\n`, spaceName, domainName, appProtocolValue, appName1, serviceInstanceName)) + Expect(session).To(Say(`%s\s+route1\s+%s\s+http\s+%s\s+%s\s+%s\s+\n`, spaceName, domainName, appProtocolValue, appName1, serviceInstanceName)) Expect(session).To(Say(`%s\s+route1a\s+%s\s+http\s+%s\s+%s\s+\n`, spaceName, domainName, appProtocolValue, appName1)) Expect(session).To(Say(`%s\s+route1b\s+%s\s+http\s+%s\s+%s\s+\n`, spaceName, domainName, appProtocolValue, appName1)) Expect(session).ToNot(Say(`%s\s+route2\s+%s\s+http\s+%s\s+%s\s+\n`, spaceName, domainName, appProtocolValue, appName2)) @@ -145,7 +145,7 @@ var _ = Describe("routes command", func() { Eventually(session).Should(Exit(0)) Expect(session).To(Say(`Getting routes for org %s as %s\.\.\.`, orgName, userName)) Expect(session).To(Say(tableHeaders)) - Expect(session).To(Say(`%s\s+route1\s+%s\s+http\s+%s\s+%s\s+%s\n`, spaceName, domainName, appProtocolValue, appName1, serviceInstanceName)) + Expect(session).To(Say(`%s\s+route1\s+%s\s+http\s+%s\s+%s\s+%s\s+\n`, spaceName, domainName, appProtocolValue, appName1, serviceInstanceName)) Expect(session).To(Say(`%s\s+route2\s+%s\s+\/dodo\s+http\s+%s\s+%s\s+\n`, otherSpaceName, domainName, appProtocolValue, appName2)) }) }) @@ -186,8 +186,8 @@ var _ = Describe("routes command", func() { Eventually(session).Should(Exit(0)) Expect(session).To(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) Expect(session).To(Say(tableHeaders)) - Expect(session).To(Say(`%s\s+route1\s+%s\s+http\s+http1, http2\s+%s\s+\n`, spaceName, domainName, fmt.Sprintf("%s, %s", appName1, appName2))) - Expect(session).To(Say(`%s\s+route2\s+%s\s+http\s+http1\s+%s\s+\n`, spaceName, domainName, appName2)) + Eventually(session).Should(Or(Say(`%s\s+route1\s+%s\s+http\s+http1, http2\s+%s\s+\n`, spaceName, domainName, fmt.Sprintf("%s, %s", appName2, appName1)), Say(`%s\s+route1\s+%s\s+http\s+http1, http2\s+%s\s+\n`, spaceName, domainName, fmt.Sprintf("%s, %s", appName1, appName2)))) + Eventually(session).Should(Say(`%s\s+route2\s+%s\s+http\s+http1\s+%s\s+\n`, spaceName, domainName, appName2)) }) }) diff --git a/integration/v7/isolated/run_task_command_test.go b/integration/v7/isolated/run_task_command_test.go index 05ec1f3d159..feb29a83824 100644 --- a/integration/v7/isolated/run_task_command_test.go +++ b/integration/v7/isolated/run_task_command_test.go @@ -4,8 +4,9 @@ import ( "fmt" "path" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -19,7 +20,7 @@ var _ = Describe("run-task command", func() { Expect(session).To(Say("NAME:")) Expect(session).To(Say(" run-task - Run a one-off task on an app")) Expect(session).To(Say("USAGE:")) - Expect(session).To(Say(` cf run-task APP_NAME \[--command COMMAND\] \[-k DISK] \[-m MEMORY\] \[--name TASK_NAME\] \[--process PROCESS_TYPE\]`)) + Expect(session).To(Say(` cf run-task APP_NAME \[--command COMMAND\] \[-k DISK] \[-m MEMORY\] \[-l LOG_RATE_LIMIT\] \[--name TASK_NAME\] \[--process PROCESS_TYPE\]`)) Expect(session).To(Say("TIP:")) Expect(session).To(Say(" Use 'cf logs' to display the logs of the app and all its tasks. If your task name is unique, grep this command's output for the task name to view task-specific logs.")) Expect(session).To(Say("EXAMPLES:")) @@ -29,11 +30,12 @@ var _ = Describe("run-task command", func() { Expect(session).To(Say("OPTIONS:")) Expect(session).To(Say(` --command, -c\s+The command to execute`)) Expect(session).To(Say(` -k Disk limit \(e\.g\. 256M, 1024M, 1G\)`)) + Expect(session).To(Say(` -l Log rate limit per second, in bytes \(e\.g\. 128B, 4K, 1M\). -l=-1 represents unlimited`)) Expect(session).To(Say(` -m Memory limit \(e\.g\. 256M, 1024M, 1G\)`)) Expect(session).To(Say(` --name Name to give the task \(generated if omitted\)`)) Expect(session).To(Say(` --process Process type to use as a template for command, memory, and disk for the created task`)) Expect(session).To(Say("SEE ALSO:")) - Expect(session).To(Say(" logs, tasks, terminate-task")) + Expect(session).To(Say(" logs, tasks, task, terminate-task")) }) }) @@ -130,6 +132,32 @@ var _ = Describe("run-task command", func() { }) }) + When("log rate limit is provided", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + When("the provided log rate limit is invalid", func() { + It("displays error and exits 1", func() { + session := helpers.CF("run-task", appName, "--command", "echo hi", "-l", "invalid") + Eventually(session).Should(Exit(1)) + Expect(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like B, K, KB, M, MB, G, or GB")) + + }) + }) + + When("the provided log rate limit is valid", func() { + It("runs the task with the provided log rate limit", func() { + logRateLimit := 1024 + session := helpers.CF("run-task", appName, "--command", "echo hi", "-l", fmt.Sprintf("%dB", logRateLimit)) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("tasks", appName, "-v") + Eventually(session).Should(Exit(0)) + Expect(session).To(Say("\"log_rate_limit_in_bytes_per_second\": %d", logRateLimit)) + }) + }) + }) + When("task memory is provided", func() { When("the provided memory is invalid", func() { It("displays error and exits 1", func() { diff --git a/integration/v7/isolated/scale_command_test.go b/integration/v7/isolated/scale_command_test.go index 1c3d3c3e3fa..b430b9b05ca 100644 --- a/integration/v7/isolated/scale_command_test.go +++ b/integration/v7/isolated/scale_command_test.go @@ -3,11 +3,13 @@ package isolated import ( "fmt" "strings" + "time" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,23 +35,24 @@ var _ = Describe("scale command", func() { It("appears in cf help -a", func() { session := helpers.CF("help", "-a") Eventually(session).Should(Exit(0)) - Expect(session).To(HaveCommandInCategoryWithDescription("scale", "APPS", "Change or view the instance count, disk space limit, and memory limit for an app")) + Expect(session).To(HaveCommandInCategoryWithDescription("scale", "APPS", "Change or view the instance count, disk space limit, memory limit, and log rate limit for an app")) }) It("displays command usage to output", func() { session := helpers.CF("scale", "--help") Eventually(session).Should(Say("NAME:")) - Eventually(session).Should(Say("scale - Change or view the instance count, disk space limit, and memory limit for an app")) + Eventually(session).Should(Say("scale - Change or view the instance count, disk space limit, memory limit, and log rate limit for an app")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf scale APP_NAME \[--process PROCESS\] \[-i INSTANCES\] \[-k DISK\] \[-m MEMORY\]`)) - Eventually(session).Should(Say("Modifying the app's disk or memory will cause the app to restart.")) + Eventually(session).Should(Say(`cf scale APP_NAME \[--process PROCESS\] \[-i INSTANCES\] \[-k DISK\] \[-m MEMORY\] \[-l LOG_RATE_LIMIT\]`)) + Eventually(session).Should(Say("Modifying the app's disk, memory, or log rate will cause the app to restart.")) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`-f\s+Force restart of app without prompt`)) Eventually(session).Should(Say(`-i\s+Number of instances`)) Eventually(session).Should(Say(`-k\s+Disk limit \(e\.g\. 256M, 1024M, 1G\)`)) + Eventually(session).Should(Say(`-l\s+Log rate limit per second, in bytes \(e\.g\. 128B, 4K, 1M\). -l=-1 represents unlimited`)) Eventually(session).Should(Say(`-m\s+Memory limit \(e\.g\. 256M, 1024M, 1G\)`)) Eventually(session).Should(Say(`--process\s+App process to scale \(Default: web\)`)) @@ -102,10 +105,10 @@ var _ = Describe("scale command", func() { helpers.WithProcfileApp(func(appDir string) { Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0)) }) - helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, false, "32M") + helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, false, "256M") }) - When("scale option flags are not provided", func() { + XWhen("scale option flags are not provided", func() { It("displays the current scale properties for all processes", func() { session := helpers.CF("scale", appName) @@ -129,8 +132,8 @@ var _ = Describe("scale command", func() { Expect(processSummary.InstanceCount).To(Equal("1/1")) instanceSummary := processSummary.Instances[0] - Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+?[KMG]?`)) - Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+?[KMG]?`)) + Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of \d+?[BKMG]?`)) + Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of \d+?[BKMG]?`)) Expect(appTable.Processes[1].Type).To(Equal("console")) Expect(appTable.Processes[1].InstanceCount).To(Equal("0/0")) @@ -159,7 +162,7 @@ var _ = Describe("scale command", func() { Consistently(session).ShouldNot(Say("Stopping")) Consistently(session).ShouldNot(Say("Starting")) - helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, true, "32M") + helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, true, "256M") session = helpers.CF("app", appName) Eventually(session).Should(Exit(0)) @@ -171,12 +174,22 @@ var _ = Describe("scale command", func() { instanceSummary := processSummary.Instances[0] Expect(processSummary.Type).To(Equal("web")) Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/3`)) - Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`)) - Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`)) + Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of \d+[BKMG]`)) + Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of \d+[BKMG]`)) }) }) - When("Scaling the memory", func() { + When("-f flag provided", func() { + It("scales without prompt", func() { + session := helpers.CF("scale", appName, "-m", "64M", "-f") + Eventually(session).Should(Exit(0)) + Expect(session).To(Say("Scaling app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName)) + + helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, false, "64M") + }) + }) + + XWhen("Scaling the memory", func() { It("scales memory to 64M", func() { buffer := NewBuffer() _, err := buffer.Write([]byte("y\n")) @@ -191,7 +204,7 @@ var _ = Describe("scale command", func() { helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, false, "64M") }) - When("-f flag provided", func() { + XWhen("-f flag provided", func() { It("scales without prompt", func() { session := helpers.CF("scale", appName, "-m", "64M", "-f") Eventually(session).Should(Exit(0)) @@ -202,7 +215,7 @@ var _ = Describe("scale command", func() { }) }) - When("Scaling the disk space", func() { + XWhen("Scaling the disk space", func() { It("scales disk to 512M", func() { buffer := NewBuffer() _, err := buffer.Write([]byte("y\n")) @@ -218,7 +231,7 @@ var _ = Describe("scale command", func() { helpers.WaitForAppDiskToTakeEffect(appName, 0, 0, false, "512M") }) - When("-f flag provided", func() { + XWhen("-f flag provided", func() { It("scales without prompt", func() { session := helpers.CF("scale", appName, "-k", "512M", "-f") Eventually(session).Should(Exit(0)) @@ -229,6 +242,37 @@ var _ = Describe("scale command", func() { }) }) + XWhen("Scaling the log rate limit", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("scales log rate limit to 1M", func() { + buffer := NewBuffer() + _, err := buffer.Write([]byte("y\n")) + Expect(err).ToNot(HaveOccurred()) + session := helpers.CFWithStdin(buffer, "scale", appName, "-l", "1M") + Eventually(session).Should(Exit(0)) + Expect(session).To(Say(`Scaling app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Expect(session).To(Say(`This will cause the app to restart\. Are you sure you want to scale %s\? \[yN\]:`, appName)) + Expect(session).To(Say(`Stopping app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Expect(session).To(Say(`Starting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) + Expect(session).To(Say(`Instances starting\.\.\.`)) + + helpers.WaitForLogRateLimitToTakeEffect(appName, 0, 0, false, "1M") + }) + + XWhen("-f flag provided", func() { + It("scales without prompt", func() { + session := helpers.CF("scale", appName, "-l", "1M", "-f") + Eventually(session).Should(Exit(0)) + Expect(session).To(Say("Scaling app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName)) + + helpers.WaitForLogRateLimitToTakeEffect(appName, 0, 0, false, "1M") + }) + }) + }) + When("Scaling to 0 instances", func() { It("scales to 0 instances", func() { session := helpers.CF("scale", appName, "-i", "0") @@ -267,6 +311,10 @@ var _ = Describe("scale command", func() { buffer := NewBuffer() _, err := buffer.Write([]byte("y\n")) Expect(err).ToNot(HaveOccurred()) + + // Delay to reduce flakiness + time.Sleep(3 * time.Second) + session := helpers.CFWithStdin(buffer, "scale", appName, "-i", "2", "-k", "512M", "-m", "60M") Eventually(session).Should(Exit(0)) Expect(session).To(Say(`Scaling app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) @@ -276,6 +324,9 @@ var _ = Describe("scale command", func() { helpers.WaitForAppMemoryToTakeEffect(appName, 0, 0, false, "60M") + // Delay to reduce flakiness + time.Sleep(5 * time.Second) + session = helpers.CF("app", appName) Eventually(session).Should(Exit(0)) @@ -287,8 +338,8 @@ var _ = Describe("scale command", func() { Expect(processSummary.Type).To(Equal("web")) Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/2`)) Expect(instanceSummary.State).To(MatchRegexp(`running|starting`)) - Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 60M`)) - Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 512M`)) + Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of 60M`)) + Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of 512M`)) }) }) @@ -320,8 +371,8 @@ var _ = Describe("scale command", func() { Expect(processSummary.Type).To(Equal("web")) Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/2`)) Expect(instanceSummary.State).To(MatchRegexp(`crashed`)) - Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 6M`)) - Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 10M`)) + Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of 6M`)) + Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[BKMG]? of 10M`)) }) }) }) @@ -361,8 +412,8 @@ var _ = Describe("scale command", func() { newInstanceSummary := newProcessSummary.Instances[0] Expect(newProcessSummary.Type).To(Equal("web")) Expect(newProcessSummary.InstanceCount).To(MatchRegexp(fmt.Sprintf(`\d/%s`, currentInstances))) - Expect(newInstanceSummary.Memory).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, maxMemory))) - Expect(newInstanceSummary.Disk).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, maxDiskSize))) + Expect(newInstanceSummary.Memory).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[BKMG]? of %s`, maxMemory))) + Expect(newInstanceSummary.Disk).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[BKMG]? of %s`, maxDiskSize))) }) }) diff --git a/integration/v7/isolated/security_groups_command_test.go b/integration/v7/isolated/security_groups_command_test.go index e92e78c24b7..515bb9671c1 100644 --- a/integration/v7/isolated/security_groups_command_test.go +++ b/integration/v7/isolated/security_groups_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -118,6 +118,7 @@ var _ = Describe("security-groups command", func() { helpers.DeleteSecurityGroup(securityGroup3) helpers.DeleteSecurityGroup(securityGroup4) helpers.DeleteSecurityGroup(securityGroup5) + helpers.QuickDeleteOrg(orgName) }) It("displays the security groups exits 0", func() { diff --git a/integration/v7/isolated/service_access_command_test.go b/integration/v7/isolated/service_access_command_test.go index 43384585d35..300153531e8 100644 --- a/integration/v7/isolated/service_access_command_test.go +++ b/integration/v7/isolated/service_access_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -49,28 +49,28 @@ var _ = Describe("service-access command", func() { When("-b is provided with a broker name that does not exist", func() { It("shows an error message", func() { - session := helpers.CF("service-access", "-b", "non-existent-broker") + session := helpers.CF("service-access", "-b", "nonexistent-broker") Eventually(session).Should(Exit(1)) - Expect(session).To(Say(`Getting service access for broker non-existent-broker as %s\.\.\.`, userName)) - Expect(session.Err).To(Say(`(Service broker 'non-existent-broker' not found|No service offerings found for service broker 'non-existent-broker')\.`)) + Expect(session).To(Say(`Getting service access for broker nonexistent-broker as %s\.\.\.`, userName)) + Expect(session.Err).To(Say(`(Service broker 'nonexistent-broker' not found|No service offerings found for service broker 'nonexistent-broker')\.`)) }) }) When("-e is provided with a service name that does not exist", func() { It("shows an error message", func() { - session := helpers.CF("service-access", "-e", "non-existent-service") + session := helpers.CF("service-access", "-e", "nonexistent-service") Eventually(session).Should(Exit(1)) - Expect(session).To(Say(`Getting service access for service offering non-existent-service as %s\.\.\.`, userName)) - Expect(session.Err).To(Say(`Service offering 'non-existent-service' not found\.`)) + Expect(session).To(Say(`Getting service access for service offering nonexistent-service as %s\.\.\.`, userName)) + Expect(session.Err).To(Say(`Service offering 'nonexistent-service' not found\.`)) }) }) When("-o is provided with a org name that does not exist", func() { It("shows an error message", func() { - session := helpers.CF("service-access", "-o", "non-existent-org") + session := helpers.CF("service-access", "-o", "nonexistent-org") Eventually(session).Should(Exit(1)) - Expect(session).To(Say(`Getting service access for organization non-existent-org as %s\.\.\.`, userName)) - Expect(session.Err).To(Say(`Organization 'non-existent-org' not found`)) + Expect(session).To(Say(`Getting service access for organization nonexistent-org as %s\.\.\.`, userName)) + Expect(session.Err).To(Say(`Organization 'nonexistent-org' not found`)) }) }) diff --git a/integration/v7/isolated/service_brokers_command_test.go b/integration/v7/isolated/service_brokers_command_test.go index 84e050170ea..cf6d867eda4 100644 --- a/integration/v7/isolated/service_brokers_command_test.go +++ b/integration/v7/isolated/service_brokers_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/service_command_test.go b/integration/v7/isolated/service_command_test.go index 39dcc1e664b..f17b3560093 100644 --- a/integration/v7/isolated/service_command_test.go +++ b/integration/v7/isolated/service_command_test.go @@ -5,9 +5,9 @@ import ( "strings" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -171,14 +171,20 @@ var _ = Describe("service command", func() { }) It("displays the bound apps", func() { + // Delay to reduce flakiness + time.Sleep(10 * time.Second) + session := helpers.CF(serviceCommand, serviceInstanceName, "-v") Eventually(session).Should(Exit(0)) + // Delay to reduce flakiness + time.Sleep(10 * time.Second) + Expect(session).To(SatisfyAll( Say(`Showing bound apps:\n`), - Say(`name\s+binding name\s+status\s+message\n`), - Say(`%s\s+%s\s+create succeeded\s*\n`, appName1, bindingName1), - Say(`%s\s+%s\s+create succeeded\s*\n`, appName2, bindingName2), + Say(`name\s+binding name\s+status\s+message\s+guid\s+created_at\n`), + Say(`%s\s+%s\s+create succeeded\s+%s\s+%s\n`, appName1, bindingName1, helpers.GUIDRegex, helpers.TimestampRegex), + Say(`%s\s+%s\s+create succeeded\s+%s\s+%s\n`, appName2, bindingName2, helpers.GUIDRegex, helpers.TimestampRegex), )) }) }) @@ -522,9 +528,9 @@ var _ = Describe("service command", func() { Expect(session).To(SatisfyAll( Say(`Showing bound apps:\n`), - Say(`name\s+binding name\s+status\s+message\n`), - Say(`%s\s+%s\s+create succeeded\s+very happy service\n`, appName1, bindingName1), - Say(`%s\s+%s\s+create succeeded\s+very happy service\n`, appName2, bindingName2), + Say(`name\s+binding name\s+status\s+message\s+guid\s+created_at\n`), + Say(`%s\s+%s\s+create succeeded\s+very happy service\s+%s\s+%s\n`, appName1, bindingName1, helpers.GUIDRegex, helpers.TimestampRegex), + Say(`%s\s+%s\s+create succeeded\s+very happy service\s+%s\s+%s\n`, appName2, bindingName2, helpers.GUIDRegex, helpers.TimestampRegex), )) }) }) diff --git a/integration/v7/isolated/service_key_command_test.go b/integration/v7/isolated/service_key_command_test.go index 28ba833ca96..e5083ff5f0c 100644 --- a/integration/v7/isolated/service_key_command_test.go +++ b/integration/v7/isolated/service_key_command_test.go @@ -1,13 +1,13 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" . "github.com/onsi/gomega/gexec" . "github.com/onsi/gomega/gbytes" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/integration/v7/isolated/service_keys_command_test.go b/integration/v7/isolated/service_keys_command_test.go index f018986d684..0d56cbb84b7 100644 --- a/integration/v7/isolated/service_keys_command_test.go +++ b/integration/v7/isolated/service_keys_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/services_command_test.go b/integration/v7/isolated/services_command_test.go index 348313e7b40..f8b8d2bcbc3 100644 --- a/integration/v7/isolated/services_command_test.go +++ b/integration/v7/isolated/services_command_test.go @@ -2,9 +2,9 @@ package isolated import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -163,11 +163,11 @@ var _ = Describe("services command", func() { Context("has shared service instances", func() { var ( - managedService, appNameOnSpaceA, appNameOnSpaceB string + managedService, appNameOnSpaceA, appNameOnSpaceB, orgName string ) BeforeEach(func() { - orgName := helpers.NewOrgName() + orgName = helpers.NewOrgName() spaceA := helpers.NewSpaceName() spaceB := helpers.NewSpaceName() managedService = helpers.PrefixedRandomName("MANAGED1") @@ -193,6 +193,10 @@ var _ = Describe("services command", func() { helpers.TargetOrgAndSpace(orgName, spaceA) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + It("should not output bound apps in the shared spaces", func() { session := helpers.CF(command) Eventually(session).Should(Exit(0)) diff --git a/integration/v7/isolated/set_droplet_command_test.go b/integration/v7/isolated/set_droplet_command_test.go index b75a4349df9..22067f86eda 100644 --- a/integration/v7/isolated/set_droplet_command_test.go +++ b/integration/v7/isolated/set_droplet_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_env_command_test.go b/integration/v7/isolated/set_env_command_test.go index fd5afe6a35c..63ad8c5fc62 100644 --- a/integration/v7/isolated/set_env_command_test.go +++ b/integration/v7/isolated/set_env_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -130,8 +130,12 @@ var _ = Describe("set-env command", func() { Eventually(session).Should(Exit(0)) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/environment_variables", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"%s": "%s"`, envVarName, envVarValue)) Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnvVarValue := helpers.GetsDefaultEnvVarValue(bytes) + Expect(actualEnvVarValue).To(Equal(envVarValue)) }) // This is to prevent the '-' being read in as another flag @@ -149,8 +153,12 @@ var _ = Describe("set-env command", func() { Eventually(session).Should(Exit(0)) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/environment_variables", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"%s": "%s"`, envVarName, envVarValue)) Eventually(session).Should(Exit(0)) + + bytes := session.Out.Contents() + + actualEnvVarValue := helpers.GetsDefaultEnvVarValue(bytes) + Expect(actualEnvVarValue).To(Equal(envVarValue)) }) }) }) @@ -170,8 +178,11 @@ var _ = Describe("set-env command", func() { Eventually(session).Should(Exit(0)) session = helpers.CF("curl", fmt.Sprintf("v3/apps/%s/environment_variables", helpers.AppGUID(appName))) - Eventually(session).Should(Say(`"%s": "%s"`, envVarName, someOtherValue)) Eventually(session).Should(Exit(0)) + bytes := session.Out.Contents() + + actualEnvVarValue := helpers.GetsDefaultEnvVarValue(bytes) + Expect(actualEnvVarValue).To(Equal(someOtherValue)) }) }) diff --git a/integration/v7/isolated/set_health_check_command_test.go b/integration/v7/isolated/set_health_check_command_test.go index a03fcf675aa..111a46b56a6 100644 --- a/integration/v7/isolated/set_health_check_command_test.go +++ b/integration/v7/isolated/set_health_check_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_label_command_test.go b/integration/v7/isolated/set_label_command_test.go index 40091753876..0dc4ad0a5fa 100644 --- a/integration/v7/isolated/set_label_command_test.go +++ b/integration/v7/isolated/set_label_command_test.go @@ -4,11 +4,11 @@ import ( "fmt" "regexp" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,7 +33,7 @@ var _ = Describe("set-label command", func() { Eventually(session).Should(Say("EXAMPLES:")) Eventually(session).Should(Say(`\s+cf set-label app dora env=production`)) Eventually(session).Should(Say(`\s+cf set-label org business pci=true public-facing=false`)) - Eventually(session).Should(Say(`\s+cf set-label buildpack go_buildpack go=1.12 -s cflinuxfs3`)) + Eventually(session).Should(Say(`\s+cf set-label buildpack go_buildpack go=1.12 -s cflinuxfs4`)) Eventually(session).Should(Say("RESOURCES:")) Eventually(session).Should(Say(`\s+app`)) Eventually(session).Should(Say(`\s+buildpack`)) @@ -68,7 +68,7 @@ var _ = Describe("set-label command", func() { testExpectedBehaviors := func(resourceType, resourceTypeFormatted, resourceName string) { By("checking the behavior when the resource does not exist", func() { - unknownResourceName := "non-existent-" + resourceType + unknownResourceName := "nonexistent-" + resourceType session := helpers.CF("set-label", resourceType, unknownResourceName, "some-key=some-value") Eventually(session.Err).Should(Say("%s '%s' not found", resourceTypeFormatted, unknownResourceName)) Eventually(session).Should(Say("FAILED")) @@ -331,9 +331,9 @@ var _ = Describe("set-label command", func() { When("the route is unknown", func() { It("displays an error", func() { - invalidRoute := "non-existent-host." + domainName + invalidRoute := "nonexistent-host." + domainName session := helpers.CF("set-label", "route", invalidRoute, "some-key=some-value") - Eventually(session.Err).Should(Say(`Route with host 'non-existent-host', domain '%s', and path '/' not found\.`, domainName)) + Eventually(session.Err).Should(Say(`Route with host 'nonexistent-host', domain '%s', and path '/' not found\.`, domainName)) Eventually(session.Out).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -427,7 +427,7 @@ var _ = Describe("set-label command", func() { When("stack is not specified", func() { It("displays an error", func() { session := helpers.CF("set-label", "buildpack", buildpackName, "some-key=some-value") - Eventually(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.", buildpackName))) + Eventually(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.", buildpackName))) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) @@ -504,13 +504,13 @@ var _ = Describe("set-label command", func() { When("no stack is specified", func() { It("displays an error", func() { session := helpers.CF("set-label", "buildpack", buildpackName, "some-key=some-value") - Eventually(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.", buildpackName))) + Eventually(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.", buildpackName))) Eventually(session).Should(Say("FAILED")) Eventually(session).Should(Exit(1)) }) }) - When("a non-existent stack is specified", func() { + When("a nonexistent stack is specified", func() { It("displays an error", func() { bogusStackName := stacks[0] + "-bogus-" + stacks[1] session := helpers.CF("set-label", "buildpack", buildpackName, "olive=3", "mangosteen=4", "--stack", bogusStackName) @@ -575,7 +575,7 @@ var _ = Describe("set-label command", func() { }) }) - When("a non-existent stack is specified", func() { + When("a nonexistent stack is specified", func() { It("displays an error", func() { bogusStackName := stacks[0] + "-bogus-" + stacks[1] session := helpers.CF("set-label", "buildpack", buildpackName, "olive=3", "mangosteen=4", "--stack", bogusStackName) diff --git a/integration/v7/isolated/set_org_default_isolation_segment_command_test.go b/integration/v7/isolated/set_org_default_isolation_segment_command_test.go index f15ef040468..1fe0a20d181 100644 --- a/integration/v7/isolated/set_org_default_isolation_segment_command_test.go +++ b/integration/v7/isolated/set_org_default_isolation_segment_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_org_quota_command_test.go b/integration/v7/isolated/set_org_quota_command_test.go index fd1fd1bcc66..7773d871fec 100644 --- a/integration/v7/isolated/set_org_quota_command_test.go +++ b/integration/v7/isolated/set_org_quota_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_org_role_command_test.go b/integration/v7/isolated/set_org_role_command_test.go index 4428cf074f8..b77b7a1c0fe 100644 --- a/integration/v7/isolated/set_org_role_command_test.go +++ b/integration/v7/isolated/set_org_role_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_space_isolation_segment_command_test.go b/integration/v7/isolated/set_space_isolation_segment_command_test.go index 44050980843..f339a3e9a5d 100644 --- a/integration/v7/isolated/set_space_isolation_segment_command_test.go +++ b/integration/v7/isolated/set_space_isolation_segment_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_space_quota_command_test.go b/integration/v7/isolated/set_space_quota_command_test.go index d92344b6cd5..e427e3de531 100644 --- a/integration/v7/isolated/set_space_quota_command_test.go +++ b/integration/v7/isolated/set_space_quota_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/set_space_role_command_test.go b/integration/v7/isolated/set_space_role_command_test.go index 8cce52ff55f..b669ef7bf9b 100644 --- a/integration/v7/isolated/set_space_role_command_test.go +++ b/integration/v7/isolated/set_space_role_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/share_private_domain_test.go b/integration/v7/isolated/share_private_domain_test.go index c4be911f8e3..1564da6915a 100644 --- a/integration/v7/isolated/share_private_domain_test.go +++ b/integration/v7/isolated/share_private_domain_test.go @@ -3,10 +3,10 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -58,6 +58,11 @@ var _ = Describe("share-private-domain command", func() { domain.CreatePrivate() }) + AfterEach(func() { + helpers.QuickDeleteOrg(sharedWithOrgName) + helpers.QuickDeleteOrg(orgName) + }) + It("should create the shared domain", func() { session := helpers.CF("share-private-domain", sharedWithOrgName, domainName) diff --git a/integration/v7/isolated/share_route_command_test.go b/integration/v7/isolated/share_route_command_test.go new file mode 100644 index 00000000000..a4bdee33eb0 --- /dev/null +++ b/integration/v7/isolated/share_route_command_test.go @@ -0,0 +1,205 @@ +package isolated + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("share route command", func() { + Context("Help", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("share-route", "ROUTES", "Share a route in between spaces")) + }) + + It("displays the help information", func() { + session := helpers.CF("share-route", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say("share-route - Share a route in between spaces")) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`Share an existing route in between two spaces:`)) + Eventually(session).Should(Say(`cf share-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] -s OTHER_SPACE \[-o OTHER_ORG\]`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf share-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo`)) + Eventually(session).Should(Say(`cf share-route example.com --hostname myHost -s TargetSpace # myhost.example.com`)) + Eventually(session).Should(Say(`cf share-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) + Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) + Eventually(session).Should(Say(`-o\s+The org of the destination space \(Default: targeted org\)`)) + Eventually(session).Should(Say(`-s\s+The space the route will be shared with \(Default: targeted space\)`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`create-route, map-route, routes, unmap-route`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "share-route", "some-domain", "-s SOME_SPACE") + }) + }) + + When("the environment is set up correctly", func() { + var ( + userName string + orgName string + spaceName string + ) + + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionHTTP2RoutingV3) + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + userName, _ = helpers.GetCredentials() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the domain exists", func() { + var ( + domainName string + targetSpaceName string + ) + + BeforeEach(func() { + domainName = helpers.NewDomainName() + }) + + When("the route exists", func() { + var ( + domain helpers.Domain + hostname string + ) + When("the target space exists in targeted org", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + }) + + It("shares the route to the destination space", func() { + session := helpers.CF("share-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say(`Sharing route %s.%s to space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the target organization does not exist", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + targetOrgName = helpers.NewOrgName() + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 and an error message", func() { + session := helpers.CF("share-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not share route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the target space exists in another existing org", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + targetOrgName = helpers.NewOrgName() + targetSpaceName = helpers.NewSpaceName() + helpers.CreateOrgAndSpace(targetOrgName, targetSpaceName) + helpers.SetupCF(orgName, spaceName) + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + helpers.QuickDeleteOrg(targetOrgName) + }) + + It("shared the route to the destination space", func() { + session := helpers.CF("share-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say(`Sharing route %s.%s to space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the space does not exist", func() { + var destinationSpaceName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + destinationSpaceName = "doesNotExistSpace" + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 with an error", func() { + session := helpers.CF("share-route", domainName, "--hostname", hostname, "-s", destinationSpaceName) + Eventually(session).Should(Say("Can not share route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the route does not exist", func() { + var ( + domain helpers.Domain + hostname string + ) + + When("the target space exists", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.Create() + }) + + It("exits with 1 with an error message", func() { + session := helpers.CF("share-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not share route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/share_service_command_test.go b/integration/v7/isolated/share_service_command_test.go index ee67eb057c0..79412ff26ee 100644 --- a/integration/v7/isolated/share_service_command_test.go +++ b/integration/v7/isolated/share_service_command_test.go @@ -1,10 +1,10 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/space_command_test.go b/integration/v7/isolated/space_command_test.go index 60334800966..0bcb5cf8700 100644 --- a/integration/v7/isolated/space_command_test.go +++ b/integration/v7/isolated/space_command_test.go @@ -3,11 +3,11 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/space_quota_command_test.go b/integration/v7/isolated/space_quota_command_test.go index 34798df7ef7..c1e4af111fc 100644 --- a/integration/v7/isolated/space_quota_command_test.go +++ b/integration/v7/isolated/space_quota_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -49,6 +49,10 @@ var _ = Describe("space-quota command", func() { helpers.TargetOrg(orgName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("the quota does not exist", func() { It("displays quota not found and exits 1", func() { session := helpers.CF("space-quota", quotaName) @@ -85,6 +89,7 @@ var _ = Describe("space-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+allowed`)) Eventually(session).Should(Say(`app instances:\s+unlimited`)) Eventually(session).Should(Say(`route ports:\s+0`)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/space_quotas_command_test.go b/integration/v7/isolated/space_quotas_command_test.go index 880a561560b..7a9b7b3456b 100644 --- a/integration/v7/isolated/space_quotas_command_test.go +++ b/integration/v7/isolated/space_quotas_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -62,8 +62,8 @@ var _ = Describe("space-quotas command", func() { It("lists the space quotas", func() { session := helpers.CF("space-quotas") Eventually(session).Should(Say(`Getting space quotas for org %s as %s\.\.\.`, orgName, userName)) - Eventually(session).Should(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports`)) - Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, quotaName, totalMemory, instanceMemory, routes, serviceInstances, "allowed", "unlimited", reservedRoutePorts)) + Eventually(session).Should(Say(`name\s+total memory\s+instance memory\s+routes\s+service instances\s+paid service plans\s+app instances\s+route ports\s+log volume per second`)) + Eventually(session).Should(Say(`%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s\s+%s`, quotaName, totalMemory, instanceMemory, routes, serviceInstances, "allowed", "unlimited", reservedRoutePorts, "unlimited")) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/space_ssh_allowed_command_test.go b/integration/v7/isolated/space_ssh_allowed_command_test.go index a115fa64834..a4b402bfee3 100644 --- a/integration/v7/isolated/space_ssh_allowed_command_test.go +++ b/integration/v7/isolated/space_ssh_allowed_command_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -65,7 +65,7 @@ var _ = Describe("space-ssh-allowed command", func() { When("the space does not exist", func() { BeforeEach(func() { - spaceName = "non-existent-space" + spaceName = "nonexistent-space" }) It("displays a missing space error message and fails", func() { diff --git a/integration/v7/isolated/space_users_command_test.go b/integration/v7/isolated/space_users_command_test.go index 5d090b2f576..abba3804516 100644 --- a/integration/v7/isolated/space_users_command_test.go +++ b/integration/v7/isolated/space_users_command_test.go @@ -3,13 +3,13 @@ package isolated import ( "regexp" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" ) var _ = Describe("space-users command", func() { @@ -42,6 +42,10 @@ var _ = Describe("space-users command", func() { helpers.CreateOrgAndSpace(orgName, spaceName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("the target space has multiple users with different roles", func() { var ( spaceManagerUser string diff --git a/integration/v7/isolated/spaces_command_test.go b/integration/v7/isolated/spaces_command_test.go index 0357a5e9ea1..16759fd65cc 100644 --- a/integration/v7/isolated/spaces_command_test.go +++ b/integration/v7/isolated/spaces_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -60,6 +60,10 @@ var _ = Describe("spaces command", func() { helpers.CreateSpace(spaceName6) }) + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + When("the --labels flag is given", func() { BeforeEach(func() { diff --git a/integration/v7/isolated/ssh_code_command_test.go b/integration/v7/isolated/ssh_code_command_test.go index 54316f2e638..cbf7397b97d 100644 --- a/integration/v7/isolated/ssh_code_command_test.go +++ b/integration/v7/isolated/ssh_code_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/ssh_command_test.go b/integration/v7/isolated/ssh_command_test.go index 69229a4adf9..fcd647ded9a 100644 --- a/integration/v7/isolated/ssh_command_test.go +++ b/integration/v7/isolated/ssh_command_test.go @@ -5,10 +5,10 @@ import ( "net/http" "time" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -283,7 +283,7 @@ var _ = Describe("ssh command", func() { var port int BeforeEach(func() { - port = 55500 + GinkgoParallelNode() + port = 55500 + GinkgoParallelProcess() }) It("configures local port to connect to the app port", func() { @@ -296,7 +296,7 @@ var _ = Describe("ssh command", func() { Eventually(BufferReader(response.Body)).Should(Say("WEBrick")) - session.Kill() + session.Interrupt() Eventually(session).Should(Exit()) }) }) diff --git a/integration/v7/isolated/ssh_enabled_command_test.go b/integration/v7/isolated/ssh_enabled_command_test.go index f5f13781c82..60d74540eb3 100644 --- a/integration/v7/isolated/ssh_enabled_command_test.go +++ b/integration/v7/isolated/ssh_enabled_command_test.go @@ -1,10 +1,10 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/stack_command_test.go b/integration/v7/isolated/stack_command_test.go index 73e138e34d2..8f065a8b649 100644 --- a/integration/v7/isolated/stack_command_test.go +++ b/integration/v7/isolated/stack_command_test.go @@ -4,10 +4,10 @@ import ( "fmt" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/stacks_command_test.go b/integration/v7/isolated/stacks_command_test.go index 8911396ddcf..6783ced7d39 100644 --- a/integration/v7/isolated/stacks_command_test.go +++ b/integration/v7/isolated/stacks_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,7 +33,7 @@ var _ = Describe("stacks command", func() { Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`--labels\s+Selector to filter stacks by labels`)) Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say("create-buildpack, delete-buildpack, rename-buildpack, stack, update-buildpack")) + Eventually(session).Should(Say("create-buildpack, delete-buildpack, stack, update-buildpack")) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/isolated/stage_package_command_test.go b/integration/v7/isolated/stage_package_command_test.go index 29091d49a22..59e86673fef 100644 --- a/integration/v7/isolated/stage_package_command_test.go +++ b/integration/v7/isolated/stage_package_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/start_command_test.go b/integration/v7/isolated/start_command_test.go index 00d7887f79f..e3ac2de11cf 100644 --- a/integration/v7/isolated/start_command_test.go +++ b/integration/v7/isolated/start_command_test.go @@ -2,14 +2,13 @@ package isolated import ( "fmt" + "regexp" "strings" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - - "regexp" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -129,8 +128,8 @@ var _ = Describe("start command", func() { Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) - Eventually(session).Should(Say(`memory usage:\s+32M`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Eventually(session).Should(Say(`memory usage:\s+256M`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details`)) Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) Eventually(session).Should(Exit(0)) @@ -187,7 +186,7 @@ var _ = Describe("start command", func() { Eventually(session).Should(Say(`requested state:\s+started`)) Eventually(session).Should(Say(`type:\s+web`)) Eventually(session).Should(Say(`instances:\s+1/1`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+details`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement\s+details`)) Eventually(session).Should(Say(`#0\s+(starting|running)\s+\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z`)) Eventually(session).Should(Exit(0)) diff --git a/integration/v7/isolated/stop_command_test.go b/integration/v7/isolated/stop_command_test.go index 4ceb44b77d3..534095e88e2 100644 --- a/integration/v7/isolated/stop_command_test.go +++ b/integration/v7/isolated/stop_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/suggest_command_test.go b/integration/v7/isolated/suggest_command_test.go index d602c2b30a6..d7c3bac87ee 100644 --- a/integration/v7/isolated/suggest_command_test.go +++ b/integration/v7/isolated/suggest_command_test.go @@ -3,7 +3,7 @@ package isolated import ( "os/exec" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/table_alignment_test.go b/integration/v7/isolated/table_alignment_test.go index 46e3cfc7cff..ff2599f9ac5 100644 --- a/integration/v7/isolated/table_alignment_test.go +++ b/integration/v7/isolated/table_alignment_test.go @@ -1,8 +1,8 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/target_command_test.go b/integration/v7/isolated/target_command_test.go index 6741b7e59a0..63644078774 100644 --- a/integration/v7/isolated/target_command_test.go +++ b/integration/v7/isolated/target_command_test.go @@ -1,11 +1,11 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/task_command_test.go b/integration/v7/isolated/task_command_test.go new file mode 100644 index 00000000000..cad0a92760b --- /dev/null +++ b/integration/v7/isolated/task_command_test.go @@ -0,0 +1,127 @@ +package isolated + +import ( + "fmt" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("task command", func() { + var ( + appName string + ) + + BeforeEach(func() { + appName = helpers.PrefixedRandomName("APP") + }) + + When("--help flag is set", func() { + It("Displays command usage to output", func() { + session := helpers.CF("task", "--help") + Eventually(session).Should(Say("NAME:")) + Eventually(session).Should(Say(" task - Display a task of an app")) + Eventually(session).Should(Say("USAGE:")) + Eventually(session).Should(Say(" cf task APP_NAME TASK_ID")) + Eventually(session).Should(Say("SEE ALSO:")) + Eventually(session).Should(Say(" apps, logs, run-task, tasks, terminate-task")) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "task", "app-name", "1") + }) + }) + + When("the environment is setup correctly", func() { + var ( + orgName string + spaceName string + ) + + BeforeEach(func() { + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + }) + + AfterEach(func() { + helpers.LoginCF() + helpers.QuickDeleteOrg(orgName) + }) + + When("the application does not exist", func() { + It("fails and outputs an app not found message", func() { + session := helpers.CF("task", appName, "1") + Eventually(session).Should(Say("FAILED")) + Eventually(session.Err).Should(Say(fmt.Sprintf("App '%s' not found", appName))) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the application exists", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CF("push", appName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0)) + }) + }) + + When("the application does not have the associated task", func() { + It("displays an erro", func() { + session := helpers.CF("task", appName, "1000") + Eventually(session.Err).Should(Say(`Task sequence ID 1000 not found`)) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the application has associated tasks", func() { + BeforeEach(func() { + Eventually(helpers.CF("run-task", appName, "--command", "echo hello world")).Should(Exit(0)) + }) + + It("displays the task", func() { + session := helpers.CF("task", appName, "1") + userName, _ := helpers.GetCredentials() + Eventually(session).Should(Say(fmt.Sprintf("Getting task 1 for app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))) + + Eventually(session).Should(Say(`id:\s+1`)) + Eventually(session).Should(Say(`name:\s+`)) + Eventually(session).Should(Say(`state:\s+`)) + Eventually(session).Should(Say(`command:\s+echo hello world`)) + + Eventually(session).Should(Exit(0)) + }) + + When("the logged in user does not have authorization to see task commands", func() { + var user string + + BeforeEach(func() { + user = helpers.NewUsername() + password := helpers.NewPassword() + Eventually(helpers.CF("create-user", user, password)).Should(Exit(0)) + Eventually(helpers.CF("set-space-role", user, orgName, spaceName, "SpaceAuditor")).Should(Exit(0)) + helpers.LogoutCF() + env := map[string]string{ + "CF_USERNAME": user, + "CF_PASSWORD": password, + } + Eventually(helpers.CFWithEnv(env, "auth")).Should(Exit(0)) + Eventually(helpers.CF("target", "-o", orgName, "-s", spaceName)).Should(Exit(0)) + }) + + It("displays [hidden] as tasks command", func() { + session := helpers.CF("task", appName, "1") + Eventually(session).Should(Say(`.*command:\s+\[hidden\]`)) + Eventually(session).Should(Exit(0)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/tasks_command_test.go b/integration/v7/isolated/tasks_command_test.go index 4c19fa0d484..41b2c609acc 100644 --- a/integration/v7/isolated/tasks_command_test.go +++ b/integration/v7/isolated/tasks_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +27,7 @@ var _ = Describe("tasks command", func() { Eventually(session).Should(Say("USAGE:")) Eventually(session).Should(Say(" cf tasks APP_NAME")) Eventually(session).Should(Say("SEE ALSO:")) - Eventually(session).Should(Say(" apps, logs, run-task, terminate-task")) + Eventually(session).Should(Say(" apps, logs, run-task, task, terminate-task")) Eventually(session).Should(Exit(0)) }) }) diff --git a/integration/v7/isolated/terminate_task_command_test.go b/integration/v7/isolated/terminate_task_command_test.go index 93d5937739c..f78dce2b36d 100644 --- a/integration/v7/isolated/terminate_task_command_test.go +++ b/integration/v7/isolated/terminate_task_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/token_refresh_test.go b/integration/v7/isolated/token_refresh_test.go index 0eec8352a38..e0fd08ad2c8 100644 --- a/integration/v7/isolated/token_refresh_test.go +++ b/integration/v7/isolated/token_refresh_test.go @@ -1,10 +1,10 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/unbind_route_service_command_test.go b/integration/v7/isolated/unbind_route_service_command_test.go index 1db4aa1eace..3a900bc5df9 100644 --- a/integration/v7/isolated/unbind_route_service_command_test.go +++ b/integration/v7/isolated/unbind_route_service_command_test.go @@ -4,10 +4,10 @@ import ( "regexp" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -87,7 +87,7 @@ var _ = Describe("unbind-route-service command", func() { var receiver struct { Resources []resources.RouteBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_route_bindings?service_instance_names=%s", serviceInstanceName) return len(receiver.Resources) } diff --git a/integration/v7/isolated/unbind_service_command_test.go b/integration/v7/isolated/unbind_service_command_test.go index f5c4a921cf9..de67bc11386 100644 --- a/integration/v7/isolated/unbind_service_command_test.go +++ b/integration/v7/isolated/unbind_service_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -70,7 +70,7 @@ var _ = Describe("unbind-service command", func() { When("the environment is not setup correctly", func() { It("fails with the appropriate errors", func() { - helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "bind-service", "app-name", "service-name") + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, command, "app-name", "service-name") }) }) @@ -85,7 +85,7 @@ var _ = Describe("unbind-service command", func() { var receiver struct { Resources []resources.ServiceCredentialBinding `json:"resources"` } - helpers.Curl(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) + helpers.Curlf(&receiver, "/v3/service_credential_bindings?service_instance_names=%s", serviceInstanceName) return len(receiver.Resources) } diff --git a/integration/v7/isolated/unmap_route_command_test.go b/integration/v7/isolated/unmap_route_command_test.go index c8e0778ef9c..4079b6727e6 100644 --- a/integration/v7/isolated/unmap_route_command_test.go +++ b/integration/v7/isolated/unmap_route_command_test.go @@ -3,9 +3,9 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -71,6 +71,7 @@ var _ = Describe("unmap-route command", func() { tcpRoute helpers.Route port int tcpDomain helpers.Domain + options map[string]*string ) BeforeEach(func() { @@ -82,12 +83,13 @@ var _ = Describe("unmap-route command", func() { helpers.SetupCF(orgName, spaceName) userName, _ = helpers.GetCredentials() domainName = helpers.DefaultSharedDomain() + options = helpers.NewOptions() routerGroupName := helpers.FindOrCreateTCPRouterGroup(4) tcpDomain = helpers.NewDomain(orgName, helpers.NewDomainName("TCP-DOMAIN")) tcpDomain.CreateWithRouterGroup(routerGroupName) - route = helpers.NewRoute(spaceName, domainName, hostName, path) + route = helpers.NewRoute(spaceName, domainName, hostName, path, options) route.V7Create() helpers.WithHelloWorldApp(func(dir string) { @@ -117,8 +119,8 @@ var _ = Describe("unmap-route command", func() { }) When("it's a TCP route", func() { BeforeEach(func() { - port = 1024 - tcpRoute = helpers.NewTCPRoute(spaceName, tcpDomain.Name, port) + port = helpers.GetPort() + tcpRoute = helpers.NewTCPRoute(spaceName, tcpDomain.Name, port, options) session := helpers.CF("map-route", appName, tcpDomain.Name, "--port", fmt.Sprintf("%d", tcpRoute.Port)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/isolated/unset_env_command_test.go b/integration/v7/isolated/unset_env_command_test.go index 866181eb176..9419e5c0a6d 100644 --- a/integration/v7/isolated/unset_env_command_test.go +++ b/integration/v7/isolated/unset_env_command_test.go @@ -3,10 +3,10 @@ package isolated import ( "fmt" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/unset_label_command_test.go b/integration/v7/isolated/unset_label_command_test.go index c63edc1a945..b20113b1ef4 100644 --- a/integration/v7/isolated/unset_label_command_test.go +++ b/integration/v7/isolated/unset_label_command_test.go @@ -4,10 +4,10 @@ import ( "fmt" "regexp" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -31,7 +31,7 @@ var _ = Describe("unset-label command", func() { Eventually(session).Should(Say("EXAMPLES:")) Eventually(session).Should(Say(`\s+cf unset-label app dora ci_signature_sha2`)) Eventually(session).Should(Say(`\s+cf unset-label org business pci public-facing`)) - Eventually(session).Should(Say(`\s+cf unset-label buildpack go_buildpack go -s cflinuxfs3`)) + Eventually(session).Should(Say(`\s+cf unset-label buildpack go_buildpack go -s cflinuxfs4`)) Eventually(session).Should(Say("RESOURCES:")) Eventually(session).Should(Say(`\s+app`)) Eventually(session).Should(Say(`\s+buildpack`)) @@ -139,9 +139,9 @@ var _ = Describe("unset-label command", func() { When("the buildpack is unknown", func() { It("displays an error", func() { - session := helpers.CF("unset-label", "buildpack", "non-existent-buildpack", "some-key=some-value") + session := helpers.CF("unset-label", "buildpack", "nonexistent-buildpack", "some-key=some-value") Eventually(session).Should(Exit(1)) - Expect(session.Err).Should(Say("Buildpack 'non-existent-buildpack' not found")) + Expect(session.Err).Should(Say("Buildpack 'nonexistent-buildpack' not found")) Expect(session).Should(Say("FAILED")) }) }) @@ -174,7 +174,7 @@ var _ = Describe("unset-label command", func() { It("displays an error", func() { session := helpers.CF("unset-label", "buildpack", buildpackName, "pci") Eventually(session).Should(Exit(1)) - Expect(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag.", buildpackName))) + Expect(session.Err).Should(Say(fmt.Sprintf("Multiple buildpacks named %s found. Specify a stack name by using a '-s' flag and/or lifecycle using a '-l' flag.", buildpackName))) Expect(session).Should(Say("FAILED")) }) }) diff --git a/integration/v7/isolated/unset_org_role_command_test.go b/integration/v7/isolated/unset_org_role_command_test.go index 3cc336c15ad..22de6551aa8 100644 --- a/integration/v7/isolated/unset_org_role_command_test.go +++ b/integration/v7/isolated/unset_org_role_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/unset_space_quota_command_test.go b/integration/v7/isolated/unset_space_quota_command_test.go index c3183e69fdb..318492f8f95 100644 --- a/integration/v7/isolated/unset_space_quota_command_test.go +++ b/integration/v7/isolated/unset_space_quota_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/unset_space_role_command_test.go b/integration/v7/isolated/unset_space_role_command_test.go index f6cf0937ced..44950142573 100644 --- a/integration/v7/isolated/unset_space_role_command_test.go +++ b/integration/v7/isolated/unset_space_role_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/unshare_private_domain_test.go b/integration/v7/isolated/unshare_private_domain_test.go index 2287b5e8cb0..0e84038dcb0 100644 --- a/integration/v7/isolated/unshare_private_domain_test.go +++ b/integration/v7/isolated/unshare_private_domain_test.go @@ -1,9 +1,9 @@ package isolated import ( - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -70,6 +70,10 @@ var _ = Describe("unshare-private-domain command", func() { domain.V7Share(sharedToOrgName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(sharedToOrgName) + }) + It("unshares the domain from the org", func() { buffer := NewBuffer() _, err := buffer.Write([]byte("y\n")) @@ -98,6 +102,10 @@ var _ = Describe("unshare-private-domain command", func() { domain.V7Share(sharedToOrgName) }) + AfterEach(func() { + helpers.QuickDeleteOrg(sharedToOrgName) + }) + It("does not unshare the domain from the org", func() { buffer := NewBuffer() _, err := buffer.Write([]byte("n\n")) diff --git a/integration/v7/isolated/unshare_route_command_test.go b/integration/v7/isolated/unshare_route_command_test.go new file mode 100644 index 00000000000..4712985954f --- /dev/null +++ b/integration/v7/isolated/unshare_route_command_test.go @@ -0,0 +1,210 @@ +package isolated + +import ( + "fmt" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("unshare route command", func() { + Context("Help", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + + fmt.Println(session) + + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("unshare-route", "ROUTES", "Unshare an existing route from a space")) + }) + + It("displays the help information", func() { + session := helpers.CF("unshare-route", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say("unshare-route - Unshare an existing route from a space")) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`Unshare an existing route from a space:`)) + Eventually(session).Should(Say(`cf unshare-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] -s OTHER_SPACE \[-o OTHER_ORG\]`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf unshare-route example.com --hostname myHost --path foo -s TargetSpace -o TargetOrg # myhost.example.com/foo`)) + Eventually(session).Should(Say(`cf unshare-route example.com --hostname myHost -s TargetSpace # myhost.example.com`)) + Eventually(session).Should(Say(`cf unshare-route example.com --hostname myHost -s TargetSpace -o TargetOrg # myhost.example.com`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) + Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) + Eventually(session).Should(Say(`-o\s+The org of the destination space \(Default: targeted org\)`)) + Eventually(session).Should(Say(`-s\s+The space to be unshared \(Default: targeted space\)`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`share-route, delete-route, map-route, routes, unmap-route`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "unshare-route", "some-domain", "-s SOME_SPACE") + }) + }) + + When("the environment is set up correctly", func() { + var ( + userName string + orgName string + spaceName string + ) + + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionHTTP2RoutingV3) + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + userName, _ = helpers.GetCredentials() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the domain extists", func() { + var ( + domainName string + targetSpaceName string + ) + + BeforeEach(func() { + domainName = helpers.NewDomainName() + }) + + When("the route exists", func() { + var ( + domain helpers.Domain + hostname string + ) + When("the target space is shared in the targedted space", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + Eventually(helpers.CF("share-route", domain.Name, "--hostname", hostname, "-s", targetSpaceName)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + }) + + It("unshares the route to the destination space", func() { + session := helpers.CF("unshare-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say(`Unsharing route %s.%s from space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the target organization does not exist", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + targetOrgName = helpers.NewOrgName() + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 and an error message", func() { + session := helpers.CF("unshare-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not unshare route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the target space exists in another existing org", func() { + var targetOrgName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + targetOrgName = helpers.NewOrgName() + targetSpaceName = helpers.NewSpaceName() + helpers.CreateOrgAndSpace(targetOrgName, targetSpaceName) + helpers.SetupCF(orgName, spaceName) + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + helpers.QuickDeleteOrg(targetOrgName) + }) + + It("unshared the route from the intended space", func() { + session := helpers.CF("unshare-route", domainName, "--hostname", hostname, "-o", targetOrgName, "-s", targetSpaceName) + Eventually(session).Should(Say(`Unsharing route %s.%s from space %s as %s`, hostname, domainName, targetSpaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("the space does not exist", func() { + var destinationSpaceName string + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "menchies-icecream" + destinationSpaceName = "doesNotExistSpace" + domain.Create() + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + It("exists with 1 with an error", func() { + session := helpers.CF("unshare-route", domainName, "--hostname", hostname, "-s", destinationSpaceName) + Eventually(session).Should(Say("Can not unshare route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the route does not exist", func() { + var ( + domain helpers.Domain + hostname string + ) + + When("the target space exists", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "panera-bread" + targetSpaceName = helpers.NewSpaceName() + helpers.CreateSpace(targetSpaceName) + domain.Create() + }) + + It("exits with 1 with an error message", func() { + session := helpers.CF("unshare-route", domainName, "--hostname", hostname, "-s", targetSpaceName) + Eventually(session).Should(Say("Can not unshare route:")) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/unshare_service_command_test.go b/integration/v7/isolated/unshare_service_command_test.go index 5fb64f8edcb..30ce0a17e10 100644 --- a/integration/v7/isolated/unshare_service_command_test.go +++ b/integration/v7/isolated/unshare_service_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/update_destination_command_test.go b/integration/v7/isolated/update_destination_command_test.go new file mode 100644 index 00000000000..05212392289 --- /dev/null +++ b/integration/v7/isolated/update_destination_command_test.go @@ -0,0 +1,155 @@ +package isolated + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("update destination command", func() { + Context("Heltp", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("update-destination", "ROUTES", "Updates the destination protocol for a route")) + }) + + It("displays the help information", func() { + session := helpers.CF("update-destination", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say(`update-destination - Updates the destination protocol for a route`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`Edit an existing HTTP route`)) + Eventually(session).Should(Say(`cf update-destination APP_NAME DOMAIN \[--hostname HOSTNAME\] \[--app-protocol PROTOCOL\] \[--path PATH\]\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf update-destination my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com`)) + Eventually(session).Should(Say(`cf update destination my-app example.com --hostname myhost --path foo --app-protocol http2 # myhost.example.com/foo`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) + Eventually(session).Should(Say(`--app-protocol\s+New Protocol for the route destination \(http1 or http2\). Only applied to HTTP routes`)) + Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`create-route, map-route, routes, unmap-route`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "update-destination", "app-name", "some-domain") + }) + }) + + When("the environment is set up correctly", func() { + var ( + userName string + orgName string + spaceName string + ) + + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionHTTP2RoutingV3) + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + userName, _ = helpers.GetCredentials() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the domain exists", func() { + var ( + domainName string + ) + + BeforeEach(func() { + domainName = helpers.NewDomainName() + }) + + When("the route exists", func() { + var ( + domain helpers.Domain + appName string + hostname string + ) + + When("it's an HTTP/1 route", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "key-lime-pie" + appName = "killer" + domain.CreatePrivate() + Eventually(helpers.CF("create-app", appName)).Should(Exit(0)) + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + Eventually(helpers.CF("map-route", appName, domain.Name, "--hostname", hostname)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + }) + + It("updates the destination protocol to http2 ", func() { + session := helpers.CF("update-destination", appName, domainName, "--hostname", hostname, "--app-protocol", "http2") + Eventually(session).Should(Say(`Updating destination protocol from %s to %s for route %s.%s in org %s / space %s as %s...`, "http1", "http2", hostname, domainName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("it's an HTTP/2 route", func() { + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "key-lime-pie" + appName = "killer2" + domain.CreatePrivate() + Eventually(helpers.CF("create-app", appName)).Should(Exit(0)) + Eventually(helpers.CF("create-route", domain.Name, "--hostname", hostname)).Should(Exit(0)) + Eventually(helpers.CF("map-route", appName, domain.Name, "--hostname", hostname, "--app-protocol", "http2")).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + }) + + It("updates the destination protocol to http1 ", func() { + session := helpers.CF("update-destination", appName, domainName, "--hostname", hostname, "--app-protocol", "http1") + Eventually(session).Should(Say(`Updating destination protocol from %s to %s for route %s.%s in org %s / space %s as %s...`, "http2", "http1", hostname, domainName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + + It("does nothing when the app-protocol is the same", func() { + session := helpers.CF("update-destination", appName, domainName, "--hostname", hostname, "--app-protocol", "http2") + Eventually(session).Should(Say(`App '%s' is already using '%s'\. Nothing has been updated`, appName, "http2")) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + + It("sets the destination protocol to 'http1' when the app-protocol is not provided", func() { + session := helpers.CF("update-destination", appName, domainName, "--hostname", hostname) + Eventually(session).Should(Say(`Updating destination protocol from %s to %s for route %s.%s in org %s / space %s as %s...`, "http2", "http1", hostname, domainName, orgName, spaceName, userName)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + }) + }) + }) +}) diff --git a/integration/v7/isolated/update_org_quota_command_test.go b/integration/v7/isolated/update_org_quota_command_test.go index e38efddd291..d5aa26e6937 100644 --- a/integration/v7/isolated/update_org_quota_command_test.go +++ b/integration/v7/isolated/update_org_quota_command_test.go @@ -1,8 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -16,7 +17,7 @@ var _ = Describe("update-org-quota command", func() { Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Say("update-org-quota - Update an existing organization quota")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf update-org-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] \[-n NEW_NAME\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans | --disallow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\]`)) + Eventually(session).Should(Say(`cf update-org-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] \[-n NEW_NAME\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans | --disallow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\] \[-l LOG_VOLUME\]`)) Eventually(session).Should(Say("ALIAS:")) Eventually(session).Should(Say("update-quota")) Eventually(session).Should(Say("OPTIONS:")) @@ -29,6 +30,7 @@ var _ = Describe("update-org-quota command", func() { Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount.`)) Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount.`)) Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount.`)) + Eventually(session).Should(Say(`-l\s+Total log volume per second all processes can have, in bytes \(e.g. 128B, 4K, 1M\). -1 represents an unlimited amount.`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("org, org-quota")) Eventually(session).Should(Exit(0)) @@ -83,9 +85,27 @@ var _ = Describe("update-org-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+%s`, "disallowed")) Eventually(session).Should(Say(`app instances:\s+%s`, appInstances)) Eventually(session).Should(Say(`route ports:\s+%s`, reservedRoutePorts)) + Eventually(session).Should(Say(`log volume per second:\s+unlimited`)) Eventually(session).Should(Exit(0)) }) + When("CAPI supports log rate limits", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("updates a quota", func() { + logVolume := "500B" + session := helpers.CF("update-org-quota", quotaName, "-l", logVolume) + Eventually(session).Should(Say(`Updating org quota %s as %s\.\.\.`, quotaName, username)) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("org-quota", quotaName) + Eventually(session).Should(Say(`log volume per second:\s+%s`, logVolume)) + Eventually(session).Should(Exit(0)) + }) + }) + When("the -n rename flag is provided", func() { var newQuotaName string diff --git a/integration/v7/isolated/update_route_command_test.go b/integration/v7/isolated/update_route_command_test.go new file mode 100644 index 00000000000..5962769c1f8 --- /dev/null +++ b/integration/v7/isolated/update_route_command_test.go @@ -0,0 +1,181 @@ +package isolated + +import ( + . "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/matchers" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("update-route command", func() { + Context("Help", func() { + It("appears in cf help -a", func() { + session := helpers.CF("help", "-a") + Eventually(session).Should(Exit(0)) + Expect(session).To(HaveCommandInCategoryWithDescription("update-route", "ROUTES", "Update a route by route specific options, e.g. load balancing algorithm")) + }) + + It("displays the help information", func() { + session := helpers.CF("update-route", "--help") + Eventually(session).Should(Say(`NAME:`)) + Eventually(session).Should(Say(`update-route - Update a route by route specific options, e.g. load balancing algorithm\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`USAGE:`)) + Eventually(session).Should(Say(`Update an existing HTTP route:\n`)) + Eventually(session).Should(Say(`cf update-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\] \[--option OPTION=VALUE\] \[--remove-option OPTION\]\n`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`EXAMPLES:`)) + Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=round-robin`)) + Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=least-connection`)) + Eventually(session).Should(Say(`cf update-route example.com -r loadbalancing`)) + Eventually(session).Should(Say(`cf update-route example.com --hostname myhost --path foo -o loadbalancing=round-robin`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`OPTIONS:`)) + Eventually(session).Should(Say(`--hostname, -n\s+Hostname for the HTTP route \(required for shared domains\)`)) + Eventually(session).Should(Say(`--path\s+Path for the HTTP route`)) + Eventually(session).Should(Say(`--option, -o\s+Set the value of a per-route option`)) + Eventually(session).Should(Say(`--remove-option, -r\s+Remove an option with the given name`)) + Eventually(session).Should(Say(`\n`)) + + Eventually(session).Should(Say(`SEE ALSO:`)) + Eventually(session).Should(Say(`check-route, domains, map-route, routes, unmap-route`)) + + Eventually(session).Should(Exit(0)) + }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "update-route", "some-domain") + }) + }) + + When("the environment is set up correctly", func() { + var ( + orgName string + spaceName string + ) + + BeforeEach(func() { + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + + helpers.SetupCF(orgName, spaceName) + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) + + When("the space and domain exist", func() { + var ( + userName string + domainName string + ) + + BeforeEach(func() { + domainName = helpers.NewDomainName() + userName, _ = helpers.GetCredentials() + }) + + When("the route already exists", func() { + var ( + domain helpers.Domain + hostname string + option string + path string + ) + + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "key-lime-pie" + path = "/a" + domain.CreatePrivate() + Eventually(helpers.CF("create-route", domainName, "--hostname", hostname, "--path", path)).Should(Exit(0)) + }) + + AfterEach(func() { + domain.Delete() + }) + When("a route option is specified", func() { + It("updates the route and runs to completion without failing", func() { + option = "loadbalancing=round-robin" + session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", option) + Eventually(session).Should(Say(`Updating route %s\.%s%s for org %s / space %s as %s\.\.\.`, hostname, domainName, path, orgName, spaceName, userName)) + Eventually(session).Should(Say(`Route %s\.%s%s has been updated`, hostname, domainName, path)) + Eventually(session).Should(Say(`OK`)) + Eventually(session).Should(Exit(0)) + }) + }) + + When("route options are not specified", func() { + It("gives an error message and fails", func() { + session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path) + Eventually(session.Err).Should(Say(`Route option support: 'No options were specified for the update of the Route %s\.%s\%s`, hostname, domainName, path)) + Eventually(session).Should(Exit(1)) + }) + }) + + When("route options are specified in the wrong format", func() { + It("gives an error message and fails", func() { + session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", "loadbalancing") + Eventually(session.Err).Should(Say(`Route option '%s' for route with host '%s', domain '%s', and path '%s' was specified incorrectly. Please use key-value pair format key=value.`, "loadbalancing", hostname, domainName, path)) + Eventually(session).Should(Say("FAILED")) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the route does not exist", func() { + var ( + domain helpers.Domain + hostname string + option string + ) + + BeforeEach(func() { + domain = helpers.NewDomain(orgName, domainName) + hostname = "key-lime-pie" + option = "loadbalancing=round-robin" + domain.CreatePrivate() + }) + + AfterEach(func() { + domain.Delete() + }) + + It("gives an error message", func() { + session := helpers.CF("update-route", domainName, "--hostname", hostname, "--option", option) + Eventually(session).Should(Say(`Updating route %s\.%s for org %s / space %s as %s\.\.\.`, hostname, domainName, orgName, spaceName, userName)) + Eventually(session.Err).Should(Say(`API endpoint not found at`)) + Eventually(session).Should(Exit(1)) + }) + }) + + }) + + When("the domain does not exist", func() { + It("gives an error message and exits", func() { + session := helpers.CF("update-route", "some-domain") + Eventually(session.Err).Should(Say(`Domain '%s' not found.`, "some-domain")) + Eventually(session).Should(Say("FAILED")) + Eventually(session).Should(Exit(1)) + }) + }) + + When("the domain is not specified", func() { + It("displays error and exits 1", func() { + session := helpers.CF("update-route") + Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `DOMAIN` was not provided\n")) + Eventually(session.Err).Should(Say("\n")) + Eventually(session).Should(Say("NAME:\n")) + Eventually(session).Should(Exit(1)) + }) + }) + }) +}) diff --git a/integration/v7/isolated/update_service_broker_command_test.go b/integration/v7/isolated/update_service_broker_command_test.go index 46933da5992..44246fadd92 100644 --- a/integration/v7/isolated/update_service_broker_command_test.go +++ b/integration/v7/isolated/update_service_broker_command_test.go @@ -1,9 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -141,10 +141,10 @@ var _ = Describe("update-service-broker command", func() { When("passing incorrect parameters", func() { It("prints an error message", func() { session := helpers.CF("update-service-broker", "b1") - - Eventually(session.Err).Should(Say("Incorrect Usage: the required arguments `USERNAME`, `PASSWORD` and `URL` were not provided")) - eventuallyRendersUpdateServiceBrokerHelp(session) Eventually(session).Should(Exit(1)) + + Expect(session.Err).To(Say("Incorrect Usage: the required arguments `USERNAME` and `URL` were not provided")) + expectToRenderUpdateServiceBrokerHelp(session) }) }) @@ -157,18 +157,26 @@ var _ = Describe("update-service-broker command", func() { When("passing --help", func() { It("displays command usage to output", func() { session := helpers.CF("update-service-broker", "--help") - - eventuallyRendersUpdateServiceBrokerHelp(session) Eventually(session).Should(Exit(0)) + + expectToRenderUpdateServiceBrokerHelp(session) }) }) }) -func eventuallyRendersUpdateServiceBrokerHelp(s *Session) { - Eventually(s).Should(Say("NAME:")) - Eventually(s).Should(Say("update-service-broker - Update a service broker")) - Eventually(s).Should(Say("USAGE:")) - Eventually(s).Should(Say("cf update-service-broker SERVICE_BROKER USERNAME PASSWORD URL")) - Eventually(s).Should(Say("SEE ALSO:")) - Eventually(s).Should(Say("rename-service-broker, service-brokers")) +func expectToRenderUpdateServiceBrokerHelp(s *Session) { + Expect(s).To(SatisfyAll( + Say("NAME:"), + Say("update-service-broker - Update a service broker"), + Say("USAGE:"), + Say("cf update-service-broker SERVICE_BROKER USERNAME PASSWORD URL"), + Say("cf update-service-broker SERVICE_BROKER USERNAME URL"), + Say(`WARNING:`), + Say(`\s+Providing your password as a command line option is highly discouraged`), + Say(`\s+Your password may be visible to others and may be recorded in your shell history`), + Say(`ENVIRONMENT:`), + Say(`\s+CF_BROKER_PASSWORD=password\s+Password associated with user. Overridden if PASSWORD argument is provided`), + Say("SEE ALSO:"), + Say("rename-service-broker, service-brokers"), + )) } diff --git a/integration/v7/isolated/update_service_command_test.go b/integration/v7/isolated/update_service_command_test.go index 6f18d8fea84..78fff6507a8 100644 --- a/integration/v7/isolated/update_service_command_test.go +++ b/integration/v7/isolated/update_service_command_test.go @@ -4,10 +4,10 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/isolated/update_space_quota_command_test.go b/integration/v7/isolated/update_space_quota_command_test.go index 5d70363ba18..235d4fb3a45 100644 --- a/integration/v7/isolated/update_space_quota_command_test.go +++ b/integration/v7/isolated/update_space_quota_command_test.go @@ -1,8 +1,9 @@ package isolated import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -24,7 +25,7 @@ var _ = Describe("update-space-quota command", func() { Eventually(session).Should(Say("NAME:")) Eventually(session).Should(Say("update-space-quota - Update an existing space quota")) Eventually(session).Should(Say("USAGE:")) - Eventually(session).Should(Say(`cf update-space-quota QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-n NEW_NAME\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans | --disallow-paid-service-plans\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\]`)) + Eventually(session).Should(Say(`cf update-space-quota QUOTA \[-m TOTAL_MEMORY\] \[-i INSTANCE_MEMORY\] \[-n NEW_NAME\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans | --disallow-paid-service-plans\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\] \[-l LOG_VOLUME\]`)) Eventually(session).Should(Say("OPTIONS:")) Eventually(session).Should(Say(`-a\s+Total number of application instances. -1 represents an unlimited amount.`)) Eventually(session).Should(Say(`--allow-paid-service-plans\s+Allow provisioning instances of paid service plans.`)) @@ -35,6 +36,7 @@ var _ = Describe("update-space-quota command", func() { Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount.`)) Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount.`)) Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount.`)) + Eventually(session).Should(Say(`-l\s+Total log volume per second all processes can have, in bytes \(e.g. 128B, 4K, 1M\). -1 represents an unlimited amount.`)) Eventually(session).Should(Say("SEE ALSO:")) Eventually(session).Should(Say("space, space-quota, space-quotas")) Eventually(session).Should(Exit(0)) @@ -94,9 +96,28 @@ var _ = Describe("update-space-quota command", func() { Eventually(session).Should(Say(`paid service plans:\s+%s`, "allowed")) Eventually(session).Should(Say(`app instances:\s+%s`, appInstances)) Eventually(session).Should(Say(`route ports:\s+%s`, reservedRoutePorts)) + Eventually(session).Should(Say(`log volume per second:\s+%s`, "unlimited")) Eventually(session).Should(Exit(0)) }) + When("CAPI supports log rate limits", func() { + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + }) + + It("updates a quota", func() { + logVolume := "500B" + session := helpers.CF("update-space-quota", quotaName, "-l", logVolume) + Eventually(session).Should(Say("Updating space quota %s for org %s as %s...", quotaName, orgName, userName)) + Eventually(session).Should(Say("OK")) + Eventually(session).Should(Exit(0)) + + session = helpers.CF("space-quota", quotaName) + Eventually(session).Should(Say(`log volume per second:\s+%s`, logVolume)) + Eventually(session).Should(Exit(0)) + }) + }) + When("the named quota does not exist", func() { It("displays a missing quota error message and fails", func() { session := helpers.CF("update-space-quota", "bogota") diff --git a/integration/v7/isolated/update_user_provided_service_command_test.go b/integration/v7/isolated/update_user_provided_service_command_test.go index 2556ceb3895..1eeee35ebe2 100644 --- a/integration/v7/isolated/update_user_provided_service_command_test.go +++ b/integration/v7/isolated/update_user_provided_service_command_test.go @@ -3,8 +3,8 @@ package isolated import ( "os" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -108,10 +108,10 @@ var _ = Describe("update-user-provided-service command", func() { When("the user-provided service instance does not exist", func() { It("displays an informative error and exits 1", func() { - session := helpers.CF("update-user-provided-service", "non-existent-service", "-l", "syslog://example.com") + session := helpers.CF("update-user-provided-service", "nonexistent-service", "-l", "syslog://example.com") Eventually(session).Should(Exit(1)) - Expect(session.Err).To(Say("Service instance 'non-existent-service' not found")) + Expect(session.Err).To(Say("Service instance 'nonexistent-service' not found")) Expect(session.Out).To(Say("FAILED")) }) }) diff --git a/integration/v7/isolated/upgrade_service_command_test.go b/integration/v7/isolated/upgrade_service_command_test.go index 41f30093eda..c69fe2e5d46 100644 --- a/integration/v7/isolated/upgrade_service_command_test.go +++ b/integration/v7/isolated/upgrade_service_command_test.go @@ -4,9 +4,9 @@ import ( "time" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers/servicebrokerstub" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -24,6 +24,7 @@ var _ = Describe("upgrade-service command", func() { Say(`\s+cf upgrade-service SERVICE_INSTANCE`), Say(`OPTIONS:`), Say(`\s+--force, -f\s+Force upgrade without asking for confirmation`), + Say(`\s+--wait, -w\s+Wait for the operation to complete\n`), Say(`SEE ALSO:`), Say(`\s+services, update-service, update-user-provided-service`), ) @@ -66,92 +67,96 @@ var _ = Describe("upgrade-service command", func() { }) }) }) + }) + + When("the environment is not setup correctly", func() { + It("fails with the appropriate errors", func() { + helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, command, "service-instance-name") + }) + }) + + When("logged in and targeting a space", func() { + var orgName, spaceName, serviceInstanceName, username string + + BeforeEach(func() { + orgName = helpers.NewOrgName() + spaceName = helpers.NewSpaceName() + helpers.SetupCF(orgName, spaceName) + username, _ = helpers.GetCredentials() + serviceInstanceName = helpers.NewServiceInstanceName() + }) + + AfterEach(func() { + helpers.QuickDeleteOrg(orgName) + }) - When("the environment is not setup correctly", func() { - It("fails with the appropriate errors", func() { - helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, command, "service-instance-name") + When("the service instance does not exist", func() { + It("prints a message and exits with error", func() { + session := helpers.CF(command, "-f", serviceInstanceName) + Eventually(session).Should(Exit(1)) + + Expect(session.Out).To(SatisfyAll( + Say("Upgrading service instance %s in org %s / space %s as %s...", serviceInstanceName, orgName, spaceName, username), + Say("\n"), + Say("FAILED"), + )) + + Expect(session.Err).To( + Say("Service instance '%s' not found\n", serviceInstanceName), + ) }) }) - When("logged in and targeting a space", func() { - var ( - orgName, spaceName, serviceInstanceName, username string - ) + When("the service instance exists", func() { + var broker *servicebrokerstub.ServiceBrokerStub BeforeEach(func() { - orgName = helpers.NewOrgName() - spaceName = helpers.NewSpaceName() - helpers.SetupCF(orgName, spaceName) - username, _ = helpers.GetCredentials() - serviceInstanceName = helpers.NewServiceInstanceName() + broker = servicebrokerstub.New().WithPlans(2).WithAsyncDelay(time.Microsecond).EnableServiceAccess() + helpers.CreateManagedServiceInstance( + broker.FirstServiceOfferingName(), + broker.FirstServicePlanName(), + serviceInstanceName, + ) }) AfterEach(func() { - helpers.QuickDeleteOrg(orgName) + broker.Forget() }) - When("the service instance does not exist", func() { - It("prints a message and exits with error", func() { + Context("but there is no upgrade available", func() { + It("prints a message and exits successfully", func() { session := helpers.CF(command, "-f", serviceInstanceName) - Eventually(session).Should(Exit(1)) + Eventually(session).Should(Exit(0)) Expect(session.Out).To(SatisfyAll( Say("Upgrading service instance %s in org %s / space %s as %s...", serviceInstanceName, orgName, spaceName, username), Say("\n"), - Say("FAILED"), + Say("No upgrade is available."), + Say("\n"), + Say("OK"), )) - - Expect(session.Err).To( - Say("Service instance '%s' not found\n", serviceInstanceName), - ) }) }) - When("the service instance exist", func() { - var broker *servicebrokerstub.ServiceBrokerStub - + Context("and there's an upgrade available", func() { BeforeEach(func() { - broker = servicebrokerstub.New().WithPlans(2).WithAsyncDelay(time.Microsecond).EnableServiceAccess() - helpers.CreateManagedServiceInstance( - broker.FirstServiceOfferingName(), - broker.FirstServicePlanName(), - serviceInstanceName, - ) - }) - - AfterEach(func() { - broker.Forget() + broker.Services[0].Plans[0].MaintenanceInfo = &config.MaintenanceInfo{Version: "9.1.2"} + broker.Configure().Register() }) - Context("but there is no upgrade available", func() { - It("prints a message and exits successfully", func() { - session := helpers.CF(command, "-f", serviceInstanceName) - Eventually(session).Should(Exit(0)) - - Expect(session.Out).To(SatisfyAll( - Say("Upgrading service instance %s in org %s / space %s as %s...", serviceInstanceName, orgName, spaceName, username), - Say("\n"), - Say("No upgrade is available."), - Say("\n"), - Say("OK"), - )) - }) - }) - - Context("and there's an upgrade available", func() { - BeforeEach(func() { - broker.Services[0].Plans[0].MaintenanceInfo = &config.MaintenanceInfo{Version: "9.1.2"} - broker.Configure().Register() - }) - - It("upgrades the service instance", func() { - session := helpers.CF(command, "-f", serviceInstanceName) + It("upgrades the service instance", func() { + session := helpers.CF(command, "-f", serviceInstanceName, "--wait") - Eventually(session).Should(Exit(0)) - Expect(session.Out).To(Say("Upgrade in progress")) - }) + Eventually(session).Should(Exit(0)) + Expect(session.Out).To(SatisfyAll( + Say(`Upgrading service instance %s in org %s / space %s as %s\.\.\.\n`, serviceInstanceName, orgName, spaceName, username), + Say(`\n`), + Say(`Waiting for the operation to complete\.+\n`), + Say(`\n`), + Say(`Upgrade of service instance %s complete\.\n`, serviceInstanceName), + Say(`OK\n`), + )) }) - }) }) }) diff --git a/integration/v7/isolated/verbose_flag_test.go b/integration/v7/isolated/verbose_flag_test.go index 466266c9d7a..ab96e19e67a 100644 --- a/integration/v7/isolated/verbose_flag_test.go +++ b/integration/v7/isolated/verbose_flag_test.go @@ -1,16 +1,15 @@ package isolated import ( - "io/ioutil" "os" "path/filepath" "runtime" "strings" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/util/configv3" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -23,7 +22,7 @@ var _ = Describe("Verbose", func() { DescribeTable("displays verbose output to terminal", func(env string, configTrace string, flag bool) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -62,7 +61,7 @@ var _ = Describe("Verbose", func() { Eventually(session).Should(Say("REQUEST:")) Eventually(session).Should(Say("POST /oauth/token")) Eventually(session).Should(Say(`User-Agent: cf/[\w.+-]+ \(go\d+\.\d+(\.\d+)?; %s %s\)`, runtime.GOARCH, runtime.GOOS)) - Eventually(session).Should(Say(`\[PRIVATE DATA HIDDEN\]`)) //This is required to test the previous line. If it fails, the previous matcher went too far. + Eventually(session).Should(Say(`\[PRIVATE DATA HIDDEN\]`)) // This is required to test the previous line. If it fails, the previous matcher went too far. Eventually(session).Should(Say("RESPONSE:")) Eventually(session).Should(Say("REQUEST:")) Eventually(session).Should(Say("GET /v3/apps")) @@ -89,7 +88,7 @@ var _ = Describe("Verbose", func() { DescribeTable("displays verbose output to multiple files", func(env string, configTrace string, flag bool, location []string) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -127,7 +126,7 @@ var _ = Describe("Verbose", func() { Eventually(session).Should(Exit(1)) for _, filePath := range location { - contents, err := ioutil.ReadFile(tmpDir + filePath) + contents, err := os.ReadFile(tmpDir + filePath) Expect(err).ToNot(HaveOccurred()) Expect(string(contents)).To(MatchRegexp("REQUEST:")) @@ -180,7 +179,7 @@ var _ = Describe("Verbose", func() { DescribeTable("displays verbose output to terminal", func(env string, configTrace string, flag bool) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -218,7 +217,7 @@ var _ = Describe("Verbose", func() { Eventually(session).Should(Say(`GET /api/v1/read/.*\?\w+`)) Eventually(session).Should(Say(`Host: log-cache\.`)) Eventually(session).Should(Say(`Authorization: \[PRIVATE DATA HIDDEN\]`)) - Eventually(session.Kill()).Should(Exit()) + Eventually(session.Interrupt()).Should(Exit()) }, Entry("CF_TRACE true: enables verbose", "true", "", false), @@ -239,7 +238,7 @@ var _ = Describe("Verbose", func() { DescribeTable("displays verbose output to multiple files", func(env string, configTrace string, location []string) { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -269,11 +268,11 @@ var _ = Describe("Verbose", func() { Eventually(session).Should(Say("RESPONSE:")) Eventually(session).Should(Say("GET /api/v1/info HTTP/1.1")) Eventually(session).Should(Say("GET /api/v1/read/")) - session.Kill() + session.Interrupt() Eventually(session).Should(Exit()) for _, filePath := range location { - contents, err := ioutil.ReadFile(tmpDir + filePath) + contents, err := os.ReadFile(tmpDir + filePath) Expect(err).ToNot(HaveOccurred()) Expect(string(contents)).To(MatchRegexp("REQUEST:")) Expect(string(contents)).To(MatchRegexp("RESPONSE:")) @@ -313,7 +312,7 @@ var _ = Describe("Verbose", func() { Describe("uaa", func() { When("the user does not provide the -v flag, the CF_TRACE env var, or the --trace config option", func() { It("should not log requests", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -332,7 +331,7 @@ var _ = Describe("Verbose", func() { When("the user provides the -v flag", func() { It("should log requests and redact cookies", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -351,7 +350,7 @@ var _ = Describe("Verbose", func() { Describe("ssh", func() { When("the user is not in verbose mode", func() { It("should not log requests", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) @@ -368,7 +367,7 @@ var _ = Describe("Verbose", func() { When("the user is in verbose mode", func() { It("should redact their one time ssh code", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") defer os.RemoveAll(tmpDir) Expect(err).NotTo(HaveOccurred()) diff --git a/integration/v7/push/app_start_timeout_flag_test.go b/integration/v7/push/app_start_timeout_flag_test.go index a8c703dc2bd..bc2f9f3f8a1 100644 --- a/integration/v7/push/app_start_timeout_flag_test.go +++ b/integration/v7/push/app_start_timeout_flag_test.go @@ -2,12 +2,11 @@ package push import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -23,7 +22,7 @@ var _ = Describe("push with health check timeout flag", func() { BeforeEach(func() { appName = helpers.NewAppName() var err error - tempDir, err = ioutil.TempDir("", "create-manifest") + tempDir, err = os.MkdirTemp("", "create-manifest") Expect(err).ToNot(HaveOccurred()) manifestFilePath = filepath.Join(tempDir, fmt.Sprintf("%s_manifest.yml", appName)) @@ -57,7 +56,7 @@ var _ = Describe("push with health check timeout flag", func() { "create-app-manifest", appName) Eventually(session).Should(Exit(0)) - createdFile, err := ioutil.ReadFile(manifestFilePath) + createdFile, err := os.ReadFile(manifestFilePath) Expect(err).ToNot(HaveOccurred()) Expect(createdFile).To(MatchRegexp("---")) diff --git a/integration/v7/push/buildpacks_test.go b/integration/v7/push/buildpacks_test.go index 9420272d70d..fb8fb065043 100644 --- a/integration/v7/push/buildpacks_test.go +++ b/integration/v7/push/buildpacks_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/canary_push_test.go b/integration/v7/push/canary_push_test.go new file mode 100644 index 00000000000..9a1cd30f6bf --- /dev/null +++ b/integration/v7/push/canary_push_test.go @@ -0,0 +1,167 @@ +package push + +import ( + "fmt" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("push with --strategy canary", func() { + var ( + appName string + userName string + ) + + BeforeEach(func() { + appName = helpers.PrefixedRandomName("app") + userName, _ = helpers.GetCredentials() + }) + + When("the app exists", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, + )).Should(Exit(0)) + }) + }) + + When("the max-in-flight flag is not given", func() { + It("pushes the app and creates a new deployment and notes the max-in-flight value", func() { + helpers.WithHelloWorldApp(func(appDir string) { + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, "--strategy", "canary", "--instance-steps=10,60", + ) + + Eventually(session).Should(Exit(0)) + Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) + Expect(session).To(Say(`Packaging files to upload\.\.\.`)) + Expect(session).To(Say(`Uploading files\.\.\.`)) + Expect(session).To(Say(`100.00%`)) + Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`)) + Expect(session).To(Say(`Staging app and tracing logs\.\.\.`)) + Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName)) + Expect(session).To(Say(`Waiting for app to deploy\.\.\.`)) + Expect(session).To(Say(`name:\s+%s`, appName)) + Expect(session).To(Say(`requested state:\s+started`)) + Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) + Expect(session).To(Say(`type:\s+web`)) + Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand)) + Expect(session).To(Say(`#0\s+running`)) + Expect(session).To(Say("Active deployment with status PAUSED")) + Expect(session).To(Say("strategy: canary")) + Expect(session).To(Say("max-in-flight: 1")) + Expect(session).To(Say("canary-steps: 1/2")) + Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Expect(session).To(Exit(0)) + }) + }) + }) + + When("the max-in-flight flag is given with a non-default value", func() { + It("pushes the app and creates a new deployment and notes the max-in-flight value", func() { + helpers.WithHelloWorldApp(func(appDir string) { + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, "--strategy", "canary", "--max-in-flight", "2", + ) + + Eventually(session).Should(Exit(0)) + Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) + Expect(session).To(Say(`Packaging files to upload\.\.\.`)) + Expect(session).To(Say(`Uploading files\.\.\.`)) + Expect(session).To(Say(`100.00%`)) + Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`)) + Expect(session).To(Say(`Staging app and tracing logs\.\.\.`)) + Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName)) + Expect(session).To(Say(`Waiting for app to deploy\.\.\.`)) + Expect(session).To(Say(`name:\s+%s`, appName)) + Expect(session).To(Say(`requested state:\s+started`)) + Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) + Expect(session).To(Say(`type:\s+web`)) + Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand)) + Expect(session).To(Say(`#0\s+running`)) + Expect(session).To(Say("Active deployment with status PAUSED")) + Expect(session).To(Say("strategy: canary")) + Expect(session).To(Say("max-in-flight: 2")) + Expect(session).To(Say("canary-steps: 1/1")) + Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName)) + Expect(session).To(Exit(0)) + }) + }) + }) + }) + + When("canceling the deployment", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, + )).Should(Exit(0)) + }) + }) + + It("displays the deployment cancellation message", func() { + helpers.WithHelloWorldApp(func(appDir string) { + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, "--strategy", "canary", + ) + + Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) + Eventually(session).Should(Say(`Packaging files to upload\.\.\.`)) + Eventually(session).Should(Say(`Uploading files\.\.\.`)) + Eventually(session).Should(Say(`100.00%`)) + Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`)) + Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`)) + Eventually(session).Should(Say(`Starting deployment for app %s\.\.\.`, appName)) + Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) + + Eventually(helpers.CF("cancel-deployment", appName)).Should(Exit(0)) + Eventually(session).Should(Say(`FAILED`)) + Eventually(session.Err).Should(Say(`Deployment has been canceled`)) + Eventually(session).Should(Exit(1)) + }) + }) + }) + + When("the app crashes", func() { + BeforeEach(func() { + helpers.WithHelloWorldApp(func(appDir string) { + Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, + )).Should(Exit(0)) + }) + }) + + It("times out", func() { + helpers.WithCrashingApp(func(appDir string) { + session := helpers.CustomCF(helpers.CFEnv{ + WorkingDirectory: appDir, + EnvVars: map[string]string{"CF_STARTUP_TIMEOUT": "0.1"}, + }, PushCommandName, appName, "--strategy", "canary") + Eventually(session).Should(Exit(1)) + Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) + Expect(session).To(Say(`Packaging files to upload\.\.\.`)) + Expect(session).To(Say(`Uploading files\.\.\.`)) + Expect(session).To(Say(`100.00%`)) + Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`)) + Expect(session).To(Say(`Staging app and tracing logs\.\.\.`)) + Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName)) + Expect(session).To(Say(`Waiting for app to deploy\.\.\.`)) + Expect(session).To(Say(`FAILED`)) + Expect(session.Err).To(Say(`Start app timeout`)) + Expect(session.Err).To(Say(`TIP: Application must be listening on the right port\. Instead of hard coding the port, use the \$PORT environment variable\.`)) + Expect(session.Err).To(Say(`Use 'cf logs %s --recent' for more information`, appName)) + appGUID := helpers.AppGUID(appName) + Eventually(func() *Buffer { + session_deployment := helpers.CF("curl", fmt.Sprintf("/v3/deployments?app_guids=%s", appGUID)) + Eventually(session_deployment).Should(Exit(0)) + return session_deployment.Out + }).Should(Say(`"reason":\s*"CANCELED"`)) + }) + }) + }) +}) diff --git a/integration/v7/push/cfignore_test.go b/integration/v7/push/cfignore_test.go index 45c735fdcff..5f80245fb65 100644 --- a/integration/v7/push/cfignore_test.go +++ b/integration/v7/push/cfignore_test.go @@ -1,12 +1,11 @@ package push import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -36,35 +35,35 @@ var _ = Describe("push with .cfignore", func() { It("pushes all the files except .cfignore", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, nil, 0666) + err = os.WriteFile(cfIgnoreFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) darcsFile := filepath.Join(appDir, "_darcs") - err = ioutil.WriteFile(darcsFile, nil, 0666) + err = os.WriteFile(darcsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) dsFile := filepath.Join(appDir, ".DS_Store") - err = ioutil.WriteFile(dsFile, nil, 0666) + err = os.WriteFile(dsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitFile := filepath.Join(appDir, ".git") - err = ioutil.WriteFile(gitFile, nil, 0666) + err = os.WriteFile(gitFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitIgnoreFile := filepath.Join(appDir, ".gitignore") - err = ioutil.WriteFile(gitIgnoreFile, nil, 0666) + err = os.WriteFile(gitIgnoreFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) hgFile := filepath.Join(appDir, ".hg") - err = ioutil.WriteFile(hgFile, nil, 0666) + err = os.WriteFile(hgFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) manifestFile := filepath.Join(appDir, "manifest.yml") @@ -78,7 +77,7 @@ var _ = Describe("push with .cfignore", func() { ) svnFile := filepath.Join(appDir, ".svn") - err = ioutil.WriteFile(svnFile, nil, 0666) + err = os.WriteFile(svnFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName) @@ -94,15 +93,15 @@ var _ = Describe("push with .cfignore", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName) @@ -117,15 +116,15 @@ var _ = Describe("push with .cfignore", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.CF("push", appName, "-p", appDir) @@ -141,18 +140,18 @@ var _ = Describe("push with .cfignore", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(appDir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) - tmpfile, err := ioutil.TempFile("", "push-archive-integration") + tmpfile, err := os.CreateTemp("", "push-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()) @@ -186,7 +185,7 @@ var _ = Describe("push with .cfignore", func() { It("does not push it", func() { helpers.WithHelloWorldApp(func(appDir string) { traceFilePath := filepath.Join(appDir, "i-am-trace.txt") - err := ioutil.WriteFile(traceFilePath, nil, 0666) + err := os.WriteFile(traceFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) previousEnv = os.Getenv("CF_TRACE") @@ -205,31 +204,31 @@ var _ = Describe("push with .cfignore", func() { It("pushes all the files except for the files ignored by default", func() { helpers.WithHelloWorldApp(func(appDir string) { file1 := filepath.Join(appDir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(appDir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) darcsFile := filepath.Join(appDir, "_darcs") - err = ioutil.WriteFile(darcsFile, nil, 0666) + err = os.WriteFile(darcsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) dsFile := filepath.Join(appDir, ".DS_Store") - err = ioutil.WriteFile(dsFile, nil, 0666) + err = os.WriteFile(dsFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitFile := filepath.Join(appDir, ".git") - err = ioutil.WriteFile(gitFile, nil, 0666) + err = os.WriteFile(gitFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) gitIgnoreFile := filepath.Join(appDir, ".gitignore") - err = ioutil.WriteFile(gitIgnoreFile, nil, 0666) + err = os.WriteFile(gitIgnoreFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) hgFile := filepath.Join(appDir, ".hg") - err = ioutil.WriteFile(hgFile, nil, 0666) + err = os.WriteFile(hgFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) manifestFile := filepath.Join(appDir, "manifest.yml") @@ -243,7 +242,7 @@ var _ = Describe("push with .cfignore", func() { ) svnFile := filepath.Join(appDir, ".svn") - err = ioutil.WriteFile(svnFile, nil, 0666) + err = os.WriteFile(svnFile, nil, 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName) diff --git a/integration/v7/push/combination_manifest_and_flag_test.go b/integration/v7/push/combination_manifest_and_flag_test.go index 315767dd266..95a5f984143 100644 --- a/integration/v7/push/combination_manifest_and_flag_test.go +++ b/integration/v7/push/combination_manifest_and_flag_test.go @@ -1,14 +1,13 @@ package push import ( - "io/ioutil" "os" "path/filepath" "regexp" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -154,7 +153,7 @@ var _ = Describe("push with a simple manifest and flags", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "combination-manifest-with-p") + tempDir, err = os.MkdirTemp("", "combination-manifest-with-p") Expect(err).ToNot(HaveOccurred()) helpers.WriteManifest(filepath.Join(tempDir, "manifest.yml"), map[string]interface{}{ @@ -209,6 +208,7 @@ var _ = Describe("push with a simple manifest and flags", func() { Entry("health check type", "-u", "port"), Entry("instances", "-i", "10"), Entry("memory", "-m", "100M"), + Entry("log rate limit", "-l", "5K"), Entry("no route", "--no-route"), Entry("stack", "-s", "something"), ) diff --git a/integration/v7/push/disk_flag_test.go b/integration/v7/push/disk_flag_test.go index 2729bd1d29b..1ffc2a8e4c6 100644 --- a/integration/v7/push/disk_flag_test.go +++ b/integration/v7/push/disk_flag_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -33,7 +33,7 @@ var _ = Describe("push with disk flag", func() { Eventually(session).Should(Exit(0)) Expect(session).To(Say(`name:\s+%s`, appName)) Expect(session).To(Say(`last uploaded:\s+%s`, helpers.ReadableDateTimeRegex)) - Expect(session).To(Say(`\s+state\s+since\s+cpu\s+memory\s+disk`)) + Expect(session).To(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement`)) Expect(session).To(Say(`#0\s+running\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ.+of.+of 70M`)) }) }) diff --git a/integration/v7/push/docker_test.go b/integration/v7/push/docker_test.go index a6ad720d08b..370d778fc56 100644 --- a/integration/v7/push/docker_test.go +++ b/integration/v7/push/docker_test.go @@ -1,11 +1,11 @@ package push import ( - "io/ioutil" + "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -20,7 +20,7 @@ var _ = Describe("pushing docker images", func() { BeforeEach(func() { appName = helpers.PrefixedRandomName("app") var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) }) diff --git a/integration/v7/push/droplet_flag_test.go b/integration/v7/push/droplet_flag_test.go index 66d3e24b25f..fe858d63406 100644 --- a/integration/v7/push/droplet_flag_test.go +++ b/integration/v7/push/droplet_flag_test.go @@ -2,11 +2,10 @@ package push import ( "fmt" - "io/ioutil" "os" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -24,7 +23,7 @@ var _ = Describe("--droplet flag", func() { appName = helpers.NewAppName() helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "dropletFile*.tgz") + tmpfile, err := os.CreateTemp("", "dropletFile*.tgz") Expect(err).ToNot(HaveOccurred()) dropletPath = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) @@ -77,7 +76,7 @@ var _ = Describe("--droplet flag", func() { When("the droplet bits path is not a gzipped tarball", func() { It("fails with a helpful error message", func() { - nonTgzFile, err := ioutil.TempFile("", "dropletFile*.txt") + nonTgzFile, err := os.CreateTemp("", "dropletFile*.txt") Expect(err).ToNot(HaveOccurred()) session := helpers.CF(PushCommandName, appName, "--droplet", nonTgzFile.Name()) Eventually(session).Should(Say(`FAILED`)) @@ -94,9 +93,9 @@ var _ = Describe("--droplet flag", func() { GUID string `json:"guid"` } - currentDropletEndpoint := fmt.Sprintf("v3/apps/%s/droplets/current", originalAppGUID) + const droppletEndpointFormat = "v3/apps/%s/droplets/current" - helpers.Curl(&routeResponse, currentDropletEndpoint) + helpers.Curlf(&routeResponse, droppletEndpointFormat, originalAppGUID) preUploadDropletGUID := routeResponse.GUID session := helpers.CF(PushCommandName, originalApp, "--droplet", dropletPath, "--no-start") @@ -105,7 +104,7 @@ var _ = Describe("--droplet flag", func() { Eventually(session).Should(Say(`requested state:\s+stopped`)) Eventually(session).Should(Exit(0)) - helpers.Curl(&routeResponse, currentDropletEndpoint) + helpers.Curlf(&routeResponse, droppletEndpointFormat, originalAppGUID) postUploadDropletGUID := routeResponse.GUID Expect(preUploadDropletGUID).To(Not(Equal(postUploadDropletGUID))) diff --git a/integration/v7/push/health_check_test.go b/integration/v7/push/health_check_test.go index 1f0f764515a..f94359e50a8 100644 --- a/integration/v7/push/health_check_test.go +++ b/integration/v7/push/health_check_test.go @@ -3,8 +3,8 @@ package push import ( "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -84,7 +84,7 @@ var _ = Describe("push with health check type", func() { session := helpers.CF("get-health-check", appName) Eventually(session).Should(Say("web\\s+http\\s+/third_endpoint.html")) - Eventually(session).Should(Exit(0)) //}) + Eventually(session).Should(Exit(0)) // }) }) }) diff --git a/integration/v7/push/help_test.go b/integration/v7/push/help_test.go index 526c611d0fc..5fe3910b324 100644 --- a/integration/v7/push/help_test.go +++ b/integration/v7/push/help_test.go @@ -4,8 +4,8 @@ import ( "regexp" "strings" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -26,11 +26,13 @@ var _ = Describe("help", func() { "[-b BUILDPACK_NAME]", "[-c COMMAND]", "[-f MANIFEST_PATH | --no-manifest]", + "[--lifecycle (buildpack | docker | cnb)]", "[--no-start]", "[--no-wait]", "[-i NUM_INSTANCES]", "[-k DISK]", "[-m MEMORY]", + "[-l LOG_RATE_LIMIT]", "[-p PATH]", "[-s STACK]", "[-t HEALTH_TIMEOUT]", @@ -55,6 +57,7 @@ var _ = Describe("help", func() { "[-i NUM_INSTANCES]", "[-k DISK]", "[-m MEMORY]", + "[-l LOG_RATE_LIMIT]", "[-p PATH]", "[-s STACK]", "[-t HEALTH_TIMEOUT]", @@ -68,16 +71,19 @@ var _ = Describe("help", func() { assertUsage(session, buildpackAppUsage, dockerAppUsage) Eventually(session).Should(Say("OPTIONS:")) - Eventually(session).Should(Say(`app-start-timeout, -t`)) + Eventually(session).Should(Say(`--app-start-timeout, -t`)) Eventually(session).Should(Say(`--buildpack, -b`)) - Eventually(session).Should(Say(`disk, -k`)) + Eventually(session).Should(Say(`--disk, -k`)) Eventually(session).Should(Say(`--docker-image, -o`)) Eventually(session).Should(Say(`--docker-username`)) Eventually(session).Should(Say(`--droplet`)) Eventually(session).Should(Say(`--endpoint`)) Eventually(session).Should(Say(`--health-check-type, -u`)) Eventually(session).Should(Say(`--instances, -i`)) + Eventually(session).Should(Say(`--instance-steps`)) + Eventually(session).Should(Say(`--log-rate-limit, -l\s+Log rate limit per second, in bytes \(e.g. 128B, 4K, 1M\). -l=-1 represents unlimited`)) Eventually(session).Should(Say(`--manifest, -f`)) + Eventually(session).Should(Say(`--max-in-flight`)) Eventually(session).Should(Say(`--memory, -m`)) Eventually(session).Should(Say(`--no-manifest`)) Eventually(session).Should(Say(`--no-route`)) diff --git a/integration/v7/push/ignore_app_files_test.go b/integration/v7/push/ignore_app_files_test.go index 8bc27d10586..f8af82b10d8 100644 --- a/integration/v7/push/ignore_app_files_test.go +++ b/integration/v7/push/ignore_app_files_test.go @@ -1,12 +1,12 @@ package push import ( - "io/ioutil" + "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -26,15 +26,15 @@ var _ = Describe("ignoring files while gathering resources", func() { It("pushes all the files", func() { helpers.WithHelloWorldApp(func(dir string) { file1 := filepath.Join(dir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(dir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(dir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, nil, 0666) + err = os.WriteFile(cfIgnoreFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") @@ -50,15 +50,15 @@ var _ = Describe("ignoring files while gathering resources", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(dir string) { file1 := filepath.Join(dir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(dir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(dir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") @@ -73,15 +73,15 @@ var _ = Describe("ignoring files while gathering resources", func() { It("does not push those files", func() { helpers.WithHelloWorldApp(func(dir string) { file1 := filepath.Join(dir, "file1") - err := ioutil.WriteFile(file1, nil, 0666) + err := os.WriteFile(file1, nil, 0666) Expect(err).ToNot(HaveOccurred()) file2 := filepath.Join(dir, "file2") - err = ioutil.WriteFile(file2, nil, 0666) + err = os.WriteFile(file2, nil, 0666) Expect(err).ToNot(HaveOccurred()) cfIgnoreFilePath := filepath.Join(dir, ".cfignore") - err = ioutil.WriteFile(cfIgnoreFilePath, []byte("/file*"), 0666) + err = os.WriteFile(cfIgnoreFilePath, []byte("/file*"), 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") @@ -98,7 +98,7 @@ var _ = Describe("ignoring files while gathering resources", func() { It("does not push it", func() { helpers.WithHelloWorldApp(func(dir string) { traceFilePath := filepath.Join(dir, "i-am-trace.txt") - err := ioutil.WriteFile(traceFilePath, nil, 0666) + err := os.WriteFile(traceFilePath, nil, 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.DebugCustomCF(helpers.CFEnv{ diff --git a/integration/v7/push/input_errors_test.go b/integration/v7/push/input_errors_test.go index 413ab6e40be..f912cd56754 100644 --- a/integration/v7/push/input_errors_test.go +++ b/integration/v7/push/input_errors_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/instances_flag_test.go b/integration/v7/push/instances_flag_test.go index 14f8e99b542..ad923b41afb 100644 --- a/integration/v7/push/instances_flag_test.go +++ b/integration/v7/push/instances_flag_test.go @@ -3,8 +3,8 @@ package push import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -29,11 +29,11 @@ var _ = Describe("push with instances flag", func() { Eventually(session).Should(Exit(0)) }) - time.Sleep(5 * time.Second) + time.Sleep(10 * time.Second) session := helpers.CF("app", appName) Eventually(session).Should(Say(`name:\s+%s`, appName)) Eventually(session).Should(Say(`last uploaded:\s+%s`, helpers.ReadableDateTimeRegex)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement`)) Eventually(session).Should(Say(`#0\s+(running|starting)\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) Eventually(session).Should(Say(`#1\s+(running|starting)\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) Eventually(session).Should(Say(`#2\s+(running|starting)\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) diff --git a/integration/v7/push/log_rate_limit_flag_test.go b/integration/v7/push/log_rate_limit_flag_test.go new file mode 100644 index 00000000000..5c49eb8f993 --- /dev/null +++ b/integration/v7/push/log_rate_limit_flag_test.go @@ -0,0 +1,35 @@ +package push + +import ( + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccversion" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("push with log rate limit flag", func() { + var ( + appName string + ) + + BeforeEach(func() { + helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) + + appName = helpers.NewAppName() + }) + + Context("when the -l flag is provided with application log rate limit", func() { + It("creates the app with the specified log rate limit", func() { + helpers.WithHelloWorldApp(func(dir string) { + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, + PushCommandName, appName, + "-l", "5K", + ) + Eventually(session).Should(Exit(0)) + }) + + helpers.WaitForLogRateLimitToTakeEffect(appName, 0, 0, false, "5K") + }) + }) +}) diff --git a/integration/v7/push/manifest_diff_test.go b/integration/v7/push/manifest_diff_test.go index cd3a56ce4f3..b29a4fe52e8 100644 --- a/integration/v7/push/manifest_diff_test.go +++ b/integration/v7/push/manifest_diff_test.go @@ -3,8 +3,8 @@ package push import ( "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -53,4 +53,43 @@ var _ = Describe("displaying manifest differences between pushes", func() { }) }) }) + When("there is an app that has been pushed and we push it again with a different manifest", func() { + It("displays the diff from the manifest", func() { + helpers.WithHelloWorldApp(func(dir string) { + + pathToManifest := filepath.Join(dir, "manifest.yml") + helpers.WriteManifest(pathToManifest, map[string]interface{}{ + "applications": []map[string]interface{}{ + { + "name": appName, + "instances": 1, + }, + }, + }) + + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName) + Eventually(session).Should(Exit(0)) + Expect(session).To(Say("name:\\s+%s", appName)) + + helpers.WriteManifest(pathToManifest, map[string]interface{}{ + "applications": []map[string]interface{}{ + { + "name": appName, + "instances": 2, + "env": map[string]interface{}{ + "super": "secret", + }, + }, + }, + }) + + session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--redact-env") + Eventually(session).Should(Exit(0)) + Expect(session).To(Say("name:\\s+%s", appName)) + Expect(session).To(Say(`\- instances: 1`)) + Expect(session).To(Say(`\+ instances: 2`)) + Expect(session).To(Say(`\+ super: `)) + }) + }) + }) }) diff --git a/integration/v7/push/manifest_location_test.go b/integration/v7/push/manifest_location_test.go index 0761441a704..00370cda5e1 100644 --- a/integration/v7/push/manifest_location_test.go +++ b/integration/v7/push/manifest_location_test.go @@ -4,8 +4,8 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/manifest_with_app_name_and_no_route_flag_test.go b/integration/v7/push/manifest_with_app_name_and_no_route_flag_test.go index c490c6e2225..65f78f99bc8 100644 --- a/integration/v7/push/manifest_with_app_name_and_no_route_flag_test.go +++ b/integration/v7/push/manifest_with_app_name_and_no_route_flag_test.go @@ -2,12 +2,11 @@ package push import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +26,7 @@ var _ = Describe("push with a manifest and an app name", func() { randomHostName = helpers.RandomName() var err error - tempDir, err = ioutil.TempDir("", "no-route-flag-with-manifest-test") + tempDir, err = os.MkdirTemp("", "no-route-flag-with-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToSetupManifest := filepath.Join(tempDir, "setup-manifest.yml") helpers.WriteManifest(pathToSetupManifest, map[string]interface{}{ diff --git a/integration/v7/push/manifest_with_app_name_test.go b/integration/v7/push/manifest_with_app_name_test.go index 3d004dae3f3..ee4871cae4d 100644 --- a/integration/v7/push/manifest_with_app_name_test.go +++ b/integration/v7/push/manifest_with_app_name_test.go @@ -2,12 +2,11 @@ package push import ( "fmt" - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -26,7 +25,7 @@ var _ = Describe("push with a manifest and an app name", func() { appName = helpers.NewAppName() secondName = helpers.NewAppName() var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -92,7 +91,7 @@ var _ = Describe("push with a manifest and an app name", func() { When("an appName is not given with a nameless manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ diff --git a/integration/v7/push/memory_flag_test.go b/integration/v7/push/memory_flag_test.go index 28e81bf476b..f1098140dbb 100644 --- a/integration/v7/push/memory_flag_test.go +++ b/integration/v7/push/memory_flag_test.go @@ -3,8 +3,8 @@ package push import ( "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -34,7 +34,7 @@ var _ = Describe("push with memory flag", func() { Eventually(session).Should(Say(`name:\s+%s`, appName)) Eventually(session).Should(Say(`last uploaded:\s+%s`, helpers.ReadableDateTimeRegex)) Eventually(session).Should(Say(`memory usage:\s+70M`)) - Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk`)) + Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+logging\s+cpu entitlement`)) Eventually(session).Should(Say(`#0\s+running\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) Eventually(session).Should(Exit(0)) }) diff --git a/integration/v7/push/name_only_test.go b/integration/v7/push/name_only_test.go index 2d80d195d0c..538bac17a6e 100644 --- a/integration/v7/push/name_only_test.go +++ b/integration/v7/push/name_only_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/no_route_test.go b/integration/v7/push/no_route_test.go index 3fdea25f1ff..01df38ab4b1 100644 --- a/integration/v7/push/no_route_test.go +++ b/integration/v7/push/no_route_test.go @@ -3,8 +3,8 @@ package push import ( "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/no_start_test.go b/integration/v7/push/no_start_test.go index 2708692551e..6a3ec5a0b7e 100644 --- a/integration/v7/push/no_start_test.go +++ b/integration/v7/push/no_start_test.go @@ -1,9 +1,9 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/no_wait_test.go b/integration/v7/push/no_wait_test.go index ca7798dda55..2c58fbc08cd 100644 --- a/integration/v7/push/no_wait_test.go +++ b/integration/v7/push/no_wait_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/path_test.go b/integration/v7/push/path_test.go index f1b0914afec..ca62a36b0ac 100644 --- a/integration/v7/push/path_test.go +++ b/integration/v7/push/path_test.go @@ -2,14 +2,13 @@ package push import ( "fmt" - "io/ioutil" "os" "path" "path/filepath" "runtime" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +26,7 @@ var _ = Describe("handle path in manifest and flag override", func() { appName = helpers.NewAppName() secondName = helpers.NewAppName() var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) }) @@ -224,7 +223,7 @@ var _ = Describe("handle path in manifest and flag override", func() { manifestDir := helpers.TempDirAbsolutePath("", "manifest-dir") defer os.RemoveAll(manifestDir) - err := ioutil.WriteFile( + err := os.WriteFile( filepath.Join(manifestDir, "manifest.yml"), []byte(fmt.Sprintf(`--- applications: @@ -248,7 +247,7 @@ applications: var emptyDir string BeforeEach(func() { - sympath, err := ioutil.TempDir("", "integration-push-path-empty") + sympath, err := os.MkdirTemp("", "integration-push-path-empty") Expect(err).ToNot(HaveOccurred()) emptyDir, err = filepath.EvalSymlinks(sympath) Expect(err).ToNot(HaveOccurred()) @@ -272,7 +271,7 @@ applications: BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "push-archive-integration") + tmpfile, err := os.CreateTemp("", "push-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()) diff --git a/integration/v7/push/push_output_test.go b/integration/v7/push/push_output_test.go index a47373158ea..26e665ec138 100644 --- a/integration/v7/push/push_output_test.go +++ b/integration/v7/push/push_output_test.go @@ -5,9 +5,9 @@ import ( "regexp" "time" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/push_suite_test.go b/integration/v7/push/push_suite_test.go index edf730363bc..0ff9050701c 100644 --- a/integration/v7/push/push_suite_test.go +++ b/integration/v7/push/push_suite_test.go @@ -2,13 +2,12 @@ package push import ( "fmt" - "io/ioutil" "os" "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -41,6 +40,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.SetupSynchronizedSuite(func() { helpers.EnableFeatureFlag("diego_docker") + helpers.EnableFeatureFlag("diego_cnb") helpers.EnableFeatureFlag("service_instance_sharing") }) @@ -48,7 +48,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { return nil }, func(_ []byte) { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) // Ginkgo Globals SetDefaultEventuallyTimeout(CFEventuallyTimeout) SetDefaultConsistentlyDuration(CFConsistentlyTimeout) @@ -67,20 +67,20 @@ var _ = SynchronizedBeforeSuite(func() []byte { helpers.DestroyHomeDir(homeDir) var err error - realDir, err = ioutil.TempDir("", "push-real-dir") + realDir, err = os.MkdirTemp("", "push-real-dir") Expect(err).ToNot(HaveOccurred()) - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized Before Each==============================", GinkgoParallelProcess()))) }) var _ = SynchronizedAfterSuite(func() { - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) homeDir = helpers.SetHomeDir() helpers.SetAPI() helpers.LoginCF() helpers.QuickDeleteOrg(organization) Expect(os.RemoveAll(realDir)).ToNot(HaveOccurred()) helpers.DestroyHomeDir(homeDir) - GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelNode()))) + GinkgoWriter.Write([]byte(fmt.Sprintf("==============================End of Global Node %d Synchronized After Each==============================", GinkgoParallelProcess()))) }, func() { }) diff --git a/integration/v7/push/random_route_test.go b/integration/v7/push/random_route_test.go index 2dc130ac882..ec48339518e 100644 --- a/integration/v7/push/random_route_test.go +++ b/integration/v7/push/random_route_test.go @@ -5,8 +5,8 @@ import ( "path" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/resource_matching_test.go b/integration/v7/push/resource_matching_test.go index 2af37efb83c..4a91485cc60 100644 --- a/integration/v7/push/resource_matching_test.go +++ b/integration/v7/push/resource_matching_test.go @@ -2,13 +2,13 @@ package push import ( "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "time" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -27,7 +27,7 @@ var _ = Describe("resource matching", func() { It("uploads the unmatched resources", func() { helpers.WithHelloWorldApp(func(dir string) { tempfile := filepath.Join(dir, "ignore.html") - err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s %s", time.Now(), strings.Repeat("a", 65*1024))), 0666) + err := os.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s %s", time.Now(), strings.Repeat("a", 65*1024))), 0666) Expect(err).ToNot(HaveOccurred()) session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start") diff --git a/integration/v7/push/rolling_push_test.go b/integration/v7/push/rolling_push_test.go index 1b4739e507c..77be25e400a 100644 --- a/integration/v7/push/rolling_push_test.go +++ b/integration/v7/push/rolling_push_test.go @@ -3,8 +3,8 @@ package push import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -53,6 +53,30 @@ var _ = Describe("push with --strategy rolling", func() { Expect(session).To(Say(`#0\s+running`)) }) }) + + It("pushes the app and creates a new deployment with max in flight set", func() { + helpers.WithHelloWorldApp(func(appDir string) { + session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, + PushCommandName, appName, "--strategy", "rolling", "--max-in-flight", "3", + ) + + Eventually(session).Should(Exit(0)) + Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) + Expect(session).To(Say(`Packaging files to upload\.\.\.`)) + Expect(session).To(Say(`Uploading files\.\.\.`)) + Expect(session).To(Say(`100.00%`)) + Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`)) + Expect(session).To(Say(`Staging app and tracing logs\.\.\.`)) + Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName)) + Expect(session).To(Say(`Waiting for app to deploy\.\.\.`)) + Expect(session).To(Say(`name:\s+%s`, appName)) + Expect(session).To(Say(`requested state:\s+started`)) + Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) + Expect(session).To(Say(`type:\s+web`)) + Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand)) + Expect(session).To(Say(`#0\s+running`)) + }) + }) }) When("canceling the deployment", func() { diff --git a/integration/v7/push/simple_manifest_only_test.go b/integration/v7/push/simple_manifest_only_test.go index 2b8e2017c79..76733d3fdb4 100644 --- a/integration/v7/push/simple_manifest_only_test.go +++ b/integration/v7/push/simple_manifest_only_test.go @@ -1,13 +1,12 @@ package push import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/integration/helpers" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -110,7 +109,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -168,7 +167,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -216,7 +215,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -267,7 +266,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -311,7 +310,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ @@ -352,7 +351,7 @@ var _ = Describe("push with a simple manifest", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "simple-manifest-test") + tempDir, err = os.MkdirTemp("", "simple-manifest-test") Expect(err).ToNot(HaveOccurred()) pathToManifest = filepath.Join(tempDir, "manifest.yml") helpers.WriteManifest(pathToManifest, map[string]interface{}{ diff --git a/integration/v7/push/stacks_test.go b/integration/v7/push/stacks_test.go index ea384ed31a9..0c2d6954e02 100644 --- a/integration/v7/push/stacks_test.go +++ b/integration/v7/push/stacks_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/start_command_test.go b/integration/v7/push/start_command_test.go index 893fbf0fe1b..9fddd54d331 100644 --- a/integration/v7/push/start_command_test.go +++ b/integration/v7/push/start_command_test.go @@ -3,10 +3,9 @@ package push import ( "fmt" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" diff --git a/integration/v7/push/symlink_resources_test.go b/integration/v7/push/symlink_resources_test.go index ee2918c3dc7..f45314ae8ab 100644 --- a/integration/v7/push/symlink_resources_test.go +++ b/integration/v7/push/symlink_resources_test.go @@ -1,13 +1,12 @@ package push import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -27,7 +26,7 @@ var _ = Describe("push with symlinked resources", func() { It("should push the symlink", func() { helpers.WithHelloWorldApp(func(dir string) { targetFile := filepath.Join(dir, "targetFile") - Expect(ioutil.WriteFile(targetFile, []byte("foo bar baz"), 0777)).ToNot(HaveOccurred()) + Expect(os.WriteFile(targetFile, []byte("foo bar baz"), 0777)).ToNot(HaveOccurred()) relativePath, err := filepath.Rel(dir, targetFile) Expect(err).ToNot(HaveOccurred()) @@ -46,7 +45,7 @@ var _ = Describe("push with symlinked resources", func() { When("the file doesn't exists", func() { It("should push the symlink", func() { helpers.WithHelloWorldApp(func(dir string) { - tempFile, err := ioutil.TempFile(dir, "tempFile") + tempFile, err := os.CreateTemp(dir, "tempFile") Expect(err).ToNot(HaveOccurred()) tempFile.Close() relativePath, err := filepath.Rel(dir, tempFile.Name()) @@ -69,7 +68,7 @@ var _ = Describe("push with symlinked resources", func() { When("the directory contains a symlink to subdirectory in the directory", func() { It("should push the symlink", func() { helpers.WithHelloWorldApp(func(dir string) { - targetDir, err := ioutil.TempDir(dir, "target-dir") + targetDir, err := os.MkdirTemp(dir, "target-dir") Expect(err).ToNot(HaveOccurred()) relativePath, err := filepath.Rel(dir, targetDir) Expect(err).ToNot(HaveOccurred()) @@ -99,13 +98,13 @@ var _ = Describe("push with symlinked resources", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "push-archive-integration") + tmpfile, err := os.CreateTemp("", "push-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) targetFile := filepath.Join(appDir, "targetFile") - Expect(ioutil.WriteFile(targetFile, []byte("some random data"), 0777)).ToNot(HaveOccurred()) + Expect(os.WriteFile(targetFile, []byte("some random data"), 0777)).ToNot(HaveOccurred()) relativePath, err := filepath.Rel(appDir, targetFile) Expect(err).ToNot(HaveOccurred()) diff --git a/integration/v7/push/symlink_test.go b/integration/v7/push/symlink_test.go index 93bc7f842b2..7853d3c183a 100644 --- a/integration/v7/push/symlink_test.go +++ b/integration/v7/push/symlink_test.go @@ -1,12 +1,11 @@ package push import ( - "io/ioutil" "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) @@ -22,7 +21,7 @@ var _ = Describe("push with symlink path", func() { appName = helpers.NewAppName() var err error - runningDir, err = ioutil.TempDir("", "push-with-symlink") + runningDir, err = os.MkdirTemp("", "push-with-symlink") Expect(err).ToNot(HaveOccurred()) symlinkedPath = filepath.Join(runningDir, "symlink-dir") }) @@ -63,7 +62,7 @@ var _ = Describe("push with symlink path", func() { BeforeEach(func() { helpers.WithHelloWorldApp(func(appDir string) { - tmpfile, err := ioutil.TempFile("", "push-archive-integration") + tmpfile, err := os.CreateTemp("", "push-archive-integration") Expect(err).ToNot(HaveOccurred()) archive = tmpfile.Name() Expect(tmpfile.Close()).ToNot(HaveOccurred()) diff --git a/integration/v7/push/targeting_test.go b/integration/v7/push/targeting_test.go index eb532fcbd88..923eca4ab62 100644 --- a/integration/v7/push/targeting_test.go +++ b/integration/v7/push/targeting_test.go @@ -1,8 +1,8 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" ) var _ = Describe("targeting the correct environment", func() { diff --git a/integration/v7/push/tasks_test.go b/integration/v7/push/tasks_test.go index 63f2f566095..1ff434146b5 100644 --- a/integration/v7/push/tasks_test.go +++ b/integration/v7/push/tasks_test.go @@ -1,13 +1,12 @@ package push import ( - "code.cloudfoundry.org/cli/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("push with --task", func() { @@ -19,7 +18,7 @@ var _ = Describe("push with --task", func() { appName = helpers.NewAppName() helpers.WithHelloWorldApp(func(dir string) { session := helpers.CF("push", appName, "-p", dir, "--task") - Eventually(session).Should(Exit(0)) + Eventually(session).Should(gexec.Exit(0)) }) }) @@ -28,7 +27,7 @@ var _ = Describe("push with --task", func() { BeforeEach(func() { session = helpers.CF("app", appName) - Eventually(session).Should(Exit(0)) + Eventually(session).Should(gexec.Exit(0)) }) It("pushes the app without starting it", func() { diff --git a/integration/v7/selfcontained/api_command_test.go b/integration/v7/selfcontained/api_command_test.go index 3347cb83b1a..98362a987ec 100644 --- a/integration/v7/selfcontained/api_command_test.go +++ b/integration/v7/selfcontained/api_command_test.go @@ -3,11 +3,11 @@ package selfcontained_test import ( "net/http" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/v7/selfcontained/fake" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" ) @@ -35,7 +35,7 @@ var _ = Describe("cf api", func() { When("pointed to cf-on-k8s", func() { BeforeEach(func() { apiConfig.Routes["GET /"] = fake.Response{ - Code: http.StatusOK, Body: ccv3.Info{CFOnK8s: true}, + Code: http.StatusOK, Body: ccv3.Root{CFOnK8s: true}, } apiServer.SetConfiguration(apiConfig) }) @@ -63,7 +63,7 @@ var _ = Describe("cf api", func() { When("pointed to cf-on-k8s", func() { BeforeEach(func() { apiConfig.Routes["GET /"] = fake.Response{ - Code: http.StatusOK, Body: ccv3.Info{CFOnK8s: true}, + Code: http.StatusOK, Body: ccv3.Root{CFOnK8s: true}, } apiServer.SetConfiguration(apiConfig) }) diff --git a/integration/v7/selfcontained/create_space_command_test.go b/integration/v7/selfcontained/create_space_command_test.go index 21c7e65ccb4..236412a6c37 100644 --- a/integration/v7/selfcontained/create_space_command_test.go +++ b/integration/v7/selfcontained/create_space_command_test.go @@ -5,10 +5,10 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/v7/selfcontained/fake" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" diff --git a/integration/v7/selfcontained/kubernetes_auth_log_test.go b/integration/v7/selfcontained/kubernetes_auth_log_test.go new file mode 100644 index 00000000000..d80aa25a90b --- /dev/null +++ b/integration/v7/selfcontained/kubernetes_auth_log_test.go @@ -0,0 +1,138 @@ +package selfcontained_test + +import ( + "net/http" + "path/filepath" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/onsi/gomega/gexec" + apiv1 "k8s.io/client-go/tools/clientcmd/api/v1" + + "code.cloudfoundry.org/cli/v8/util/configv3" +) + +var _ = Describe("logclient auth-provider", func() { + var ( + apiConfig fake.CFAPIConfig + kubeConfig apiv1.Config + ) + + BeforeEach(func() { + apiConfig = fake.CFAPIConfig{ + Routes: map[string]fake.Response{ + "GET /api/v1/read/test-guid": { + Code: http.StatusOK, Body: map[string]interface{}{ + "envelopes": map[string]interface{}{ + "batch": []string{}, + }, + }, + }, + "GET /api/v1/info": { + Code: http.StatusOK, Body: map[string]interface{}{ + "version": "42.1.2", + "vm_uptime": "0", + }, + }, + "GET /v3/apps": { + Code: http.StatusOK, Body: map[string]interface{}{ + "pagination": map[string]interface{}{}, + "resources": []map[string]string{ + { + "guid": "test-guid", + }, + }, + }, + }, + "GET /whoami": { + Code: http.StatusOK, Body: map[string]interface{}{ + "name": "my-user", + "kind": "User", + }, + }, + }, + } + apiServer.SetConfiguration(apiConfig) + helpers.SetConfig(func(config *configv3.Config) { + config.ConfigFile.Target = apiServer.URL() + config.ConfigFile.LogCacheEndpoint = apiServer.URL() + config.ConfigFile.CFOnK8s.Enabled = true + config.ConfigFile.CFOnK8s.AuthInfo = "my-user" + config.ConfigFile.TargetedOrganization = configv3.Organization{ + GUID: "my-org", + Name: "My Org", + } + + config.ConfigFile.TargetedSpace = configv3.Space{ + GUID: "my-space", + Name: "My Space", + } + }) + + kubeConfig = apiv1.Config{ + Kind: "Config", + APIVersion: "v1", + AuthInfos: []apiv1.NamedAuthInfo{ + { + Name: "my-user", + AuthInfo: apiv1.AuthInfo{ + AuthProvider: &apiv1.AuthProviderConfig{ + Name: "oidc", + Config: map[string]string{ + "id-token": string(token), + "idp-issuer-url": "-", + "client-id": "-", + }, + }, + }, + }, + }, + Clusters: []apiv1.NamedCluster{ + { + Name: "my-cluster", + Cluster: apiv1.Cluster{ + Server: "https://example.org", + }, + }, + }, + Contexts: []apiv1.NamedContext{ + { + Name: "my-context", + Context: apiv1.Context{ + Cluster: "my-cluster", + AuthInfo: "my-auth-info", + Namespace: "my-namespace", + }, + }, + }, + CurrentContext: "my-context", + } + kubeConfigPath := filepath.Join(homeDir, ".kube", "config") + storeKubeConfig(kubeConfig, kubeConfigPath) + + env = helpers.CFEnv{ + EnvVars: map[string]string{ + "KUBECONFIG": kubeConfigPath, + }, + } + }) + + JustBeforeEach(func() { + Eventually(helpers.CustomCF(env, "logs", "--recent", "my-test-app")).Should(gexec.Exit(0)) + }) + + It("sends the Bearer token in the Authorization header", func() { + reqs := apiServer.ReceivedRequests()["GET /api/v1/read/test-guid"] + Expect(reqs).To(HaveLen(1)) + Expect(reqs[0].Header).To(HaveKeyWithValue("Authorization", ConsistOf("Bearer "+string(token)))) + }) + + It("sends the User-Agent header", func() { + reqs := apiServer.ReceivedRequests()["GET /api/v1/read/test-guid"] + Expect(reqs).To(HaveLen(1)) + Expect(reqs[0].Header).To(HaveKeyWithValue("User-Agent", ConsistOf(ContainSubstring("cf")))) + }) +}) diff --git a/integration/v7/selfcontained/kubernetes_auth_test.go b/integration/v7/selfcontained/kubernetes_auth_test.go index 113c8e4f175..d1bdefd93c7 100644 --- a/integration/v7/selfcontained/kubernetes_auth_test.go +++ b/integration/v7/selfcontained/kubernetes_auth_test.go @@ -4,14 +4,15 @@ import ( "net/http" "path/filepath" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/v7/selfcontained/fake" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" apiv1 "k8s.io/client-go/tools/clientcmd/api/v1" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) var _ = Describe("auth-provider", func() { @@ -29,13 +30,19 @@ var _ = Describe("auth-provider", func() { "resources": []resources.Application{}, }, }, + "GET /whoami": { + Code: http.StatusOK, Body: map[string]interface{}{ + "name": "my-user", + "kind": "User", + }, + }, }, } apiServer.SetConfiguration(apiConfig) helpers.SetConfig(func(config *configv3.Config) { config.ConfigFile.Target = apiServer.URL() config.ConfigFile.CFOnK8s.Enabled = true - config.ConfigFile.CFOnK8s.AuthInfo = "one" + config.ConfigFile.CFOnK8s.AuthInfo = "my-user" config.ConfigFile.TargetedOrganization = configv3.Organization{ GUID: "my-org", Name: "My Org", @@ -52,7 +59,8 @@ var _ = Describe("auth-provider", func() { APIVersion: "v1", AuthInfos: []apiv1.NamedAuthInfo{ { - Name: "one", AuthInfo: apiv1.AuthInfo{ + Name: "my-user", + AuthInfo: apiv1.AuthInfo{ AuthProvider: &apiv1.AuthProviderConfig{ Name: "oidc", Config: map[string]string{ diff --git a/integration/v7/selfcontained/login_command_test.go b/integration/v7/selfcontained/login_command_test.go index 5e41d783fec..a33d264642f 100644 --- a/integration/v7/selfcontained/login_command_test.go +++ b/integration/v7/selfcontained/login_command_test.go @@ -6,16 +6,17 @@ import ( "os" "path/filepath" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/v7/selfcontained/fake" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" apiv1 "k8s.io/client-go/tools/clientcmd/api/v1" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/util/configv3" ) var _ = Describe("LoginCommand", func() { @@ -38,13 +39,19 @@ var _ = Describe("LoginCommand", func() { apiConfig = fake.CFAPIConfig{ Routes: map[string]fake.Response{ - "GET /": {Code: http.StatusOK, Body: ccv3.Info{CFOnK8s: true}}, + "GET /": {Code: http.StatusOK, Body: ccv3.Root{CFOnK8s: true}}, "GET /v3/organizations": { Code: http.StatusOK, Body: map[string]interface{}{ "pagination": map[string]interface{}{}, "resources": []resources.Organization{}, }, }, + "GET /whoami": { + Code: http.StatusOK, Body: map[string]interface{}{ + "name": "two", + "kind": "User", + }, + }, }, } apiServer.SetConfiguration(apiConfig) diff --git a/integration/v7/selfcontained/logout_command_test.go b/integration/v7/selfcontained/logout_command_test.go index 55e53f35a5d..6d3e0230b03 100644 --- a/integration/v7/selfcontained/logout_command_test.go +++ b/integration/v7/selfcontained/logout_command_test.go @@ -1,23 +1,86 @@ package selfcontained_test import ( - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "net/http" + "path/filepath" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" + apiv1 "k8s.io/client-go/tools/clientcmd/api/v1" + + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/util/configv3" ) var _ = Describe("cf logout", func() { BeforeEach(func() { helpers.SetConfig(func(config *configv3.Config) { config.ConfigFile.CFOnK8s.Enabled = true - config.ConfigFile.CFOnK8s.AuthInfo = "something" + config.ConfigFile.CFOnK8s.AuthInfo = "my-user" }) + + apiServer.SetConfiguration(fake.CFAPIConfig{Routes: map[string]fake.Response{ + "GET /whoami": { + Code: http.StatusOK, Body: map[string]interface{}{ + "name": "my-user", + "kind": "User", + }, + }, + }}) + + kubeConfig := apiv1.Config{ + Kind: "Config", + APIVersion: "v1", + AuthInfos: []apiv1.NamedAuthInfo{ + { + Name: "my-user", + AuthInfo: apiv1.AuthInfo{ + AuthProvider: &apiv1.AuthProviderConfig{ + Name: "oidc", + Config: map[string]string{ + "id-token": string(token), + "idp-issuer-url": "-", + "client-id": "-", + }, + }, + }, + }, + }, + Clusters: []apiv1.NamedCluster{ + { + Name: "my-cluster", + Cluster: apiv1.Cluster{ + Server: "https://example.org", + }, + }, + }, + Contexts: []apiv1.NamedContext{ + { + Name: "my-context", + Context: apiv1.Context{ + Cluster: "my-cluster", + AuthInfo: "my-auth-info", + Namespace: "my-namespace", + }, + }, + }, + CurrentContext: "my-context", + } + + kubeConfigPath := filepath.Join(homeDir, ".kube", "config") + storeKubeConfig(kubeConfig, kubeConfigPath) + + env = helpers.CFEnv{ + EnvVars: map[string]string{ + "KUBECONFIG": kubeConfigPath, + }, + } }) JustBeforeEach(func() { - Eventually(helpers.CF("logout")).Should(gexec.Exit(0)) + Eventually(helpers.CustomCF(env, "logout")).Should(gexec.Exit(0)) }) It("clears the auth-info", func() { diff --git a/integration/v7/selfcontained/selfcontained_suite_test.go b/integration/v7/selfcontained/selfcontained_suite_test.go index 403915d2aed..bfb928a7a1c 100644 --- a/integration/v7/selfcontained/selfcontained_suite_test.go +++ b/integration/v7/selfcontained/selfcontained_suite_test.go @@ -6,18 +6,17 @@ import ( "crypto/rsa" "encoding/base64" "encoding/json" - "io/ioutil" "os" "path/filepath" "testing" "time" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/integration/v7/selfcontained/fake" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/integration/helpers" + "code.cloudfoundry.org/cli/v8/integration/v7/selfcontained/fake" + "code.cloudfoundry.org/cli/v8/util/configv3" "github.com/SermoDigital/jose/crypto" "github.com/SermoDigital/jose/jws" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "gopkg.in/yaml.v2" apiv1 "k8s.io/client-go/tools/clientcmd/api/v1" @@ -58,7 +57,7 @@ var _ = AfterEach(func() { }) func loadConfig() configv3.JSONConfig { - rawConfig, err := ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + rawConfig, err := os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).NotTo(HaveOccurred()) var configFile configv3.JSONConfig diff --git a/main.go b/main.go index be48a9b048c..c0dfc6aceea 100644 --- a/main.go +++ b/main.go @@ -7,13 +7,13 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/cf/cmd" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/util/command_parser" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/panichandler" - plugin_util "code.cloudfoundry.org/cli/util/plugin" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/cf/cmd" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/util/command_parser" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/panichandler" + plugin_util "code.cloudfoundry.org/cli/v8/util/plugin" + "code.cloudfoundry.org/cli/v8/util/ui" ) func main() { @@ -32,7 +32,7 @@ func main() { os.Exit(1) } - p, err := command_parser.NewCommandParser() + p, err := command_parser.NewCommandParser(config) if err != nil { fmt.Fprintf(os.Stderr, "Unexpected error: %s\n", err.Error()) os.Exit(1) @@ -55,7 +55,7 @@ func main() { case common.ShouldFallbackToLegacy: cmd.Main(os.Getenv("CF_TRACE"), os.Args) - //NOT REACHED, legacy main will exit the process + // NOT REACHED, legacy main will exit the process default: unknownCommandError.Suggest(plugin_util.PluginCommandNames()) diff --git a/plugin/cli_connection.go b/plugin/cli_connection.go index d1a902997d8..4d02a140a2a 100644 --- a/plugin/cli_connection.go +++ b/plugin/cli_connection.go @@ -8,7 +8,7 @@ import ( "os" "time" - plugin_models "code.cloudfoundry.org/cli/plugin/models" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" ) type cliConnection struct { @@ -110,7 +110,7 @@ func (c *cliConnection) callCliCommand(silently bool, args ...string) ([]string, } func (c *cliConnection) pingCLI() { - //call back to cf saying we have been setup + // call back to cf saying we have been setup var connErr error var conn net.Conn for i := 0; i < 5; i++ { diff --git a/plugin/plugin.go b/plugin/plugin.go index 47853eb4d4d..596301fb4cd 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -1,10 +1,14 @@ package plugin -import plugin_models "code.cloudfoundry.org/cli/plugin/models" +import plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + +/* +* -/** Command interface needs to be implemented for a runnable plugin of `cf` -**/ + +* +*/ type Plugin interface { Run(cliConnection CliConnection, args []string) GetMetadata() PluginMetadata @@ -70,5 +74,5 @@ type Command struct { Name string Alias string HelpText string - UsageDetails Usage //Detail usage to be displayed in `cf help ` + UsageDetails Usage // Detail usage to be displayed in `cf help ` } diff --git a/plugin/plugin_examples/README.md b/plugin/plugin_examples/README.md index 44a088f8e18..b4cf7ddd939 100644 --- a/plugin/plugin_examples/README.md +++ b/plugin/plugin_examples/README.md @@ -14,15 +14,15 @@ Our current plugin architecture currently requires a review and possible large o # Changes in v6.14.0 - API `AccessToken()` now provides a refreshed o-auth token. -- [Examples](https://github.com/cloudfoundry/cli/tree/master/plugin/plugin_examples#test-driven-development-tdd) on how to use fake `CliConnection` and test RPC server for TDD development. +- [Examples](https://github.com/cloudfoundry/cli/tree/v8/plugin/plugin_examples#test-driven-development-tdd) on how to use fake `CliConnection` and test RPC server for TDD development. - Fix Plugin API file descriptors leakage. - Fix bug where some CLI versions does not respect `PluginMetadata.MinCliVersion`. - The field `PackageUpdatedAt` returned by `GetApp()` API is now populated. -[Complete change log ...](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/CHANGELOG.md) +[Complete change log ...](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/CHANGELOG.md) # Developing a Plugin -[Go here for documentation of the plugin API](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/DOC.md) +[Go here for documentation of the plugin API](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/DOC.md) This README discusses how to develop a cf CLI plugin. For user-focused documentation, see [Using the cf CLI](http://docs.cloudfoundry.org/cf-cli/use-cli-plugins.html). @@ -50,26 +50,26 @@ Here is an illustration of the work flow when a plugin command is being invoked. 1: CLI launches 2 processes, the rpc server and the independent plugin executable

-workflow 1 +workflow 1

2: Plugin establishes a connection to the RPC server, the connection is used to invoke core cli commands.

-workflow 1 +workflow 1

3: When a plugin invokes a cli command, it talks to the rpc server, and the rpc server interacts with cf cli to perform the command. The result is passed back to the plugin through the rpc server.

-workflow 1 +workflow 1

- Plugins that you develop for the cf CLI must conform to a predefined plugin interface that we discuss below. ## Writing a Plugin -[Go here for documentation of the plugin API](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/DOC.md) +[Go here for documentation of the plugin API](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/DOC.md) -To write a plugin for the cf CLI, implement the [predefined plugin interface](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin.go). +To write a plugin for the cf CLI, implement the [predefined plugin interface](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin.go). The interface uses a `Run(...)` method as the main entry point between the CLI and a plugin. This method receives the following arguments: @@ -82,21 +82,21 @@ Plugin names with spaces must be enclosed in quotes when installed and uninstall To initialize a plugin, call `plugin.Start(new(MyPluginStruct))` from within the `main()` method of your plugin. The `plugin.Start(...)` function requires a new reference to the struct that implements the defined interface. -This repo contains a basic plugin example [here](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/basic_plugin.go).
-To see more examples, go [here](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/). +This repo contains a basic plugin example [here](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/basic_plugin/basic_plugin.go).
+To see more examples, go [here](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/). ### Uninstalling A Plugin Uninstall of the plugin needs to be explicitly handled. When a user calls the `cf uninstall-plugin` command, CLI notifies the plugin via a call with `CLI-MESSAGE-UNINSTALL` as the first item in `[]args` from within the plugin's `Run(...)` method. ### Test Driven Development (TDD) An example which was developed using TDD is available: -- `Test RPC server`: an RPC server to be used as a back-end for the plugin. It allows the plugin to be tested as a stand alone binary without replying on CLI as a back-end. [See example](https://github.com/cloudfoundry/cli/tree/master/plugin/plugin_examples/test_rpc_server_example) +- `Test RPC server`: an RPC server to be used as a back-end for the plugin. It allows the plugin to be tested as a stand alone binary without replying on CLI as a back-end. [See example](https://github.com/cloudfoundry/cli/tree/v8/plugin/plugin_examples/test_rpc_server_example) ### Using Command Line Arguments The `Run(...)` method accepts the command line arguments and flags that you define for a plugin. - See the [command line arguments example] (https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/echo.go) included in this repo. + See the [command line arguments example] (https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/echo/echo.go) included in this repo. #### Global Flags There are several global flags that will not be passed to the plugin. These are: @@ -109,15 +109,15 @@ You can invoke CLI commands with `cliConnection.CliCommand([]args)` from within The `cliConnection.CliCommand([]args)` returns the output printed by the command and an error. The output is returned as a slice of strings. The error will be present if the call to the CLI command fails. -See the [test plugin example](https://github.com/cloudfoundry/cli/blob/master/integration/assets/test_plugin/test_plugin.go) included in this repo. +See the [test plugin example](https://github.com/cloudfoundry/cli/blob/v8/integration/assets/test_plugin/test_plugin.go) included in this repo. ### Creating Interactive Plugins -Because a plugin has access to stdin during a call to the `Run(...)` method, you can create interactive plugins. See the [interactive plugin example](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/interactive.go) included in this repo. +Because a plugin has access to stdin during a call to the `Run(...)` method, you can create interactive plugins. See the [interactive plugin example](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/interactive/interactive.go) included in this repo. ### Creating Plugins with multiple commands -A single plugin binary can have more than one command, and each command can have it's own help text defined. For an example of multi-command plugins, see the [multiple commands example](https://github.com/cloudfoundry/cli/blob/master/plugin/plugin_examples/multiple_commands.go) +A single plugin binary can have more than one command, and each command can have it's own help text defined. For an example of multi-command plugins, see the [multiple commands example](https://github.com/cloudfoundry/cli/blob/v8/plugin/plugin_examples/multiple_commands/multiple_commands.go) ### Enforcing a minimum CLI version required for the plugin. diff --git a/plugin/plugin_examples/basic_plugin.go b/plugin/plugin_examples/basic_plugin/basic_plugin.go similarity index 91% rename from plugin/plugin_examples/basic_plugin.go rename to plugin/plugin_examples/basic_plugin/basic_plugin.go index f3d7f90d76a..083319ffc2c 100644 --- a/plugin/plugin_examples/basic_plugin.go +++ b/plugin/plugin_examples/basic_plugin/basic_plugin.go @@ -3,11 +3,11 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) // BasicPlugin is the struct implementing the interface defined by the core CLI. It can -// be found at "code.cloudfoundry.org/cli/plugin/plugin.go" +// be found at "code.cloudfoundry.org/cli/v8/plugin/plugin.go" type BasicPlugin struct{} // Run must be implemented by any plugin because it is part of the @@ -15,7 +15,7 @@ type BasicPlugin struct{} // // Run(....) is the entry point when the core CLI is invoking a command defined // by a plugin. The first parameter, plugin.CliConnection, is a struct that can -// be used to invoke cli commands. The second paramter, args, is a slice of +// be used to invoke cli commands. The second parameter, args, is a slice of // strings. args[0] will be the name of the command, and will be followed by // any additional arguments a cli user typed in. // @@ -35,7 +35,7 @@ func (c *BasicPlugin) Run(cliConnection plugin.CliConnection, args []string) { // GetMetadata() returns a PluginMetadata struct. The first field, Name, // determines the name of the plugin which should generally be without spaces. // If there are spaces in the name a user will need to properly quote the name -// during uninstall otherwise the name will be treated as seperate arguments. +// during uninstall otherwise the name will be treated as separate arguments. // The second value is a slice of Command structs. Our slice only contains one // Command Struct, but could contain any number of them. The first field Name // defines the command `cf basic-plugin-command` once installed into the CLI. The @@ -77,7 +77,7 @@ func main() { // Any initialization for your plugin can be handled here // // Note: to run the plugin.Start method, we pass in a pointer to the struct - // implementing the interface defined at "code.cloudfoundry.org/cli/plugin/plugin.go" + // implementing the interface defined at "code.cloudfoundry.org/cli/v8/plugin/plugin.go" // // Note: The plugin's main() method is invoked at install time to collect // metadata. The plugin will exit 0 and the Run([]string) method will not be diff --git a/plugin/plugin_examples/echo.go b/plugin/plugin_examples/echo/echo.go similarity index 94% rename from plugin/plugin_examples/echo.go rename to plugin/plugin_examples/echo/echo.go index 770cc8db807..98111a71bda 100644 --- a/plugin/plugin_examples/echo.go +++ b/plugin/plugin_examples/echo/echo.go @@ -11,7 +11,7 @@ import ( "os" "strings" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type PluginDemonstratingParams struct { @@ -25,7 +25,7 @@ func main() { func (pluginDemo *PluginDemonstratingParams) Run(cliConnection plugin.CliConnection, args []string) { // Initialize flags echoFlagSet := flag.NewFlagSet("echo", flag.ExitOnError) - uppercase := echoFlagSet.Bool("uppercase", false, "displayes all provided text in uppercase") + uppercase := echoFlagSet.Bool("uppercase", false, "displayed all provided text in uppercase") // Parse starting from [1] because the [0]th element is the // name of the command diff --git a/plugin/plugin_examples/interactive.go b/plugin/plugin_examples/interactive/interactive.go similarity index 96% rename from plugin/plugin_examples/interactive.go rename to plugin/plugin_examples/interactive/interactive.go index 3f45d0983f2..88d958794a4 100644 --- a/plugin/plugin_examples/interactive.go +++ b/plugin/plugin_examples/interactive/interactive.go @@ -9,7 +9,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type Interactive struct{} diff --git a/plugin/plugin_examples/multiple_commands.go b/plugin/plugin_examples/multiple_commands/multiple_commands.go similarity index 96% rename from plugin/plugin_examples/multiple_commands.go rename to plugin/plugin_examples/multiple_commands/multiple_commands.go index d74b7026f49..d759acab571 100644 --- a/plugin/plugin_examples/multiple_commands.go +++ b/plugin/plugin_examples/multiple_commands/multiple_commands.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/plugin" ) type MultiCmd struct{} diff --git a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example.go b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example.go index bda8800a64b..707f1a487ac 100644 --- a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example.go +++ b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example.go @@ -9,8 +9,8 @@ import ( "fmt" "os" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/plugin" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/plugin" ) type DemoCmd struct{} diff --git a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_suite_test.go b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_suite_test.go index ec3e95fbb87..e6594a9bd46 100644 --- a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_suite_test.go +++ b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_suite_test.go @@ -1,13 +1,12 @@ package main_test import ( + "testing" "time" - "code.cloudfoundry.org/cli/cf/util/testhelpers/pluginbuilder" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/pluginbuilder" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) func TestTestRpcServerExample(t *testing.T) { diff --git a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_test.go b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_test.go index 5e506e0514f..a1f895c36d7 100644 --- a/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_test.go +++ b/plugin/plugin_examples/test_rpc_server_example/test_rpc_server_example_test.go @@ -5,12 +5,12 @@ import ( "errors" "os/exec" - . "code.cloudfoundry.org/cli/plugin/plugin_examples/test_rpc_server_example" + . "code.cloudfoundry.org/cli/v8/plugin/plugin_examples/test_rpc_server_example" - "code.cloudfoundry.org/cli/cf/util/testhelpers/rpcserver" - "code.cloudfoundry.org/cli/cf/util/testhelpers/rpcserver/rpcserverfakes" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/rpcserver" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/rpcserver/rpcserverfakes" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" @@ -31,15 +31,15 @@ var _ = Describe("App-Lister", func() { ts, err = rpcserver.NewTestRPCServer(rpcHandlers) Expect(err).NotTo(HaveOccurred()) - //set rpc.CallCoreCommand to a successful call - //rpc.CallCoreCommand is used in both cliConnection.CliCommand() and - //cliConnection.CliWithoutTerminalOutput() + // set rpc.CallCoreCommand to a successful call + // rpc.CallCoreCommand is used in both cliConnection.CliCommand() and + // cliConnection.CliWithoutTerminalOutput() rpcHandlers.CallCoreCommandStub = func(_ []string, retVal *bool) error { *retVal = true return nil } - //set rpc.GetOutputAndReset to return empty string; this is used by CliCommand()/CliWithoutTerminalOutput() + // set rpc.GetOutputAndReset to return empty string; this is used by CliCommand()/CliWithoutTerminalOutput() rpcHandlers.GetOutputAndResetStub = func(_ bool, retVal *[]string) error { *retVal = []string{"{}"} return nil diff --git a/plugin/plugin_shim_test.go b/plugin/plugin_shim_test.go index c7495d62d7a..40398e02bc2 100644 --- a/plugin/plugin_shim_test.go +++ b/plugin/plugin_shim_test.go @@ -4,10 +4,10 @@ import ( "os/exec" "path/filepath" - "code.cloudfoundry.org/cli/cf/util/testhelpers/rpcserver" - "code.cloudfoundry.org/cli/cf/util/testhelpers/rpcserver/rpcserverfakes" - "code.cloudfoundry.org/cli/plugin" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/rpcserver" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/rpcserver/rpcserverfakes" + "code.cloudfoundry.org/cli/v8/plugin" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gexec" @@ -15,7 +15,7 @@ import ( var _ = Describe("Command", func() { var ( - validPluginPath = filepath.Join("..", "fixtures", "plugins", "test_1.exe") + validPluginPath = filepath.Join("..", "fixtures", "plugins", "test_1", "test_1.exe") ) Describe(".Start", func() { diff --git a/plugin/plugin_suite_test.go b/plugin/plugin_suite_test.go index e05394e937a..f3f3448be33 100644 --- a/plugin/plugin_suite_test.go +++ b/plugin/plugin_suite_test.go @@ -2,16 +2,15 @@ package plugin_test import ( "path/filepath" + "testing" - "code.cloudfoundry.org/cli/cf/util/testhelpers/pluginbuilder" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/pluginbuilder" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) func TestPlugin(t *testing.T) { RegisterFailHandler(Fail) - pluginbuilder.BuildTestBinary(filepath.Join("..", "fixtures", "plugins"), "test_1") + pluginbuilder.BuildTestBinary(filepath.Join("..", "fixtures", "plugins", "test_1"), "test_1") RunSpecs(t, "Plugin Suite") } diff --git a/plugin/pluginfakes/fake_cli_connection.go b/plugin/pluginfakes/fake_cli_connection.go index 2c439c1a8cc..784a4600e6e 100644 --- a/plugin/pluginfakes/fake_cli_connection.go +++ b/plugin/pluginfakes/fake_cli_connection.go @@ -4,8 +4,8 @@ package pluginfakes import ( "sync" - "code.cloudfoundry.org/cli/plugin" - plugin_models "code.cloudfoundry.org/cli/plugin/models" + "code.cloudfoundry.org/cli/v8/plugin" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" ) type FakeCliConnection struct { @@ -352,15 +352,16 @@ func (fake *FakeCliConnection) AccessToken() (string, error) { ret, specificReturn := fake.accessTokenReturnsOnCall[len(fake.accessTokenArgsForCall)] fake.accessTokenArgsForCall = append(fake.accessTokenArgsForCall, struct { }{}) + stub := fake.AccessTokenStub + fakeReturns := fake.accessTokenReturns fake.recordInvocation("AccessToken", []interface{}{}) fake.accessTokenMutex.Unlock() - if fake.AccessTokenStub != nil { - return fake.AccessTokenStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.accessTokenReturns return fakeReturns.result1, fakeReturns.result2 } @@ -407,15 +408,16 @@ func (fake *FakeCliConnection) ApiEndpoint() (string, error) { ret, specificReturn := fake.apiEndpointReturnsOnCall[len(fake.apiEndpointArgsForCall)] fake.apiEndpointArgsForCall = append(fake.apiEndpointArgsForCall, struct { }{}) + stub := fake.ApiEndpointStub + fakeReturns := fake.apiEndpointReturns fake.recordInvocation("ApiEndpoint", []interface{}{}) fake.apiEndpointMutex.Unlock() - if fake.ApiEndpointStub != nil { - return fake.ApiEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.apiEndpointReturns return fakeReturns.result1, fakeReturns.result2 } @@ -462,15 +464,16 @@ func (fake *FakeCliConnection) ApiVersion() (string, error) { ret, specificReturn := fake.apiVersionReturnsOnCall[len(fake.apiVersionArgsForCall)] fake.apiVersionArgsForCall = append(fake.apiVersionArgsForCall, struct { }{}) + stub := fake.ApiVersionStub + fakeReturns := fake.apiVersionReturns fake.recordInvocation("ApiVersion", []interface{}{}) fake.apiVersionMutex.Unlock() - if fake.ApiVersionStub != nil { - return fake.ApiVersionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.apiVersionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -518,15 +521,16 @@ func (fake *FakeCliConnection) CliCommand(arg1 ...string) ([]string, error) { fake.cliCommandArgsForCall = append(fake.cliCommandArgsForCall, struct { arg1 []string }{arg1}) + stub := fake.CliCommandStub + fakeReturns := fake.cliCommandReturns fake.recordInvocation("CliCommand", []interface{}{arg1}) fake.cliCommandMutex.Unlock() - if fake.CliCommandStub != nil { - return fake.CliCommandStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.cliCommandReturns return fakeReturns.result1, fakeReturns.result2 } @@ -581,15 +585,16 @@ func (fake *FakeCliConnection) CliCommandWithoutTerminalOutput(arg1 ...string) ( fake.cliCommandWithoutTerminalOutputArgsForCall = append(fake.cliCommandWithoutTerminalOutputArgsForCall, struct { arg1 []string }{arg1}) + stub := fake.CliCommandWithoutTerminalOutputStub + fakeReturns := fake.cliCommandWithoutTerminalOutputReturns fake.recordInvocation("CliCommandWithoutTerminalOutput", []interface{}{arg1}) fake.cliCommandWithoutTerminalOutputMutex.Unlock() - if fake.CliCommandWithoutTerminalOutputStub != nil { - return fake.CliCommandWithoutTerminalOutputStub(arg1...) + if stub != nil { + return stub(arg1...) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.cliCommandWithoutTerminalOutputReturns return fakeReturns.result1, fakeReturns.result2 } @@ -643,15 +648,16 @@ func (fake *FakeCliConnection) DopplerEndpoint() (string, error) { ret, specificReturn := fake.dopplerEndpointReturnsOnCall[len(fake.dopplerEndpointArgsForCall)] fake.dopplerEndpointArgsForCall = append(fake.dopplerEndpointArgsForCall, struct { }{}) + stub := fake.DopplerEndpointStub + fakeReturns := fake.dopplerEndpointReturns fake.recordInvocation("DopplerEndpoint", []interface{}{}) fake.dopplerEndpointMutex.Unlock() - if fake.DopplerEndpointStub != nil { - return fake.DopplerEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.dopplerEndpointReturns return fakeReturns.result1, fakeReturns.result2 } @@ -699,15 +705,16 @@ func (fake *FakeCliConnection) GetApp(arg1 string) (plugin_models.GetAppModel, e fake.getAppArgsForCall = append(fake.getAppArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetAppStub + fakeReturns := fake.getAppReturns fake.recordInvocation("GetApp", []interface{}{arg1}) fake.getAppMutex.Unlock() - if fake.GetAppStub != nil { - return fake.GetAppStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAppReturns return fakeReturns.result1, fakeReturns.result2 } @@ -761,15 +768,16 @@ func (fake *FakeCliConnection) GetApps() ([]plugin_models.GetAppsModel, error) { ret, specificReturn := fake.getAppsReturnsOnCall[len(fake.getAppsArgsForCall)] fake.getAppsArgsForCall = append(fake.getAppsArgsForCall, struct { }{}) + stub := fake.GetAppsStub + fakeReturns := fake.getAppsReturns fake.recordInvocation("GetApps", []interface{}{}) fake.getAppsMutex.Unlock() - if fake.GetAppsStub != nil { - return fake.GetAppsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getAppsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -816,15 +824,16 @@ func (fake *FakeCliConnection) GetCurrentOrg() (plugin_models.Organization, erro ret, specificReturn := fake.getCurrentOrgReturnsOnCall[len(fake.getCurrentOrgArgsForCall)] fake.getCurrentOrgArgsForCall = append(fake.getCurrentOrgArgsForCall, struct { }{}) + stub := fake.GetCurrentOrgStub + fakeReturns := fake.getCurrentOrgReturns fake.recordInvocation("GetCurrentOrg", []interface{}{}) fake.getCurrentOrgMutex.Unlock() - if fake.GetCurrentOrgStub != nil { - return fake.GetCurrentOrgStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getCurrentOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -871,15 +880,16 @@ func (fake *FakeCliConnection) GetCurrentSpace() (plugin_models.Space, error) { ret, specificReturn := fake.getCurrentSpaceReturnsOnCall[len(fake.getCurrentSpaceArgsForCall)] fake.getCurrentSpaceArgsForCall = append(fake.getCurrentSpaceArgsForCall, struct { }{}) + stub := fake.GetCurrentSpaceStub + fakeReturns := fake.getCurrentSpaceReturns fake.recordInvocation("GetCurrentSpace", []interface{}{}) fake.getCurrentSpaceMutex.Unlock() - if fake.GetCurrentSpaceStub != nil { - return fake.GetCurrentSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getCurrentSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -927,15 +937,16 @@ func (fake *FakeCliConnection) GetOrg(arg1 string) (plugin_models.GetOrg_Model, fake.getOrgArgsForCall = append(fake.getOrgArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetOrgStub + fakeReturns := fake.getOrgReturns fake.recordInvocation("GetOrg", []interface{}{arg1}) fake.getOrgMutex.Unlock() - if fake.GetOrgStub != nil { - return fake.GetOrgStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getOrgReturns return fakeReturns.result1, fakeReturns.result2 } @@ -991,15 +1002,16 @@ func (fake *FakeCliConnection) GetOrgUsers(arg1 string, arg2 ...string) ([]plugi arg1 string arg2 []string }{arg1, arg2}) + stub := fake.GetOrgUsersStub + fakeReturns := fake.getOrgUsersReturns fake.recordInvocation("GetOrgUsers", []interface{}{arg1, arg2}) fake.getOrgUsersMutex.Unlock() - if fake.GetOrgUsersStub != nil { - return fake.GetOrgUsersStub(arg1, arg2...) + if stub != nil { + return stub(arg1, arg2...) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getOrgUsersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1053,15 +1065,16 @@ func (fake *FakeCliConnection) GetOrgs() ([]plugin_models.GetOrgs_Model, error) ret, specificReturn := fake.getOrgsReturnsOnCall[len(fake.getOrgsArgsForCall)] fake.getOrgsArgsForCall = append(fake.getOrgsArgsForCall, struct { }{}) + stub := fake.GetOrgsStub + fakeReturns := fake.getOrgsReturns fake.recordInvocation("GetOrgs", []interface{}{}) fake.getOrgsMutex.Unlock() - if fake.GetOrgsStub != nil { - return fake.GetOrgsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getOrgsReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1109,15 +1122,16 @@ func (fake *FakeCliConnection) GetService(arg1 string) (plugin_models.GetService fake.getServiceArgsForCall = append(fake.getServiceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetServiceStub + fakeReturns := fake.getServiceReturns fake.recordInvocation("GetService", []interface{}{arg1}) fake.getServiceMutex.Unlock() - if fake.GetServiceStub != nil { - return fake.GetServiceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServiceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1171,15 +1185,16 @@ func (fake *FakeCliConnection) GetServices() ([]plugin_models.GetServices_Model, ret, specificReturn := fake.getServicesReturnsOnCall[len(fake.getServicesArgsForCall)] fake.getServicesArgsForCall = append(fake.getServicesArgsForCall, struct { }{}) + stub := fake.GetServicesStub + fakeReturns := fake.getServicesReturns fake.recordInvocation("GetServices", []interface{}{}) fake.getServicesMutex.Unlock() - if fake.GetServicesStub != nil { - return fake.GetServicesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getServicesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1227,15 +1242,16 @@ func (fake *FakeCliConnection) GetSpace(arg1 string) (plugin_models.GetSpace_Mod fake.getSpaceArgsForCall = append(fake.getSpaceArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetSpaceStub + fakeReturns := fake.getSpaceReturns fake.recordInvocation("GetSpace", []interface{}{arg1}) fake.getSpaceMutex.Unlock() - if fake.GetSpaceStub != nil { - return fake.GetSpaceStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1291,15 +1307,16 @@ func (fake *FakeCliConnection) GetSpaceUsers(arg1 string, arg2 string) ([]plugin arg1 string arg2 string }{arg1, arg2}) + stub := fake.GetSpaceUsersStub + fakeReturns := fake.getSpaceUsersReturns fake.recordInvocation("GetSpaceUsers", []interface{}{arg1, arg2}) fake.getSpaceUsersMutex.Unlock() - if fake.GetSpaceUsersStub != nil { - return fake.GetSpaceUsersStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSpaceUsersReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1353,15 +1370,16 @@ func (fake *FakeCliConnection) GetSpaces() ([]plugin_models.GetSpaces_Model, err ret, specificReturn := fake.getSpacesReturnsOnCall[len(fake.getSpacesArgsForCall)] fake.getSpacesArgsForCall = append(fake.getSpacesArgsForCall, struct { }{}) + stub := fake.GetSpacesStub + fakeReturns := fake.getSpacesReturns fake.recordInvocation("GetSpaces", []interface{}{}) fake.getSpacesMutex.Unlock() - if fake.GetSpacesStub != nil { - return fake.GetSpacesStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getSpacesReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1408,15 +1426,16 @@ func (fake *FakeCliConnection) HasAPIEndpoint() (bool, error) { ret, specificReturn := fake.hasAPIEndpointReturnsOnCall[len(fake.hasAPIEndpointArgsForCall)] fake.hasAPIEndpointArgsForCall = append(fake.hasAPIEndpointArgsForCall, struct { }{}) + stub := fake.HasAPIEndpointStub + fakeReturns := fake.hasAPIEndpointReturns fake.recordInvocation("HasAPIEndpoint", []interface{}{}) fake.hasAPIEndpointMutex.Unlock() - if fake.HasAPIEndpointStub != nil { - return fake.HasAPIEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.hasAPIEndpointReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1463,15 +1482,16 @@ func (fake *FakeCliConnection) HasOrganization() (bool, error) { ret, specificReturn := fake.hasOrganizationReturnsOnCall[len(fake.hasOrganizationArgsForCall)] fake.hasOrganizationArgsForCall = append(fake.hasOrganizationArgsForCall, struct { }{}) + stub := fake.HasOrganizationStub + fakeReturns := fake.hasOrganizationReturns fake.recordInvocation("HasOrganization", []interface{}{}) fake.hasOrganizationMutex.Unlock() - if fake.HasOrganizationStub != nil { - return fake.HasOrganizationStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.hasOrganizationReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1518,15 +1538,16 @@ func (fake *FakeCliConnection) HasSpace() (bool, error) { ret, specificReturn := fake.hasSpaceReturnsOnCall[len(fake.hasSpaceArgsForCall)] fake.hasSpaceArgsForCall = append(fake.hasSpaceArgsForCall, struct { }{}) + stub := fake.HasSpaceStub + fakeReturns := fake.hasSpaceReturns fake.recordInvocation("HasSpace", []interface{}{}) fake.hasSpaceMutex.Unlock() - if fake.HasSpaceStub != nil { - return fake.HasSpaceStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.hasSpaceReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1573,15 +1594,16 @@ func (fake *FakeCliConnection) IsLoggedIn() (bool, error) { ret, specificReturn := fake.isLoggedInReturnsOnCall[len(fake.isLoggedInArgsForCall)] fake.isLoggedInArgsForCall = append(fake.isLoggedInArgsForCall, struct { }{}) + stub := fake.IsLoggedInStub + fakeReturns := fake.isLoggedInReturns fake.recordInvocation("IsLoggedIn", []interface{}{}) fake.isLoggedInMutex.Unlock() - if fake.IsLoggedInStub != nil { - return fake.IsLoggedInStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.isLoggedInReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1628,15 +1650,16 @@ func (fake *FakeCliConnection) IsSSLDisabled() (bool, error) { ret, specificReturn := fake.isSSLDisabledReturnsOnCall[len(fake.isSSLDisabledArgsForCall)] fake.isSSLDisabledArgsForCall = append(fake.isSSLDisabledArgsForCall, struct { }{}) + stub := fake.IsSSLDisabledStub + fakeReturns := fake.isSSLDisabledReturns fake.recordInvocation("IsSSLDisabled", []interface{}{}) fake.isSSLDisabledMutex.Unlock() - if fake.IsSSLDisabledStub != nil { - return fake.IsSSLDisabledStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.isSSLDisabledReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1683,15 +1706,16 @@ func (fake *FakeCliConnection) LoggregatorEndpoint() (string, error) { ret, specificReturn := fake.loggregatorEndpointReturnsOnCall[len(fake.loggregatorEndpointArgsForCall)] fake.loggregatorEndpointArgsForCall = append(fake.loggregatorEndpointArgsForCall, struct { }{}) + stub := fake.LoggregatorEndpointStub + fakeReturns := fake.loggregatorEndpointReturns fake.recordInvocation("LoggregatorEndpoint", []interface{}{}) fake.loggregatorEndpointMutex.Unlock() - if fake.LoggregatorEndpointStub != nil { - return fake.LoggregatorEndpointStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.loggregatorEndpointReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1738,15 +1762,16 @@ func (fake *FakeCliConnection) UserEmail() (string, error) { ret, specificReturn := fake.userEmailReturnsOnCall[len(fake.userEmailArgsForCall)] fake.userEmailArgsForCall = append(fake.userEmailArgsForCall, struct { }{}) + stub := fake.UserEmailStub + fakeReturns := fake.userEmailReturns fake.recordInvocation("UserEmail", []interface{}{}) fake.userEmailMutex.Unlock() - if fake.UserEmailStub != nil { - return fake.UserEmailStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.userEmailReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1793,15 +1818,16 @@ func (fake *FakeCliConnection) UserGuid() (string, error) { ret, specificReturn := fake.userGuidReturnsOnCall[len(fake.userGuidArgsForCall)] fake.userGuidArgsForCall = append(fake.userGuidArgsForCall, struct { }{}) + stub := fake.UserGuidStub + fakeReturns := fake.userGuidReturns fake.recordInvocation("UserGuid", []interface{}{}) fake.userGuidMutex.Unlock() - if fake.UserGuidStub != nil { - return fake.UserGuidStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.userGuidReturns return fakeReturns.result1, fakeReturns.result2 } @@ -1848,15 +1874,16 @@ func (fake *FakeCliConnection) Username() (string, error) { ret, specificReturn := fake.usernameReturnsOnCall[len(fake.usernameArgsForCall)] fake.usernameArgsForCall = append(fake.usernameArgsForCall, struct { }{}) + stub := fake.UsernameStub + fakeReturns := fake.usernameReturns fake.recordInvocation("Username", []interface{}{}) fake.usernameMutex.Unlock() - if fake.UsernameStub != nil { - return fake.UsernameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.usernameReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/plugin/rpc/call_command_registry.go b/plugin/rpc/call_command_registry.go index cb83f95e9d9..bfe3d893571 100644 --- a/plugin/rpc/call_command_registry.go +++ b/plugin/rpc/call_command_registry.go @@ -3,9 +3,9 @@ package rpc import ( "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . CommandRunner diff --git a/plugin/rpc/call_command_registry_test.go b/plugin/rpc/call_command_registry_test.go index 1cc3b48149d..36554dfa252 100644 --- a/plugin/rpc/call_command_registry_test.go +++ b/plugin/rpc/call_command_registry_test.go @@ -3,19 +3,19 @@ package rpc_test import ( "os" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" - "code.cloudfoundry.org/cli/cf/trace/tracefakes" - . "code.cloudfoundry.org/cli/plugin/rpc" - . "code.cloudfoundry.org/cli/plugin/rpc/fakecommand" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/terminal/terminalfakes" + "code.cloudfoundry.org/cli/v8/cf/trace/tracefakes" + . "code.cloudfoundry.org/cli/v8/plugin/rpc" + . "code.cloudfoundry.org/cli/v8/plugin/rpc/fakecommand" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("calling commands in commandregistry", func() { - _ = FakeCommand1{} //make sure fake_command is imported and self-registered with init() - _ = FakeCommand3{} //make sure fake_command is imported and self-registered with init() - _ = FakeCommand4{} //make sure fake_command is imported and self-registered with init() + _ = FakeCommand1{} // make sure fake_command is imported and self-registered with init() + _ = FakeCommand3{} // make sure fake_command is imported and self-registered with init() + _ = FakeCommand4{} // make sure fake_command is imported and self-registered with init() var ( ui *terminalfakes.FakeUI diff --git a/plugin/rpc/cli_rpc_server.go b/plugin/rpc/cli_rpc_server.go index 128484896da..1c44f551e52 100644 --- a/plugin/rpc/cli_rpc_server.go +++ b/plugin/rpc/cli_rpc_server.go @@ -1,29 +1,26 @@ package rpc import ( - "os" - "strings" - - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/terminal" - "code.cloudfoundry.org/cli/plugin" - plugin_models "code.cloudfoundry.org/cli/plugin/models" - "code.cloudfoundry.org/cli/version" - "github.com/blang/semver" - + "bytes" "fmt" + "io" "net" "net/rpc" + "os" "strconv" - - "bytes" - "io" - + "strings" "sync" - "code.cloudfoundry.org/cli/cf/trace" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/terminal" + "code.cloudfoundry.org/cli/v8/plugin" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + "code.cloudfoundry.org/cli/v8/version" + "github.com/blang/semver/v4" + + "code.cloudfoundry.org/cli/v8/cf/trace" ) var dialTimeout = os.Getenv("CF_DIAL_TIMEOUT") @@ -179,12 +176,12 @@ func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error { if cmdRegistry.CommandExists(args[0]) { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator - //set command ui's TeePrinter to be the one used by RpcService, for output to be captured + // set command ui's TeePrinter to be the one used by RpcService, for output to be captured deps.UI = terminal.NewUI(os.Stdin, cmd.stdout, cmd.outputCapture.(*terminal.TeePrinter), cmd.logger) err = cmd.newCmdRunner.Command(args, deps, false) @@ -307,8 +304,8 @@ func (cmd *CliRpcCmd) AccessToken(args string, retVal *string) error { func (cmd *CliRpcCmd) GetApp(appName string, retVal *plugin_models.GetAppModel) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Application = retVal @@ -321,8 +318,8 @@ func (cmd *CliRpcCmd) GetApp(appName string, retVal *plugin_models.GetAppModel) func (cmd *CliRpcCmd) GetApps(_ string, retVal *[]plugin_models.GetAppsModel) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.AppsSummary = retVal @@ -335,8 +332,8 @@ func (cmd *CliRpcCmd) GetApps(_ string, retVal *[]plugin_models.GetAppsModel) er func (cmd *CliRpcCmd) GetOrgs(_ string, retVal *[]plugin_models.GetOrgs_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Organizations = retVal @@ -349,8 +346,8 @@ func (cmd *CliRpcCmd) GetOrgs(_ string, retVal *[]plugin_models.GetOrgs_Model) e func (cmd *CliRpcCmd) GetSpaces(_ string, retVal *[]plugin_models.GetSpaces_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Spaces = retVal @@ -363,9 +360,9 @@ func (cmd *CliRpcCmd) GetSpaces(_ string, retVal *[]plugin_models.GetSpaces_Mode func (cmd *CliRpcCmd) GetServices(_ string, retVal *[]plugin_models.GetServices_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Services = retVal @@ -378,8 +375,8 @@ func (cmd *CliRpcCmd) GetServices(_ string, retVal *[]plugin_models.GetServices_ func (cmd *CliRpcCmd) GetOrgUsers(args []string, retVal *[]plugin_models.GetOrgUsers_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.OrgUsers = retVal @@ -392,8 +389,8 @@ func (cmd *CliRpcCmd) GetOrgUsers(args []string, retVal *[]plugin_models.GetOrgU func (cmd *CliRpcCmd) GetSpaceUsers(args []string, retVal *[]plugin_models.GetSpaceUsers_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.SpaceUsers = retVal @@ -406,8 +403,8 @@ func (cmd *CliRpcCmd) GetSpaceUsers(args []string, retVal *[]plugin_models.GetSp func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.GetOrg_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Organization = retVal @@ -420,8 +417,8 @@ func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.GetOrg_Model) func (cmd *CliRpcCmd) GetSpace(spaceName string, retVal *plugin_models.GetSpace_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Space = retVal @@ -434,8 +431,8 @@ func (cmd *CliRpcCmd) GetSpace(spaceName string, retVal *plugin_models.GetSpace_ func (cmd *CliRpcCmd) GetService(serviceInstance string, retVal *plugin_models.GetService_Model) error { deps := commandregistry.NewDependency(cmd.stdout, cmd.logger, dialTimeout) - //set deps objs to be the one used by all other commands - //once all commands are converted, we can make fresh deps for each command run + // set deps objs to be the one used by all other commands + // once all commands are converted, we can make fresh deps for each command run deps.Config = cmd.cliConfig deps.RepoLocator = cmd.repoLocator deps.PluginModels.Service = retVal diff --git a/plugin/rpc/cli_rpc_server_test.go b/plugin/rpc/cli_rpc_server_test.go index 9c863767f4d..2759ab49e19 100644 --- a/plugin/rpc/cli_rpc_server_test.go +++ b/plugin/rpc/cli_rpc_server_test.go @@ -7,25 +7,25 @@ import ( "os" "time" - "code.cloudfoundry.org/cli/cf/api" - "code.cloudfoundry.org/cli/cf/api/authentication/authenticationfakes" - "code.cloudfoundry.org/cli/cf/configuration/coreconfig" - "code.cloudfoundry.org/cli/cf/models" - "code.cloudfoundry.org/cli/cf/terminal" - testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - "code.cloudfoundry.org/cli/plugin" - plugin_models "code.cloudfoundry.org/cli/plugin/models" - . "code.cloudfoundry.org/cli/plugin/rpc" - cmdRunner "code.cloudfoundry.org/cli/plugin/rpc" - . "code.cloudfoundry.org/cli/plugin/rpc/fakecommand" - "code.cloudfoundry.org/cli/plugin/rpc/rpcfakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/cf/api" + "code.cloudfoundry.org/cli/v8/cf/api/authentication/authenticationfakes" + "code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig" + "code.cloudfoundry.org/cli/v8/cf/models" + "code.cloudfoundry.org/cli/v8/cf/terminal" + testconfig "code.cloudfoundry.org/cli/v8/cf/util/testhelpers/configuration" + "code.cloudfoundry.org/cli/v8/plugin" + plugin_models "code.cloudfoundry.org/cli/v8/plugin/models" + . "code.cloudfoundry.org/cli/v8/plugin/rpc" + cmdRunner "code.cloudfoundry.org/cli/v8/plugin/rpc" + . "code.cloudfoundry.org/cli/v8/plugin/rpc/fakecommand" + "code.cloudfoundry.org/cli/v8/plugin/rpc/rpcfakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Server", func() { - _ = FakeCommand1{} //make sure fake_command is imported and self-registered with init() + _ = FakeCommand1{} // make sure fake_command is imported and self-registered with init() var ( err error @@ -69,7 +69,7 @@ var _ = Describe("Server", func() { It("shuts down the rpc server", func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port()) @@ -91,7 +91,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) @@ -192,7 +192,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) @@ -222,7 +222,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) @@ -298,7 +298,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) @@ -441,7 +441,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) @@ -472,7 +472,7 @@ var _ = Describe("Server", func() { AfterEach(func() { rpcService.Stop() - //give time for server to stop + // give time for server to stop time.Sleep(50 * time.Millisecond) }) diff --git a/plugin/rpc/fakecommand/fake_command1.go b/plugin/rpc/fakecommand/fake_command1.go index a154ebde385..ecf87aed98e 100644 --- a/plugin/rpc/fakecommand/fake_command1.go +++ b/plugin/rpc/fakecommand/fake_command1.go @@ -3,10 +3,10 @@ package fakecommand import ( "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type FakeCommand1 struct { diff --git a/plugin/rpc/fakecommand/fake_command2.go b/plugin/rpc/fakecommand/fake_command2.go index d329e6c3c4f..eccba4e1851 100644 --- a/plugin/rpc/fakecommand/fake_command2.go +++ b/plugin/rpc/fakecommand/fake_command2.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" - "code.cloudfoundry.org/cli/cf/terminal" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/terminal" ) type FakeCommand2 struct { diff --git a/plugin/rpc/fakecommand/fake_command3.go b/plugin/rpc/fakecommand/fake_command3.go index b13505d7b29..0ea7c6541db 100644 --- a/plugin/rpc/fakecommand/fake_command3.go +++ b/plugin/rpc/fakecommand/fake_command3.go @@ -1,9 +1,9 @@ package fakecommand import ( - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) type FakeCommand3 struct { diff --git a/plugin/rpc/fakecommand/fake_command4.go b/plugin/rpc/fakecommand/fake_command4.go index e5b11eb8863..bb79e8690d4 100644 --- a/plugin/rpc/fakecommand/fake_command4.go +++ b/plugin/rpc/fakecommand/fake_command4.go @@ -3,9 +3,9 @@ package fakecommand import ( "errors" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/cf/flags" - "code.cloudfoundry.org/cli/cf/requirements" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/cf/flags" + "code.cloudfoundry.org/cli/v8/cf/requirements" ) var ErrFakeCommand4 = errors.New("ZOMG command errored") diff --git a/plugin/rpc/rpc_suite_test.go b/plugin/rpc/rpc_suite_test.go index 3d55040f792..1feaec7ecca 100644 --- a/plugin/rpc/rpc_suite_test.go +++ b/plugin/rpc/rpc_suite_test.go @@ -1,8 +1,8 @@ package rpc_test import ( - "code.cloudfoundry.org/cli/plugin/rpc" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/plugin/rpc" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/plugin/rpc/rpcfakes/fake_command_runner.go b/plugin/rpc/rpcfakes/fake_command_runner.go index fa70fde8646..8f940b1176e 100644 --- a/plugin/rpc/rpcfakes/fake_command_runner.go +++ b/plugin/rpc/rpcfakes/fake_command_runner.go @@ -4,8 +4,8 @@ package rpcfakes import ( "sync" - "code.cloudfoundry.org/cli/cf/commandregistry" - "code.cloudfoundry.org/cli/plugin/rpc" + "code.cloudfoundry.org/cli/v8/cf/commandregistry" + "code.cloudfoundry.org/cli/v8/plugin/rpc" ) type FakeCommandRunner struct { @@ -39,15 +39,16 @@ func (fake *FakeCommandRunner) Command(arg1 []string, arg2 commandregistry.Depen arg2 commandregistry.Dependency arg3 bool }{arg1Copy, arg2, arg3}) + stub := fake.CommandStub + fakeReturns := fake.commandReturns fake.recordInvocation("Command", []interface{}{arg1Copy, arg2, arg3}) fake.commandMutex.Unlock() - if fake.CommandStub != nil { - return fake.CommandStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - fakeReturns := fake.commandReturns return fakeReturns.result1 } diff --git a/plugin/rpc/rpcfakes/fake_output_capture.go b/plugin/rpc/rpcfakes/fake_output_capture.go index 9d37d2ef93d..01880aed6b9 100644 --- a/plugin/rpc/rpcfakes/fake_output_capture.go +++ b/plugin/rpc/rpcfakes/fake_output_capture.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/plugin/rpc" + "code.cloudfoundry.org/cli/v8/plugin/rpc" ) type FakeOutputCapture struct { @@ -23,9 +23,10 @@ func (fake *FakeOutputCapture) SetOutputBucket(arg1 io.Writer) { fake.setOutputBucketArgsForCall = append(fake.setOutputBucketArgsForCall, struct { arg1 io.Writer }{arg1}) + stub := fake.SetOutputBucketStub fake.recordInvocation("SetOutputBucket", []interface{}{arg1}) fake.setOutputBucketMutex.Unlock() - if fake.SetOutputBucketStub != nil { + if stub != nil { fake.SetOutputBucketStub(arg1) } } diff --git a/plugin/rpc/rpcfakes/fake_terminal_output_switch.go b/plugin/rpc/rpcfakes/fake_terminal_output_switch.go index 58e4cf01e7e..6989e71f6f1 100644 --- a/plugin/rpc/rpcfakes/fake_terminal_output_switch.go +++ b/plugin/rpc/rpcfakes/fake_terminal_output_switch.go @@ -4,7 +4,7 @@ package rpcfakes import ( "sync" - "code.cloudfoundry.org/cli/plugin/rpc" + "code.cloudfoundry.org/cli/v8/plugin/rpc" ) type FakeTerminalOutputSwitch struct { @@ -22,9 +22,10 @@ func (fake *FakeTerminalOutputSwitch) DisableTerminalOutput(arg1 bool) { fake.disableTerminalOutputArgsForCall = append(fake.disableTerminalOutputArgsForCall, struct { arg1 bool }{arg1}) + stub := fake.DisableTerminalOutputStub fake.recordInvocation("DisableTerminalOutput", []interface{}{arg1}) fake.disableTerminalOutputMutex.Unlock() - if fake.DisableTerminalOutputStub != nil { + if stub != nil { fake.DisableTerminalOutputStub(arg1) } } diff --git a/plugin/rpc/run_plugin.go b/plugin/rpc/run_plugin.go index 295184628f7..f57d194668c 100644 --- a/plugin/rpc/run_plugin.go +++ b/plugin/rpc/run_plugin.go @@ -4,7 +4,7 @@ import ( "os" "os/exec" - "code.cloudfoundry.org/cli/cf/configuration/pluginconfig" + "code.cloudfoundry.org/cli/v8/cf/configuration/pluginconfig" ) func RunMethodIfExists(rpcService *CliRpcService, args []string, pluginList map[string]pluginconfig.PluginMetadata) bool { diff --git a/plugin/transition/run_plugin_legacy.go b/plugin/transition/run_plugin_legacy.go index ffac5683f3a..3493276e378 100644 --- a/plugin/transition/run_plugin_legacy.go +++ b/plugin/transition/run_plugin_legacy.go @@ -3,9 +3,9 @@ package plugin_transition import ( "os" - "code.cloudfoundry.org/cli/cf/cmd" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/cf/cmd" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/util/configv3" ) func RunPlugin(plugin configv3.Plugin, _ command.UI) error { diff --git a/resources/api_links_resource.go b/resources/api_links_resource.go index cfb2c499bf8..91aca3306d6 100644 --- a/resources/api_links_resource.go +++ b/resources/api_links_resource.go @@ -20,7 +20,7 @@ type APILinkMeta struct { HostKeyFingerprint string `json:"host_key_fingerprint"` // Identifier for UAA queries - OAuthClient string `json:"oath_client"` + OAuthClient string `json:"oauth_client"` } // APILinks is a directory of follow-up urls for the resource. diff --git a/resources/application_resource.go b/resources/application_resource.go index b663ce8f8ce..c0e3dacf01f 100644 --- a/resources/application_resource.go +++ b/resources/application_resource.go @@ -1,9 +1,10 @@ package resources import ( - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" "encoding/json" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Application represents a Cloud Controller V3 Application. @@ -24,24 +25,39 @@ type Application struct { SpaceGUID string // State is the desired state of the application. State constant.ApplicationState + // Credentials are used by Cloud Native Buildpacks lifecycle to pull buildpacks + Credentials map[string]interface{} + // CurrentDropletGUID is the unique identifier of the droplet currently attached to the application. + CurrentDropletGUID string +} + +// ApplicationNameOnly represents only the name field of a Cloud Controller V3 Application +type ApplicationNameOnly struct { + // Name is the name given to the application. + Name string `json:"name,omitempty"` } // MarshalJSON converts an Application into a Cloud Controller Application. func (a Application) MarshalJSON() ([]byte, error) { ccApp := ccApplication{ + GUID: a.GUID, Name: a.Name, Metadata: a.Metadata, } + ccApp.Relationships = Relationships{} + if a.SpaceGUID != "" { - ccApp.Relationships = Relationships{ - constant.RelationshipTypeSpace: Relationship{GUID: a.SpaceGUID}, - } + ccApp.Relationships[constant.RelationshipTypeSpace] = Relationship{GUID: a.SpaceGUID} + } + + if a.CurrentDropletGUID != "" { + ccApp.Relationships[constant.RelationshipTypeCurrentDroplet] = Relationship{GUID: a.CurrentDropletGUID} } if a.LifecycleType == constant.AppLifecycleTypeDocker { ccApp.setDockerLifecycle() - } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack { + } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack || a.LifecycleType == constant.AppLifecycleTypeCNB { if len(a.LifecycleBuildpacks) > 0 || a.StackName != "" { if a.hasAutodetectedBuildpack() { ccApp.setAutodetectedBuildpackLifecycle(a) @@ -72,6 +88,9 @@ func (a *Application) UnmarshalJSON(data []byte) error { a.LifecycleType = lifecycle.Type a.Name = ccApp.Name a.SpaceGUID = ccApp.Relationships[constant.RelationshipTypeSpace].GUID + if _, ok := ccApp.Relationships[constant.RelationshipTypeCurrentDroplet]; ok { + a.CurrentDropletGUID = ccApp.Relationships[constant.RelationshipTypeCurrentDroplet].GUID + } a.State = ccApp.State a.Metadata = ccApp.Metadata @@ -93,11 +112,18 @@ func (a Application) hasAutodetectedBuildpack() bool { return a.LifecycleBuildpacks[0] == constant.AutodetectBuildpackValueDefault || a.LifecycleBuildpacks[0] == constant.AutodetectBuildpackValueNull } +type ccCredentials map[string]interface{} + +func (ccCredentials) UnmarshalJSON(data []byte) error { + return nil +} + type ccLifecycle struct { Type constant.AppLifecycleType `json:"type,omitempty"` Data struct { - Buildpacks []string `json:"buildpacks,omitempty"` - Stack string `json:"stack,omitempty"` + Buildpacks []string `json:"buildpacks,omitempty"` + Stack string `json:"stack,omitempty"` + Credentials ccCredentials `json:"credentials,omitempty"` } `json:"data"` } @@ -128,6 +154,7 @@ func (ccApp *ccApplication) setBuildpackLifecycle(a Application) { lifecycle.Type = a.LifecycleType lifecycle.Data.Buildpacks = a.LifecycleBuildpacks lifecycle.Data.Stack = a.StackName + lifecycle.Data.Credentials = a.Credentials ccApp.Lifecycle = lifecycle } diff --git a/resources/build_resource.go b/resources/build_resource.go index e190de90a6a..47c4c727624 100644 --- a/resources/build_resource.go +++ b/resources/build_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Build represent the process of staging an application package. diff --git a/resources/buildpack_resource.go b/resources/buildpack_resource.go index 04d29e271c2..6724f9ecd74 100644 --- a/resources/buildpack_resource.go +++ b/resources/buildpack_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/types" ) // Buildpack represents a Cloud Controller V3 buildpack. @@ -31,20 +31,24 @@ type Buildpack struct { Links APILinks // Metadata is used for custom tagging of API resources Metadata *Metadata + // Lifecycle is the lifecycle used with this buildpack + Lifecycle string } // MarshalJSON converts a Package into a Cloud Controller Package. func (buildpack Buildpack) MarshalJSON() ([]byte, error) { ccBuildpack := struct { - Name string `json:"name,omitempty"` - Stack string `json:"stack,omitempty"` - Position *int `json:"position,omitempty"` - Enabled *bool `json:"enabled,omitempty"` - Locked *bool `json:"locked,omitempty"` - Metadata *Metadata `json:"metadata,omitempty"` + Name string `json:"name,omitempty"` + Stack string `json:"stack,omitempty"` + Position *int `json:"position,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Locked *bool `json:"locked,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` + Lifecycle string `json:"lifecycle,omitempty"` }{ - Name: buildpack.Name, - Stack: buildpack.Stack, + Name: buildpack.Name, + Stack: buildpack.Stack, + Lifecycle: buildpack.Lifecycle, } if buildpack.Position.IsSet { @@ -62,16 +66,17 @@ func (buildpack Buildpack) MarshalJSON() ([]byte, error) { func (buildpack *Buildpack) UnmarshalJSON(data []byte) error { var ccBuildpack struct { - GUID string `json:"guid,omitempty"` - Links APILinks `json:"links,omitempty"` - Name string `json:"name,omitempty"` - Filename string `json:"filename,omitempty"` - Stack string `json:"stack,omitempty"` - State string `json:"state,omitempty"` - Enabled types.NullBool `json:"enabled"` - Locked types.NullBool `json:"locked"` - Position types.NullInt `json:"position"` - Metadata *Metadata `json:"metadata"` + GUID string `json:"guid,omitempty"` + Links APILinks `json:"links,omitempty"` + Name string `json:"name,omitempty"` + Filename string `json:"filename,omitempty"` + Stack string `json:"stack,omitempty"` + State string `json:"state,omitempty"` + Enabled types.NullBool `json:"enabled"` + Locked types.NullBool `json:"locked"` + Position types.NullInt `json:"position"` + Metadata *Metadata `json:"metadata"` + Lifecycle string `json:"lifecycle"` } err := cloudcontroller.DecodeJSON(data, &ccBuildpack) @@ -89,6 +94,7 @@ func (buildpack *Buildpack) UnmarshalJSON(data []byte) error { buildpack.State = ccBuildpack.State buildpack.Links = ccBuildpack.Links buildpack.Metadata = ccBuildpack.Metadata + buildpack.Lifecycle = ccBuildpack.Lifecycle return nil } diff --git a/resources/deployment_resource.go b/resources/deployment_resource.go index 144ac076426..e23ae4d4763 100644 --- a/resources/deployment_resource.go +++ b/resources/deployment_resource.go @@ -3,21 +3,48 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/types" ) type Deployment struct { - GUID string - State constant.DeploymentState - StatusValue constant.DeploymentStatusValue - StatusReason constant.DeploymentStatusReason - RevisionGUID string - DropletGUID string - CreatedAt string - UpdatedAt string - Relationships Relationships - NewProcesses []Process + GUID string + State constant.DeploymentState + StatusValue constant.DeploymentStatusValue + StatusReason constant.DeploymentStatusReason + CanaryStatus CanaryStatus + LastStatusChange string + Options DeploymentOpts + RevisionGUID string + DropletGUID string + CreatedAt string + UpdatedAt string + Relationships Relationships + NewProcesses []Process + Strategy constant.DeploymentStrategy +} + +type DeploymentOpts struct { + MaxInFlight int `json:"max_in_flight,omitempty"` + CanaryDeploymentOptions *CanaryDeploymentOptions `json:"canary,omitempty"` + Instances types.NullInt `json:"web_instances,omitempty"` + MemoryInMB types.NullUint64 `json:"memory_in_mb,omitempty"` + DiskInMB types.NullUint64 `json:"disk_in_mb,omitempty"` + LogRateLimitInBPS types.NullInt `json:"log_rate_limit_in_bytes_per_second,omitempty"` +} + +func (d DeploymentOpts) IsEmpty() bool { + return d.MaxInFlight == 0 && (d.CanaryDeploymentOptions == nil || len(d.CanaryDeploymentOptions.Steps) == 0) && + !d.Instances.IsSet && !d.MemoryInMB.IsSet && !d.DiskInMB.IsSet && !d.LogRateLimitInBPS.IsSet +} + +type CanaryDeploymentOptions struct { + Steps []CanaryStep `json:"steps"` +} + +type CanaryStep struct { + InstanceWeight int64 `json:"instance_weight"` } // MarshalJSON converts a Deployment into a Cloud Controller Deployment. @@ -30,9 +57,11 @@ func (d Deployment) MarshalJSON() ([]byte, error) { } var ccDeployment struct { - Droplet *Droplet `json:"droplet,omitempty"` - Revision *Revision `json:"revision,omitempty"` - Relationships Relationships `json:"relationships,omitempty"` + Droplet *Droplet `json:"droplet,omitempty"` + Options *DeploymentOpts `json:"options,omitempty"` + Revision *Revision `json:"revision,omitempty"` + Strategy constant.DeploymentStrategy `json:"strategy,omitempty"` + Relationships Relationships `json:"relationships,omitempty"` } if d.DropletGUID != "" { @@ -43,11 +72,28 @@ func (d Deployment) MarshalJSON() ([]byte, error) { ccDeployment.Revision = &Revision{d.RevisionGUID} } + if d.Strategy != "" { + ccDeployment.Strategy = d.Strategy + } + + if !d.Options.IsEmpty() { + ccDeployment.Options = &d.Options + } + ccDeployment.Relationships = d.Relationships return json.Marshal(ccDeployment) } +type CanaryStepStatus struct { + CurrentStep int `json:"current"` + TotalSteps int `json:"total"` +} + +type CanaryStatus struct { + Steps CanaryStepStatus `json:"steps"` +} + // UnmarshalJSON helps unmarshal a Cloud Controller Deployment response. func (d *Deployment) UnmarshalJSON(data []byte) error { var ccDeployment struct { @@ -56,12 +102,19 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { Relationships Relationships `json:"relationships,omitempty"` State constant.DeploymentState `json:"state,omitempty"` Status struct { - Value constant.DeploymentStatusValue `json:"value"` - Reason constant.DeploymentStatusReason `json:"reason"` + Details struct { + LastStatusChange string `json:"last_status_change"` + } + Value constant.DeploymentStatusValue `json:"value"` + Reason constant.DeploymentStatusReason `json:"reason"` + CanaryStatus CanaryStatus `json:"canary,omitempty"` } `json:"status"` - Droplet Droplet `json:"droplet,omitempty"` - NewProcesses []Process `json:"new_processes,omitempty"` + Droplet Droplet `json:"droplet,omitempty"` + NewProcesses []Process `json:"new_processes,omitempty"` + Strategy constant.DeploymentStrategy `json:"strategy"` + Options DeploymentOpts `json:"options,omitempty"` } + err := cloudcontroller.DecodeJSON(data, &ccDeployment) if err != nil { return err @@ -73,8 +126,12 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { d.State = ccDeployment.State d.StatusValue = ccDeployment.Status.Value d.StatusReason = ccDeployment.Status.Reason + d.CanaryStatus = ccDeployment.Status.CanaryStatus + d.LastStatusChange = ccDeployment.Status.Details.LastStatusChange d.DropletGUID = ccDeployment.Droplet.GUID d.NewProcesses = ccDeployment.NewProcesses + d.Strategy = ccDeployment.Strategy + d.Options = ccDeployment.Options return nil } diff --git a/resources/domain_resource.go b/resources/domain_resource.go index 35dda7d0d7b..591127ba0b3 100644 --- a/resources/domain_resource.go +++ b/resources/domain_resource.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" ) diff --git a/resources/droplet_resource.go b/resources/droplet_resource.go index 515bfc61133..0a31bba82c7 100644 --- a/resources/droplet_resource.go +++ b/resources/droplet_resource.go @@ -1,18 +1,25 @@ package resources import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "encoding/json" + + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Droplet represents a Cloud Controller droplet's metadata. A droplet is a set of // compiled bits for a given application. type Droplet struct { - //Buildpacks are the detected buildpacks from the staging process. + // AppGUID is the unique identifier of the application associated with the droplet. + AppGUID string `json:"app_guid"` + // Buildpacks are the detected buildpacks from the staging process. Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"` // CreatedAt is the timestamp that the Cloud Controller created the droplet. CreatedAt string `json:"created_at"` // GUID is the unique droplet identifier. GUID string `json:"guid"` + // An object describing the lifecycle that was used when staging the droplet + Lifecycle DropletLifecycle `json:"lifecycle"` // Image is the Docker image name. Image string `json:"image"` // Stack is the root filesystem to use with the buildpack. @@ -28,10 +35,104 @@ type Droplet struct { type DropletBuildpack struct { // Name is the buildpack name. Name string `json:"name"` - // BuildpackName is the the name reported by the buildpack. + // BuildpackName is the name reported by the buildpack. BuildpackName string `json:"buildpack_name"` // DetectOutput is the output of the buildpack detect script. DetectOutput string `json:"detect_output"` // Version is the version of the detected buildpack. Version string `json:"version"` } + +// An object describing the lifecycle that was used when staging the droplet +// possible values for type: "buildpack", "cnb", "docker" +type DropletLifecycle struct { + Type string `json:"type"` +} + +func (d Droplet) MarshallJSON() ([]byte, error) { + type ccDroplet struct { + GUID string `json:"guid,omitempty"` + Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + Lifecycle DropletLifecycle `json:"lifecycle,omitempty"` + Image string `json:"image,omitempty"` + Stack string `json:"stack,omitempty"` + State constant.DropletState `json:"state,omitempty"` + Relationships *struct { + App struct { + Data struct { + GUID string `json:"guid,omitempty"` + } `json:"data,omitempty"` + } `json:"app,omitempty"` + } `json:"relationships,omitempty"` + } + + ccD := ccDroplet{ + GUID: d.GUID, + Buildpacks: d.Buildpacks, + CreatedAt: d.CreatedAt, + Lifecycle: d.Lifecycle, + Image: d.Image, + Stack: d.Stack, + State: d.State, + } + + if d.AppGUID != "" { + ccD.Relationships = &struct { + App struct { + Data struct { + GUID string `json:"guid,omitempty"` + } `json:"data,omitempty"` + } `json:"app,omitempty"` + }{ + App: struct { + Data struct { + GUID string `json:"guid,omitempty"` + } `json:"data,omitempty"` + }{ + Data: struct { + GUID string `json:"guid,omitempty"` + }{ + GUID: d.AppGUID, + }, + }, + } + } + + return json.Marshal(ccD) +} + +func (d *Droplet) UnmarshalJSON(data []byte) error { + var alias struct { + GUID string `json:"guid,omitempty"` + Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + Image string `json:"image,omitempty"` + Lifecycle DropletLifecycle `json:"lifecycle,omitempty"` + Stack string `json:"stack,omitempty"` + State constant.DropletState `json:"state,omitempty"` + Relationships struct { + App struct { + Data struct { + GUID string `json:"guid,omitempty"` + } `json:"data,omitempty"` + } `json:"app,omitempty"` + } + } + + err := cloudcontroller.DecodeJSON(data, &alias) + if err != nil { + return err + } + + d.GUID = alias.GUID + d.Buildpacks = alias.Buildpacks + d.CreatedAt = alias.CreatedAt + d.Image = alias.Image + d.Lifecycle = alias.Lifecycle + d.Stack = alias.Stack + d.State = alias.State + d.AppGUID = alias.Relationships.App.Data.GUID + + return nil +} diff --git a/resources/environment_variables_resource.go b/resources/environment_variables_resource.go index 357641d2260..0c293fcbfcb 100644 --- a/resources/environment_variables_resource.go +++ b/resources/environment_variables_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/types" ) type EnvironmentVariables map[string]types.FilteredString diff --git a/resources/last_operation_resource_test.go b/resources/last_operation_resource_test.go index 87267b65bbe..b3cfd45d1be 100644 --- a/resources/last_operation_resource_test.go +++ b/resources/last_operation_resource_test.go @@ -3,9 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/metadata_resource.go b/resources/metadata_resource.go index 414fe1427de..a13c7bb713b 100644 --- a/resources/metadata_resource.go +++ b/resources/metadata_resource.go @@ -1,9 +1,10 @@ package resources -import "code.cloudfoundry.org/cli/types" +import "code.cloudfoundry.org/cli/v8/types" type Metadata struct { - Labels map[string]types.NullString `json:"labels,omitempty"` + Annotations map[string]types.NullString `json:"annotations,omitempty"` + Labels map[string]types.NullString `json:"labels,omitempty"` } type ResourceMetadata struct { diff --git a/resources/options_resource.go b/resources/options_resource.go new file mode 100644 index 00000000000..1730b9d4712 --- /dev/null +++ b/resources/options_resource.go @@ -0,0 +1,24 @@ +package resources + +import "strings" + +func CreateRouteOptions(options []string) (map[string]*string, *string) { + routeOptions := map[string]*string{} + for _, option := range options { + key, value, found := strings.Cut(option, "=") + if found { + routeOptions[key] = &value + } else { + return routeOptions, &option + } + } + return routeOptions, nil +} + +func RemoveRouteOptions(options []string) map[string]*string { + routeOptions := map[string]*string{} + for _, option := range options { + routeOptions[option] = nil + } + return routeOptions +} diff --git a/resources/organization_resource.go b/resources/organization_resource.go index 187bb1beb7c..7db5e720560 100644 --- a/resources/organization_resource.go +++ b/resources/organization_resource.go @@ -12,7 +12,8 @@ type Organization struct { Name string `json:"name"` // QuotaGUID is the GUID of the organization Quota applied to this Organization QuotaGUID string `json:"-"` - + // Suspended is the status of the organization applied to this Organization + Suspended bool `json:"suspended"` // Metadata is used for custom tagging of API resources Metadata *Metadata `json:"metadata,omitempty"` } diff --git a/resources/package_resource.go b/resources/package_resource.go index c17e66a5fe7..eeda9caa1d3 100644 --- a/resources/package_resource.go +++ b/resources/package_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Package represents a Cloud Controller V3 Package. diff --git a/resources/process_resource.go b/resources/process_resource.go index 5376f8e6ab6..30cbec45ffb 100644 --- a/resources/process_resource.go +++ b/resources/process_resource.go @@ -4,24 +4,29 @@ import ( "encoding/json" "fmt" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/types" ) type Process struct { GUID string Type string // Command is the process start command. Note: This value will be obfuscated when obtained from listing. - Command types.FilteredString - HealthCheckType constant.HealthCheckType - HealthCheckEndpoint string - HealthCheckInvocationTimeout int64 - HealthCheckTimeout int64 - Instances types.NullInt - MemoryInMB types.NullUint64 - DiskInMB types.NullUint64 - AppGUID string + Command types.FilteredString + HealthCheckType constant.HealthCheckType + HealthCheckEndpoint string + HealthCheckInvocationTimeout int64 + HealthCheckTimeout int64 + ReadinessHealthCheckType constant.HealthCheckType + ReadinessHealthCheckEndpoint string + ReadinessHealthCheckInvocationTimeout int64 + ReadinessHealthCheckInterval int64 + Instances types.NullInt + MemoryInMB types.NullUint64 + DiskInMB types.NullUint64 + LogRateLimitInBPS types.NullInt + AppGUID string } func (p Process) MarshalJSON() ([]byte, error) { @@ -31,20 +36,23 @@ func (p Process) MarshalJSON() ([]byte, error) { marshalInstances(p, &ccProcess) marshalMemory(p, &ccProcess) marshalDisk(p, &ccProcess) + marshalLogRateLimit(p, &ccProcess) marshalHealthCheck(p, &ccProcess) + marshalReadinessHealthCheck(p, &ccProcess) return json.Marshal(ccProcess) } func (p *Process) UnmarshalJSON(data []byte) error { var ccProcess struct { - Command types.FilteredString `json:"command"` - DiskInMB types.NullUint64 `json:"disk_in_mb"` - GUID string `json:"guid"` - Instances types.NullInt `json:"instances"` - MemoryInMB types.NullUint64 `json:"memory_in_mb"` - Type string `json:"type"` - Relationships Relationships `json:"relationships"` + Command types.FilteredString `json:"command"` + DiskInMB types.NullUint64 `json:"disk_in_mb"` + GUID string `json:"guid"` + Instances types.NullInt `json:"instances"` + MemoryInMB types.NullUint64 `json:"memory_in_mb"` + LogRateLimitInBPS types.NullInt `json:"log_rate_limit_in_bytes_per_second"` + Type string `json:"type"` + Relationships Relationships `json:"relationships"` HealthCheck struct { Type constant.HealthCheckType `json:"type"` @@ -54,6 +62,15 @@ func (p *Process) UnmarshalJSON(data []byte) error { Timeout int64 `json:"timeout"` } `json:"data"` } `json:"health_check"` + + ReadinessHealthCheck struct { + Type constant.HealthCheckType `json:"type"` + Data struct { + Endpoint string `json:"endpoint"` + InvocationTimeout int64 `json:"invocation_timeout"` + Interval int64 `json:"interval"` + } `json:"data"` + } `json:"readiness_health_check"` } err := cloudcontroller.DecodeJSON(data, &ccProcess) @@ -68,8 +85,13 @@ func (p *Process) UnmarshalJSON(data []byte) error { p.HealthCheckInvocationTimeout = ccProcess.HealthCheck.Data.InvocationTimeout p.HealthCheckTimeout = ccProcess.HealthCheck.Data.Timeout p.HealthCheckType = ccProcess.HealthCheck.Type + p.ReadinessHealthCheckEndpoint = ccProcess.ReadinessHealthCheck.Data.Endpoint + p.ReadinessHealthCheckType = ccProcess.ReadinessHealthCheck.Type + p.ReadinessHealthCheckInvocationTimeout = ccProcess.ReadinessHealthCheck.Data.InvocationTimeout + p.ReadinessHealthCheckInterval = ccProcess.ReadinessHealthCheck.Data.Interval p.Instances = ccProcess.Instances p.MemoryInMB = ccProcess.MemoryInMB + p.LogRateLimitInBPS = ccProcess.LogRateLimitInBPS p.Type = ccProcess.Type p.AppGUID = ccProcess.Relationships[constant.RelationshipTypeApplication].GUID @@ -85,13 +107,24 @@ type healthCheck struct { } `json:"data"` } -type marshalProcess struct { - Command interface{} `json:"command,omitempty"` - Instances json.Number `json:"instances,omitempty"` - MemoryInMB json.Number `json:"memory_in_mb,omitempty"` - DiskInMB json.Number `json:"disk_in_mb,omitempty"` +type readinessHealthCheck struct { + Type constant.HealthCheckType `json:"type,omitempty"` + Data struct { + Endpoint interface{} `json:"endpoint,omitempty"` + InvocationTimeout int64 `json:"invocation_timeout,omitempty"` + Interval int64 `json:"interval,omitempty"` + } `json:"data"` +} - HealthCheck *healthCheck `json:"health_check,omitempty"` +type marshalProcess struct { + Command interface{} `json:"command,omitempty"` + Instances json.Number `json:"instances,omitempty"` + MemoryInMB json.Number `json:"memory_in_mb,omitempty"` + DiskInMB json.Number `json:"disk_in_mb,omitempty"` + LogRateLimitInBPS json.Number `json:"log_rate_limit_in_bytes_per_second,omitempty"` + + HealthCheck *healthCheck `json:"health_check,omitempty"` + ReadinessHealthCheck *readinessHealthCheck `json:"readiness_health_check,omitempty"` } func marshalCommand(p Process, ccProcess *marshalProcess) { @@ -118,6 +151,18 @@ func marshalHealthCheck(p Process, ccProcess *marshalProcess) { } } +func marshalReadinessHealthCheck(p Process, ccProcess *marshalProcess) { + if p.ReadinessHealthCheckType != "" || p.ReadinessHealthCheckEndpoint != "" || p.ReadinessHealthCheckInvocationTimeout != 0 { + ccProcess.ReadinessHealthCheck = new(readinessHealthCheck) + ccProcess.ReadinessHealthCheck.Type = p.ReadinessHealthCheckType + ccProcess.ReadinessHealthCheck.Data.InvocationTimeout = p.ReadinessHealthCheckInvocationTimeout + ccProcess.ReadinessHealthCheck.Data.Interval = p.ReadinessHealthCheckInterval + if p.ReadinessHealthCheckEndpoint != "" { + ccProcess.ReadinessHealthCheck.Data.Endpoint = p.ReadinessHealthCheckEndpoint + } + } +} + func marshalInstances(p Process, ccProcess *marshalProcess) { if p.Instances.IsSet { ccProcess.Instances = json.Number(fmt.Sprint(p.Instances.Value)) @@ -129,3 +174,9 @@ func marshalMemory(p Process, ccProcess *marshalProcess) { ccProcess.MemoryInMB = json.Number(fmt.Sprint(p.MemoryInMB.Value)) } } + +func marshalLogRateLimit(p Process, ccProcess *marshalProcess) { + if p.LogRateLimitInBPS.IsSet { + ccProcess.LogRateLimitInBPS = json.Number(fmt.Sprint(p.LogRateLimitInBPS.Value)) + } +} diff --git a/resources/process_resource_test.go b/resources/process_resource_test.go index 394e8f1a61e..c275cb93cca 100644 --- a/resources/process_resource_test.go +++ b/resources/process_resource_test.go @@ -3,10 +3,10 @@ package resources_test import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" ) @@ -64,6 +64,18 @@ var _ = Describe("Process", func() { }) }) + When("log rate limit is provided", func() { + BeforeEach(func() { + process = resources.Process{ + LogRateLimitInBPS: types.NullInt{Value: 1024, IsSet: true}, + } + }) + + It("sets the log rate limit to be set", func() { + Expect(string(processBytes)).To(MatchJSON(`{"log_rate_limit_in_bytes_per_second": 1024}`)) + }) + }) + When("health check type http is provided", func() { BeforeEach(func() { process = resources.Process{ @@ -101,6 +113,43 @@ var _ = Describe("Process", func() { }) }) + When("readiness health check type http is provided", func() { + BeforeEach(func() { + process = resources.Process{ + ReadinessHealthCheckType: constant.HTTP, + ReadinessHealthCheckEndpoint: "some-endpoint", + } + }) + + It("sets the readiness health check type to http and has an endpoint", func() { + Expect(string(processBytes)).To(MatchJSON(`{"readiness_health_check":{"type":"http", "data": {"endpoint": "some-endpoint"}}}`)) + }) + }) + + When("readiness health check type port is provided", func() { + BeforeEach(func() { + process = resources.Process{ + ReadinessHealthCheckType: constant.Port, + } + }) + + It("sets the readiness health check type to port", func() { + Expect(string(processBytes)).To(MatchJSON(`{"readiness_health_check":{"type":"port", "data": {}}}`)) + }) + }) + + When("readiness health check type process is provided", func() { + BeforeEach(func() { + process = resources.Process{ + ReadinessHealthCheckType: constant.Process, + } + }) + + It("sets the readiness health check type to process", func() { + Expect(string(processBytes)).To(MatchJSON(`{"readiness_health_check":{"type":"process", "data": {}}}`)) + }) + }) + When("process has no fields provided", func() { BeforeEach(func() { process = resources.Process{} @@ -126,6 +175,17 @@ var _ = Describe("Process", func() { err = json.Unmarshal(processBytes, &process) Expect(err).ToNot(HaveOccurred()) }) + When("log rate limit is provided", func() { + BeforeEach(func() { + processBytes = []byte(`{"log_rate_limit_in_bytes_per_second": 512}`) + }) + + It("sets the log rate limit", func() { + Expect(process).To(MatchFields(IgnoreExtras, Fields{ + "LogRateLimitInBPS": Equal(types.NullInt{Value: 512, IsSet: true}), + })) + }) + }) When("health check type http is provided", func() { BeforeEach(func() { processBytes = []byte(`{"health_check":{"type":"http", "data": {"endpoint": "some-endpoint"}}}`) @@ -162,5 +222,42 @@ var _ = Describe("Process", func() { })) }) }) + + When("readiness health check type http is provided", func() { + BeforeEach(func() { + processBytes = []byte(`{"readiness_health_check":{"type":"http", "data": {"endpoint": "some-endpoint"}}}`) + }) + + It("sets the readiness health check type to http and has an endpoint", func() { + Expect(process).To(MatchFields(IgnoreExtras, Fields{ + "ReadinessHealthCheckType": Equal(constant.HTTP), + "ReadinessHealthCheckEndpoint": Equal("some-endpoint"), + })) + }) + }) + + When("readiness health check type port is provided", func() { + BeforeEach(func() { + processBytes = []byte(`{"readiness_health_check":{"type":"port", "data": {"endpoint": null}}}`) + }) + + It("sets the readiness health check type to port", func() { + Expect(process).To(MatchFields(IgnoreExtras, Fields{ + "ReadinessHealthCheckType": Equal(constant.Port), + })) + }) + }) + + When("readiness health check type process is provided", func() { + BeforeEach(func() { + processBytes = []byte(`{"readiness_health_check":{"type":"process", "data": {"endpoint": null}}}`) + }) + + It("sets the readiness health check type to process", func() { + Expect(process).To(MatchFields(IgnoreExtras, Fields{ + "ReadinessHealthCheckType": Equal(constant.Process), + })) + }) + }) }) }) diff --git a/resources/quota_resource.go b/resources/quota_resource.go index f78ec80699b..35ddc6e3f9b 100644 --- a/resources/quota_resource.go +++ b/resources/quota_resource.go @@ -3,7 +3,7 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) type Quota struct { @@ -23,6 +23,7 @@ type AppLimit struct { TotalMemory *types.NullInt `json:"total_memory_in_mb,omitempty"` InstanceMemory *types.NullInt `json:"per_process_memory_in_mb,omitempty"` TotalAppInstances *types.NullInt `json:"total_instances,omitempty"` + TotalLogVolume *types.NullInt `json:"log_rate_limit_in_bytes_per_second,omitempty"` } func (al *AppLimit) UnmarshalJSON(rawJSON []byte) error { @@ -57,6 +58,13 @@ func (al *AppLimit) UnmarshalJSON(rawJSON []byte) error { } } + if al.TotalLogVolume == nil { + al.TotalLogVolume = &types.NullInt{ + IsSet: false, + Value: 0, + } + } + return nil } diff --git a/resources/quota_resource_test.go b/resources/quota_resource_test.go index fb5e96ed80b..f7576d11861 100644 --- a/resources/quota_resource_test.go +++ b/resources/quota_resource_test.go @@ -3,9 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,6 +19,9 @@ var _ = Describe("quota limits", func() { Entry("total memory", AppLimit{TotalMemory: &types.NullInt{IsSet: true, Value: 1}}, []byte(`{"total_memory_in_mb":1}`)), Entry("total memory", AppLimit{TotalMemory: nil}, []byte(`{}`)), Entry("total memory", AppLimit{TotalMemory: &types.NullInt{IsSet: false}}, []byte(`{"total_memory_in_mb":null}`)), + Entry("total log volume", AppLimit{TotalLogVolume: &types.NullInt{IsSet: true, Value: 1}}, []byte(`{"log_rate_limit_in_bytes_per_second":1}`)), + Entry("total log volume", AppLimit{TotalLogVolume: nil}, []byte(`{}`)), + Entry("total log volume", AppLimit{TotalLogVolume: &types.NullInt{IsSet: false}}, []byte(`{"log_rate_limit_in_bytes_per_second":null}`)), Entry("instance memory", AppLimit{InstanceMemory: &types.NullInt{IsSet: true, Value: 1}}, []byte(`{"per_process_memory_in_mb":1}`)), Entry("instance memory", AppLimit{InstanceMemory: nil}, []byte(`{}`)), Entry("instance memory", AppLimit{InstanceMemory: &types.NullInt{IsSet: false}}, []byte(`{"per_process_memory_in_mb":null}`)), @@ -37,35 +39,48 @@ var _ = Describe("quota limits", func() { }, Entry( "no null values", - []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":2,"total_instances":3}`), + []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":2,"total_instances":3,"log_rate_limit_in_bytes_per_second":4}`), AppLimit{ TotalMemory: &types.NullInt{IsSet: true, Value: 1}, InstanceMemory: &types.NullInt{IsSet: true, Value: 2}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 3}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 4}, }), Entry( "total memory is null", - []byte(`{"total_memory_in_mb":null,"per_process_memory_in_mb":2,"total_instances":3}`), + []byte(`{"total_memory_in_mb":null,"per_process_memory_in_mb":2,"total_instances":3,"log_rate_limit_in_bytes_per_second":4}`), AppLimit{ TotalMemory: &types.NullInt{IsSet: false, Value: 0}, InstanceMemory: &types.NullInt{IsSet: true, Value: 2}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 3}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 4}, }), Entry( "per process memory is null", - []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":null,"total_instances":3}`), + []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":null,"total_instances":3,"log_rate_limit_in_bytes_per_second":4}`), AppLimit{ TotalMemory: &types.NullInt{IsSet: true, Value: 1}, InstanceMemory: &types.NullInt{IsSet: false, Value: 0}, TotalAppInstances: &types.NullInt{IsSet: true, Value: 3}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 4}, }), Entry( "total instances is null", - []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":2,"total_instances":null}`), + []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":2,"total_instances":null,"log_rate_limit_in_bytes_per_second":4}`), AppLimit{ TotalMemory: &types.NullInt{IsSet: true, Value: 1}, InstanceMemory: &types.NullInt{IsSet: true, Value: 2}, TotalAppInstances: &types.NullInt{IsSet: false, Value: 0}, + TotalLogVolume: &types.NullInt{IsSet: true, Value: 4}, + }), + Entry( + "total log volume is null", + []byte(`{"total_memory_in_mb":1,"per_process_memory_in_mb":2,"total_instances":3,"log_rate_limit_in_bytes_per_second":null}`), + AppLimit{ + TotalMemory: &types.NullInt{IsSet: true, Value: 1}, + InstanceMemory: &types.NullInt{IsSet: true, Value: 2}, + TotalAppInstances: &types.NullInt{IsSet: true, Value: 3}, + TotalLogVolume: &types.NullInt{IsSet: false, Value: 0}, }), ) }) diff --git a/resources/relationship_resource.go b/resources/relationship_resource.go index 322fe2a2b4a..6bb5704271a 100644 --- a/resources/relationship_resource.go +++ b/resources/relationship_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Relationships represent associations between resources. Relationships is a diff --git a/resources/resources_suite_test.go b/resources/resources_suite_test.go index 3b4f1a6335a..dd8d7c3e7dd 100644 --- a/resources/resources_suite_test.go +++ b/resources/resources_suite_test.go @@ -3,7 +3,7 @@ package resources_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/revision_resource.go b/resources/revision_resource.go index 39d577a26ef..e187c951f01 100644 --- a/resources/revision_resource.go +++ b/resources/revision_resource.go @@ -1,11 +1,13 @@ package resources type Revision struct { - GUID string `json:"guid"` - Version int `json:"version"` - Deployable bool `json:"deployable"` - Description string `json:"description"` - Droplet Droplet `json:"droplet"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` + GUID string `json:"guid"` + Version int `json:"version"` + Deployable bool `json:"deployable"` + Description string `json:"description"` + Droplet Droplet `json:"droplet"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + Links APILinks `json:"links"` + Metadata *Metadata `json:"metadata,omitempty"` } diff --git a/resources/role_resource.go b/resources/role_resource.go index 48963678a61..70bd6899fbb 100644 --- a/resources/role_resource.go +++ b/resources/role_resource.go @@ -3,8 +3,8 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/api/cloudcontroller" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // IncludedUsers represent a set of users included on an API response. diff --git a/resources/route_binding.go b/resources/route_binding.go index cb71b99a025..5f73948db0d 100644 --- a/resources/route_binding.go +++ b/resources/route_binding.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" ) diff --git a/resources/route_binding_test.go b/resources/route_binding_test.go index 2979101eb4b..52178510f64 100644 --- a/resources/route_binding_test.go +++ b/resources/route_binding_test.go @@ -3,9 +3,9 @@ package resources import ( "encoding/json" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/types" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/route_resource.go b/resources/route_resource.go index 5bf31b49b25..c4790d8b39b 100644 --- a/resources/route_resource.go +++ b/resources/route_resource.go @@ -2,8 +2,9 @@ package resources import ( "encoding/json" + "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller" ) type RouteDestinationApp struct { @@ -31,6 +32,7 @@ type Route struct { URL string Destinations []RouteDestination Metadata *Metadata + Options map[string]*string } func (r Route) MarshalJSON() ([]byte, error) { @@ -49,12 +51,13 @@ func (r Route) MarshalJSON() ([]byte, error) { // Building up the request body in ccRoute type ccRoute struct { - GUID string `json:"guid,omitempty"` - Host string `json:"host,omitempty"` - Path string `json:"path,omitempty"` - Protocol string `json:"protocol,omitempty"` - Port int `json:"port,omitempty"` - Relationships *Relationships `json:"relationships,omitempty"` + GUID string `json:"guid,omitempty"` + Host string `json:"host,omitempty"` + Path string `json:"path,omitempty"` + Protocol string `json:"protocol,omitempty"` + Port int `json:"port,omitempty"` + Relationships *Relationships `json:"relationships,omitempty"` + Options map[string]*string `json:"options,omitempty"` } ccR := ccRoute{ @@ -63,6 +66,7 @@ func (r Route) MarshalJSON() ([]byte, error) { Path: r.Path, Protocol: r.Protocol, Port: r.Port, + Options: r.Options, } if r.SpaceGUID != "" { @@ -85,6 +89,7 @@ func (r *Route) UnmarshalJSON(data []byte) error { URL string `json:"url,omitempty"` Destinations []RouteDestination `json:"destinations,omitempty"` Metadata *Metadata `json:"metadata,omitempty"` + Options map[string]*string `json:"options,omitempty"` Relationships struct { Space struct { @@ -115,6 +120,19 @@ func (r *Route) UnmarshalJSON(data []byte) error { r.URL = alias.URL r.Destinations = alias.Destinations r.Metadata = alias.Metadata + r.Options = alias.Options return nil } + +func (r *Route) FormattedOptions() string { + var routeOpts = []string{} + formattedOptions := "" + if r.Options != nil && len(r.Options) > 0 { + for optKey, optVal := range r.Options { + routeOpts = append(routeOpts, optKey+"="+*optVal) + } + formattedOptions = " {" + strings.Join(routeOpts, ", ") + "}" + } + return formattedOptions +} diff --git a/resources/security_group_resource_test.go b/resources/security_group_resource_test.go index 5370d473923..2008a05247b 100644 --- a/resources/security_group_resource_test.go +++ b/resources/security_group_resource_test.go @@ -3,9 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_broker_resource_test.go b/resources/service_broker_resource_test.go index c89ffda1426..6079a8d0960 100644 --- a/resources/service_broker_resource_test.go +++ b/resources/service_broker_resource_test.go @@ -3,10 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_credential_binding_resource.go b/resources/service_credential_binding_resource.go index 0cd9bb988d5..c7378698c53 100644 --- a/resources/service_credential_binding_resource.go +++ b/resources/service_credential_binding_resource.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" ) @@ -12,6 +12,13 @@ const ( KeyBinding ServiceCredentialBindingType = "key" ) +type BindingStrategyType string + +const ( + SingleBindingStrategy BindingStrategyType = "single" + MultipleBindingStrategy BindingStrategyType = "multiple" +) + type ServiceCredentialBinding struct { // Type is either "app" or "key" Type ServiceCredentialBindingType `jsonry:"type,omitempty"` @@ -31,6 +38,10 @@ type ServiceCredentialBinding struct { LastOperation LastOperation `jsonry:"last_operation"` // Parameters can be specified when creating a binding Parameters types.OptionalObject `jsonry:"parameters"` + // Strategy can be "single" or "multiple" (if empty, "single" is set as default by backend) + Strategy BindingStrategyType `jsonry:"strategy,omitempty"` + // CreatedAt timestamp when the binding was created (useful for distinguishing multiple bindings) + CreatedAt string `json:"created_at,omitempty"` } func (s ServiceCredentialBinding) MarshalJSON() ([]byte, error) { diff --git a/resources/service_credential_binding_resource_test.go b/resources/service_credential_binding_resource_test.go index f73c02079ae..ccb4beeb4c2 100644 --- a/resources/service_credential_binding_resource_test.go +++ b/resources/service_credential_binding_resource_test.go @@ -3,10 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -61,6 +60,16 @@ var _ = Describe("service credential binding resource", func() { } }`, ), + Entry("created_at", ServiceCredentialBinding{CreatedAt: "fake-created-at"}, `{"created_at": "fake-created-at"}`), + Entry( + "strategy", + ServiceCredentialBinding{ + Strategy: SingleBindingStrategy, + }, + `{ + "strategy": "single" + }`, + ), Entry( "everything", ServiceCredentialBinding{ @@ -72,6 +81,8 @@ var _ = Describe("service credential binding resource", func() { Parameters: types.NewOptionalObject(map[string]interface{}{ "foo": "bar", }), + Strategy: MultipleBindingStrategy, + CreatedAt: "fake-created-at", }, `{ "type": "app", @@ -91,7 +102,9 @@ var _ = Describe("service credential binding resource", func() { }, "parameters": { "foo": "bar" - } + }, + "strategy": "multiple", + "created_at": "fake-created-at" }`, ), ) diff --git a/resources/service_instance_resource.go b/resources/service_instance_resource.go index 3259c3e1cfd..b57a31ffcac 100644 --- a/resources/service_instance_resource.go +++ b/resources/service_instance_resource.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" ) diff --git a/resources/service_instance_resource_test.go b/resources/service_instance_resource_test.go index 66e0e217168..52f1cbbc455 100644 --- a/resources/service_instance_resource_test.go +++ b/resources/service_instance_resource_test.go @@ -3,11 +3,10 @@ package resources_test import ( "encoding/json" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_instance_usage_summary_resource.go b/resources/service_instance_usage_summary_resource.go index 45be72edf13..20a5e147a76 100644 --- a/resources/service_instance_usage_summary_resource.go +++ b/resources/service_instance_usage_summary_resource.go @@ -13,7 +13,7 @@ func (s *ServiceInstanceUsageSummaryList) UnmarshalJSON(data []byte) error { } type ServiceInstanceUsageSummary struct { - SpaceGUID string `jsonry:"space.guid""` + SpaceGUID string `jsonry:"space.guid"` BoundAppCount int `jsonry:"bound_app_count"` } diff --git a/resources/service_instance_usage_summary_resource_test.go b/resources/service_instance_usage_summary_resource_test.go index d411c89b408..e441471eb02 100644 --- a/resources/service_instance_usage_summary_resource_test.go +++ b/resources/service_instance_usage_summary_resource_test.go @@ -3,9 +3,8 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_offering_resource.go b/resources/service_offering_resource.go index dbdc8da59a8..8a26192f9d8 100644 --- a/resources/service_offering_resource.go +++ b/resources/service_offering_resource.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" ) diff --git a/resources/service_offering_resource_test.go b/resources/service_offering_resource_test.go index 5ed65584d03..088f3b8bd6a 100644 --- a/resources/service_offering_resource_test.go +++ b/resources/service_offering_resource_test.go @@ -3,10 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_plan_resource_test.go b/resources/service_plan_resource_test.go index 27df2e3b14a..6306b932095 100644 --- a/resources/service_plan_resource_test.go +++ b/resources/service_plan_resource_test.go @@ -3,10 +3,9 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/service_plan_visibility_resource_test.go b/resources/service_plan_visibility_resource_test.go index 51c08820751..882c360911b 100644 --- a/resources/service_plan_visibility_resource_test.go +++ b/resources/service_plan_visibility_resource_test.go @@ -3,9 +3,8 @@ package resources_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/shared_to_spaces_resource_test.go b/resources/shared_to_spaces_resource_test.go index 5fc486a931d..128b9fb645f 100644 --- a/resources/shared_to_spaces_resource_test.go +++ b/resources/shared_to_spaces_resource_test.go @@ -1,12 +1,11 @@ package resources_test import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" "encoding/json" - . "code.cloudfoundry.org/cli/resources" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" + . "code.cloudfoundry.org/cli/v8/resources" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/resources/sidecar_resource.go b/resources/sidecar_resource.go index fc3c53fcea1..415207e8d0c 100644 --- a/resources/sidecar_resource.go +++ b/resources/sidecar_resource.go @@ -1,6 +1,6 @@ package resources -import "code.cloudfoundry.org/cli/types" +import "code.cloudfoundry.org/cli/v8/types" type Sidecar struct { GUID string `json:"guid"` diff --git a/resources/space_quota_resource.go b/resources/space_quota_resource.go index 0fc2a110227..f1e6742eef5 100644 --- a/resources/space_quota_resource.go +++ b/resources/space_quota_resource.go @@ -23,6 +23,9 @@ func (sq SpaceQuota) MarshalJSON() ([]byte, error) { if sq.Apps.TotalAppInstances != nil { appLimits["total_instances"] = sq.Apps.TotalAppInstances } + if sq.Apps.TotalLogVolume != nil { + appLimits["log_rate_limit_in_bytes_per_second"] = sq.Apps.TotalLogVolume + } serviceLimits := map[string]interface{}{} if sq.Services.PaidServicePlans != nil { diff --git a/resources/task_resource.go b/resources/task_resource.go index 4bc1f96f012..9797bab9511 100644 --- a/resources/task_resource.go +++ b/resources/task_resource.go @@ -1,7 +1,7 @@ package resources import ( - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) // Task represents a Cloud Controller V3 Task. @@ -15,6 +15,8 @@ type Task struct { DiskInMB uint64 `json:"disk_in_mb,omitempty"` // GUID represents the unique task identifier. GUID string `json:"guid,omitempty"` + // LogRateLimitInBPS represents the log rate limit in bytes allocated for the task. + LogRateLimitInBPS int `json:"log_rate_limit_in_bytes_per_second,omitempty"` // MemoryInMB represents the memory in MB allocated for the task. MemoryInMB uint64 `json:"memory_in_mb,omitempty"` // Name represents the name of the task. @@ -30,6 +32,9 @@ type Task struct { // Using a pointer so that it can be set to nil to prevent // json serialization when no template is used Template *TaskTemplate `json:"template,omitempty"` + + // Result contains the task result + Result *TaskResult `json:"result,omitempty"` } type TaskTemplate struct { @@ -39,3 +44,7 @@ type TaskTemplate struct { type TaskProcessTemplate struct { Guid string `json:"guid,omitempty"` } + +type TaskResult struct { + FailureReason string `json:"failure_reason,omitempty"` +} diff --git a/scripts/fly-execute-windows-integration.sh b/scripts/fly-execute-windows-integration.sh index a31ca2a625e..88727c17842 100755 --- a/scripts/fly-execute-windows-integration.sh +++ b/scripts/fly-execute-windows-integration.sh @@ -15,7 +15,7 @@ CERT_DIR=cf-credentials/cert_dir source ~/workspace/cli-private/set_int_test_foundation.sh $ENV -cd $GOPATH/src/code.cloudfoundry.org/cli +cd $GOPATH/src/code.cloudfoundry.org/cli/v8 echo "Making windows..." make out/cf-cli_winx64.exe diff --git a/tools/tools.go b/tools/tools.go index 1316cf0af2a..e6fa2b8f2e5 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools package tools diff --git a/types/filtered_interface_test.go b/types/filtered_interface_test.go index bf10aaf8515..77367b42405 100644 --- a/types/filtered_interface_test.go +++ b/types/filtered_interface_test.go @@ -1,8 +1,8 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/filtered_string_test.go b/types/filtered_string_test.go index bad9d09fa9c..07ca30a2b64 100644 --- a/types/filtered_string_test.go +++ b/types/filtered_string_test.go @@ -1,9 +1,9 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/types" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/json_object_test.go b/types/json_object_test.go index 5291979e293..5d2a507ad47 100644 --- a/types/json_object_test.go +++ b/types/json_object_test.go @@ -3,8 +3,8 @@ package types_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/null_bool_test.go b/types/null_bool_test.go index 03e63ff77bf..adb4218f525 100644 --- a/types/null_bool_test.go +++ b/types/null_bool_test.go @@ -1,9 +1,8 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/null_bytesize_in_mb_test.go b/types/null_bytesize_in_mb_test.go index 1bb4c20f205..0554471da51 100644 --- a/types/null_bytesize_in_mb_test.go +++ b/types/null_bytesize_in_mb_test.go @@ -1,8 +1,8 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/null_float64.go b/types/null_float64.go new file mode 100644 index 00000000000..992b51811b0 --- /dev/null +++ b/types/null_float64.go @@ -0,0 +1,81 @@ +package types + +import ( + "fmt" + "strconv" + + "github.com/jessevdk/go-flags" +) + +// NullFloat64 is a wrapper around float64 values that can be null or a +// float64. Use IsSet to check if the value is provided, instead of checking +// against 0. +type NullFloat64 struct { + IsSet bool + Value float64 +} + +// ParseStringValue is used to parse a user provided flag argument. +func (n *NullFloat64) ParseStringValue(val string) error { + if val == "" { + n.IsSet = false + n.Value = 0 + return nil + } + + // float64Val, err := strconv.Atoi(val) + float64Val, err := strconv.ParseFloat(val, 64) + if err != nil { + n.IsSet = false + n.Value = 0 + return &flags.Error{ + Type: flags.ErrMarshal, + Message: fmt.Sprintf("invalid float64 value `%s`", val), + } + } + + n.Value = float64Val + n.IsSet = true + + return nil +} + +// IsValidValue returns an error if the input value is not a float64. +func (n *NullFloat64) IsValidValue(val string) error { + return n.ParseStringValue(val) +} + +// ParseFloat64Value is used to parse a user provided *float64 argument. +func (n *NullFloat64) ParseFloat64Value(val *float64) { + if val == nil { + n.IsSet = false + n.Value = 0 + return + } + + n.Value = *val + n.IsSet = true +} + +func (n *NullFloat64) UnmarshalFlag(val string) error { + return n.ParseStringValue(val) +} + +func (n *NullFloat64) UnmarshalJSON(rawJSON []byte) error { + stringValue := string(rawJSON) + + if stringValue == JsonNull { + n.Value = 0 + n.IsSet = false + return nil + } + + return n.ParseStringValue(stringValue) +} + +func (n NullFloat64) MarshalJSON() ([]byte, error) { + if n.IsSet { + return []byte(fmt.Sprint(n.Value)), nil + } + return []byte(JsonNull), nil +} diff --git a/types/null_float64_test.go b/types/null_float64_test.go new file mode 100644 index 00000000000..11248b0bcee --- /dev/null +++ b/types/null_float64_test.go @@ -0,0 +1,145 @@ +package types_test + +import ( + . "code.cloudfoundry.org/cli/v8/types" + "github.com/jessevdk/go-flags" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("NullFloat64", func() { + var nullFloat64 NullFloat64 + + BeforeEach(func() { + nullFloat64 = NullFloat64{ + IsSet: true, + Value: 0xBAD, + } + }) + + Describe("IsValidValue", func() { + var ( + input string + executeErr error + ) + + JustBeforeEach(func() { + executeErr = nullFloat64.IsValidValue(input) + }) + + When("the value is a positive float", func() { + BeforeEach(func() { + input = "1.01" + }) + + It("does not error", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) + + When("the value is a negative float", func() { + BeforeEach(func() { + input = "-21.94" + }) + + It("does not error", func() { + Expect(executeErr).ToNot(HaveOccurred()) + }) + }) + + When("the value is a non float", func() { + BeforeEach(func() { + input = "not-a-integer" + }) + + It("returns an error", func() { + Expect(executeErr).To(MatchError("invalid float64 value `not-a-integer`")) + }) + }) + }) + + Describe("ParseFloat64Value", func() { + When("nil is provided", func() { + It("sets IsSet to false", func() { + nullFloat64.ParseFloat64Value(nil) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: false})) + }) + }) + + When("non-nil pointer is provided", func() { + It("sets IsSet to true and Value to provided value", func() { + n := 5.04 + nullFloat64.ParseFloat64Value(&n) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 5.04, IsSet: true})) + }) + }) + }) + + Describe("ParseStringValue", func() { + When("the empty string is provided", func() { + It("sets IsSet to false", func() { + err := nullFloat64.ParseStringValue("") + Expect(err).ToNot(HaveOccurred()) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: false})) + }) + }) + + When("an invalid float64 is provided", func() { + It("returns an error", func() { + err := nullFloat64.ParseStringValue("abcdef") + Expect(err).To(MatchError(&flags.Error{ + Type: flags.ErrMarshal, + Message: "invalid float64 value `abcdef`", + })) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: false})) + }) + }) + + When("a valid float64 is provided", func() { + It("stores the integer and sets IsSet to true", func() { + err := nullFloat64.ParseStringValue("0") + Expect(err).ToNot(HaveOccurred()) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: true})) + }) + }) + }) + + Describe("UnmarshalJSON", func() { + When("float64 value is provided", func() { + It("parses JSON number correctly", func() { + err := nullFloat64.UnmarshalJSON([]byte("42.333333")) + Expect(err).ToNot(HaveOccurred()) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 42.333333, IsSet: true})) + }) + }) + + When("a null value is provided", func() { + It("returns an unset NullFloat64", func() { + err := nullFloat64.UnmarshalJSON([]byte("null")) + Expect(err).ToNot(HaveOccurred()) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: false})) + }) + }) + + When("an empty string is provided", func() { + It("returns an unset NullFloat64", func() { + err := nullFloat64.UnmarshalJSON([]byte("")) + Expect(err).ToNot(HaveOccurred()) + Expect(nullFloat64).To(Equal(NullFloat64{Value: 0, IsSet: false})) + }) + }) + }) + + DescribeTable("MarshalJSON", + func(nullFloat64 NullFloat64, expectedBytes []byte) { + bytes, err := nullFloat64.MarshalJSON() + Expect(err).ToNot(HaveOccurred()) + Expect(bytes).To(Equal(expectedBytes)) + }, + Entry("negative number", NullFloat64{IsSet: true, Value: -1.5}, []byte("-1.5")), + Entry("positive number", NullFloat64{IsSet: true, Value: 1.8}, []byte("1.8")), + Entry("0", NullFloat64{IsSet: true, Value: 0.0}, []byte("0")), + Entry("no value", NullFloat64{IsSet: false}, []byte("null")), + ) +}) diff --git a/types/null_int_test.go b/types/null_int_test.go index c24bda0f666..76097bae1fb 100644 --- a/types/null_int_test.go +++ b/types/null_int_test.go @@ -1,10 +1,10 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" + . "code.cloudfoundry.org/cli/v8/types" "github.com/jessevdk/go-flags" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/null_string_test.go b/types/null_string_test.go index 816397cce32..f1aa312e4ec 100644 --- a/types/null_string_test.go +++ b/types/null_string_test.go @@ -3,8 +3,8 @@ package types_test import ( "encoding/json" - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/null_uint64.go b/types/null_uint64.go index 276c26906a5..91ee2734b00 100644 --- a/types/null_uint64.go +++ b/types/null_uint64.go @@ -1,6 +1,7 @@ package types import ( + "fmt" "strconv" ) @@ -43,3 +44,10 @@ func (n *NullUint64) UnmarshalJSON(rawJSON []byte) error { return n.ParseStringValue(stringValue) } + +func (n *NullUint64) MarshalJSON() ([]byte, error) { + if n.IsSet { + return []byte(fmt.Sprint(n.Value)), nil + } + return []byte(JsonNull), nil +} diff --git a/types/null_uint64_test.go b/types/null_uint64_test.go index 329d282200a..54dfa37a7ff 100644 --- a/types/null_uint64_test.go +++ b/types/null_uint64_test.go @@ -1,8 +1,8 @@ package types_test import ( - . "code.cloudfoundry.org/cli/types" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/optional_boolean_test.go b/types/optional_boolean_test.go index 146c5a33764..4eaec5080ad 100644 --- a/types/optional_boolean_test.go +++ b/types/optional_boolean_test.go @@ -1,10 +1,9 @@ package types_test import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/optional_object_test.go b/types/optional_object_test.go index 9dab7eb5144..9338430d745 100644 --- a/types/optional_object_test.go +++ b/types/optional_object_test.go @@ -1,9 +1,9 @@ package types_test import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/optional_string_slice_test.go b/types/optional_string_slice_test.go index e2eb6baf6ca..932d966fdff 100644 --- a/types/optional_string_slice_test.go +++ b/types/optional_string_slice_test.go @@ -1,9 +1,9 @@ package types_test import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/optional_string_test.go b/types/optional_string_test.go index 7c84ed661dd..a0408ef83d7 100644 --- a/types/optional_string_test.go +++ b/types/optional_string_test.go @@ -1,9 +1,9 @@ package types_test import ( - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" "code.cloudfoundry.org/jsonry" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/types/types_suite_test.go b/types/types_suite_test.go index b026169c12b..5cd5acbcb2a 100644 --- a/types/types_suite_test.go +++ b/types/types_suite_test.go @@ -1,7 +1,7 @@ package types_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/batcher/batcher.go b/util/batcher/batcher.go index ad5ad47e8d3..561e2c6539a 100644 --- a/util/batcher/batcher.go +++ b/util/batcher/batcher.go @@ -1,6 +1,6 @@ package batcher -import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" const BatchSize = 200 diff --git a/util/batcher/batcher_suite_test.go b/util/batcher/batcher_suite_test.go index 1f0a5c4e9fb..b3ac7ff6ac8 100644 --- a/util/batcher/batcher_suite_test.go +++ b/util/batcher/batcher_suite_test.go @@ -3,7 +3,7 @@ package batcher_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/batcher/batcher_test.go b/util/batcher/batcher_test.go index 28e635b3298..575b5da54a1 100644 --- a/util/batcher/batcher_test.go +++ b/util/batcher/batcher_test.go @@ -3,11 +3,11 @@ package batcher_test import ( "fmt" - "code.cloudfoundry.org/cli/cf/errors" + "code.cloudfoundry.org/cli/v8/cf/errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/util/batcher" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/util/batcher" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -52,7 +52,8 @@ var _ = Describe("Batcher", func() { }) It("calls the callback", func() { - batcher.RequestByGUID([]string{"one", "two", "three"}, fakeCallback) + _, err := batcher.RequestByGUID([]string{"one", "two", "three"}, fakeCallback) + Expect(err).NotTo(HaveOccurred()) Expect(calls).To(HaveLen(1)) Expect(calls[0]).To(Equal([]string{"one", "two", "three"})) @@ -60,7 +61,8 @@ var _ = Describe("Batcher", func() { When("the guids list exceeds the batch size", func() { It("calls the callback multiple times", func() { - batcher.RequestByGUID(spreadGuids(0, 520), fakeCallback) + _, err := batcher.RequestByGUID(spreadGuids(0, 520), fakeCallback) + Expect(err).NotTo(HaveOccurred()) Expect(calls).To(HaveLen(3)) Expect(calls[0]).To(Equal(spreadGuids(0, 200))) diff --git a/util/checksum_test.go b/util/checksum_test.go index bcd4b712820..68ff3bb62fd 100644 --- a/util/checksum_test.go +++ b/util/checksum_test.go @@ -2,12 +2,11 @@ package util_test import ( "fmt" - "io/ioutil" "os" - . "code.cloudfoundry.org/cli/util" + . "code.cloudfoundry.org/cli/v8/util" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -35,7 +34,7 @@ var _ = Describe("Sha1Checksum", func() { ) BeforeEach(func() { - f, err = ioutil.TempFile("", "sha1_test_") + f, err = os.CreateTemp("", "sha1_test_") Expect(err).NotTo(HaveOccurred()) defer f.Close() _, err = f.Write([]byte("abc")) @@ -79,7 +78,7 @@ var _ = Describe("Sha1Checksum", func() { ) BeforeEach(func() { - f, err = ioutil.TempFile("", "sha1_test_") + f, err = os.CreateTemp("", "sha1_test_") Expect(err).NotTo(HaveOccurred()) defer f.Close() _, err = f.Write([]byte("abc")) diff --git a/util/clissh/clisshfakes/fake_listener_factory.go b/util/clissh/clisshfakes/fake_listener_factory.go index dbd41adab16..b6730a87ce2 100644 --- a/util/clissh/clisshfakes/fake_listener_factory.go +++ b/util/clissh/clisshfakes/fake_listener_factory.go @@ -5,7 +5,7 @@ import ( "net" "sync" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/util/clissh" ) type FakeListenerFactory struct { @@ -34,15 +34,16 @@ func (fake *FakeListenerFactory) Listen(arg1 string, arg2 string) (net.Listener, arg1 string arg2 string }{arg1, arg2}) + stub := fake.ListenStub + fakeReturns := fake.listenReturns fake.recordInvocation("Listen", []interface{}{arg1, arg2}) fake.listenMutex.Unlock() - if fake.ListenStub != nil { - return fake.ListenStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.listenReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/util/clissh/clisshfakes/fake_secure_client.go b/util/clissh/clisshfakes/fake_secure_client.go index f4643d96839..adff99966ec 100644 --- a/util/clissh/clisshfakes/fake_secure_client.go +++ b/util/clissh/clisshfakes/fake_secure_client.go @@ -5,7 +5,7 @@ import ( "net" "sync" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/util/clissh" "golang.org/x/crypto/ssh" ) @@ -75,15 +75,16 @@ func (fake *FakeSecureClient) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -127,15 +128,16 @@ func (fake *FakeSecureClient) Conn() ssh.Conn { ret, specificReturn := fake.connReturnsOnCall[len(fake.connArgsForCall)] fake.connArgsForCall = append(fake.connArgsForCall, struct { }{}) + stub := fake.ConnStub + fakeReturns := fake.connReturns fake.recordInvocation("Conn", []interface{}{}) fake.connMutex.Unlock() - if fake.ConnStub != nil { - return fake.ConnStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.connReturns return fakeReturns.result1 } @@ -181,15 +183,16 @@ func (fake *FakeSecureClient) Dial(arg1 string, arg2 string) (net.Conn, error) { arg1 string arg2 string }{arg1, arg2}) + stub := fake.DialStub + fakeReturns := fake.dialReturns fake.recordInvocation("Dial", []interface{}{arg1, arg2}) fake.dialMutex.Unlock() - if fake.DialStub != nil { - return fake.DialStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.dialReturns return fakeReturns.result1, fakeReturns.result2 } @@ -243,15 +246,16 @@ func (fake *FakeSecureClient) NewSession() (clissh.SecureSession, error) { ret, specificReturn := fake.newSessionReturnsOnCall[len(fake.newSessionArgsForCall)] fake.newSessionArgsForCall = append(fake.newSessionArgsForCall, struct { }{}) + stub := fake.NewSessionStub + fakeReturns := fake.newSessionReturns fake.recordInvocation("NewSession", []interface{}{}) fake.newSessionMutex.Unlock() - if fake.NewSessionStub != nil { - return fake.NewSessionStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.newSessionReturns return fakeReturns.result1, fakeReturns.result2 } @@ -298,15 +302,16 @@ func (fake *FakeSecureClient) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/util/clissh/clisshfakes/fake_secure_dialer.go b/util/clissh/clisshfakes/fake_secure_dialer.go index 18d537a5448..6d020738564 100644 --- a/util/clissh/clisshfakes/fake_secure_dialer.go +++ b/util/clissh/clisshfakes/fake_secure_dialer.go @@ -4,7 +4,7 @@ package clisshfakes import ( "sync" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/util/clissh" "golang.org/x/crypto/ssh" ) @@ -36,15 +36,16 @@ func (fake *FakeSecureDialer) Dial(arg1 string, arg2 string, arg3 *ssh.ClientCon arg2 string arg3 *ssh.ClientConfig }{arg1, arg2, arg3}) + stub := fake.DialStub + fakeReturns := fake.dialReturns fake.recordInvocation("Dial", []interface{}{arg1, arg2, arg3}) fake.dialMutex.Unlock() - if fake.DialStub != nil { - return fake.DialStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.dialReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/util/clissh/clisshfakes/fake_secure_session.go b/util/clissh/clisshfakes/fake_secure_session.go index 9c9f57c01b7..c4cf5cb42c3 100644 --- a/util/clissh/clisshfakes/fake_secure_session.go +++ b/util/clissh/clisshfakes/fake_secure_session.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/util/clissh" + "code.cloudfoundry.org/cli/v8/util/clissh" "golang.org/x/crypto/ssh" ) @@ -125,15 +125,16 @@ func (fake *FakeSecureSession) Close() error { ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] fake.closeArgsForCall = append(fake.closeArgsForCall, struct { }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns fake.recordInvocation("Close", []interface{}{}) fake.closeMutex.Unlock() - if fake.CloseStub != nil { - return fake.CloseStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.closeReturns return fakeReturns.result1 } @@ -181,15 +182,16 @@ func (fake *FakeSecureSession) RequestPty(arg1 string, arg2 int, arg3 int, arg4 arg3 int arg4 ssh.TerminalModes }{arg1, arg2, arg3, arg4}) + stub := fake.RequestPtyStub + fakeReturns := fake.requestPtyReturns fake.recordInvocation("RequestPty", []interface{}{arg1, arg2, arg3, arg4}) fake.requestPtyMutex.Unlock() - if fake.RequestPtyStub != nil { - return fake.RequestPtyStub(arg1, arg2, arg3, arg4) + if stub != nil { + return stub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - fakeReturns := fake.requestPtyReturns return fakeReturns.result1 } @@ -248,15 +250,16 @@ func (fake *FakeSecureSession) SendRequest(arg1 string, arg2 bool, arg3 []byte) arg2 bool arg3 []byte }{arg1, arg2, arg3Copy}) + stub := fake.SendRequestStub + fakeReturns := fake.sendRequestReturns fake.recordInvocation("SendRequest", []interface{}{arg1, arg2, arg3Copy}) fake.sendRequestMutex.Unlock() - if fake.SendRequestStub != nil { - return fake.SendRequestStub(arg1, arg2, arg3) + if stub != nil { + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.sendRequestReturns return fakeReturns.result1, fakeReturns.result2 } @@ -310,15 +313,16 @@ func (fake *FakeSecureSession) Shell() error { ret, specificReturn := fake.shellReturnsOnCall[len(fake.shellArgsForCall)] fake.shellArgsForCall = append(fake.shellArgsForCall, struct { }{}) + stub := fake.ShellStub + fakeReturns := fake.shellReturns fake.recordInvocation("Shell", []interface{}{}) fake.shellMutex.Unlock() - if fake.ShellStub != nil { - return fake.ShellStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.shellReturns return fakeReturns.result1 } @@ -363,15 +367,16 @@ func (fake *FakeSecureSession) Start(arg1 string) error { fake.startArgsForCall = append(fake.startArgsForCall, struct { arg1 string }{arg1}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{arg1}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } @@ -422,15 +427,16 @@ func (fake *FakeSecureSession) StderrPipe() (io.Reader, error) { ret, specificReturn := fake.stderrPipeReturnsOnCall[len(fake.stderrPipeArgsForCall)] fake.stderrPipeArgsForCall = append(fake.stderrPipeArgsForCall, struct { }{}) + stub := fake.StderrPipeStub + fakeReturns := fake.stderrPipeReturns fake.recordInvocation("StderrPipe", []interface{}{}) fake.stderrPipeMutex.Unlock() - if fake.StderrPipeStub != nil { - return fake.StderrPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stderrPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -477,15 +483,16 @@ func (fake *FakeSecureSession) StdinPipe() (io.WriteCloser, error) { ret, specificReturn := fake.stdinPipeReturnsOnCall[len(fake.stdinPipeArgsForCall)] fake.stdinPipeArgsForCall = append(fake.stdinPipeArgsForCall, struct { }{}) + stub := fake.StdinPipeStub + fakeReturns := fake.stdinPipeReturns fake.recordInvocation("StdinPipe", []interface{}{}) fake.stdinPipeMutex.Unlock() - if fake.StdinPipeStub != nil { - return fake.StdinPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stdinPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -532,15 +539,16 @@ func (fake *FakeSecureSession) StdoutPipe() (io.Reader, error) { ret, specificReturn := fake.stdoutPipeReturnsOnCall[len(fake.stdoutPipeArgsForCall)] fake.stdoutPipeArgsForCall = append(fake.stdoutPipeArgsForCall, struct { }{}) + stub := fake.StdoutPipeStub + fakeReturns := fake.stdoutPipeReturns fake.recordInvocation("StdoutPipe", []interface{}{}) fake.stdoutPipeMutex.Unlock() - if fake.StdoutPipeStub != nil { - return fake.StdoutPipeStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.stdoutPipeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -587,15 +595,16 @@ func (fake *FakeSecureSession) Wait() error { ret, specificReturn := fake.waitReturnsOnCall[len(fake.waitArgsForCall)] fake.waitArgsForCall = append(fake.waitArgsForCall, struct { }{}) + stub := fake.WaitStub + fakeReturns := fake.waitReturns fake.recordInvocation("Wait", []interface{}{}) fake.waitMutex.Unlock() - if fake.WaitStub != nil { - return fake.WaitStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.waitReturns return fakeReturns.result1 } diff --git a/util/clissh/clisshfakes/fake_terminal_helper.go b/util/clissh/clisshfakes/fake_terminal_helper.go index 941fd8e1d1a..4cc33ae1769 100644 --- a/util/clissh/clisshfakes/fake_terminal_helper.go +++ b/util/clissh/clisshfakes/fake_terminal_helper.go @@ -5,8 +5,8 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/util/clissh" - "github.com/moby/moby/pkg/term" + "code.cloudfoundry.org/cli/v8/util/clissh" + "github.com/moby/term" ) type FakeTerminalHelper struct { @@ -85,15 +85,16 @@ func (fake *FakeTerminalHelper) GetFdInfo(arg1 interface{}) (uintptr, bool) { fake.getFdInfoArgsForCall = append(fake.getFdInfoArgsForCall, struct { arg1 interface{} }{arg1}) + stub := fake.GetFdInfoStub + fakeReturns := fake.getFdInfoReturns fake.recordInvocation("GetFdInfo", []interface{}{arg1}) fake.getFdInfoMutex.Unlock() - if fake.GetFdInfoStub != nil { - return fake.GetFdInfoStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getFdInfoReturns return fakeReturns.result1, fakeReturns.result2 } @@ -148,15 +149,16 @@ func (fake *FakeTerminalHelper) GetWinsize(arg1 uintptr) (*term.Winsize, error) fake.getWinsizeArgsForCall = append(fake.getWinsizeArgsForCall, struct { arg1 uintptr }{arg1}) + stub := fake.GetWinsizeStub + fakeReturns := fake.getWinsizeReturns fake.recordInvocation("GetWinsize", []interface{}{arg1}) fake.getWinsizeMutex.Unlock() - if fake.GetWinsizeStub != nil { - return fake.GetWinsizeStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getWinsizeReturns return fakeReturns.result1, fakeReturns.result2 } @@ -212,15 +214,16 @@ func (fake *FakeTerminalHelper) RestoreTerminal(arg1 uintptr, arg2 *term.State) arg1 uintptr arg2 *term.State }{arg1, arg2}) + stub := fake.RestoreTerminalStub + fakeReturns := fake.restoreTerminalReturns fake.recordInvocation("RestoreTerminal", []interface{}{arg1, arg2}) fake.restoreTerminalMutex.Unlock() - if fake.RestoreTerminalStub != nil { - return fake.RestoreTerminalStub(arg1, arg2) + if stub != nil { + return stub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.restoreTerminalReturns return fakeReturns.result1 } @@ -272,15 +275,16 @@ func (fake *FakeTerminalHelper) SetRawTerminal(arg1 uintptr) (*term.State, error fake.setRawTerminalArgsForCall = append(fake.setRawTerminalArgsForCall, struct { arg1 uintptr }{arg1}) + stub := fake.SetRawTerminalStub + fakeReturns := fake.setRawTerminalReturns fake.recordInvocation("SetRawTerminal", []interface{}{arg1}) fake.setRawTerminalMutex.Unlock() - if fake.SetRawTerminalStub != nil { - return fake.SetRawTerminalStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.setRawTerminalReturns return fakeReturns.result1, fakeReturns.result2 } @@ -334,15 +338,16 @@ func (fake *FakeTerminalHelper) StdStreams() (io.ReadCloser, io.Writer, io.Write ret, specificReturn := fake.stdStreamsReturnsOnCall[len(fake.stdStreamsArgsForCall)] fake.stdStreamsArgsForCall = append(fake.stdStreamsArgsForCall, struct { }{}) + stub := fake.StdStreamsStub + fakeReturns := fake.stdStreamsReturns fake.recordInvocation("StdStreams", []interface{}{}) fake.stdStreamsMutex.Unlock() - if fake.StdStreamsStub != nil { - return fake.StdStreamsStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } - fakeReturns := fake.stdStreamsReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } diff --git a/util/clissh/sigwinch/sigwinch.go b/util/clissh/sigwinch/sigwinch.go index ace01f9a2a2..6eab1ee5e72 100644 --- a/util/clissh/sigwinch/sigwinch.go +++ b/util/clissh/sigwinch/sigwinch.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package sigwinch diff --git a/util/clissh/sigwinch/sigwinch_win.go b/util/clissh/sigwinch/sigwinch_win.go index eac5f1ec141..045da2d6721 100644 --- a/util/clissh/sigwinch/sigwinch_win.go +++ b/util/clissh/sigwinch/sigwinch_win.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package sigwinch diff --git a/util/clissh/ssh.go b/util/clissh/ssh.go index 43fd4f1ef2a..3fa807edfa4 100644 --- a/util/clissh/ssh.go +++ b/util/clissh/ssh.go @@ -5,6 +5,7 @@ import ( "crypto/sha1" "crypto/sha256" "encoding/base64" + "encoding/hex" "errors" "fmt" "io" @@ -17,9 +18,9 @@ import ( "syscall" "time" - "code.cloudfoundry.org/cli/cf/ssh/sigwinch" - "code.cloudfoundry.org/cli/util/clissh/ssherror" - "github.com/moby/moby/pkg/term" + "code.cloudfoundry.org/cli/v8/cf/ssh/sigwinch" + "code.cloudfoundry.org/cli/v8/util/clissh/ssherror" + "github.com/moby/term" log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" ) @@ -28,6 +29,7 @@ const ( md5FingerprintLength = 47 // inclusive of space between bytes hexSha1FingerprintLength = 59 // inclusive of space between bytes base64Sha256FingerprintLength = 43 + sha256FingerprintLength = 64 DefaultKeepAliveInterval = 30 * time.Second ) @@ -264,6 +266,7 @@ func (c *SecureShell) localForwardAcceptLoop(listener net.Listener, addr string) for { conn, err := listener.Accept() if err != nil { + //nolint:staticcheck if netErr, ok := err.(net.Error); ok && netErr.Temporary() { time.Sleep(100 * time.Millisecond) continue @@ -330,9 +333,12 @@ func (c *SecureShell) terminalType() string { return term } -func base64Sha256Fingerprint(key ssh.PublicKey) string { +func sha256Fingerprint(key ssh.PublicKey, encode bool) string { sum := sha256.Sum256(key.Marshal()) - return base64.RawStdEncoding.EncodeToString(sum[:]) + if encode { + return base64.RawStdEncoding.EncodeToString(sum[:]) + } + return hex.EncodeToString(sum[:]) } func copyAndClose(wg *sync.WaitGroup, dest io.WriteCloser, src io.Reader) { @@ -363,8 +369,10 @@ func fingerprintCallback(skipHostValidation bool, expectedFingerprint string) ss var fingerprint string switch len(expectedFingerprint) { + case sha256FingerprintLength: + fingerprint = sha256Fingerprint(key, false) case base64Sha256FingerprintLength: - fingerprint = base64Sha256Fingerprint(key) + fingerprint = sha256Fingerprint(key, true) case hexSha1FingerprintLength: fingerprint = hexSha1Fingerprint(key) case md5FingerprintLength: diff --git a/util/clissh/ssh_suite_test.go b/util/clissh/ssh_suite_test.go index 0adf40c9b9d..1276d6b36af 100644 --- a/util/clissh/ssh_suite_test.go +++ b/util/clissh/ssh_suite_test.go @@ -1,16 +1,15 @@ package clissh_test import ( - "io/ioutil" + "os" "path/filepath" + "testing" "time" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" - - "testing" ) var ( @@ -26,12 +25,12 @@ func TestCmd(t *testing.T) { var _ = BeforeSuite(func() { SetDefaultEventuallyTimeout(3 * time.Second) - hostKeyBytes, err := ioutil.ReadFile(filepath.Join("..", "..", "fixtures", "host-key")) + hostKeyBytes, err := os.ReadFile(filepath.Join("..", "..", "fixtures", "host-key")) Expect(err).NotTo(HaveOccurred()) hostKey, err := ssh.ParsePrivateKey(hostKeyBytes) Expect(err).NotTo(HaveOccurred()) - privateKeyBytes, err := ioutil.ReadFile(filepath.Join("..", "..", "fixtures", "private-key")) + privateKeyBytes, err := os.ReadFile(filepath.Join("..", "..", "fixtures", "private-key")) Expect(err).NotTo(HaveOccurred()) privateKey, err := ssh.ParsePrivateKey(privateKeyBytes) Expect(err).NotTo(HaveOccurred()) diff --git a/util/clissh/ssh_test.go b/util/clissh/ssh_test.go index 7bd48c47dc0..79b64498ea7 100644 --- a/util/clissh/ssh_test.go +++ b/util/clissh/ssh_test.go @@ -1,3 +1,4 @@ +//go:build !windows && !386 // +build !windows,!386 // skipping 386 because lager uses UInt64 in Session() @@ -16,19 +17,19 @@ import ( "syscall" "time" - . "code.cloudfoundry.org/cli/util/clissh" - "code.cloudfoundry.org/cli/util/clissh/clisshfakes" - "code.cloudfoundry.org/cli/util/clissh/ssherror" + . "code.cloudfoundry.org/cli/v8/util/clissh" + "code.cloudfoundry.org/cli/v8/util/clissh/clisshfakes" + "code.cloudfoundry.org/cli/v8/util/clissh/ssherror" "code.cloudfoundry.org/diego-ssh/server" fake_server "code.cloudfoundry.org/diego-ssh/server/fakes" "code.cloudfoundry.org/diego-ssh/test_helpers" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_io" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_net" "code.cloudfoundry.org/diego-ssh/test_helpers/fake_ssh" - "code.cloudfoundry.org/lager/lagertest" - "github.com/kr/pty" - "github.com/moby/moby/pkg/term" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/lager/v3/lagertest" + "github.com/creack/pty" + "github.com/moby/term" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "golang.org/x/crypto/ssh" ) @@ -49,7 +50,7 @@ func BlockAcceptOnClose(fake *fake_net.FakeListener) { } } -var _ = Describe("CLI SSH", func() { +var _ = Describe("CLI SSH", Serial, FlakeAttempts(9), func() { var ( fakeSecureDialer *clisshfakes.FakeSecureDialer fakeSecureClient *clisshfakes.FakeSecureClient @@ -124,7 +125,7 @@ var _ = Describe("CLI SSH", func() { ) }) - Describe("Connect", func() { + Describe("Connect", Serial, func() { var connectErr error JustBeforeEach(func() { @@ -174,7 +175,7 @@ var _ = Describe("CLI SSH", func() { }) }) - Describe("InteractiveSession", func() { + Describe("InteractiveSession", Serial, func() { var ( stdin *fake_io.FakeReadCloser stdout, stderr *fake_io.FakeWriter @@ -252,6 +253,28 @@ var _ = Describe("CLI SSH", func() { }) }) + Context("when the sha256 fingerprint matches", func() { + BeforeEach(func() { + sshEndpointFingerprint = "b29fe3acbba3ebaafecab2c350a65d254e6d773b789aafd469288d063a60afef" + }) + + It("does not return an error", func() { + Expect(callback("", addr, TestHostKey.PublicKey())).ToNot(HaveOccurred()) + }) + }) + + When("the SHA256 fingerprint does not match", func() { + BeforeEach(func() { + sshEndpointFingerprint = "0000000000000000000000000000000000000000000000000000000000000000" + }) + + It("returns an error'", func() { + err := callback("", addr, TestHostKey.PublicKey()) + Expect(err).To(MatchError(MatchRegexp(`Host key verification failed\.`))) + Expect(err).To(MatchError(MatchRegexp("The fingerprint of the received key was \".*\""))) + }) + }) + When("the base64 SHA256 fingerprint does not match", func() { BeforeEach(func() { sshEndpointFingerprint = "0000000000000000000000000000000000000000000" @@ -477,7 +500,7 @@ var _ = Describe("CLI SSH", func() { Expect(fakeSecureSession.ShellCallCount()).To(Equal(1)) }) - It("does not not restore the terminal", func() { + It("does not restore the terminal", func() { Expect(fakeSecureSession.ShellCallCount()).To(Equal(1)) Expect(fakeTerminalHelper.SetRawTerminalCallCount()).To(Equal(1)) Expect(fakeTerminalHelper.RestoreTerminalCallCount()).To(Equal(0)) @@ -577,7 +600,7 @@ var _ = Describe("CLI SSH", func() { }) }) - When("a command is specifed", func() { + When("a command is specified", func() { BeforeEach(func() { commands = []string{"echo", "-n", "hello"} }) @@ -819,7 +842,7 @@ var _ = Describe("CLI SSH", func() { }) }) - Describe("LocalPortForward", func() { + Describe("LocalPortForward", Serial, func() { var ( forwardErr error @@ -864,7 +887,7 @@ var _ = Describe("CLI SSH", func() { fakeLocalListener = new(fake_net.FakeListener) fakeLocalListener.AcceptReturns(nil, errors.New("Not Accepting Connections")) - echoServer = server.NewServer(logger.Session("echo"), "", echoHandler) + echoServer = server.NewServer(logger.Session("echo"), "", echoHandler, 500*time.Millisecond) err = echoServer.SetListener(echoListener) Expect(err).NotTo(HaveOccurred()) go echoServer.Serve() @@ -1148,7 +1171,7 @@ var _ = Describe("CLI SSH", func() { }) }) - Describe("Wait", func() { + Describe("Wait", Serial, func() { var waitErr error JustBeforeEach(func() { @@ -1202,7 +1225,7 @@ var _ = Describe("CLI SSH", func() { }) }) - Describe("Close", func() { + Describe("Close", Serial, func() { JustBeforeEach(func() { connectErr := secureShell.Connect(username, passcode, sshEndpoint, sshEndpointFingerprint, skipHostValidation) Expect(connectErr).NotTo(HaveOccurred()) diff --git a/util/clissh/terminal_helper.go b/util/clissh/terminal_helper.go index 092fe4915c8..88f72474144 100644 --- a/util/clissh/terminal_helper.go +++ b/util/clissh/terminal_helper.go @@ -3,7 +3,7 @@ package clissh import ( "io" - "github.com/moby/moby/pkg/term" + "github.com/moby/term" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . TerminalHelper diff --git a/util/command_parser/command_parser.go b/util/command_parser/command_parser.go index c8e31f3a0ec..75ab630e73a 100644 --- a/util/command_parser/command_parser.go +++ b/util/command_parser/command_parser.go @@ -7,13 +7,13 @@ import ( "reflect" "strings" - "code.cloudfoundry.org/cli/cf/cmd" - "code.cloudfoundry.org/cli/command" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/command/flag" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" + "code.cloudfoundry.org/cli/v8/cf/cmd" + "code.cloudfoundry.org/cli/v8/command" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/command/flag" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" "github.com/jessevdk/go-flags" log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" @@ -43,13 +43,8 @@ type CommandParser struct { UI *ui.UI } -func NewCommandParser() (CommandParser, error) { - cfConfig, err := configv3.GetCFConfig() - if err != nil { - return CommandParser{}, err - } - - return CommandParser{Config: cfConfig}, nil +func NewCommandParser(config *configv3.Config) (CommandParser, error) { + return CommandParser{Config: config}, nil } func (p *CommandParser) ParseCommandFromArgs(ui *ui.UI, args []string) (int, error) { @@ -232,7 +227,7 @@ func (p *CommandParser) parse(args []string, commandList interface{}) (int, erro return 1, nil } else if err == ParseErr { fmt.Println() - p.parse([]string{"help", args[0]}, commandList) //nolint: errcheck + p.parse([]string{"help", args[0]}, commandList) // nolint: errcheck return 1, err } else if exitError, ok := err.(*ssh.ExitError); ok { return exitError.ExitStatus(), nil diff --git a/util/command_parser/command_parser_test.go b/util/command_parser/command_parser_test.go index ecc44f4f8f1..ea30a0cf654 100644 --- a/util/command_parser/command_parser_test.go +++ b/util/command_parser/command_parser_test.go @@ -1,25 +1,25 @@ package command_parser_test import ( - "io/ioutil" + "io" - "code.cloudfoundry.org/cli/command/commandfakes" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/util/command_parser" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/util/command_parser" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Command 'Parser'", func() { var ( pluginUI *ui.UI + v3Config *configv3.Config ) BeforeEach(func() { var err error - fakeConfig := new(commandfakes.FakeConfig) - pluginUI, err = ui.NewPluginUI(fakeConfig, ioutil.Discard, ioutil.Discard) + v3Config = new(configv3.Config) + pluginUI, err = ui.NewPluginUI(v3Config, io.Discard, io.Discard) Expect(err).ToNot(HaveOccurred()) }) @@ -30,7 +30,7 @@ var _ = Describe("Command 'Parser'", func() { ) BeforeEach(func() { - parser, newErr := command_parser.NewCommandParser() + parser, newErr := command_parser.NewCommandParser(v3Config) Expect(newErr).ToNot(HaveOccurred()) exitCode, err = parser.ParseCommandFromArgs(pluginUI, []string{"howdy"}) }) @@ -52,7 +52,7 @@ var _ = Describe("Command 'Parser'", func() { common.Commands.VerboseOrVersion = false var err error - parser, err = command_parser.NewCommandParser() + parser, err = command_parser.NewCommandParser(v3Config) Expect(err).ToNot(HaveOccurred()) }) diff --git a/util/command_parser/parser_suite_test.go b/util/command_parser/parser_suite_test.go index 73090e428ea..1e796cb6cfb 100644 --- a/util/command_parser/parser_suite_test.go +++ b/util/command_parser/parser_suite_test.go @@ -1,7 +1,7 @@ package command_parser_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" diff --git a/util/command_parser/prevent_extra_args_v7.go b/util/command_parser/prevent_extra_args_v7.go index 1f1800dd2d1..b1ca94816b8 100644 --- a/util/command_parser/prevent_extra_args_v7.go +++ b/util/command_parser/prevent_extra_args_v7.go @@ -3,7 +3,7 @@ package command_parser import ( "strings" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) func preventExtraArgs(args []string) error { diff --git a/util/command_parser/unknown_command_error.go b/util/command_parser/unknown_command_error.go index 72374f060e3..26e28812240 100644 --- a/util/command_parser/unknown_command_error.go +++ b/util/command_parser/unknown_command_error.go @@ -4,8 +4,8 @@ import ( "fmt" "reflect" - "code.cloudfoundry.org/cli/cf/util/spellcheck" - "code.cloudfoundry.org/cli/command/common" + "code.cloudfoundry.org/cli/v8/cf/util/spellcheck" + "code.cloudfoundry.org/cli/v8/command/common" ) type UnknownCommandError struct { diff --git a/util/configv3/color.go b/util/configv3/color.go index 50301cc8a81..51cfa5655a8 100644 --- a/util/configv3/color.go +++ b/util/configv3/color.go @@ -22,9 +22,9 @@ const ( type ColorSetting int // ColorEnabled returns the color setting based off: -// 1. The $CF_COLOR environment variable if set (0/1/t/f/true/false) -// 2. The 'ColorEnabled' value in the .cf/config.json if set -// 3. Defaults to ColorAuto if nothing is set +// 1. The $CF_COLOR environment variable if set (0/1/t/f/true/false) +// 2. The 'ColorEnabled' value in the .cf/config.json if set +// 3. Defaults to ColorAuto if nothing is set func (config *Config) ColorEnabled() ColorSetting { if config.ENV.CFColor != "" { val, err := strconv.ParseBool(config.ENV.CFColor) diff --git a/util/configv3/color_test.go b/util/configv3/color_test.go index 249784077e2..3c80305d8e2 100644 --- a/util/configv3/color_test.go +++ b/util/configv3/color_test.go @@ -4,9 +4,8 @@ import ( "fmt" "os" - . "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/config.go b/util/configv3/config.go index c6afb35ff5d..b25df4a14ed 100644 --- a/util/configv3/config.go +++ b/util/configv3/config.go @@ -5,7 +5,7 @@ import ( "path/filepath" "strconv" - "code.cloudfoundry.org/cli/version" + "code.cloudfoundry.org/cli/v8/version" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UserConfig diff --git a/util/configv3/config_suite_test.go b/util/configv3/config_suite_test.go index 07630b8b33d..ed141f6c4f6 100644 --- a/util/configv3/config_suite_test.go +++ b/util/configv3/config_suite_test.go @@ -1,15 +1,13 @@ package configv3_test import ( - "io/ioutil" "os" "path/filepath" + "testing" - "code.cloudfoundry.org/cli/integration/helpers" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/integration/helpers" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - - "testing" ) const ( @@ -23,7 +21,7 @@ func TestConfig(t *testing.T) { } func setup() string { - homeDir, err := ioutil.TempDir("", "cli-config-tests") + homeDir, err := os.MkdirTemp("", "cli-config-tests") Expect(err).NotTo(HaveOccurred()) err = os.Setenv("CF_HOME", homeDir) Expect(err).NotTo(HaveOccurred()) diff --git a/util/configv3/config_test.go b/util/configv3/config_test.go index b8f6e35aff2..2112ec52638 100644 --- a/util/configv3/config_test.go +++ b/util/configv3/config_test.go @@ -3,8 +3,8 @@ package configv3_test import ( "os" - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/config_unix_test.go b/util/configv3/config_unix_test.go index 9c790ee1522..3bdea010889 100644 --- a/util/configv3/config_unix_test.go +++ b/util/configv3/config_unix_test.go @@ -1,17 +1,16 @@ +//go:build !windows // +build !windows package configv3_test import ( "fmt" - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -100,13 +99,13 @@ var _ = Describe("Verbose", func() { BeforeEach(func() { var err error - tempDir, err = ioutil.TempDir("", "config-trace") + tempDir, err = os.MkdirTemp("", "config-trace") Expect(err).ToNot(HaveOccurred()) tempDirAbs, err := filepath.EvalSymlinks(tempDir) Expect(err).ToNot(HaveOccurred()) ogLogPath = filepath.Join(tempDirAbs, "og.log") - err = ioutil.WriteFile(ogLogPath, nil, 0666) + err = os.WriteFile(ogLogPath, nil, 0666) Expect(err).ToNot(HaveOccurred()) symlinkLogPath = filepath.Join(tempDirAbs, "sym.log") diff --git a/util/configv3/config_windows_test.go b/util/configv3/config_windows_test.go index 0c0a6016051..75b3874b4a7 100644 --- a/util/configv3/config_windows_test.go +++ b/util/configv3/config_windows_test.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package configv3_test @@ -7,10 +8,9 @@ import ( "os" "path/filepath" - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/configv3fakes/fake_user_config.go b/util/configv3/configv3fakes/fake_user_config.go index 72198fbd8a0..6cd582d04fe 100644 --- a/util/configv3/configv3fakes/fake_user_config.go +++ b/util/configv3/configv3fakes/fake_user_config.go @@ -4,7 +4,7 @@ package configv3fakes import ( "sync" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" ) type FakeUserConfig struct { @@ -41,15 +41,16 @@ func (fake *FakeUserConfig) CurrentUser() (configv3.User, error) { ret, specificReturn := fake.currentUserReturnsOnCall[len(fake.currentUserArgsForCall)] fake.currentUserArgsForCall = append(fake.currentUserArgsForCall, struct { }{}) + stub := fake.CurrentUserStub + fakeReturns := fake.currentUserReturns fake.recordInvocation("CurrentUser", []interface{}{}) fake.currentUserMutex.Unlock() - if fake.CurrentUserStub != nil { - return fake.CurrentUserStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserReturns return fakeReturns.result1, fakeReturns.result2 } @@ -96,15 +97,16 @@ func (fake *FakeUserConfig) CurrentUserName() (string, error) { ret, specificReturn := fake.currentUserNameReturnsOnCall[len(fake.currentUserNameArgsForCall)] fake.currentUserNameArgsForCall = append(fake.currentUserNameArgsForCall, struct { }{}) + stub := fake.CurrentUserNameStub + fakeReturns := fake.currentUserNameReturns fake.recordInvocation("CurrentUserName", []interface{}{}) fake.currentUserNameMutex.Unlock() - if fake.CurrentUserNameStub != nil { - return fake.CurrentUserNameStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.currentUserNameReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/util/configv3/default_user_config_test.go b/util/configv3/default_user_config_test.go index 350a94b6ff0..b7d13ca6fe5 100644 --- a/util/configv3/default_user_config_test.go +++ b/util/configv3/default_user_config_test.go @@ -1,8 +1,8 @@ package configv3_test import ( - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/dynamic_user_config_test.go b/util/configv3/dynamic_user_config_test.go index 907250acb10..e094a51b528 100644 --- a/util/configv3/dynamic_user_config_test.go +++ b/util/configv3/dynamic_user_config_test.go @@ -3,9 +3,9 @@ package configv3_test import ( "errors" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/configv3/configv3fakes" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3/configv3fakes" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/env.go b/util/configv3/env.go index 031be343c7d..2cf5ecb121d 100644 --- a/util/configv3/env.go +++ b/util/configv3/env.go @@ -1,9 +1,12 @@ package configv3 import ( + "encoding/json" "strconv" "strings" "time" + + "code.cloudfoundry.org/cli/v8/util/trace" ) // EnvOverride represents all the environment variables read by the CF CLI @@ -19,7 +22,9 @@ type EnvOverride struct { CFStartupTimeout string CFTrace string CFUsername string + CFB3TraceID string DockerPassword string + CNBCredentials string Experimental string ForceTTY string HTTPSProxy string @@ -43,8 +48,8 @@ func (config *Config) CFUsername() string { } // DialTimeout returns the timeout to use when dialing. This is based off of: -// 1. The $CF_DIAL_TIMEOUT environment variable if set -// 2. Falling back to the default +// 1. The $CF_DIAL_TIMEOUT environment variable if set +// 2. Falling back to the default func (config *Config) DialTimeout() time.Duration { if config.ENV.CFDialTimeout != "" { envVal, err := strconv.ParseInt(config.ENV.CFDialTimeout, 10, 64) @@ -61,10 +66,25 @@ func (config *Config) DockerPassword() string { return config.ENV.DockerPassword } +// CNBCredentials retrurns CNB credentials from the environment +func (config *Config) CNBCredentials() (map[string]interface{}, error) { + if config.ENV.CNBCredentials == "" { + return nil, nil + } + + creds := map[string]interface{}{} + + if err := json.Unmarshal([]byte(config.ENV.CNBCredentials), &creds); err != nil { + return nil, err + } + + return creds, nil +} + // Experimental returns whether or not to run experimental CLI commands. This // is based on the following: -// 1. The $CF_CLI_EXPERIMENTAL environment variable if set -// 2. Defaults to false +// 1. The $CF_CLI_EXPERIMENTAL environment variable if set +// 2. Defaults to false func (config *Config) Experimental() bool { if config.ENV.Experimental != "" { envVal, err := strconv.ParseBool(config.ENV.Experimental) @@ -78,8 +98,8 @@ func (config *Config) Experimental() bool { // HTTPSProxy returns the proxy url that the CLI should use. The url is based // off of: -// 1. The $https_proxy environment variable if set -// 2. Defaults to the empty string +// 1. The $https_proxy environment variable if set +// 2. Defaults to the empty string func (config *Config) HTTPSProxy() string { return config.ENV.HTTPSProxy } @@ -114,8 +134,8 @@ func (config *Config) LogLevel() int { // StagingTimeout returns the max time an application staging should take. The // time is based off of: -// 1. The $CF_STAGING_TIMEOUT environment variable if set -// 2. Defaults to the DefaultStagingTimeout +// 1. The $CF_STAGING_TIMEOUT environment variable if set +// 2. Defaults to the DefaultStagingTimeout func (config *Config) StagingTimeout() time.Duration { if config.ENV.CFStagingTimeout != "" { timeoutInMin, err := strconv.ParseFloat(config.ENV.CFStagingTimeout, 64) @@ -130,8 +150,8 @@ func (config *Config) StagingTimeout() time.Duration { // StartupTimeout returns the max time an application should take to start. The // time is based off of: -// 1. The $CF_STARTUP_TIMEOUT environment variable if set -// 2. Defaults to the DefaultStartupTimeout +// 1. The $CF_STARTUP_TIMEOUT environment variable if set +// 2. Defaults to the DefaultStartupTimeout func (config *Config) StartupTimeout() time.Duration { if config.ENV.CFStartupTimeout != "" { timeoutInMin, err := strconv.ParseFloat(config.ENV.CFStartupTimeout, 64) @@ -143,3 +163,10 @@ func (config *Config) StartupTimeout() time.Duration { return DefaultStartupTimeout } + +func (config *Config) B3TraceID() string { + if config.ENV.CFB3TraceID == "" { + config.ENV.CFB3TraceID = trace.GenerateUUIDTraceID() + } + return config.ENV.CFB3TraceID +} diff --git a/util/configv3/env_test.go b/util/configv3/env_test.go index aa77499d6f0..d20dced7e87 100644 --- a/util/configv3/env_test.go +++ b/util/configv3/env_test.go @@ -3,10 +3,9 @@ package configv3_test import ( "time" - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/home_dir_unix.go b/util/configv3/home_dir_unix.go index 425f34fae1a..b735d7b0797 100644 --- a/util/configv3/home_dir_unix.go +++ b/util/configv3/home_dir_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package configv3 diff --git a/util/configv3/home_dir_windows.go b/util/configv3/home_dir_windows.go index 60a5f6d3143..18b1eee6787 100644 --- a/util/configv3/home_dir_windows.go +++ b/util/configv3/home_dir_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package configv3 diff --git a/util/configv3/json_config.go b/util/configv3/json_config.go index c672de98ad9..0089bb4365d 100644 --- a/util/configv3/json_config.go +++ b/util/configv3/json_config.go @@ -92,8 +92,8 @@ func (config *Config) MinCLIVersion() string { // OverallPollingTimeout returns the overall polling timeout for async // operations. The time is based off of: -// 1. The config file's AsyncTimeout value (integer) is > 0 -// 2. Defaults to the DefaultOverallPollingTimeout +// 1. The config file's AsyncTimeout value (integer) is > 0 +// 2. Defaults to the DefaultOverallPollingTimeout func (config *Config) OverallPollingTimeout() time.Duration { if config.ConfigFile.AsyncTimeout == 0 { return DefaultOverallPollingTimeout diff --git a/util/configv3/json_config_test.go b/util/configv3/json_config_test.go index 19c16b1c420..e12ecaacc54 100644 --- a/util/configv3/json_config_test.go +++ b/util/configv3/json_config_test.go @@ -4,10 +4,9 @@ import ( "fmt" "time" - "code.cloudfoundry.org/cli/util/configv3" - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -513,7 +512,7 @@ var _ = Describe("JSONConfig", func() { }) Describe("CurrentUser", func() { - var user configv3.User + var user User JustBeforeEach(func() { user, err = config.CurrentUser() diff --git a/util/configv3/k8s_test.go b/util/configv3/k8s_test.go index 2b6dfd6b209..342dbdfc51e 100644 --- a/util/configv3/k8s_test.go +++ b/util/configv3/k8s_test.go @@ -1,10 +1,10 @@ package configv3_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" ) var _ = Describe("K8s", func() { diff --git a/util/configv3/kubernetes_user_config_test.go b/util/configv3/kubernetes_user_config_test.go index 6229df54ebd..518315e63c9 100644 --- a/util/configv3/kubernetes_user_config_test.go +++ b/util/configv3/kubernetes_user_config_test.go @@ -1,8 +1,8 @@ package configv3_test import ( - "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/configv3" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/load_config.go b/util/configv3/load_config.go index 90470e2464d..1dd39d75d7e 100644 --- a/util/configv3/load_config.go +++ b/util/configv3/load_config.go @@ -2,13 +2,14 @@ package configv3 import ( "encoding/json" - "io/ioutil" + "errors" "math" "os" "path/filepath" + "time" - "code.cloudfoundry.org/cli/command/translatableerror" - "golang.org/x/crypto/ssh/terminal" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "golang.org/x/term" ) func (c *Config) loadPluginConfig() error { @@ -19,7 +20,7 @@ func (c *Config) loadPluginConfig() error { } } else { var file []byte - file, err = ioutil.ReadFile(pluginFilePath) + file, err = os.ReadFile(pluginFilePath) if err != nil { return err } @@ -54,14 +55,14 @@ func GetCFConfig() (*Config, error) { // // The '.cf' directory will be read in one of the following locations on UNIX // Systems: -// 1. $CF_HOME/.cf if $CF_HOME is set -// 2. $HOME/.cf as the default +// 1. $CF_HOME/.cf if $CF_HOME is set +// 2. $HOME/.cf as the default // // The '.cf' directory will be read in one of the following locations on // Windows Systems: -// 1. CF_HOME\.cf if CF_HOME is set -// 2. HOMEDRIVE\HOMEPATH\.cf if HOMEDRIVE or HOMEPATH is set -// 3. USERPROFILE\.cf as the default +// 1. CF_HOME\.cf if CF_HOME is set +// 2. HOMEDRIVE\HOMEPATH\.cf if HOMEDRIVE or HOMEPATH is set +// 3. USERPROFILE\.cf as the default func LoadConfig(flags ...FlagOverride) (*Config, error) { err := removeOldTempConfigFiles() if err != nil { @@ -86,7 +87,7 @@ func LoadConfig(flags ...FlagOverride) (*Config, error) { if _, err = os.Stat(configFilePath); err == nil || !os.IsNotExist(err) { var file []byte - file, err = ioutil.ReadFile(configFilePath) + file, err = os.ReadFile(configFilePath) if err != nil { return nil, err } @@ -126,7 +127,9 @@ func LoadConfig(flags ...FlagOverride) (*Config, error) { CFStartupTimeout: os.Getenv("CF_STARTUP_TIMEOUT"), CFTrace: os.Getenv("CF_TRACE"), CFUsername: os.Getenv("CF_USERNAME"), + CFB3TraceID: os.Getenv("CF_B3_TRACE_ID"), DockerPassword: os.Getenv("CF_DOCKER_PASSWORD"), + CNBCredentials: os.Getenv("CF_CNB_REGISTRY_CREDS"), Experimental: os.Getenv("CF_CLI_EXPERIMENTAL"), ForceTTY: os.Getenv("FORCE_TTY"), HTTPSProxy: os.Getenv("https_proxy"), @@ -149,12 +152,12 @@ func LoadConfig(flags ...FlagOverride) (*Config, error) { } // Developer Note: The following is untested! Change at your own risk. - isTTY := terminal.IsTerminal(int(os.Stdout.Fd())) + isTTY := term.IsTerminal(int(os.Stdout.Fd())) terminalWidth := math.MaxInt32 if isTTY { var err error - terminalWidth, _, err = terminal.GetSize(int(os.Stdout.Fd())) + terminalWidth, _, err = term.GetSize(int(os.Stdout.Fd())) if err != nil { return nil, err } @@ -182,8 +185,20 @@ func removeOldTempConfigFiles() error { } for _, oldTempFileName := range oldTempFileNames { - err = os.Remove(oldTempFileName) + fi, err := os.Lstat(oldTempFileName) if err != nil { + // ignore if file doesn't exist anymore due to race conditions if multiple cli commands are running in parallel + if errors.Is(err, os.ErrNotExist) { + continue + } + return err + } + // only delete old orphans which are not caught by the signal handler in WriteConfig + if fi.ModTime().After(time.Now().Add(-5 * time.Minute)) { + continue + } + err = os.Remove(oldTempFileName) + if err != nil && !errors.Is(err, os.ErrNotExist) { return err } } diff --git a/util/configv3/load_config_test.go b/util/configv3/load_config_test.go index cd98d810e2d..e387b22e808 100644 --- a/util/configv3/load_config_test.go +++ b/util/configv3/load_config_test.go @@ -2,16 +2,16 @@ package configv3_test import ( "fmt" - "io/ioutil" "os" "path/filepath" + "time" - "code.cloudfoundry.org/cli/command/translatableerror" - "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" - . "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/command/translatableerror" + "code.cloudfoundry.org/cli/v8/integration/helpers" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/configv3" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -60,22 +60,48 @@ var _ = Describe("Config", func() { }) When("there are old temp-config* files lingering from previous failed attempts to write the config", func() { - BeforeEach(func() { - configDir := filepath.Join(homeDir, ".cf") - Expect(os.MkdirAll(configDir, 0777)).To(Succeed()) - for i := 0; i < 3; i++ { - tmpFile, fileErr := ioutil.TempFile(configDir, "temp-config") - Expect(fileErr).ToNot(HaveOccurred()) - tmpFile.Close() - } + Context("and the files are younger than 5 minutes", func() { + BeforeEach(func() { + configDir := filepath.Join(homeDir, ".cf") + Expect(os.MkdirAll(configDir, 0777)).To(Succeed()) + for i := 0; i < 3; i++ { + configDir := filepath.Join(homeDir, ".cf") + tmpFile, fileErr := os.CreateTemp(configDir, "temp-config") + Expect(fileErr).ToNot(HaveOccurred()) + tmpFile.Close() + } + }) + + It("keeps the files", func() { + Expect(loadErr).ToNot(HaveOccurred()) + + oldTempFileNames, configErr := filepath.Glob(filepath.Join(homeDir, ".cf", "temp-config?*")) + Expect(configErr).ToNot(HaveOccurred()) + Expect(oldTempFileNames).To(HaveLen(3)) + }) }) - It("removes the lingering temp-config* files", func() { - Expect(loadErr).ToNot(HaveOccurred()) + Context("and the files are older than 5 minutes", func() { + BeforeEach(func() { + configDir := filepath.Join(homeDir, ".cf") + Expect(os.MkdirAll(configDir, 0777)).To(Succeed()) + for i := 0; i < 3; i++ { + tmpFile, fileErr := os.CreateTemp(configDir, "temp-config") + Expect(fileErr).ToNot(HaveOccurred()) + tmpFile.Close() + oldTime := time.Now().Add(-time.Minute * 10) + err := os.Chtimes(tmpFile.Name(), oldTime, oldTime) + Expect(err).ToNot(HaveOccurred()) + } + }) - oldTempFileNames, configErr := filepath.Glob(filepath.Join(homeDir, ".cf", "temp-config?*")) - Expect(configErr).ToNot(HaveOccurred()) - Expect(oldTempFileNames).To(BeEmpty()) + It("removes the lingering temp-config* files", func() { + Expect(loadErr).ToNot(HaveOccurred()) + + oldTempFileNames, configErr := filepath.Glob(filepath.Join(homeDir, ".cf", "temp-config?*")) + Expect(configErr).ToNot(HaveOccurred()) + Expect(oldTempFileNames).To(BeEmpty()) + }) }) }) @@ -87,7 +113,7 @@ var _ = Describe("Config", func() { Expect(config.ConfigFile).To(Equal( JSONConfig{ ColorEnabled: DefaultColorEnabled, - ConfigVersion: configv3.CurrentConfigVersion, + ConfigVersion: CurrentConfigVersion, SSHOAuthClient: DefaultSSHOAuthClient, UAAOAuthClient: DefaultUAAOAuthClient, UAAOAuthClientSecret: DefaultUAAOAuthClientSecret, @@ -127,7 +153,7 @@ var _ = Describe("Config", func() { Expect(config.ConfigFile).To(Equal( JSONConfig{ ColorEnabled: DefaultColorEnabled, - ConfigVersion: configv3.CurrentConfigVersion, + ConfigVersion: CurrentConfigVersion, SSHOAuthClient: DefaultSSHOAuthClient, UAAOAuthClient: DefaultUAAOAuthClient, UAAOAuthClientSecret: DefaultUAAOAuthClientSecret, @@ -173,7 +199,7 @@ var _ = Describe("Config", func() { { "UAAOAuthClient": "", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion+1) + }`, CurrentConfigVersion+1) setConfig(homeDir, rawConfig) }) @@ -195,11 +221,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion-1) + }`, CurrentConfigVersion-1) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("")) }) }) @@ -210,11 +236,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion) + }`, CurrentConfigVersion) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("bearer shazbat!")) }) }) @@ -225,11 +251,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion+1) + }`, CurrentConfigVersion+1) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("")) }) }) diff --git a/util/configv3/locale.go b/util/configv3/locale.go index 99da3e0688f..dd5c4c47475 100644 --- a/util/configv3/locale.go +++ b/util/configv3/locale.go @@ -9,10 +9,10 @@ const ( // Locale returns the locale/language the UI should be displayed in. This value // is based off of: -// 1. The 'Locale' setting in the .cf/config.json -// 2. The $LC_ALL environment variable if set -// 3. The $LANG environment variable if set -// 4. Defaults to DefaultLocale +// 1. The 'Locale' setting in the .cf/config.json +// 2. The $LC_ALL environment variable if set +// 3. The $LANG environment variable if set +// 4. Defaults to DefaultLocale func (config *Config) Locale() string { if config.ConfigFile.Locale != "" { return config.ConfigFile.Locale diff --git a/util/configv3/locale_test.go b/util/configv3/locale_test.go index 6049d87c235..69ed4b99c85 100644 --- a/util/configv3/locale_test.go +++ b/util/configv3/locale_test.go @@ -4,10 +4,9 @@ import ( "fmt" "os" - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/plugin_repository_test.go b/util/configv3/plugin_repository_test.go index 6a8b9dc5c95..952e86d40a3 100644 --- a/util/configv3/plugin_repository_test.go +++ b/util/configv3/plugin_repository_test.go @@ -1,9 +1,9 @@ package configv3_test import ( - . "code.cloudfoundry.org/cli/util/configv3" + . "code.cloudfoundry.org/cli/v8/util/configv3" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/configv3/plugins_config.go b/util/configv3/plugins_config.go index d5776e9ba8a..7f47e477b47 100644 --- a/util/configv3/plugins_config.go +++ b/util/configv3/plugins_config.go @@ -3,13 +3,12 @@ package configv3 import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "sort" "strings" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/util" ) const notApplicable = "N/A" @@ -114,8 +113,8 @@ func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) } // PluginHome returns the plugin configuration directory to: -// 1. The $CF_PLUGIN_HOME/.cf/plugins environment variable if set -// 2. Defaults to the home directory (outlined in LoadConfig)/.cf/plugins +// 1. The $CF_PLUGIN_HOME/.cf/plugins environment variable if set +// 2. Defaults to the home directory (outlined in LoadConfig)/.cf/plugins func (config *Config) PluginHome() string { if config.ENV.CFPluginHome != "" { return filepath.Join(config.ENV.CFPluginHome, ".cf", "plugins") @@ -157,5 +156,5 @@ func (config *Config) WritePluginConfig() error { } // Write to file - return ioutil.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) + return os.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) } diff --git a/util/configv3/plugins_config_test.go b/util/configv3/plugins_config_test.go index 58e92819a29..f320db663f3 100644 --- a/util/configv3/plugins_config_test.go +++ b/util/configv3/plugins_config_test.go @@ -1,14 +1,13 @@ package configv3_test import ( - "io/ioutil" "os" "path/filepath" "syscall" - . "code.cloudfoundry.org/cli/util/configv3" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/util/configv3" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -308,7 +307,7 @@ var _ = Describe("PluginsConfig", func() { setPluginConfig(pluginsPath, rawConfig) }) - It("returns the pluging sorted by name", func() { + It("returns the plugins sorted by name", func() { config, err := LoadConfig() Expect(err).ToNot(HaveOccurred()) Expect(config.Plugins()).To(Equal([]Plugin{ @@ -397,7 +396,7 @@ var _ = Describe("PluginsConfig", func() { config = new(Config) var err error - pluginHome, err = ioutil.TempDir("", "my-plugin-home") + pluginHome, err = os.MkdirTemp("", "my-plugin-home") Expect(err).ToNot(HaveOccurred()) Expect(os.RemoveAll(pluginHome)).ToNot(HaveOccurred()) }) @@ -427,7 +426,7 @@ var _ = Describe("PluginsConfig", func() { var tempFile string BeforeEach(func() { - f, err := ioutil.TempFile("", "fail-plugin-home") + f, err := os.CreateTemp("", "fail-plugin-home") Expect(err).ToNot(HaveOccurred()) Expect(f.Close()).ToNot(HaveOccurred()) tempFile = f.Name() @@ -455,11 +454,11 @@ var _ = Describe("PluginsConfig", func() { BeforeEach(func() { var err error - file, err = ioutil.TempFile("", "") + file, err = os.CreateTemp("", "") Expect(err).NotTo(HaveOccurred()) defer file.Close() - err = ioutil.WriteFile(file.Name(), []byte("foo"), 0600) + err = os.WriteFile(file.Name(), []byte("foo"), 0600) Expect(err).NotTo(HaveOccurred()) plugin.Location = file.Name() @@ -480,7 +479,7 @@ var _ = Describe("PluginsConfig", func() { BeforeEach(func() { var err error - dirPath, err = ioutil.TempDir("", "") + dirPath, err = os.MkdirTemp("", "") Expect(err).NotTo(HaveOccurred()) plugin.Location = dirPath diff --git a/util/configv3/write_config.go b/util/configv3/write_config.go index 15f02637820..950ae9accd1 100644 --- a/util/configv3/write_config.go +++ b/util/configv3/write_config.go @@ -2,7 +2,6 @@ package configv3 import ( "encoding/json" - "io/ioutil" "os" "os/signal" "syscall" @@ -31,7 +30,7 @@ func (c *Config) WriteConfig() error { signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, os.Interrupt) defer signal.Stop(sig) - tempConfigFile, err := ioutil.TempFile(dir, "temp-config") + tempConfigFile, err := os.CreateTemp(dir, "temp-config") if err != nil { return err } @@ -40,7 +39,7 @@ func (c *Config) WriteConfig() error { go catchSignal(sig, tempConfigFileName) - err = ioutil.WriteFile(tempConfigFileName, rawConfig, 0600) + err = os.WriteFile(tempConfigFileName, rawConfig, 0600) if err != nil { return err } diff --git a/util/configv3/write_config_test.go b/util/configv3/write_config_test.go index 2e1bf574a6f..89536ded551 100644 --- a/util/configv3/write_config_test.go +++ b/util/configv3/write_config_test.go @@ -2,15 +2,15 @@ package configv3_test import ( "encoding/json" - "io/ioutil" + "os" "path/filepath" "sort" "strings" - "code.cloudfoundry.org/cli/util/configv3" + "code.cloudfoundry.org/cli/v8/util/configv3" "gopkg.in/yaml.v2" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -45,7 +45,7 @@ var _ = Describe("Config", func() { err := config.WriteConfig() Expect(err).ToNot(HaveOccurred()) - file, err = ioutil.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) + file, err = os.ReadFile(filepath.Join(homeDir, ".cf", "config.json")) Expect(err).ToNot(HaveOccurred()) }) diff --git a/util/download/download_suite_test.go b/util/download/download_suite_test.go index 329010ea23a..ea48ecc88b1 100644 --- a/util/download/download_suite_test.go +++ b/util/download/download_suite_test.go @@ -3,7 +3,7 @@ package download_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/download/downloader.go b/util/download/downloader.go index 36560464b4b..9d5679696f6 100644 --- a/util/download/downloader.go +++ b/util/download/downloader.go @@ -2,14 +2,13 @@ package download import ( "io" - "io/ioutil" "net" "net/http" "os" "path/filepath" "time" - "code.cloudfoundry.org/cli/util" + "code.cloudfoundry.org/cli/v8/util" ) type Downloader struct { @@ -43,7 +42,7 @@ func (downloader Downloader) Download(url string, tmpDirPath string) (string, er defer resp.Body.Close() if resp.StatusCode >= 400 { - rawBytes, readErr := ioutil.ReadAll(resp.Body) + rawBytes, readErr := io.ReadAll(resp.Body) if readErr != nil { return bpFileName, readErr } diff --git a/util/download/downloader_test.go b/util/download/downloader_test.go index cc5b4f56581..439c2c09bfd 100644 --- a/util/download/downloader_test.go +++ b/util/download/downloader_test.go @@ -2,16 +2,16 @@ package download_test import ( "errors" - "io/ioutil" + "io" "net/http" "os" "strings" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "code.cloudfoundry.org/cli/util/download" - "code.cloudfoundry.org/cli/util/download/downloadfakes" + . "code.cloudfoundry.org/cli/v8/util/download" + "code.cloudfoundry.org/cli/v8/util/download/downloadfakes" ) var _ = Describe("Downloader", func() { @@ -39,7 +39,7 @@ var _ = Describe("Downloader", func() { url = "https://some.url" var err error - tmpDirPath, err = ioutil.TempDir("", "bpdir-") + tmpDirPath, err = os.MkdirTemp("", "bpdir-") Expect(err).ToNot(HaveOccurred()) }) @@ -57,7 +57,7 @@ var _ = Describe("Downloader", func() { BeforeEach(func() { responseBody = "some response body" response := &http.Response{ - Body: ioutil.NopCloser(strings.NewReader(responseBody)), + Body: io.NopCloser(strings.NewReader(responseBody)), ContentLength: int64(len(responseBody)), StatusCode: http.StatusOK, } @@ -67,7 +67,7 @@ var _ = Describe("Downloader", func() { It("returns correct path to the downloaded file", func() { Expect(executeErr).ToNot(HaveOccurred()) - raw, err := ioutil.ReadFile(file) + raw, err := os.ReadFile(file) Expect(err).ToNot(HaveOccurred()) Expect(string(raw)).To(Equal(responseBody)) }) @@ -96,7 +96,7 @@ var _ = Describe("Downloader", func() { BeforeEach(func() { responseBody = "not found" response := &http.Response{ - Body: ioutil.NopCloser(strings.NewReader(responseBody)), + Body: io.NopCloser(strings.NewReader(responseBody)), StatusCode: http.StatusNotFound, Status: "404 Not Found", } diff --git a/util/download/downloadfakes/fake_httpclient.go b/util/download/downloadfakes/fake_httpclient.go index 1d37dec2fd4..9dcab50b963 100644 --- a/util/download/downloadfakes/fake_httpclient.go +++ b/util/download/downloadfakes/fake_httpclient.go @@ -5,7 +5,7 @@ import ( "net/http" "sync" - "code.cloudfoundry.org/cli/util/download" + "code.cloudfoundry.org/cli/v8/util/download" ) type FakeHTTPClient struct { @@ -32,15 +32,16 @@ func (fake *FakeHTTPClient) Get(arg1 string) (*http.Response, error) { fake.getArgsForCall = append(fake.getArgsForCall, struct { arg1 string }{arg1}) + stub := fake.GetStub + fakeReturns := fake.getReturns fake.recordInvocation("Get", []interface{}{arg1}) fake.getMutex.Unlock() - if fake.GetStub != nil { - return fake.GetStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1, ret.result2 } - fakeReturns := fake.getReturns return fakeReturns.result1, fakeReturns.result2 } diff --git a/util/download/downloadfakes/fake_progress_bar.go b/util/download/downloadfakes/fake_progress_bar.go index c23e09c6012..8d70e369ce8 100644 --- a/util/download/downloadfakes/fake_progress_bar.go +++ b/util/download/downloadfakes/fake_progress_bar.go @@ -5,7 +5,7 @@ import ( "io" "sync" - "code.cloudfoundry.org/cli/util/download" + "code.cloudfoundry.org/cli/v8/util/download" pb "gopkg.in/cheggaaa/pb.v1" ) @@ -54,9 +54,10 @@ func (fake *FakeProgressBar) Finish() { fake.finishMutex.Lock() fake.finishArgsForCall = append(fake.finishArgsForCall, struct { }{}) + stub := fake.FinishStub fake.recordInvocation("Finish", []interface{}{}) fake.finishMutex.Unlock() - if fake.FinishStub != nil { + if stub != nil { fake.FinishStub() } } @@ -79,15 +80,16 @@ func (fake *FakeProgressBar) NewProxyReader(arg1 io.Reader) *pb.Reader { fake.newProxyReaderArgsForCall = append(fake.newProxyReaderArgsForCall, struct { arg1 io.Reader }{arg1}) + stub := fake.NewProxyReaderStub + fakeReturns := fake.newProxyReaderReturns fake.recordInvocation("NewProxyReader", []interface{}{arg1}) fake.newProxyReaderMutex.Unlock() - if fake.NewProxyReaderStub != nil { - return fake.NewProxyReaderStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.newProxyReaderReturns return fakeReturns.result1 } @@ -139,15 +141,16 @@ func (fake *FakeProgressBar) SetTotal(arg1 int) *pb.ProgressBar { fake.setTotalArgsForCall = append(fake.setTotalArgsForCall, struct { arg1 int }{arg1}) + stub := fake.SetTotalStub + fakeReturns := fake.setTotalReturns fake.recordInvocation("SetTotal", []interface{}{arg1}) fake.setTotalMutex.Unlock() - if fake.SetTotalStub != nil { - return fake.SetTotalStub(arg1) + if stub != nil { + return stub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.setTotalReturns return fakeReturns.result1 } @@ -198,15 +201,16 @@ func (fake *FakeProgressBar) Start() *pb.ProgressBar { ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { }{}) + stub := fake.StartStub + fakeReturns := fake.startReturns fake.recordInvocation("Start", []interface{}{}) fake.startMutex.Unlock() - if fake.StartStub != nil { - return fake.StartStub() + if stub != nil { + return stub() } if specificReturn { return ret.result1 } - fakeReturns := fake.startReturns return fakeReturns.result1 } diff --git a/util/extract/extract.go b/util/extract/extract.go index 917960e6543..25ff0435ad6 100644 --- a/util/extract/extract.go +++ b/util/extract/extract.go @@ -4,7 +4,7 @@ import ( "reflect" "strings" - "code.cloudfoundry.org/cli/util/unique" + "code.cloudfoundry.org/cli/v8/util/unique" ) type appender func(string) diff --git a/util/extract/extract_suite_test.go b/util/extract/extract_suite_test.go index bf5dce81754..e6c74bf8312 100644 --- a/util/extract/extract_suite_test.go +++ b/util/extract/extract_suite_test.go @@ -3,7 +3,7 @@ package extract_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/extract/extract_test.go b/util/extract/extract_test.go index 309d91407c9..b7fc5955c38 100644 --- a/util/extract/extract_test.go +++ b/util/extract/extract_test.go @@ -1,8 +1,8 @@ package extract_test import ( - "code.cloudfoundry.org/cli/util/extract" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/extract" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/generic/architecture_test.go b/util/generic/architecture_test.go index 89cd081dcdd..1ae5bb0843e 100644 --- a/util/generic/architecture_test.go +++ b/util/generic/architecture_test.go @@ -1,9 +1,8 @@ package generic_test import ( - . "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/generic/executable_filename_unix.go b/util/generic/executable_filename_unix.go index 894053524b2..65de1273664 100644 --- a/util/generic/executable_filename_unix.go +++ b/util/generic/executable_filename_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package generic diff --git a/util/generic/executable_filename_unix_test.go b/util/generic/executable_filename_unix_test.go index 318268df5eb..620340c5d4c 100644 --- a/util/generic/executable_filename_unix_test.go +++ b/util/generic/executable_filename_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package generic_test @@ -5,8 +6,8 @@ package generic_test import ( "path/filepath" - . "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/generic/executable_filename_windows.go b/util/generic/executable_filename_windows.go index a0a00f4c5e5..12b39103fa5 100644 --- a/util/generic/executable_filename_windows.go +++ b/util/generic/executable_filename_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package generic diff --git a/util/generic/executable_filename_windows_test.go b/util/generic/executable_filename_windows_test.go index fe0eb03c03d..82fc055e568 100644 --- a/util/generic/executable_filename_windows_test.go +++ b/util/generic/executable_filename_windows_test.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package generic_test @@ -6,8 +7,8 @@ import ( "fmt" "path/filepath" - . "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/generic/generic_suite_test.go b/util/generic/generic_suite_test.go index da96edae237..0352c6f9584 100644 --- a/util/generic/generic_suite_test.go +++ b/util/generic/generic_suite_test.go @@ -1,7 +1,7 @@ package generic_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/generic/map_test.go b/util/generic/map_test.go index c3471fe81cb..3be5bdc51c6 100644 --- a/util/generic/map_test.go +++ b/util/generic/map_test.go @@ -1,8 +1,8 @@ package generic_test import ( - . "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/generic/slice_test.go b/util/generic/slice_test.go index e24def73d2e..f4dfcec92a6 100644 --- a/util/generic/slice_test.go +++ b/util/generic/slice_test.go @@ -1,8 +1,8 @@ package generic_test import ( - "code.cloudfoundry.org/cli/util/generic" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/generic" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/lookuptable/lookuptable_suite_test.go b/util/lookuptable/lookuptable_suite_test.go index d5b9c294b9b..cf9ea276954 100644 --- a/util/lookuptable/lookuptable_suite_test.go +++ b/util/lookuptable/lookuptable_suite_test.go @@ -3,7 +3,7 @@ package lookuptable_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/lookuptable/name_from_guid_test.go b/util/lookuptable/name_from_guid_test.go index 3bc95936932..d44a4f88a76 100644 --- a/util/lookuptable/name_from_guid_test.go +++ b/util/lookuptable/name_from_guid_test.go @@ -1,8 +1,8 @@ package lookuptable_test import ( - "code.cloudfoundry.org/cli/util/lookuptable" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/util/lookuptable" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/lookuptable/resource_from_guid.go b/util/lookuptable/resource_from_guid.go index 878a6b93bd4..e8a42d7648c 100644 --- a/util/lookuptable/resource_from_guid.go +++ b/util/lookuptable/resource_from_guid.go @@ -1,6 +1,6 @@ package lookuptable -import "code.cloudfoundry.org/cli/resources" +import "code.cloudfoundry.org/cli/v8/resources" func OrgFromGUID(orgs []resources.Organization) map[string]resources.Organization { result := make(map[string]resources.Organization) diff --git a/util/manifest/application.go b/util/manifest/application.go index e539a719028..708f2d16225 100644 --- a/util/manifest/application.go +++ b/util/manifest/application.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "code.cloudfoundry.org/cli/types" + "code.cloudfoundry.org/cli/v8/types" ) type Application struct { @@ -150,7 +150,7 @@ func (app *Application) UnmarshalYAML(unmarshaller func(interface{}) error) erro } // "null" values are identical to non-existant values in YAML. In order to - // detect if an explicit null is given, a manual existance check is required. + // detect if an explicit null is given, a manual existence check is required. exists := map[string]interface{}{} err = unmarshaller(&exists) if err != nil { diff --git a/util/manifest/manifest.go b/util/manifest/manifest.go index e993b116a1c..3d244ac8275 100644 --- a/util/manifest/manifest.go +++ b/util/manifest/manifest.go @@ -1,7 +1,7 @@ package manifest import ( - "io/ioutil" + "os" "path/filepath" "github.com/cloudfoundry/bosh-cli/director/template" @@ -59,7 +59,7 @@ func ReadAndInterpolateManifest(pathToManifest string, pathsToVarsFiles []string // interpolates variables if a vars file is provided, and returns the // Unmarshalled result. func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { - rawManifest, err := ioutil.ReadFile(pathToManifest) + rawManifest, err := os.ReadFile(pathToManifest) if err != nil { return nil, err } @@ -68,7 +68,7 @@ func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []str fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { - rawVarsFile, ioerr := ioutil.ReadFile(path) + rawVarsFile, ioerr := os.ReadFile(path) if ioerr != nil { return nil, ioerr } @@ -105,7 +105,7 @@ func WriteApplicationManifest(application Application, filePath string) error { return ManifestCreationError{Err: err} } - err = ioutil.WriteFile(filePath, manifestBytes, 0644) + err = os.WriteFile(filePath, manifestBytes, 0644) if err != nil { return ManifestCreationError{Err: err} } diff --git a/util/manifest/manifest_suite_test.go b/util/manifest/manifest_suite_test.go index 2d894f1dec8..8cb408bd8ba 100644 --- a/util/manifest/manifest_suite_test.go +++ b/util/manifest/manifest_suite_test.go @@ -1,7 +1,7 @@ package manifest_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/manifest/manifest_test.go b/util/manifest/manifest_test.go index cb91fdbed03..e43cf7bf1a2 100644 --- a/util/manifest/manifest_test.go +++ b/util/manifest/manifest_test.go @@ -3,16 +3,15 @@ package manifest_test import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strings" - "code.cloudfoundry.org/cli/types" - . "code.cloudfoundry.org/cli/util/manifest" + "code.cloudfoundry.org/cli/v8/types" + . "code.cloudfoundry.org/cli/v8/util/manifest" "github.com/cloudfoundry/bosh-cli/director/template" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" ) @@ -30,7 +29,7 @@ var _ = Describe("Manifest", func() { ) BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "manifest-test-") + tempFile, err := os.CreateTemp("", "manifest-test-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).ToNot(HaveOccurred()) pathToManifest = tempFile.Name() @@ -108,7 +107,7 @@ applications: random-route: true ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -214,7 +213,7 @@ applications: When("global fields are provided", func() { DescribeTable("raises a GlobalFieldsError", func(manifestProperty string, numberOfValues int) { - tempManifest, err := ioutil.TempFile("", "manifest-test-") + tempManifest, err := os.CreateTemp("", "manifest-test-") Expect(err).ToNot(HaveOccurred()) Expect(tempManifest.Close()).ToNot(HaveOccurred()) manifestPath := tempManifest.Name() @@ -226,7 +225,7 @@ applications: values := []string{"A", "B"} manifest = fmt.Sprintf("---\n%s: [%s]", manifestProperty, strings.Join(values, ",")) } - err = ioutil.WriteFile(manifestPath, []byte(manifest), 0666) + err = os.WriteFile(manifestPath, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) _, err = ReadAndInterpolateManifest(manifestPath, pathsToVarsFiles, vars) @@ -267,7 +266,7 @@ applications: - name: "app-1" ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -285,7 +284,7 @@ applications: memory: 200M instances: 10 ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -319,7 +318,7 @@ applications: - "some-other-buildpack-2" memory: 2048M instances: 0` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -357,7 +356,7 @@ applications: memory: 200M instances: 10 ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -382,7 +381,7 @@ applications: - name: app-1 buildpacks: ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -399,7 +398,7 @@ applications: - name: ((var1)) instances: ((var2)) ` - err := ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err := os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -410,15 +409,15 @@ applications: BeforeEach(func() { var err error - varsDir, err = ioutil.TempDir("", "vars-test") + varsDir, err = os.MkdirTemp("", "vars-test") Expect(err).ToNot(HaveOccurred()) varsFilePath1 := filepath.Join(varsDir, "vars-1") - err = ioutil.WriteFile(varsFilePath1, []byte("var1: app-1"), 0666) + err = os.WriteFile(varsFilePath1, []byte("var1: app-1"), 0666) Expect(err).ToNot(HaveOccurred()) varsFilePath2 := filepath.Join(varsDir, "vars-2") - err = ioutil.WriteFile(varsFilePath2, []byte("var2: 4"), 0666) + err = os.WriteFile(varsFilePath2, []byte("var2: 4"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = append(pathsToVarsFiles, varsFilePath1, varsFilePath2) @@ -431,11 +430,11 @@ applications: When("multiple values for the same variable(s) are provided", func() { BeforeEach(func() { varsFilePath1 := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath1, []byte("var1: garbageapp\nvar1: app-1\nvar2: 0"), 0666) + err := os.WriteFile(varsFilePath1, []byte("var1: garbageapp\nvar1: app-1\nvar2: 0"), 0666) Expect(err).ToNot(HaveOccurred()) varsFilePath2 := filepath.Join(varsDir, "vars-2") - err = ioutil.WriteFile(varsFilePath2, []byte("var2: 4"), 0666) + err = os.WriteFile(varsFilePath2, []byte("var2: 4"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = append(pathsToVarsFiles, varsFilePath1, varsFilePath2) @@ -459,7 +458,7 @@ applications: When("a variable in the manifest is not provided in the vars file", func() { BeforeEach(func() { varsFilePath := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath, []byte("notvar: foo"), 0666) + err := os.WriteFile(varsFilePath, []byte("notvar: foo"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} @@ -484,7 +483,7 @@ applications: When("the provided file is not a valid yaml file", func() { BeforeEach(func() { varsFilePath := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath, []byte(": bad"), 0666) + err := os.WriteFile(varsFilePath, []byte(": bad"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} @@ -522,12 +521,12 @@ applications: When("vars and vars files are provided", func() { var varsFilePath string BeforeEach(func() { - tmp, err := ioutil.TempFile("", "util-manifest-varsilfe") + tmp, err := os.CreateTemp("", "util-manifest-varsilfe") Expect(err).NotTo(HaveOccurred()) Expect(tmp.Close()).NotTo(HaveOccurred()) varsFilePath = tmp.Name() - err = ioutil.WriteFile(varsFilePath, []byte("var1: app-1\nvar2: 12345"), 0666) + err = os.WriteFile(varsFilePath, []byte("var1: app-1\nvar2: 12345"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} @@ -560,7 +559,7 @@ applications: BeforeEach(func() { var err error - tmpDir, err = ioutil.TempDir("", "manifest-test-") + tmpDir, err = os.MkdirTemp("", "manifest-test-") Expect(err).NotTo(HaveOccurred()) filePath = filepath.Join(tmpDir, "manifest.yml") }) @@ -619,7 +618,7 @@ applications: It("creates and writes the manifest to the specified filepath", func() { Expect(executeErr).NotTo(HaveOccurred()) - manifestBytes, err := ioutil.ReadFile(filePath) + manifestBytes, err := os.ReadFile(filePath) Expect(err).NotTo(HaveOccurred()) Expect(string(manifestBytes)).To(Equal(`applications: - name: app-1 @@ -664,7 +663,7 @@ applications: It("does not save them in manifest", func() { Expect(executeErr).NotTo(HaveOccurred()) - manifestBytes, err := ioutil.ReadFile(filePath) + manifestBytes, err := os.ReadFile(filePath) Expect(err).NotTo(HaveOccurred()) Expect(string(manifestBytes)).To(Equal(`applications: - name: app-1 @@ -694,7 +693,7 @@ applications: It("writes the file in an expanded path", func() { Expect(executeErr).ToNot(HaveOccurred()) - manifestBytes, err := ioutil.ReadFile(filepath.Join(tmpDir, "manifest.yml")) + manifestBytes, err := os.ReadFile(filepath.Join(tmpDir, "manifest.yml")) Expect(err).ToNot(HaveOccurred()) Expect(string(manifestBytes)).To(Equal(`applications: - name: app-1 @@ -704,7 +703,7 @@ applications: When("the file already exists", func() { BeforeEach(func() { - err := ioutil.WriteFile(filePath, []byte(`{}`), 0644) + err := os.WriteFile(filePath, []byte(`{}`), 0644) Expect(err).ToNot(HaveOccurred()) application = Application{ Name: "app-1", @@ -714,7 +713,7 @@ applications: Context("writes the file", func() { It("truncates and writes the manifest to specified filepath", func() { Expect(executeErr).ToNot(HaveOccurred()) - manifestBytes, err := ioutil.ReadFile(filePath) + manifestBytes, err := os.ReadFile(filePath) Expect(err).ToNot(HaveOccurred()) Expect(string(manifestBytes)).To(Equal(`applications: - name: app-1 diff --git a/util/manifest/manifest_unix_test.go b/util/manifest/manifest_unix_test.go index 748d5cac4cb..26476a80a69 100644 --- a/util/manifest/manifest_unix_test.go +++ b/util/manifest/manifest_unix_test.go @@ -1,15 +1,15 @@ +//go:build !windows // +build !windows package manifest_test import ( - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/util/manifest" + . "code.cloudfoundry.org/cli/v8/util/manifest" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,12 +20,12 @@ var _ = Describe("Manifest with paths", func() { ) JustBeforeEach(func() { - tempFile, err := ioutil.TempFile("", "manifest-test-") + tempFile, err := os.CreateTemp("", "manifest-test-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).ToNot(HaveOccurred()) pathToManifest = tempFile.Name() - err = ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err = os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) diff --git a/util/manifest/manifest_windows_test.go b/util/manifest/manifest_windows_test.go index 629ce11bb8c..9c815927959 100644 --- a/util/manifest/manifest_windows_test.go +++ b/util/manifest/manifest_windows_test.go @@ -1,15 +1,15 @@ +//go:build windows // +build windows package manifest_test import ( - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/util/manifest" + . "code.cloudfoundry.org/cli/v8/util/manifest" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,12 +20,12 @@ var _ = Describe("Manifest with paths", func() { ) JustBeforeEach(func() { - tempFile, err := ioutil.TempFile("", "manifest-test-") + tempFile, err := os.CreateTemp("", "manifest-test-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).ToNot(HaveOccurred()) pathToManifest = tempFile.Name() - err = ioutil.WriteFile(pathToManifest, []byte(manifest), 0666) + err = os.WriteFile(pathToManifest, []byte(manifest), 0666) Expect(err).ToNot(HaveOccurred()) }) diff --git a/util/manifestparser/application.go b/util/manifestparser/application.go index c51121f8e61..6c0f5c8dc37 100644 --- a/util/manifestparser/application.go +++ b/util/manifestparser/application.go @@ -4,7 +4,7 @@ import ( "errors" "reflect" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) type Docker struct { @@ -16,21 +16,23 @@ type Docker struct { // add a field for the CLI to extract from the manifest, just add it to this // struct. type Application struct { - Name string `yaml:"name"` - DiskQuota string `yaml:"disk-quota,omitempty"` - Docker *Docker `yaml:"docker,omitempty"` - HealthCheckType constant.HealthCheckType `yaml:"health-check-type,omitempty"` - HealthCheckEndpoint string `yaml:"health-check-http-endpoint,omitempty"` - HealthCheckTimeout int64 `yaml:"timeout,omitempty"` - Instances *int `yaml:"instances,omitempty"` - Path string `yaml:"path,omitempty"` - Processes []Process `yaml:"processes,omitempty"` - Memory string `yaml:"memory,omitempty"` - NoRoute bool `yaml:"no-route,omitempty"` - RandomRoute bool `yaml:"random-route,omitempty"` - DefaultRoute bool `yaml:"default-route,omitempty"` - Stack string `yaml:"stack,omitempty"` - RemainingManifestFields map[string]interface{} `yaml:"-,inline"` + Name string `yaml:"name"` + DiskQuota string `yaml:"disk-quota,omitempty"` + Docker *Docker `yaml:"docker,omitempty"` + HealthCheckType constant.HealthCheckType `yaml:"health-check-type,omitempty"` + HealthCheckEndpoint string `yaml:"health-check-http-endpoint,omitempty"` + HealthCheckTimeout int64 `yaml:"timeout,omitempty"` + Instances *int `yaml:"instances,omitempty"` + Path string `yaml:"path,omitempty"` + Processes []Process `yaml:"processes,omitempty"` + Memory string `yaml:"memory,omitempty"` + NoRoute bool `yaml:"no-route,omitempty"` + RandomRoute bool `yaml:"random-route,omitempty"` + DefaultRoute bool `yaml:"default-route,omitempty"` + Stack string `yaml:"stack,omitempty"` + LogRateLimit string `yaml:"log-rate-limit-per-second,omitempty"` + Lifecycle constant.AppLifecycleType `yaml:"lifecycle,omitempty"` + RemainingManifestFields map[string]interface{} `yaml:"-,inline"` } func (application Application) HasBuildpacks() bool { @@ -60,7 +62,7 @@ func (application *Application) SetStartCommand(command string) { func (application *Application) UnmarshalYAML(unmarshal func(v interface{}) error) error { // This prevents infinite recursion. The alias type does not implement the unmarshaller interface - // so by casting application to a alias pointer, it will unmarshal in to the same memory without calling + // so by casting application to a alias pointer, it will unmarshal into the same memory without calling // UnmarshalYAML on itself infinite times type Alias Application aliasPntr := (*Alias)(application) diff --git a/util/manifestparser/application_test.go b/util/manifestparser/application_test.go index 467274711a9..9f52d3a16cc 100644 --- a/util/manifestparser/application_test.go +++ b/util/manifestparser/application_test.go @@ -1,10 +1,10 @@ package manifestparser_test import ( - . "code.cloudfoundry.org/cli/util/manifestparser" + . "code.cloudfoundry.org/cli/v8/util/manifestparser" "gopkg.in/yaml.v2" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -178,13 +178,13 @@ buildpacks: Context("when stack is provided", func() { BeforeEach(func() { rawYAML = []byte(`--- -stack: cflinuxfs3 +stack: cflinuxfs4 `) }) It("unmarshals the stack property", func() { Expect(executeErr).ToNot(HaveOccurred()) - Expect(application.Stack).To(Equal("cflinuxfs3")) + Expect(application.Stack).To(Equal("cflinuxfs4")) }) }) @@ -349,6 +349,22 @@ processes: }) }) + Context("when a log rate limit is provided", func() { + BeforeEach(func() { + rawYAML = []byte(`--- +processes: +- log-rate-limit-per-second: 512M +`) + }) + + It("unmarshals the processes property with the log rate limit", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(application.Processes).To(Equal([]Process{ + {LogRateLimit: "512M", RemainingManifestFields: emptyMap}, + })) + }) + }) + Context("when an unknown field is provided", func() { BeforeEach(func() { rawYAML = []byte(`--- @@ -392,6 +408,19 @@ processes: Expect(remarshalledYaml).To(MatchYAML(rawYAML)) }) }) + + Context("when a log rate limit is provided", func() { + BeforeEach(func() { + rawYAML = []byte(`--- +log-rate-limit-per-second: 5K +`) + }) + + It("unmarshals the log rate limit", func() { + Expect(executeErr).ToNot(HaveOccurred()) + Expect(application.LogRateLimit).To(Equal("5K")) + }) + }) }) Describe("SetStartCommand", func() { @@ -456,7 +485,7 @@ processes: app.RemainingManifestFields = map[string]interface{}{} }) - It("sets the buildpackks in the map", func() { + It("sets the buildpacks in the map", func() { Expect(app.RemainingManifestFields["buildpacks"]).To(ConsistOf("bp1", "bp2")) }) diff --git a/util/manifestparser/locator_test.go b/util/manifestparser/locator_test.go index 64483923a15..74099d2531a 100644 --- a/util/manifestparser/locator_test.go +++ b/util/manifestparser/locator_test.go @@ -1,14 +1,13 @@ package manifestparser_test import ( - "io/ioutil" "os" "path/filepath" "strings" - . "code.cloudfoundry.org/cli/util/manifestparser" + . "code.cloudfoundry.org/cli/v8/util/manifestparser" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -33,7 +32,7 @@ var _ = Describe("Locator", func() { BeforeEach(func() { var err error - workingDir, err = ioutil.TempDir("", "manifest-locator-working-dir") + workingDir, err = os.MkdirTemp("", "manifest-locator-working-dir") Expect(err).ToNot(HaveOccurred()) workingDir, err = filepath.EvalSymlinks(workingDir) Expect(err).ToNot(HaveOccurred()) @@ -50,7 +49,7 @@ var _ = Describe("Locator", func() { When("given a file path", func() { BeforeEach(func() { filepathOrDirectory = filepath.Join(workingDir, "some-manifest.yml") - Expect(ioutil.WriteFile(filepathOrDirectory, nil, 0600)).To(Succeed()) + Expect(os.WriteFile(filepathOrDirectory, nil, 0600)).To(Succeed()) }) It("returns the path and true", func() { @@ -67,7 +66,7 @@ var _ = Describe("Locator", func() { When("a manifest.yml exists in the directory", func() { BeforeEach(func() { - Expect(ioutil.WriteFile(filepath.Join(workingDir, "manifest.yml"), nil, 0600)).To(Succeed()) + Expect(os.WriteFile(filepath.Join(workingDir, "manifest.yml"), nil, 0600)).To(Succeed()) }) It("returns the path and true", func() { @@ -79,7 +78,7 @@ var _ = Describe("Locator", func() { When("a manifest.yaml exists in the directory", func() { BeforeEach(func() { - Expect(ioutil.WriteFile(filepath.Join(workingDir, "manifest.yaml"), nil, 0600)).To(Succeed()) + Expect(os.WriteFile(filepath.Join(workingDir, "manifest.yaml"), nil, 0600)).To(Succeed()) }) It("returns the path and true", func() { @@ -135,7 +134,7 @@ var _ = Describe("Locator", func() { When("the path to the manifest is a symbolic link", func() { BeforeEach(func() { originalFilepathOrDirectory = filepath.Join(workingDir, "some-manifest.yml") - Expect(ioutil.WriteFile(originalFilepathOrDirectory, nil, 0600)).To(Succeed()) + Expect(os.WriteFile(originalFilepathOrDirectory, nil, 0600)).To(Succeed()) filepathOrDirectory = filepath.Join(workingDir, "link-to-some-manifest.yml") err := os.Symlink(originalFilepathOrDirectory, filepathOrDirectory) Expect(err).To(BeNil()) diff --git a/util/manifestparser/manifest_test.go b/util/manifestparser/manifest_test.go index b4e11d6133a..855cc814889 100644 --- a/util/manifestparser/manifest_test.go +++ b/util/manifestparser/manifest_test.go @@ -1,8 +1,8 @@ package manifestparser_test import ( - . "code.cloudfoundry.org/cli/util/manifestparser" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "gopkg.in/yaml.v2" ) diff --git a/util/manifestparser/manifestparser_suite_test.go b/util/manifestparser/manifestparser_suite_test.go index a612b2f47ec..3034178ef52 100644 --- a/util/manifestparser/manifestparser_suite_test.go +++ b/util/manifestparser/manifestparser_suite_test.go @@ -3,7 +3,7 @@ package manifestparser_test import ( "testing" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/manifestparser/parser.go b/util/manifestparser/parser.go index 2c8839bd3a7..4f1f2a83d80 100644 --- a/util/manifestparser/parser.go +++ b/util/manifestparser/parser.go @@ -2,7 +2,7 @@ package manifestparser import ( "errors" - "io/ioutil" + "os" "github.com/cloudfoundry/bosh-cli/director/template" "gopkg.in/yaml.v2" @@ -19,7 +19,7 @@ type ManifestParser struct{} // applications and leave only a single application in the resulting parsed // manifest structure. func (m ManifestParser) InterpolateManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { - rawManifest, err := ioutil.ReadFile(pathToManifest) + rawManifest, err := os.ReadFile(pathToManifest) if err != nil { return nil, err } @@ -28,7 +28,7 @@ func (m ManifestParser) InterpolateManifest(pathToManifest string, pathsToVarsFi fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { - rawVarsFile, ioerr := ioutil.ReadFile(path) + rawVarsFile, ioerr := os.ReadFile(path) if ioerr != nil { return nil, ioerr } diff --git a/util/manifestparser/parser_test.go b/util/manifestparser/parser_test.go index 5720fcd24bd..16e1071e523 100644 --- a/util/manifestparser/parser_test.go +++ b/util/manifestparser/parser_test.go @@ -2,13 +2,12 @@ package manifestparser_test import ( "errors" - "io/ioutil" "os" "path/filepath" - . "code.cloudfoundry.org/cli/util/manifestparser" + . "code.cloudfoundry.org/cli/v8/util/manifestparser" "github.com/cloudfoundry/bosh-cli/director/template" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "gopkg.in/yaml.v2" ) @@ -28,7 +27,7 @@ var _ = Describe("ManifestParser", func() { ) BeforeEach(func() { - tempFile, err := ioutil.TempFile("", "manifest-test-") + tempFile, err := os.CreateTemp("", "manifest-test-") Expect(err).ToNot(HaveOccurred()) Expect(tempFile.Close()).ToNot(HaveOccurred()) pathToManifest = tempFile.Name() @@ -55,7 +54,7 @@ applications: - name: spark - name: flame `) - err := ioutil.WriteFile(pathToManifest, givenManifest, 0666) + err := os.WriteFile(pathToManifest, givenManifest, 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -76,7 +75,7 @@ applications: - name: ((var1)) - name: ((var2)) `) - err := ioutil.WriteFile(pathToManifest, givenManifest, 0666) + err := os.WriteFile(pathToManifest, givenManifest, 0666) Expect(err).ToNot(HaveOccurred()) }) @@ -87,15 +86,15 @@ applications: BeforeEach(func() { var err error - varsDir, err = ioutil.TempDir("", "vars-test") + varsDir, err = os.MkdirTemp("", "vars-test") Expect(err).ToNot(HaveOccurred()) varsFilePath1 := filepath.Join(varsDir, "vars-1") - err = ioutil.WriteFile(varsFilePath1, []byte("var1: spark"), 0666) + err = os.WriteFile(varsFilePath1, []byte("var1: spark"), 0666) Expect(err).ToNot(HaveOccurred()) varsFilePath2 := filepath.Join(varsDir, "vars-2") - err = ioutil.WriteFile(varsFilePath2, []byte("var2: flame"), 0666) + err = os.WriteFile(varsFilePath2, []byte("var2: flame"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = append(pathsToVarsFiles, varsFilePath1, varsFilePath2) @@ -108,11 +107,11 @@ applications: When("multiple values for the same variable(s) are provided", func() { BeforeEach(func() { varsFilePath1 := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath1, []byte("var1: garbageapp\nvar1: spark\nvar2: doesn't matter"), 0666) + err := os.WriteFile(varsFilePath1, []byte("var1: garbageapp\nvar1: spark\nvar2: doesn't matter"), 0666) Expect(err).ToNot(HaveOccurred()) varsFilePath2 := filepath.Join(varsDir, "vars-2") - err = ioutil.WriteFile(varsFilePath2, []byte("var2: flame"), 0666) + err = os.WriteFile(varsFilePath2, []byte("var2: flame"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = append(pathsToVarsFiles, varsFilePath1, varsFilePath2) @@ -140,7 +139,7 @@ applications: When("a variable in the manifest is not provided in the vars file", func() { BeforeEach(func() { varsFilePath := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath, []byte("notvar: foo"), 0666) + err := os.WriteFile(varsFilePath, []byte("notvar: foo"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} @@ -165,7 +164,7 @@ applications: When("the provided file is not a valid yaml file", func() { BeforeEach(func() { varsFilePath := filepath.Join(varsDir, "vars-1") - err := ioutil.WriteFile(varsFilePath, []byte(": bad"), 0666) + err := os.WriteFile(varsFilePath, []byte(": bad"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} @@ -200,12 +199,12 @@ applications: When("vars and vars files are provided", func() { var varsFilePath string BeforeEach(func() { - tmp, err := ioutil.TempFile("", "util-manifest-varsilfe") + tmp, err := os.CreateTemp("", "util-manifest-varsilfe") Expect(err).NotTo(HaveOccurred()) Expect(tmp.Close()).NotTo(HaveOccurred()) varsFilePath = tmp.Name() - err = ioutil.WriteFile(varsFilePath, []byte("var1: spark\nvar2: 12345"), 0666) + err = os.WriteFile(varsFilePath, []byte("var1: spark\nvar2: 12345"), 0666) Expect(err).ToNot(HaveOccurred()) pathsToVarsFiles = []string{varsFilePath} diff --git a/util/manifestparser/process.go b/util/manifestparser/process.go index 611cbf2a1df..39b9113e63c 100644 --- a/util/manifestparser/process.go +++ b/util/manifestparser/process.go @@ -5,7 +5,7 @@ import ( "reflect" "strings" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant" ) type Process struct { @@ -16,6 +16,7 @@ type Process struct { Instances *int `yaml:"instances,omitempty"` Memory string `yaml:"memory,omitempty"` Type string `yaml:"type"` + LogRateLimit string `yaml:"log-rate-limit-per-second,omitempty"` RemainingManifestFields map[string]interface{} `yaml:"-,inline"` } @@ -33,7 +34,7 @@ func (process *Process) SetStartCommand(command string) { func (process *Process) UnmarshalYAML(unmarshal func(v interface{}) error) error { // This prevents infinite recursion. The Alias type does not implement the unmarshaller interface - // so by casting application to a alias pointer, it will unmarshal in to the same memory without calling + // so by casting application to a alias pointer, it will unmarshal into the same memory without calling // UnmarshalYAML on itself infinite times type Alias Process aliasPntr := (*Alias)(process) diff --git a/util/manifestparser/process_test.go b/util/manifestparser/process_test.go index 33753ba85bf..29ca1313114 100644 --- a/util/manifestparser/process_test.go +++ b/util/manifestparser/process_test.go @@ -1,8 +1,8 @@ package manifestparser_test import ( - . "code.cloudfoundry.org/cli/util/manifestparser" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util/manifestparser" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "gopkg.in/yaml.v2" ) @@ -77,6 +77,5 @@ var _ = Describe("Process", func() { Expect(process).To(Equal(Process{DiskQuota: "5G", RemainingManifestFields: map[string]interface{}{}})) }) }) - }) }) diff --git a/util/panichandler/handler.go b/util/panichandler/handler.go index 73e0c1faddb..65001a02dbb 100644 --- a/util/panichandler/handler.go +++ b/util/panichandler/handler.go @@ -7,7 +7,7 @@ import ( "strings" "text/template" - "code.cloudfoundry.org/cli/version" + "code.cloudfoundry.org/cli/v8/version" ) const maxStackSizeLimit = 1024 * 1024 @@ -26,9 +26,9 @@ func HandlePanic() { variable CF_TRACE set to true. Also, please update to the latest cli and try the command again: - https://code.cloudfoundry.org/cli/releases + https://code.cloudfoundry.org/cli/v8/releases - Please create an issue at: https://code.cloudfoundry.org/cli/issues + Please create an issue at: https://code.cloudfoundry.org/cli/v8/issues Include the below information when creating the issue: diff --git a/util/plugin/plugin.go b/util/plugin/plugin.go index 67ce1896bf7..7ee637ae422 100644 --- a/util/plugin/plugin.go +++ b/util/plugin/plugin.go @@ -1,17 +1,16 @@ package plugin import ( - "os" - "errors" "fmt" + "os" - plugin_transition "code.cloudfoundry.org/cli/plugin/transition" - "code.cloudfoundry.org/cli/util/configv3" - "code.cloudfoundry.org/cli/util/ui" + plugin_transition "code.cloudfoundry.org/cli/v8/plugin/transition" + "code.cloudfoundry.org/cli/v8/util/configv3" + "code.cloudfoundry.org/cli/v8/util/ui" - "code.cloudfoundry.org/cli/command/common" - "code.cloudfoundry.org/cli/command/translatableerror" + "code.cloudfoundry.org/cli/v8/command/common" + "code.cloudfoundry.org/cli/v8/command/translatableerror" ) var ErrFailed = errors.New("command failed") diff --git a/util/railway/railway.go b/util/railway/railway.go index 1564004d39c..04b8cc529df 100644 --- a/util/railway/railway.go +++ b/util/railway/railway.go @@ -1,6 +1,6 @@ package railway -import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" +import "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" type funcWithWarningsAndError = func() (ccv3.Warnings, error) diff --git a/util/railway/railway_suite_test.go b/util/railway/railway_suite_test.go index 04e72c78003..0582af51a94 100644 --- a/util/railway/railway_suite_test.go +++ b/util/railway/railway_suite_test.go @@ -1,7 +1,7 @@ package railway_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/railway/railway_test.go b/util/railway/railway_test.go index 8f17f36571f..04c545b0033 100644 --- a/util/railway/railway_test.go +++ b/util/railway/railway_test.go @@ -3,9 +3,9 @@ package railway_test import ( "errors" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/util/railway" - . "github.com/onsi/ginkgo" + "code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/v8/util/railway" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -17,10 +17,11 @@ var _ = Describe("Sequentially()", func() { j = 0 ) - railway.Sequentially( + _, err := railway.Sequentially( func() (ccv3.Warnings, error) { i = 1; return ccv3.Warnings{}, nil }, func() (ccv3.Warnings, error) { j = 2; return ccv3.Warnings{}, nil }, ) + Expect(err).NotTo(HaveOccurred()) Expect(i).To(Equal(1)) Expect(j).To(Equal(2)) @@ -29,10 +30,11 @@ var _ = Describe("Sequentially()", func() { It("calls the tracks in order", func() { i := 0 - railway.Sequentially( + _, err := railway.Sequentially( func() (ccv3.Warnings, error) { i = 1; return ccv3.Warnings{}, nil }, func() (ccv3.Warnings, error) { i = 2; return ccv3.Warnings{}, nil }, ) + Expect(err).NotTo(HaveOccurred()) Expect(i).To(Equal(2)) }) diff --git a/util/randomword/generator.go b/util/randomword/generator.go index 06eba5f22ab..404b777cb83 100644 --- a/util/randomword/generator.go +++ b/util/randomword/generator.go @@ -83,7 +83,7 @@ wacky wise zany` -const nouns = `ardvark +const nouns = `aardvark alligator antelope baboon @@ -170,7 +170,7 @@ rabbit ratel raven reedbuck -rhinocerous +rhinoceros roan sable serval @@ -193,35 +193,36 @@ wolverine wombat zebra` -type Generator struct{} +type Generator struct { + r *rand.Rand +} func NewGenerator() Generator { - rand.Seed(time.Now().UnixNano()) - return Generator{} + return Generator{r: rand.New(rand.NewSource(time.Now().UnixNano()))} } func (gen Generator) Babble() string { return fmt.Sprintf("%s-%s-%s", gen.RandomAdjective(), gen.RandomNoun(), gen.RandomTwoLetters()) } -func (Generator) RandomAdjective() string { - return randomElement(adjectives) +func (gen Generator) RandomAdjective() string { + return randomElement(gen.r, adjectives) } -func (Generator) RandomNoun() string { - return randomElement(nouns) +func (gen Generator) RandomNoun() string { + return randomElement(gen.r, nouns) } -func (Generator) RandomTwoLetters() string { +func (gen Generator) RandomTwoLetters() string { var asciiLetterA = 97 - letterOne := string(rand.Intn(26) + asciiLetterA) - letterTwo := string(rand.Intn(26) + asciiLetterA) + letterOne := string(rune(gen.r.Intn(26) + asciiLetterA)) + letterTwo := string(rune(gen.r.Intn(26) + asciiLetterA)) return letterOne + letterTwo } -func randomElement(fullList string) string { +func randomElement(r *rand.Rand, fullList string) string { wordList := strings.Split(fullList, "\n") - randomWordIndex := rand.Int() % len(wordList) + randomWordIndex := r.Int() % len(wordList) return wordList[randomWordIndex] } diff --git a/util/randomword/generator_test.go b/util/randomword/generator_test.go index 1ba1bb58798..4320c8c4a42 100644 --- a/util/randomword/generator_test.go +++ b/util/randomword/generator_test.go @@ -1,14 +1,14 @@ package randomword_test import ( - . "code.cloudfoundry.org/cli/util/randomword" + . "code.cloudfoundry.org/cli/v8/util/randomword" - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Generator", func() { - var gen Generator = NewGenerator() + gen := NewGenerator() Describe("RandomAdjective", func() { It("generates a random adjective each time it is called", func() { diff --git a/util/randomword/randomword_suite_test.go b/util/randomword/randomword_suite_test.go index e19bc398e9e..2f6ebd45a26 100644 --- a/util/randomword/randomword_suite_test.go +++ b/util/randomword/randomword_suite_test.go @@ -1,7 +1,7 @@ package randomword_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/sorting/alphabetic_test.go b/util/sorting/alphabetic_test.go index 807056a0308..53a57b84174 100644 --- a/util/sorting/alphabetic_test.go +++ b/util/sorting/alphabetic_test.go @@ -3,10 +3,9 @@ package sorting_test import ( "sort" - . "code.cloudfoundry.org/cli/util/sorting" + . "code.cloudfoundry.org/cli/v8/util/sorting" - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/util/sorting/sorting_suite_test.go b/util/sorting/sorting_suite_test.go index ad6b83ae553..f11f3692b98 100644 --- a/util/sorting/sorting_suite_test.go +++ b/util/sorting/sorting_suite_test.go @@ -1,7 +1,7 @@ package sorting_test import ( - . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "testing" diff --git a/util/tls_test.go b/util/tls_test.go index 96e6570d2c1..b3df44184cd 100644 --- a/util/tls_test.go +++ b/util/tls_test.go @@ -5,8 +5,8 @@ import ( "crypto/x509" "encoding/pem" - . "code.cloudfoundry.org/cli/util" - . "github.com/onsi/ginkgo" + . "code.cloudfoundry.org/cli/v8/util" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -66,6 +66,7 @@ RVNEplh5ZEYbbWclddUBf46JPRU/eEu4JMqOJOykTdwbByFa3909Bzs= }) It("adds them to the trusted CAs", func() { + //nolint:staticcheck Expect(tlsConfig.RootCAs.Subjects()).To(ContainElement(ContainSubstring("Cloud Foundry"))) }) }) diff --git a/util/trace/trace.go b/util/trace/trace.go new file mode 100644 index 00000000000..3bd530f1e24 --- /dev/null +++ b/util/trace/trace.go @@ -0,0 +1,25 @@ +package trace + +import ( + "crypto/rand" + "encoding/hex" + "strings" + + "github.com/google/uuid" +) + +// GenerateUUIDTraceID returns a UUID v4 string with the dashes removed as a 32 lower-hex encoded string. +func GenerateUUIDTraceID() string { + uuidV4 := uuid.New() + return strings.ReplaceAll(uuidV4.String(), "-", "") +} + +// GenerateRandomTraceID returns a random hex string of the given length. +func GenerateRandomTraceID(length int) string { + b := make([]byte, length/2) + if _, err := rand.Read(b); err != nil { + panic(err) + } + + return hex.EncodeToString(b) +} diff --git a/util/trace/trace_suite_test.go b/util/trace/trace_suite_test.go new file mode 100644 index 00000000000..943b695d17c --- /dev/null +++ b/util/trace/trace_suite_test.go @@ -0,0 +1,13 @@ +package trace_test + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "testing" +) + +func TestTrace(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Trace Suite") +} diff --git a/util/trace/trace_test.go b/util/trace/trace_test.go new file mode 100644 index 00000000000..974a5fcf354 --- /dev/null +++ b/util/trace/trace_test.go @@ -0,0 +1,19 @@ +package trace_test + +import ( + "code.cloudfoundry.org/cli/v8/util/trace" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("GenerateHex", func() { + It("returns random trace id", func() { + Expect(trace.GenerateUUIDTraceID()).To(HaveLen(32)) + }) +}) + +var _ = Describe("GenerateRandomTraceID", func() { + It("returns random trace id", func() { + Expect(trace.GenerateRandomTraceID(16)).To(HaveLen(16)) + }) +}) diff --git a/util/ui/config.go b/util/ui/config.go index f17cd6e3802..33145ced072 100644 --- a/util/ui/config.go +++ b/util/ui/config.go @@ -1,6 +1,6 @@ package ui -import "code.cloudfoundry.org/cli/util/configv3" +import "code.cloudfoundry.org/cli/v8/util/configv3" //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . Config diff --git a/util/ui/i18n.go b/util/ui/i18n.go index 38b5c101f37..3aa2eb03b6a 100644 --- a/util/ui/i18n.go +++ b/util/ui/i18n.go @@ -7,7 +7,7 @@ import ( "strings" "text/template" - "code.cloudfoundry.org/cli/i18n/resources" + "code.cloudfoundry.org/cli/v8/i18n/resources" log "github.com/sirupsen/logrus" "golang.org/x/text/language" ) @@ -63,7 +63,7 @@ func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) { } // ParseLocale will return a locale formatted as "-" for all non-Chinese lanagues. For Chinese, it will return +// code>" for all non-Chinese languages. For Chinese, it will return // "zh-