fix: remove unused cobra args
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
This commit is contained in:
parent
4409beb18a
commit
7221812dfa
26 changed files with 84 additions and 72 deletions
2
Makefile
2
Makefile
|
|
@ -83,7 +83,7 @@ $(LOCALBIN):
|
|||
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
|
||||
|
||||
## Tool Versions
|
||||
GOLANGCI_LINT_VERSION ?= v1.55.2
|
||||
GOLANGCI_LINT_VERSION ?= v1.56.2
|
||||
|
||||
.PHONY: golangci-lint
|
||||
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. If wrong version is installed, it will be overwritten.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import (
|
|||
"github.com/cloudbase/garm/auth"
|
||||
"github.com/cloudbase/garm/metrics"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner"
|
||||
"github.com/cloudbase/garm/runner" //nolint:typecheck
|
||||
wsWriter "github.com/cloudbase/garm/websocket"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ var infoShowCmd = &cobra.Command{
|
|||
Short: "Show information",
|
||||
Long: `Show information about the current controller.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func init() {
|
|||
Short: "List configured github credentials",
|
||||
Long: `List the names of the github personal access tokens available to the garm.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ var enterpriseAddCmd = &cobra.Command{
|
|||
Short: "Add enterprise",
|
||||
Long: `Add a new enterprise to the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ var enterpriseListCmd = &cobra.Command{
|
|||
Short: "List enterprises",
|
||||
Long: `List all configured enterprises that are currently managed.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ var enterpriseShowCmd = &cobra.Command{
|
|||
Short: "Show details for one enterprise",
|
||||
Long: `Displays detailed information about a single enterprise.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ var enterpriseDeleteCmd = &cobra.Command{
|
|||
Short: "Removes one enterprise",
|
||||
Long: `Delete one enterprise from the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ var enterpriseUpdateCmd = &cobra.Command{
|
|||
Short: "Update enterprise",
|
||||
Long: `Update enterprise credentials or webhook secret.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Example usage:
|
|||
|
||||
garm-cli init --name=dev --url=https://runner.example.com --username=admin --password=superSecretPassword
|
||||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if cfg != nil {
|
||||
if cfg.HasManager(loginProfileName) {
|
||||
return fmt.Errorf("a manager with name %s already exists in your local config", loginProfileName)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var jobsListCmd = &cobra.Command{
|
|||
Short: "List jobs",
|
||||
Long: `List all jobs currently recorded in the system.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ var logCmd = &cobra.Command{
|
|||
SilenceUsage: true,
|
||||
Short: "Stream garm log",
|
||||
Long: `Stream all garm logging to the terminal.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt)
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ var metricsTokenCreateCmd = &cobra.Command{
|
|||
Short: "Create a metrics token",
|
||||
Long: `Create a metrics token.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var orgWebhookInstallCmd = &cobra.Command{
|
|||
Short: "Install webhook",
|
||||
Long: `Install webhook for an organization.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ var orgHookInfoShowCmd = &cobra.Command{
|
|||
Short: "Show webhook info",
|
||||
Long: `Show webhook info for an organization.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ var orgWebhookUninstallCmd = &cobra.Command{
|
|||
Short: "Uninstall webhook",
|
||||
Long: `Uninstall webhook for an organization.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ var orgAddCmd = &cobra.Command{
|
|||
Short: "Add organization",
|
||||
Long: `Add a new organization to the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ var orgUpdateCmd = &cobra.Command{
|
|||
Short: "Update organization",
|
||||
Long: `Update organization credentials or webhook secret.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ var orgListCmd = &cobra.Command{
|
|||
Short: "List organizations",
|
||||
Long: `List all configured organizations that are currently managed.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ var orgShowCmd = &cobra.Command{
|
|||
Short: "Show details for one organization",
|
||||
Long: `Displays detailed information about a single organization.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ var orgDeleteCmd = &cobra.Command{
|
|||
Short: "Removes one organization",
|
||||
Long: `Delete one organization from the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ var poolShowCmd = &cobra.Command{
|
|||
Short: "Show details for a runner",
|
||||
Long: `Displays a detailed view of a single runner.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ var poolDeleteCmd = &cobra.Command{
|
|||
Short: "Delete pool by ID",
|
||||
Long: `Delete one pool by referencing it's ID, regardless of repo or org.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ var poolAddCmd = &cobra.Command{
|
|||
Short: "Add pool",
|
||||
Long: `Add a new pool to a repository or organization.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ This command will list all currently defined profiles in the local configuration
|
|||
file of the garm client.
|
||||
`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ var profileDeleteCmd = &cobra.Command{
|
|||
Short: "Delete profile",
|
||||
Long: `Delete a profile from the local CLI configuration.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ var poolSwitchCmd = &cobra.Command{
|
|||
Short: "Switch to a different profile",
|
||||
Long: `Switch the CLI to a different profile.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ var profileAddCmd = &cobra.Command{
|
|||
Short: "Add profile",
|
||||
Long: `Create a profile for a new garm installation.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if cfg != nil {
|
||||
if cfg.HasManager(loginProfileName) {
|
||||
return fmt.Errorf("a manager with name %s already exists in your local config", loginProfileName)
|
||||
|
|
@ -180,7 +180,7 @@ This command will refresh the bearer token associated with an already defined ga
|
|||
installation, by performing a login.
|
||||
`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func init() {
|
|||
Short: "List all configured providers",
|
||||
Long: `List all cloud providers configured with the service.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ var repoWebhookInstallCmd = &cobra.Command{
|
|||
Short: "Install webhook",
|
||||
Long: `Install webhook for a repository.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ var repoHookInfoShowCmd = &cobra.Command{
|
|||
Short: "Show webhook info",
|
||||
Long: `Show webhook info for a repository.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ var repoWebhookUninstallCmd = &cobra.Command{
|
|||
Short: "Uninstall webhook",
|
||||
Long: `Uninstall webhook for a repository.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ var repoAddCmd = &cobra.Command{
|
|||
Short: "Add repository",
|
||||
Long: `Add a new repository to the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ var repoListCmd = &cobra.Command{
|
|||
Short: "List repositories",
|
||||
Long: `List all configured repositories that are currently managed.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ var repoUpdateCmd = &cobra.Command{
|
|||
Short: "Update repository",
|
||||
Long: `Update repository credentials or webhook secret.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ var repoShowCmd = &cobra.Command{
|
|||
Short: "Show details for one repository",
|
||||
Long: `Displays detailed information about a single repository.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ var repoDeleteCmd = &cobra.Command{
|
|||
Short: "Removes one repository",
|
||||
Long: `Delete one repository from the manager.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ var runnerShowCmd = &cobra.Command{
|
|||
Short: "Show details for a runner",
|
||||
Long: `Displays a detailed view of a single runner.`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ NOTE: An active runner cannot be removed from Github. You will have
|
|||
to either cancel the workflow or wait for it to finish.
|
||||
`,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if needsInit {
|
||||
return errNeedsInitError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ var versionCmd = &cobra.Command{
|
|||
Use: "version",
|
||||
SilenceUsage: true,
|
||||
Short: "Print version and exit",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Println(Version)
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import (
|
|||
"github.com/cloudbase/garm/database"
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/metrics"
|
||||
"github.com/cloudbase/garm/runner"
|
||||
"github.com/cloudbase/garm/runner" //nolint:typecheck
|
||||
runnerMetrics "github.com/cloudbase/garm/runner/metrics"
|
||||
garmUtil "github.com/cloudbase/garm/util"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
|
|
|
|||
7
database/sql/common_test.go
Normal file
7
database/sql/common_test.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package sql
|
||||
|
||||
const (
|
||||
wrongPassphrase = "wrong-passphrase"
|
||||
webhookSecret = "webhook-secret"
|
||||
falseString = "false"
|
||||
)
|
||||
|
|
@ -104,7 +104,7 @@ func (s *EnterpriseTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
@ -182,7 +182,7 @@ func (s *EnterpriseTestSuite) TestCreateEnterpriseInvalidDBPassphrase() {
|
|||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||
}
|
||||
// make sure we use a 'sqlDatabase' struct with a wrong 'cfg.Passphrase'
|
||||
cfg.Passphrase = "wrong-passphrase" // it must have a size different than 32
|
||||
cfg.Passphrase = wrongPassphrase // it must have a size different than 32
|
||||
sqlDB := &sqlDatabase{
|
||||
conn: conn,
|
||||
cfg: cfg,
|
||||
|
|
@ -321,7 +321,7 @@ func (s *EnterpriseTestSuite) TestUpdateEnterpriseInvalidEnterpriseID() {
|
|||
}
|
||||
|
||||
func (s *EnterpriseTestSuite) TestUpdateEnterpriseDBEncryptErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `enterprises` WHERE id = ? AND `enterprises`.`deleted_at` IS NULL ORDER BY `enterprises`.`id` LIMIT 1")).
|
||||
|
|
@ -354,8 +354,8 @@ func (s *EnterpriseTestSuite) TestUpdateEnterpriseDBSaveErr() {
|
|||
}
|
||||
|
||||
func (s *EnterpriseTestSuite) TestUpdateEnterpriseDBDecryptingErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = "webhook-secret"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = webhookSecret
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `enterprises` WHERE id = ? AND `enterprises`.`deleted_at` IS NULL ORDER BY `enterprises`.`id` LIMIT 1")).
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ func (s *InstancesTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ func (s *OrgTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
@ -182,7 +182,7 @@ func (s *OrgTestSuite) TestCreateOrganizationInvalidDBPassphrase() {
|
|||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||
}
|
||||
// make sure we use a 'sqlDatabase' struct with a wrong 'cfg.Passphrase'
|
||||
cfg.Passphrase = "wrong-passphrase" // it must have a size different than 32
|
||||
cfg.Passphrase = wrongPassphrase // it must have a size different than 32
|
||||
sqlDB := &sqlDatabase{
|
||||
conn: conn,
|
||||
cfg: cfg,
|
||||
|
|
@ -321,7 +321,7 @@ func (s *OrgTestSuite) TestUpdateOrganizationInvalidOrgID() {
|
|||
}
|
||||
|
||||
func (s *OrgTestSuite) TestUpdateOrganizationDBEncryptErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `organizations` WHERE id = ? AND `organizations`.`deleted_at` IS NULL ORDER BY `organizations`.`id` LIMIT 1")).
|
||||
|
|
@ -354,8 +354,8 @@ func (s *OrgTestSuite) TestUpdateOrganizationDBSaveErr() {
|
|||
}
|
||||
|
||||
func (s *OrgTestSuite) TestUpdateOrganizationDBDecryptingErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = "webhook-secret"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = webhookSecret
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `organizations` WHERE id = ? AND `organizations`.`deleted_at` IS NULL ORDER BY `organizations`.`id` LIMIT 1")).
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ import (
|
|||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
const (
|
||||
entityTypeEnterpriseName = "enterprise_id"
|
||||
entityTypeOrgName = "org_id"
|
||||
entityTypeRepoName = "repo_id"
|
||||
)
|
||||
|
||||
func (s *sqlDatabase) ListAllPools(_ context.Context) ([]params.Pool, error) {
|
||||
var pools []Pool
|
||||
|
||||
|
|
@ -92,11 +98,11 @@ func (s *sqlDatabase) getEntityPool(_ context.Context, entityType params.PoolTyp
|
|||
var fieldName string
|
||||
switch entityType {
|
||||
case params.RepositoryPool:
|
||||
fieldName = "repo_id"
|
||||
fieldName = entityTypeRepoName
|
||||
case params.OrganizationPool:
|
||||
fieldName = "org_id"
|
||||
fieldName = entityTypeOrgName
|
||||
case params.EnterprisePool:
|
||||
fieldName = "enterprise_id"
|
||||
fieldName = entityTypeEnterpriseName
|
||||
default:
|
||||
return Pool{}, fmt.Errorf("invalid entityType: %v", entityType)
|
||||
}
|
||||
|
|
@ -106,7 +112,6 @@ func (s *sqlDatabase) getEntityPool(_ context.Context, entityType params.PoolTyp
|
|||
err = q.Model(&Pool{}).
|
||||
Where(condition, u, entityID).
|
||||
First(&pool).Error
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return Pool{}, errors.Wrap(runnerErrors.ErrNotFound, "finding pool")
|
||||
|
|
@ -132,11 +137,11 @@ func (s *sqlDatabase) listEntityPools(_ context.Context, entityType params.PoolT
|
|||
var fieldName string
|
||||
switch entityType {
|
||||
case params.RepositoryPool:
|
||||
fieldName = "repo_id"
|
||||
fieldName = entityTypeRepoName
|
||||
case params.OrganizationPool:
|
||||
fieldName = "org_id"
|
||||
fieldName = entityTypeOrgName
|
||||
case params.EnterprisePool:
|
||||
fieldName = "enterprise_id"
|
||||
fieldName = entityTypeEnterpriseName
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid entityType: %v", entityType)
|
||||
}
|
||||
|
|
@ -169,11 +174,11 @@ func (s *sqlDatabase) findPoolByTags(id string, poolType params.PoolType, tags [
|
|||
var fieldName string
|
||||
switch poolType {
|
||||
case params.RepositoryPool:
|
||||
fieldName = "repo_id"
|
||||
fieldName = entityTypeRepoName
|
||||
case params.OrganizationPool:
|
||||
fieldName = "org_id"
|
||||
fieldName = entityTypeOrgName
|
||||
case params.EnterprisePool:
|
||||
fieldName = "enterprise_id"
|
||||
fieldName = entityTypeEnterpriseName
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid poolType: %v", poolType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func (s *PoolsTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ func (s *RepoTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
@ -197,7 +197,7 @@ func (s *RepoTestSuite) TestCreateRepositoryInvalidDBPassphrase() {
|
|||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||
}
|
||||
// make sure we use a 'sqlDatabase' struct with a wrong 'cfg.Passphrase'
|
||||
cfg.Passphrase = "wrong-passphrase" // it must have a size different than 32
|
||||
cfg.Passphrase = wrongPassphrase // it must have a size different than 32
|
||||
sqlDB := &sqlDatabase{
|
||||
conn: conn,
|
||||
cfg: cfg,
|
||||
|
|
@ -296,7 +296,7 @@ func (s *RepoTestSuite) TestListRepositoriesDBFetchErr() {
|
|||
}
|
||||
|
||||
func (s *RepoTestSuite) TestListRepositoriesDBDecryptingErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `repositories` WHERE `repositories`.`deleted_at` IS NULL")).
|
||||
|
|
@ -360,7 +360,7 @@ func (s *RepoTestSuite) TestUpdateRepositoryInvalidRepoID() {
|
|||
}
|
||||
|
||||
func (s *RepoTestSuite) TestUpdateRepositoryDBEncryptErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `repositories` WHERE id = ? AND `repositories`.`deleted_at` IS NULL ORDER BY `repositories`.`id` LIMIT 1")).
|
||||
|
|
@ -392,8 +392,8 @@ func (s *RepoTestSuite) TestUpdateRepositoryDBSaveErr() {
|
|||
}
|
||||
|
||||
func (s *RepoTestSuite) TestUpdateRepositoryDBDecryptingErr() {
|
||||
s.StoreSQLMocked.cfg.Passphrase = "wrong-passphrase"
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = "webhook-secret"
|
||||
s.StoreSQLMocked.cfg.Passphrase = wrongPassphrase
|
||||
s.Fixtures.UpdateRepoParams.WebhookSecret = webhookSecret
|
||||
|
||||
s.Fixtures.SQLMock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM `repositories` WHERE id = ? AND `repositories`.`deleted_at` IS NULL ORDER BY `repositories`.`id` LIMIT 1")).
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func (s *UserTestSuite) SetupTest() {
|
|||
SkipInitializeWithVersion: true,
|
||||
}
|
||||
gormConfig := &gorm.Config{}
|
||||
if flag.Lookup("test.v").Value.String() == "false" {
|
||||
if flag.Lookup("test.v").Value.String() == falseString {
|
||||
gormConfig.Logger = logger.Default.LogMode(logger.Silent)
|
||||
}
|
||||
gormConn, err := gorm.Open(mysql.New(mysqlConfig), gormConfig)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/cloudbase/garm/metrics"
|
||||
"github.com/cloudbase/garm/runner"
|
||||
"github.com/cloudbase/garm/runner" //nolint:typecheck
|
||||
)
|
||||
|
||||
// CollectOrganizationMetric collects the metrics for the enterprise objects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue