-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
223 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package diagnostics | ||
|
||
import ( | ||
"github.com/kubeshop/testkube/pkg/diagnostics" | ||
"github.com/kubeshop/testkube/pkg/diagnostics/validators/deps" | ||
"github.com/kubeshop/testkube/pkg/ui" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func RegisterInstallValidators(_ *cobra.Command, d diagnostics.Diagnostics) { | ||
depsGroup := d.AddValidatorGroup("install.dependencies", nil) | ||
depsGroup.AddValidator(deps.NewKubectlDependencyValidator()) | ||
depsGroup.AddValidator(deps.NewHelmDependencyValidator()) | ||
} | ||
|
||
func NewInstallCheckCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "install", | ||
Aliases: []string{"ins", "i"}, | ||
Short: "Diagnose pre-installation dependencies", | ||
Run: RunInstallCheckFunc(), | ||
} | ||
|
||
cmd.Flags().StringP("key-override", "k", "", "Pass License key manually (we will not try to locate it automatically)") | ||
cmd.Flags().StringP("file-override", "f", "", "Pass License file manually (we will not try to locate it automatically)") | ||
|
||
return cmd | ||
} | ||
|
||
func RunInstallCheckFunc() func(cmd *cobra.Command, args []string) { | ||
return func(cmd *cobra.Command, args []string) { | ||
d := diagnostics.New() | ||
RegisterInstallValidators(cmd, d) | ||
|
||
err := d.Run() | ||
ui.ExitOnError("Running validations", err) | ||
ui.NL(2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package diagnostics | ||
|
||
import ( | ||
"github.com/kubeshop/testkube/pkg/diagnostics" | ||
"github.com/kubeshop/testkube/pkg/diagnostics/loader" | ||
"github.com/kubeshop/testkube/pkg/diagnostics/validators/license" | ||
"github.com/kubeshop/testkube/pkg/ui" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func RegisterLicenseValidators(cmd *cobra.Command, d diagnostics.Diagnostics) { | ||
|
||
namespace := cmd.Flag("namespace").Value.String() | ||
keyOverride := cmd.Flag("key-override").Value.String() | ||
fileOverride := cmd.Flag("file-override").Value.String() | ||
|
||
l, err := loader.GetLicenseConfig(namespace, "") | ||
ui.ExitOnError("loading license data", err) | ||
|
||
if keyOverride != "" { | ||
l.EnterpriseLicenseKey = keyOverride | ||
} | ||
if fileOverride != "" { | ||
l.EnterpriseLicenseFile = fileOverride | ||
} | ||
|
||
// License validator | ||
licenseKeyGroup := d.AddValidatorGroup("license.key", l.EnterpriseLicenseKey) | ||
if l.EnterpriseOfflineActivation { | ||
licenseKeyGroup.AddValidator(license.NewOfflineLicenseKeyValidator()) | ||
|
||
// for offline license also add license file validator | ||
licenseFileGroup := d.AddValidatorGroup("license.file", l.EnterpriseLicenseFile) | ||
licenseFileGroup.AddValidator(license.NewFileValidator()) | ||
|
||
offlineLicenseGroup := d.AddValidatorGroup("license.offline.check", l.EnterpriseLicenseFile) | ||
offlineLicenseGroup.AddValidator(license.NewOfflineLicenseValidator(l.EnterpriseLicenseKey, l.EnterpriseLicenseFile)) | ||
} else { | ||
licenseKeyGroup.AddValidator(license.NewOnlineLicenseKeyValidator()) | ||
} | ||
|
||
// common validator for both key types | ||
licenseKeyGroup.AddValidator(license.NewKeygenShValidator()) | ||
} | ||
|
||
func NewLicenseCheckCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "license", | ||
Aliases: []string{"lic", "l"}, | ||
Short: "Diagnose license errors", | ||
Run: RunLicenseCheckFunc(), | ||
} | ||
|
||
cmd.Flags().StringP("key-override", "k", "", "Pass License key manually (we will not try to locate it automatically)") | ||
cmd.Flags().StringP("file-override", "f", "", "Pass License file manually (we will not try to locate it automatically)") | ||
|
||
return cmd | ||
} | ||
|
||
func RunLicenseCheckFunc() func(cmd *cobra.Command, args []string) { | ||
return func(cmd *cobra.Command, args []string) { | ||
d := diagnostics.New() | ||
RegisterLicenseValidators(cmd, d) | ||
|
||
err := d.Run() | ||
ui.ExitOnError("Running validations", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.