diff --git a/cmd/api-server/main.go b/cmd/api-server/main.go index 7bca30f8f88..bb388683137 100644 --- a/cmd/api-server/main.go +++ b/cmd/api-server/main.go @@ -535,6 +535,7 @@ func main() { EnvID: cfg.TestkubeProEnvID, OrgID: cfg.TestkubeProOrgID, Migrate: cfg.TestkubeProMigrate, + ConnectionTimeout: cfg.TestkubeProConnectionTimeout, } api.WithProContext(&proContext) diff --git a/go.mod b/go.mod index 81ed4455878..716851edc56 100644 --- a/go.mod +++ b/go.mod @@ -188,7 +188,7 @@ require ( golang.org/x/time v0.3.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.31.0 + google.golang.org/protobuf v1.32.0 gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 3503a6a7c5b..c903a6d5a9b 100644 --- a/go.sum +++ b/go.sum @@ -960,6 +960,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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= diff --git a/internal/config/config.go b/internal/config/config.go index 6de38388193..84eeaa28077 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -72,6 +72,7 @@ type Config struct { TestkubeProEnvID string `envconfig:"TESTKUBE_PRO_ENV_ID" default:""` TestkubeProOrgID string `envconfig:"TESTKUBE_PRO_ORG_ID" default:""` TestkubeProMigrate string `envconfig:"TESTKUBE_PRO_MIGRATE" default:"false"` + TestkubeProConnectionTimeout int `envconfig:"TESTKUBE_PRO_CONNECTION_TIMEOUT" default:"10"` TestkubeWatcherNamespaces string `envconfig:"TESTKUBE_WATCHER_NAMESPACES" default:""` GraphqlPort string `envconfig:"TESTKUBE_GRAPHQL_PORT" default:"8070"` TestkubeRegistry string `envconfig:"TESTKUBE_REGISTRY" default:""` diff --git a/internal/config/procontext.go b/internal/config/procontext.go index 163d74297ae..24831170d5f 100644 --- a/internal/config/procontext.go +++ b/internal/config/procontext.go @@ -11,4 +11,5 @@ type ProContext struct { EnvID string OrgID string Migrate string + ConnectionTimeout int } diff --git a/licenses/TCL.txt b/licenses/TCL.txt new file mode 100644 index 00000000000..ee5b74c2386 --- /dev/null +++ b/licenses/TCL.txt @@ -0,0 +1,391 @@ +Testkube Community License Agreement + +Please read this Testkube Community License Agreement (the “Agreement”) +carefully before using Testkube (as defined below), which is offered by +Testkube or its affiliated Legal Entities (“Testkube”). + +By accessing, installing, downloading or in any manner using Testkube, +You agree that You have read and agree to be bound by the terms of this +Agreement. If You are accessing Testkube on behalf of a Legal Entity, +You represent and warrant that You have the authority to agree to these +terms on its behalf and the right to bind that Legal Entity to this +Agreement. Use of Testkube is expressly conditioned upon Your assent to +all the terms of this Agreement, as well as the other Testkube agreements, +including the Testkube Privacy Policy and Testkube Terms and Conditions, +accessible at: https://testkube.io/privacy-policy and +https://testkube.io/terms-and-conditions. + +1. Definitions. In addition to other terms defined elsewhere in this Agreement +and in the other Testkube agreements, the terms below have the following +meanings. + +(a) “Testkube” shall mean the Test Orchestration and Execution software +provided by Testkube, including both Testkube Core and Testkube Pro, as +defined below. + +(b) “Testkube Core” shall mean the version and features of Testkube designated +as free of charge at https://testkube.io/pricing and available at +https://github.com/kubeshop/testkube pursuant to the terms of the MIT license. + +(c) “Testkube Pro” shall mean the version of Testkube which includes the +additional paid features of Testkube designated at +https://testkube.io/pricing and made available by Testkube, also at +https://github.com/kubeshop/testkube, the use of which is subject to additional +terms set out below. + +(d) “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 Testkube 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 Testkube 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, +Testkube 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.” + +(e) “Contributor” shall mean any copyright owner or individual or Legal Entity +authorized by the copyright owner, other than Testkube, from whom Testkube +receives a Contribution that Testkube subsequently incorporates within the Work. + +(f) “Derivative Works” shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work, such as a translation, abridgement, +condensation, or any other recasting, transformation, or adaptation 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. You may create certain Derivative Works of Testkube Pro (“Pro +Derivative Works”, as defined below) provided that such Pro Derivative Works +are solely created, distributed, and accessed for Your internal use, and are +not created, distributed, or accessed in such a way that the Pro Derivative +Works would modify, circumvent, or otherwise bypass controls implemented, if +any, to ensure that Testkube Pro users comply with the terms of the Paid Pro +License. Notwithstanding anything contained herein to the contrary, You may not +modify or alter the Source of Testkube Pro absent Testkube’s prior express +written permission. If You have any questions about creating Pro Derivative +Works or otherwise modifying or redistributing Testkube Pro, please contact +Testkube at support@testkube.io. + +(g) “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. + +(h) “License” shall mean the terms and conditions for use, reproduction, and +distribution of a Work as defined by this Agreement. + +(i) “Licensor” shall mean Testkube or a Contributor, as applicable. + +(j) “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. + +(k) “Source” form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, and +configuration files. + +(l) “Third Party Works” shall mean Works, including Contributions, and other +technology owned by a person or Legal Entity other than Testkube, as indicated +by a copyright notice that is included in or attached to such Works or technology. + +(m) “Work” shall mean the work of authorship, whether in Source or Object form, +made available under a License, as indicated by a copyright notice that is +included in or attached to the work. + +(n) “You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +2. Licenses. + +(a) License to Testkube Core. The License for the applicable version of +Testkube Core can be found on the Testkube Licensing FAQs page and in the +applicable license file within the Testkube GitHub repository(ies). Testkube +Core is a no-cost, entry-level license and as such, contains the following +disclaimers: NOTWITHSTANDING ANYTHING TO THE CONTRARY HEREIN, TESTKUBE CORE +IS PROVIDED “AS IS” AND “AS AVAILABLE”, AND ALL EXPRESS OR IMPLIED WARRANTIES +ARE EXCLUDED AND DISCLAIMED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND ANY +WARRANTIES ARISING BY STATUTE OR OTHERWISE IN LAW OR FROM COURSE OF DEALING, +COURSE OF PERFORMANCE, OR USE IN TRADE. For clarity, the terms of this Agreement, +other than the relevant definitions in Section 1 and this Section 2(a) do not +apply to Testkube Core. + +(b) License to Testkube Pro. + +(i) Grant of Copyright License: Subject to the terms of this Agreement, Licensor +hereby grants to You a worldwide, non-exclusive, non-transferable limited +license to reproduce, prepare Pro Derivative Works (as defined below) of, +publicly display, publicly perform, sublicense, and distribute Testkube Pro for +Your business purposes, for so long as You are not in violation of this +Section 2(b) and are current on all payments required by Section 4 below. + +(ii) Grant of Patent License: Subject to the terms of this Agreement, Licensor +hereby grants to You a worldwide, non-exclusive, non-transferable limited patent +license to make, have made, use, and import Testkube Pro, where such license +applies only to those patent claims licensable by Licensor 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. + +(iii) License to Third Party Works: From time to time Testkube may use, or +provide You access to, Third Party Works in connection with Testkube Pro. You +acknowledge and agree that in addition to this Agreement, Your use of Third Party +Works is subject to all other terms and conditions set forth in the License +provided with or contained in such Third Party Works. Some Third Party Works may +be licensed to You solely for use with Testkube Pro under the terms of a third +party License, or as otherwise notified by Testkube, and not under the terms of +this Agreement. You agree that the owners and third party licensors of Third +Party Works are intended third party beneficiaries to this Agreement, and You +agree to abide by all third party terms and conditions and licenses. + +3. Support. From time to time, in its sole discretion, Testkube may offer +professional services or support for Testkube, which may now or in the future be +subject to additional fees, as outlined at https://testkube.io/pricing. + +4. Fees for Testkube Pro or Testkube Support. + +(a) Fees. The License to Testkube Pro is conditioned upon Your entering into a +subscription agreement with Testkube for its use (a “Paid Pro License”) and +timely paying Testkube for such Paid Pro License; provided that features of +Testkube Pro that are features of Testkube Core and are not designated as “Pro +features” at https://testkube.io/pricing may be used for free under the terms of +the Agreement without a Paid Pro License. Testkube Pro may at its discretion +include within Testkube Pro certain Source code solely intended to determine +Your compliance with the Paid Pro License which may be accessed without a Paid +Pro License, provided that under no circumstances may You modify Testkube Pro +to circumvent the Paid Pro License requirement. Any professional services or +support for Testkube may also be subject to Your payment of fees, which will be +specified by Testkube when you sign up to receive such professional services or +support. Testkube reserves the right to change the fees at any time with prior +written notice; for recurring fees, any such adjustments will take effect as of +the next pay period. + +(b) Overdue Payments and Taxes. Overdue payments are subject to a service charge +equal to the lesser of 1.5% per month or the maximum legal interest rate allowed +by law, and You shall pay all Testkube reasonable costs of collection, including +court costs and attorneys’ fees. Fees are stated and payable in U.S. dollars and +are exclusive of all sales, use, value added and similar taxes, duties, +withholdings and other governmental assessments (but excluding taxes based on +Testkube income) that may be levied on the transactions contemplated by this +Agreement in any jurisdiction, all of which are Your responsibility unless you +have provided Testkube with a valid tax-exempt certificate. If You owe Testkube +overdue payments, Testkube reserves the right to revoke any license(s) granted +by this Agreement and revoke to Your access to Testkube Core and to Testkube Pro. + +(c) Record-keeping and Audit. If fees for Testkube Pro are based on the number +of environments running on Testkube Pro or another use-based unit of measurement, +including number of users, You must maintain complete and accurate records with +respect Your use of Testkube Pro and will provide such records to Testkube for +inspection or audit upon Testkube’s reasonable request. If an inspection or +audit uncovers additional usage by You for which fees are owed under this +Agreement, then You shall pay for such additional usage at Testkube’s +then-current rates. + +5. Trial License. If You have signed up for a trial or evaluation of Testkube +Pro, Your License to Testkube Pro is granted without charge for the trial or +evaluation period specified when You signed up, or if no term was specified, for +forty-five (45) calendar days, provided that Your License is granted solely for +purposes of Your internal evaluation of Testkube Pro during the trial or +evaluation period (a “Trial License”). You may not use Testkube Pro or any +Testkube Pro features under a Trial License more than once in any twelve (12) +month period. Testkube may revoke a Trial License at any time and for any reason. +Sections 3, 4, 9 and 11 of this Agreement do not apply to Trial Licenses. + +6. 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, including for internal purposes at Your Legal Entities, 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” or equivalent 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 or equivalent files are for informational purposes only +and do not modify the License. You may add Your own attribution notices within +Derivative Works that You distribute for Your internal use, 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 not create Derivative Works, including Pro Derivative Works (as defined +below), which add Your own copyright statements or 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. All Derivative +Works, including Your use, reproduction, and distribution of the Work, must +comply in all respects with the conditions stated in this License. + +(e) Pro Derivative Works: Derivative Works of Testkube Pro (“Pro Derivative +Works”) may only be made, reproduced and distributed, without modifications, in +Source or Object form, provided that such Pro Derivative Works are solely for +Your internal use. Each Pro Derivative Work shall be governed by this Agreement, +shall include a License to Testkube Pro, and thus will be subject to the payment +of fees to Testkube by any user of the Pro Derivative Work. + +7. Submission of Contributions. Unless You explicitly state otherwise, any +Contribution submitted for inclusion in Testkube Pro by You to Testkube shall be +under the terms and conditions of this Agreement, without any additional terms +or conditions, payments of royalties or otherwise to Your benefit. Testkube may +at any time, at its sole discretion, elect for the Contribution to be subject to +the Paid Pro License. If You wish to reserve any rights regarding Your +Contribution, You must contact Testkube at support@testkube.io prior to +submitting the Contribution. + +8. Trademarks. This License does not grant permission to use the trade names, +trademarks, service marks, or product names of Licensor, except as required for +reasonable and customary use in describing the origin of the Work and reproducing +the content of the NOTICE or equivalent file. + +9. Limited Warranty. + +(a) Warranties. Subject to the terms of the Paid Pro License, or any other +agreement between You and Testkube which governs the terms of Your access to +Testkube Pro, Testkube warrants to You that: (i) Testkube Pro will materially +perform in accordance with the applicable documentation for thirty (30) days +after initial delivery to You; and (ii) any professional services performed by +Testkube under this Agreement will be performed in a workmanlike manner, in +accordance with general industry standards. + +(b) Exclusions. Testkube’s warranties in this Section 9 do not extend to problems +that result from: (i) Your failure to implement updates issued by Testkube during +the warranty period; (ii) any alterations or additions (including Pro Derivative +Works and Contributions) to Testkube not performed by or at the direction of +Testkube; (iii) failures that are not reproducible by Testkube; (iv) operation +of Testkube Pro in violation of this Agreement or not in accordance with its +documentation; (v) failures caused by software, hardware, or products not +licensed or provided by Testkube hereunder; or (vi) Third Party Works. + +(c) Remedies. In the event of a breach of a warranty under this Section 9, +Testkube will, at its discretion and cost, either repair, replace or re-perform +the applicable Works or services or refund a portion of fees previously paid to +Testkube that are associated with the defective Works or services. This is Your +exclusive remedy, and Testkube’s sole liability, arising in connection with the +limited warranties herein and shall, in all cases, be limited to the fees paid +to Testkube in the three (3) months preceding the delivery of the defective Works +or services. + +10. Disclaimer of Warranty. Except as set out in Section 9, unless required by +applicable law, 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, arising out of course of dealing, course of +performance, or usage in trade, including, without limitation, any warranties +or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, CORRECTNESS, +RELIABILITY, or FITNESS FOR A PARTICULAR PURPOSE, all of which are hereby +disclaimed. You are solely responsible for determining the appropriateness of +using or redistributing Works and assume any risks associated with Your exercise +of permissions under the applicable License for such Works. + +11. Limited Indemnity. + +(a) Indemnity. Testkube will defend, indemnify and hold You harmless against +any third party claims, liabilities or expenses incurred (including reasonable +attorneys’ fees), as well as amounts finally awarded in a settlement or a +non-appealable judgement by a court (“Losses”), to the extent arising from any +claim or allegation by a third party that Testkube Pro infringes or +misappropriates a valid United States patent, copyright, or trade secret right +of a third party; provided that You give Testkube: (i) prompt written notice of +any such claim or allegation; (ii) sole control of the defense and settlement +thereof; and (iii) reasonable cooperation and assistance in such defense or +settlement. If any Work within Testkube Pro becomes or in Testkube’s opinion is +likely to become, the subject of an injunction, Testkube may, at its option, +(A) procure for You the right to continue using such Work, (B) replace or modify +such Work so that it becomes non-infringing without substantially compromising +its functionality, or, if (A) and (B) are not commercially practicable, then (C) +terminate Your license to the allegedly infringing Work and refund to You a +prorated portion of the prepaid and unearned fees for such infringing Work. The +foregoing comprises the entire liability of Testkube with respect to infringement +of patents, copyrights, trade secrets, or other intellectual property rights. + +(b) Exclusions. The foregoing obligations on Testkube shall not apply to: (i) +Works modified by any party other than Testkube (including Pro Derivative Works +and Contributions) where the alleged infringement relates to such modification, +(ii) Works combined or bundled with any products, processes, or materials not +provided by Testkube where the alleged infringement relates to such combination, +(iii) use of a version of Testkube Pro other than the version that was current at +the time of such use, as long as a non-infringing version had been released at +the time of the alleged infringement, (iv) any Works created to Your +specifications, (v) infringement or misappropriation of any proprietary or +intellectual property right in which You have an interest, or (vi) Third Party +Works. You will defend, indemnify, and hold Testkube harmless against any Losses +arising from any such claim or allegation as described in the scenarios in this +Section 11(b), subject to conditions reciprocal to those in Section 11(a). + +12. Limitation of Liability. In no event and under no legal or equitable theory, +whether in tort (including negligence), contract, or otherwise, unless required +by applicable law (such as deliberate and grossly negligent acts), and +notwithstanding anything in this Agreement to the contrary, shall Licensor or +any Contributor be liable to You for (i) any amounts in excess, in the aggregate, +of the fees paid by You to Testkube under this Agreement in the twelve (12) +months preceding the date the first cause of liability arose, or (ii) any +indirect, special, incidental, punitive, exemplary, reliance, or consequential +damages of any character arising as a result of this Agreement or out of the use +or inability to use the Work (including but not limited to damages for loss of +goodwill, profits, data or data use, work stoppage, computer failure or +malfunction, cost of procurement of substitute goods, technology or services, +or any and all other commercial damages or losses), even if such Licensor or +Contributor has been advised of the possibility of such damages. THESE +LIMITATIONS SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF +ANY LIMITED REMEDY. + +13. General. + +(a) Relationship of Parties. You and Testkube are independent contractors, and +nothing herein shall be deemed to constitute either party as the agent or +representative of the other or both parties as joint venturers or partners for +any purpose. + +(b) Export Control. You shall comply with the U.S. Foreign Corrupt Practices Act +and all applicable export laws, restrictions and regulations of the U.S. +Department of Commerce, U.S. Department of Treasury, and any other applicable +U.S. and foreign authority(ies). + +(c) Assignment. This Agreement and the rights and obligations herein may not be +assigned or transferred, in whole or in part, by You without the prior written +consent of Testkube. Any assignment in violation of this provision is void. This +Agreement shall be binding upon, and inure to the benefit of, the successors and +permitted assigns of the parties. + +(d) Governing Law. This Agreement shall be governed by and construed under the +laws of the State of Delaware and the United States without regard to conflicts +of laws provisions thereof, and without regard to the Uniform Computer +Information Transactions Act. + +(e) Attorneys’ Fees. In any action or proceeding to enforce rights under this +Agreement, the prevailing party shall be entitled to recover its costs, expenses, +and attorneys’ fees. + +(f) Severability. If any provision of this Agreement is held to be invalid, +illegal, or unenforceable in any respect, that provision shall be limited or +eliminated to the minimum extent necessary so that this Agreement otherwise +remains in full force and effect and enforceable. + +(g) Entire Agreement; Waivers; Modification. This Agreement constitutes the +entire agreement between the parties relating to the subject matter hereof and +supersedes all proposals, understandings, or discussions, whether written or +oral, relating to the subject matter of this Agreement and all past dealing or +industry custom. The failure of either party to enforce its rights under this +Agreement at any time for any period shall not be construed as a waiver of such +rights. No changes, modifications or waivers to this Agreement will be effective +unless in writing and signed by both parties. diff --git a/pkg/cloud/data/config/commands.go b/pkg/cloud/data/config/commands.go index b6a2668880b..e4ab0d4bdb5 100644 --- a/pkg/cloud/data/config/commands.go +++ b/pkg/cloud/data/config/commands.go @@ -7,4 +7,5 @@ const ( CmdConfigGetTelemetryEnabled executor.Command = "get_telemetry_enabled" CmdConfigGet executor.Command = "get" CmdConfigUpsert executor.Command = "upsert" + CmdConfigGetOrganizationPlan executor.Command = "get_org_plan" ) diff --git a/pkg/executor/common.go b/pkg/executor/common.go index c10723a8b4b..0a281c8dca2 100644 --- a/pkg/executor/common.go +++ b/pkg/executor/common.go @@ -123,6 +123,10 @@ var RunnerEnvVars = []corev1.EnvVar{ Name: "RUNNER_PRO_API_SKIP_VERIFY", Value: getOr("TESTKUBE_PRO_SKIP_VERIFY", "false"), }, + { + Name: "RUNNER_PRO_CONNECTION_TIMEOUT", + Value: getOr("TESTKUBE_PRO_CONNECTION_TIMEOUT", "10"), + }, { Name: "RUNNER_DASHBOARD_URI", Value: os.Getenv("TESTKUBE_DASHBOARD_URI"), diff --git a/pkg/executor/containerexecutor/containerexecutor_test.go b/pkg/executor/containerexecutor/containerexecutor_test.go index dfe0776e5c2..f11ac56f194 100644 --- a/pkg/executor/containerexecutor/containerexecutor_test.go +++ b/pkg/executor/containerexecutor/containerexecutor_test.go @@ -159,6 +159,7 @@ func TestNewExecutorJobSpecWithArgs(t *testing.T) { {Name: "RUNNER_PRO_API_URL", Value: ""}, {Name: "RUNNER_PRO_API_TLS_INSECURE", Value: "false"}, {Name: "RUNNER_PRO_API_SKIP_VERIFY", Value: "false"}, + {Name: "RUNNER_PRO_CONNECTION_TIMEOUT", Value: "10"}, {Name: "RUNNER_CLOUD_MODE", Value: "false"}, // DEPRECATED {Name: "RUNNER_CLOUD_API_KEY", Value: ""}, // DEPRECATED {Name: "RUNNER_CLOUD_API_URL", Value: ""}, // DEPRECATED diff --git a/pkg/tcl/README.md b/pkg/tcl/README.md new file mode 100644 index 00000000000..19ed9a40b45 --- /dev/null +++ b/pkg/tcl/README.md @@ -0,0 +1,7 @@ +# Testkube Operator - TCL Package + +This folder contains special code with the Testkube Community license. + +## License + +The code in this folder is licensed under the Testkube Community License. Please see the [LICENSE](../../licenses/TCL.txt) file and consult the [FAQ](../../docs/docs/articles/testkube-licensing-FAQ.md) for more information. diff --git a/pkg/tcl/checktcl/organization_plan.go b/pkg/tcl/checktcl/organization_plan.go new file mode 100644 index 00000000000..8d38df6ec6f --- /dev/null +++ b/pkg/tcl/checktcl/organization_plan.go @@ -0,0 +1,50 @@ +// Copyright 2024 Testkube. +// +// Licensed as a Testkube Pro file under the Testkube Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt + +package checktcl + +// Enterprise / Pro mode. +type OrganizationPlanTestkubeMode string + +const ( + OrganizationPlanTestkubeModeEnterprise OrganizationPlanTestkubeMode = "enterprise" + // TODO: Use "pro" in the future when refactoring TK Pro API server to use "pro" instead of "cloud" + OrganizationPlanTestkubeModePro OrganizationPlanTestkubeMode = "cloud" +) + +// Ref: #/components/schemas/PlanStatus +type PlanStatus string + +const ( + PlanStatusActive PlanStatus = "Active" + PlanStatusCanceled PlanStatus = "Canceled" + PlanStatusIncomplete PlanStatus = "Incomplete" + PlanStatusIncompleteExpired PlanStatus = "IncompleteExpired" + PlanStatusPastDue PlanStatus = "PastDue" + PlanStatusTrailing PlanStatus = "Trailing" + PlanStatusUnpaid PlanStatus = "Unpaid" + PlanStatusDeleted PlanStatus = "Deleted" + PlanStatusLocked PlanStatus = "Locked" + PlanStatusBlocked PlanStatus = "Blocked" +) + +// Ref: #/components/schemas/OrganizationPlan +type OrganizationPlan struct { + // Enterprise / Pro mode. + TestkubeMode OrganizationPlanTestkubeMode `json:"testkubeMode"` + // Is current plan trial. + IsTrial bool `json:"isTrial"` + PlanStatus PlanStatus `json:"planStatus"` +} + +type GetOrganizationPlanRequest struct{} +type GetOrganizationPlanResponse struct { + TestkubeMode string + IsTrial bool + PlanStatus string +} diff --git a/pkg/tcl/checktcl/subscription.go b/pkg/tcl/checktcl/subscription.go new file mode 100644 index 00000000000..0759e3b9061 --- /dev/null +++ b/pkg/tcl/checktcl/subscription.go @@ -0,0 +1,83 @@ +// Copyright 2024 Testkube. +// +// Licensed as a Testkube Pro file under the Testkube Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt + +package checktcl + +import ( + "context" + "encoding/json" + + "github.com/pkg/errors" + "google.golang.org/grpc" + + "github.com/kubeshop/testkube/internal/config" + "github.com/kubeshop/testkube/pkg/cloud" + cloudconfig "github.com/kubeshop/testkube/pkg/cloud/data/config" + "github.com/kubeshop/testkube/pkg/cloud/data/executor" +) + +type SubscriptionChecker struct { + proContext config.ProContext + orgPlan *OrganizationPlan +} + +// NewSubscriptionChecker creates a new subscription checker using the agent token +func NewSubscriptionChecker(ctx context.Context, proContext config.ProContext, cloudClient cloud.TestKubeCloudAPIClient, grpcConn *grpc.ClientConn) (*SubscriptionChecker, error) { + executor := executor.NewCloudGRPCExecutor(cloudClient, grpcConn, proContext.APIKey) + + req := GetOrganizationPlanRequest{} + response, err := executor.Execute(ctx, cloudconfig.CmdConfigGetOrganizationPlan, req) + if err != nil { + return nil, err + } + + var commandResponse GetOrganizationPlanResponse + if err := json.Unmarshal(response, &commandResponse); err != nil { + return nil, err + } + + subscription := OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeMode(commandResponse.TestkubeMode), + IsTrial: commandResponse.IsTrial, + PlanStatus: PlanStatus(commandResponse.PlanStatus), + } + + return &SubscriptionChecker{proContext: proContext, orgPlan: &subscription}, nil +} + +// GetCurrentOrganizationPlan returns current organization plan +func (c *SubscriptionChecker) GetCurrentOrganizationPlan() (*OrganizationPlan, error) { + if c.orgPlan == nil { + return nil, errors.New("organization plan is not set") + } + return c.orgPlan, nil +} + +// IsOrgPlanEnterprise checks if organization plan is enterprise +func (c *SubscriptionChecker) IsOrgPlanEnterprise() (bool, error) { + if c.orgPlan == nil { + return false, errors.New("organization plan is not set") + } + return c.orgPlan.TestkubeMode == OrganizationPlanTestkubeModeEnterprise, nil +} + +// IsOrgPlanCloud checks if organization plan is cloud +func (c *SubscriptionChecker) IsOrgPlanPro() (bool, error) { + if c.orgPlan == nil { + return false, errors.New("organization plan is not set") + } + return c.orgPlan.TestkubeMode == OrganizationPlanTestkubeModePro, nil +} + +// IsOrgPlanActive checks if organization plan is active +func (c *SubscriptionChecker) IsOrgPlanActive() (bool, error) { + if c.orgPlan == nil { + return false, errors.New("organization plan is not set") + } + return c.orgPlan.PlanStatus == PlanStatusActive, nil +} diff --git a/pkg/tcl/checktcl/subscription_test.go b/pkg/tcl/checktcl/subscription_test.go new file mode 100644 index 00000000000..fa662477a34 --- /dev/null +++ b/pkg/tcl/checktcl/subscription_test.go @@ -0,0 +1,192 @@ +// Copyright 2024 Testkube. +// +// Licensed as a Testkube Pro file under the Testkube Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt + +package checktcl + +import ( + "reflect" + "testing" +) + +func TestSubscriptionChecker_GetCurrentOrganizationPlan(t *testing.T) { + tests := []struct { + name string + orgPlan *OrganizationPlan + want *OrganizationPlan + wantErr bool + }{ + { + name: "Org plan does not exist", + wantErr: true, + }, + { + name: "Org plan exists", + orgPlan: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModeEnterprise, + IsTrial: false, + PlanStatus: PlanStatusActive, + }, + want: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModeEnterprise, + IsTrial: false, + PlanStatus: PlanStatusActive, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &SubscriptionChecker{ + orgPlan: tt.orgPlan, + } + got, err := c.GetCurrentOrganizationPlan() + if (err != nil) != tt.wantErr { + t.Errorf("SubscriptionChecker.GetCurrentOrganizationPlan() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("SubscriptionChecker.GetCurrentOrganizationPlan() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestSubscriptionChecker_IsOrgPlanEnterprise(t *testing.T) { + tests := []struct { + name string + orgPlan *OrganizationPlan + want bool + wantErr bool + }{ + { + name: "no org plan", + wantErr: true, + }, + { + name: "enterprise org plan", + orgPlan: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModeEnterprise, + }, + want: true, + wantErr: false, + }, + { + name: "pro org plan", + orgPlan: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModePro, + }, + want: false, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &SubscriptionChecker{ + orgPlan: tt.orgPlan, + } + got, err := c.IsOrgPlanEnterprise() + if (err != nil) != tt.wantErr { + t.Errorf("SubscriptionChecker.IsOrgPlanEnterprise() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("SubscriptionChecker.IsOrgPlanEnterprise() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestSubscriptionChecker_IsOrgPlanPro(t *testing.T) { + tests := []struct { + name string + orgPlan *OrganizationPlan + want bool + wantErr bool + }{ + { + name: "no org plan", + wantErr: true, + }, + { + name: "enterprise org plan", + orgPlan: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModeEnterprise, + }, + want: false, + wantErr: false, + }, + { + name: "pro org plan", + orgPlan: &OrganizationPlan{ + TestkubeMode: OrganizationPlanTestkubeModePro, + }, + want: true, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &SubscriptionChecker{ + orgPlan: tt.orgPlan, + } + got, err := c.IsOrgPlanPro() + if (err != nil) != tt.wantErr { + t.Errorf("SubscriptionChecker.IsOrgPlanPro() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("SubscriptionChecker.IsOrgPlanPro() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestSubscriptionChecker_IsOrgPlanActive(t *testing.T) { + tests := []struct { + name string + orgPlan *OrganizationPlan + want bool + wantErr bool + }{ + { + name: "no org plan", + wantErr: true, + }, + { + name: "active org plan", + orgPlan: &OrganizationPlan{ + PlanStatus: PlanStatusActive, + }, + want: true, + wantErr: false, + }, + { + name: "inactive org plan", + orgPlan: &OrganizationPlan{ + PlanStatus: PlanStatusUnpaid, + }, + want: false, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &SubscriptionChecker{ + orgPlan: tt.orgPlan, + } + got, err := c.IsOrgPlanActive() + if (err != nil) != tt.wantErr { + t.Errorf("SubscriptionChecker.IsOrgPlanActive() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("SubscriptionChecker.IsOrgPlanActive() = %v, want %v", got, tt.want) + } + }) + } +}