Chore: explore possibilities of using makefile (#17039)
* Chore: explore possibilities of using makefile This is an exploratory commit - I wanted to see how revive/gosec linters could be integrated with makefile and our build scripts. Looks better then I expected :) * Chore: make revive happy Revive execution was not supplied with path, if you restore there is couple errors that were popping up - so I fixed them * Chore: make revive happy
This commit is contained in:
@@ -18,10 +18,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
IoHelper m.IoUtil = IoUtilImp{}
|
||||
HttpClient http.Client
|
||||
grafanaVersion string
|
||||
NotFoundError = errors.New("404 not found error")
|
||||
IoHelper m.IoUtil = IoUtilImp{}
|
||||
HttpClient http.Client
|
||||
grafanaVersion string
|
||||
ErrNotFoundError = errors.New("404 not found error")
|
||||
)
|
||||
|
||||
func Init(version string, skipTLSVerify bool) {
|
||||
@@ -131,7 +131,7 @@ func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) {
|
||||
|
||||
if err != nil {
|
||||
logger.Info("Failed to send request: ", err)
|
||||
if err == NotFoundError {
|
||||
if err == ErrNotFoundError {
|
||||
return m.Plugin{}, fmt.Errorf("Failed to find requested plugin, check if the plugin_id is correct. error: %v", err)
|
||||
}
|
||||
return m.Plugin{}, fmt.Errorf("Failed to send request. error: %v", err)
|
||||
@@ -174,7 +174,7 @@ func sendRequest(repoUrl string, subPaths ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
if res.StatusCode == 404 {
|
||||
return []byte{}, NotFoundError
|
||||
return []byte{}, ErrNotFoundError
|
||||
}
|
||||
if res.StatusCode/100 != 2 {
|
||||
return []byte{}, fmt.Errorf("Api returned invalid status: %s", res.Status)
|
||||
|
||||
@@ -31,12 +31,12 @@ func isDevEnvironment() bool {
|
||||
defaultsPath := filepath.Join(exPath, "../conf/defaults.ini")
|
||||
_, err = os.Stat(defaultsPath)
|
||||
return err == nil
|
||||
} else {
|
||||
// But at the same time there are per platform directories that contain the binaries and can also be used.
|
||||
defaultsPath := filepath.Join(exPath, "../../conf/defaults.ini")
|
||||
_, err = os.Stat(defaultsPath)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// But at the same time there are per platform directories that contain the binaries and can also be used.
|
||||
defaultsPath := filepath.Join(exPath, "../../conf/defaults.ini")
|
||||
_, err = os.Stat(defaultsPath)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func returnOsDefault(currentOs string) string {
|
||||
|
||||
@@ -9,7 +9,7 @@ var (
|
||||
ErrProviderDeniedRequest = errors.New("Login provider denied login request")
|
||||
ErrSignUpNotAllowed = errors.New("Signup is not allowed for this adapter")
|
||||
ErrTooManyLoginAttempts = errors.New("Too many consecutive incorrect login attempts for user. Login for user temporarily blocked")
|
||||
ErrPasswordEmpty = errors.New("No password provided.")
|
||||
ErrPasswordEmpty = errors.New("No password provided")
|
||||
ErrUsersQuotaReached = errors.New("Users quota reached")
|
||||
ErrGettingUserQuota = errors.New("Error getting user quota")
|
||||
)
|
||||
|
||||
@@ -25,9 +25,8 @@ func (dpm *DashboardProvisionerMock) Provision() error {
|
||||
dpm.Calls.Provision = append(dpm.Calls.Provision, nil)
|
||||
if dpm.ProvisionFunc != nil {
|
||||
return dpm.ProvisionFunc()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpm *DashboardProvisionerMock) PollChanges(ctx context.Context) {
|
||||
@@ -41,7 +40,6 @@ func (dpm *DashboardProvisionerMock) GetProvisionerResolvedPath(name string) str
|
||||
dpm.Calls.PollChanges = append(dpm.Calls.GetProvisionerResolvedPath, name)
|
||||
if dpm.GetProvisionerResolvedPathFunc != nil {
|
||||
return dpm.GetProvisionerResolvedPathFunc(name)
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -25,34 +25,30 @@ func (mock *ProvisioningServiceMock) ProvisionDatasources() error {
|
||||
mock.Calls.ProvisionDatasources = append(mock.Calls.ProvisionDatasources, nil)
|
||||
if mock.ProvisionDatasourcesFunc != nil {
|
||||
return mock.ProvisionDatasourcesFunc()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock *ProvisioningServiceMock) ProvisionNotifications() error {
|
||||
mock.Calls.ProvisionNotifications = append(mock.Calls.ProvisionNotifications, nil)
|
||||
if mock.ProvisionNotificationsFunc != nil {
|
||||
return mock.ProvisionNotificationsFunc()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock *ProvisioningServiceMock) ProvisionDashboards() error {
|
||||
mock.Calls.ProvisionDashboards = append(mock.Calls.ProvisionDashboards, nil)
|
||||
if mock.ProvisionDashboardsFunc != nil {
|
||||
return mock.ProvisionDashboardsFunc()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock *ProvisioningServiceMock) GetDashboardProvisionerResolvedPath(name string) string {
|
||||
mock.Calls.GetDashboardProvisionerResolvedPath = append(mock.Calls.GetDashboardProvisionerResolvedPath, name)
|
||||
if mock.GetDashboardProvisionerResolvedPathFunc != nil {
|
||||
return mock.GetDashboardProvisionerResolvedPathFunc(name)
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// A set of value types to use in provisioning. They add custom unmarshaling logic that puts the string values
|
||||
// Package values is a set of value types to use in provisioning. They add custom unmarshaling logic that puts the string values
|
||||
// through os.ExpandEnv.
|
||||
// Usage:
|
||||
// type Data struct {
|
||||
|
||||
Reference in New Issue
Block a user