Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jgramoll committed Nov 17, 2020
1 parent 3a60535 commit 6eed4de
Show file tree
Hide file tree
Showing 106 changed files with 602 additions and 488 deletions.
1 change: 1 addition & 0 deletions client/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ProviderSettings struct {
AWS *AwsProviderSettings `json:"aws"`
}

// DataSources data sources for application
type DataSources struct {
Disabled *[]string `json:"disabled"`
Enabled *[]string `json:"enabled"`
Expand Down
2 changes: 2 additions & 0 deletions client/application_permissions.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package client

// ApplicationPermissions application permissions
type ApplicationPermissions struct {
Execute []string `json:"EXECUTE"`
Read []string `json:"READ"`
Write []string `json:"WRITE"`
}

// NewApplicationPermissions new application permissions
func NewApplicationPermissions() *ApplicationPermissions {
return &ApplicationPermissions{}
}
2 changes: 1 addition & 1 deletion client/application_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (service *ApplicationService) DeleteApplication(app *Application) error {
func (service *ApplicationService) sendTask(app *Application, jobType string, taskDescription string) error {
task := Task{
Job: &[]*Job{
&Job{
{
Type: jobType,
Application: app,
User: service.Config.Auth.UserEmail,
Expand Down
3 changes: 3 additions & 0 deletions client/canary_analysis_config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package client

// CanaryAnalysisConfigScoreThreadholds thresholds
type CanaryAnalysisConfigScoreThreadholds struct {
Marginal string `json:"marginal"`
Pass string `json:"pass"`
}

// CanaryAnalysisConfig config
type CanaryAnalysisConfig struct {
CanaryAnalysisIntervalMins string `json:"canaryAnalysisIntervalMins"`
CanaryConfigId string `json:"canaryConfigId"`
Expand All @@ -17,6 +19,7 @@ type CanaryAnalysisConfig struct {
StorageAccountName string `json:"storageAccountName"`
}

// NewCanaryAnalysisConfig new config
func NewCanaryAnalysisConfig() *CanaryAnalysisConfig {
return &CanaryAnalysisConfig{
ScoreThresholds: CanaryAnalysisConfigScoreThreadholds{},
Expand Down
1 change: 1 addition & 0 deletions client/canary_analysis_config_scope.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package client

// CanaryAnalysisConfigScope canary analysis
type CanaryAnalysisConfigScope struct {
ControlLocation string `json:"controlLocation,omitempty"`
ControlScope string `json:"controlScope,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions client/canary_analysis_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"github.com/mitchellh/mapstructure"
)

// CanaryAnalysisStageType stage type
var CanaryAnalysisStageType StageType = "kayentaCanary"

func init() {
stageFactories[CanaryAnalysisStageType] = parseCanaryAnalysisStage
}

// CanaryAnalysisStage canary analysis stage
type CanaryAnalysisStage struct {
BaseStage `mapstructure:",squash"`

Expand All @@ -18,6 +20,7 @@ type CanaryAnalysisStage struct {
Deployments *[]*DeploymentCluster `json:"deployments,omitempty"`
}

// NewCanaryAnalysisStage new canary analysis stage
func NewCanaryAnalysisStage() *CanaryAnalysisStage {
return &CanaryAnalysisStage{
BaseStage: *newBaseStage(CanaryAnalysisStageType),
Expand Down
4 changes: 4 additions & 0 deletions client/canary_config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package client

// CanaryConfig canary config
type CanaryConfig struct {
Id string `json:"id,omitempty"`
Name string `json:"name"`
Expand All @@ -12,6 +13,7 @@ type CanaryConfig struct {
Judge *CanaryConfigJudge `json:"judge"`
}

// NewCanaryConfig new config
func NewCanaryConfig(judge *CanaryConfigJudge, name string, application string) *CanaryConfig {
return &CanaryConfig{
Name: name,
Expand All @@ -24,10 +26,12 @@ func NewCanaryConfig(judge *CanaryConfigJudge, name string, application string)
}
}

// AddGroup add group
func (config *CanaryConfig) AddGroup(group string, weight float64) {
config.Classifier.GroupWeights[group] = weight
}

// AddMetric add metric
func (config *CanaryConfig) AddMetric(metric *CanaryConfigMetric) {
config.Metrics = append(config.Metrics, metric)
}
2 changes: 2 additions & 0 deletions client/canary_config_classifier.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package client

// CanaryConfigClassifier classifier
type CanaryConfigClassifier struct {
GroupWeights map[string]float64 `json:"groupWeights"`
}

// NewCanaryConfigClassifier new classifier
func NewCanaryConfigClassifier() *CanaryConfigClassifier {
return &CanaryConfigClassifier{
GroupWeights: map[string]float64{},
Expand Down
2 changes: 2 additions & 0 deletions client/canary_config_judge.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package client

// CanaryConfigJudge judge
type CanaryConfigJudge struct {
Name string `json:"name"`
JudgeConfigurations map[string]interface{} `json:"judgeConfigurations"`
}

// NewCanaryConfigJudge new judge
func NewCanaryConfigJudge(name string) *CanaryConfigJudge {
return &CanaryConfigJudge{
Name: name,
Expand Down
2 changes: 2 additions & 0 deletions client/canary_config_metric.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package client

// CanaryConfigMetric config metric
type CanaryConfigMetric struct {
// AnalysisConfigurations interface `json:"analysisConfigurations"`
Name string `json:"name"`
Expand All @@ -8,6 +9,7 @@ type CanaryConfigMetric struct {
ScopeName string `json:"scopeName"`
}

// NewCanaryConfigMetric new config metric
func NewCanaryConfigMetric(
group string, name string, metricQuery *CanaryConfigMetricQuery,
) *CanaryConfigMetric {
Expand Down
2 changes: 2 additions & 0 deletions client/canary_config_metric_query.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package client

// CanaryConfigMetricQuery metric query
type CanaryConfigMetricQuery struct {
Type string `json:"type"`
ServiceType string `json:"serviceType"`
MetricName string `json:"metricName"`
}

// NewCanaryConfigMetricQuery new metric query
func NewCanaryConfigMetricQuery(metric string, serviceType string, metricType string) *CanaryConfigMetricQuery {
return &CanaryConfigMetricQuery{
Type: metricType,
Expand Down
13 changes: 10 additions & 3 deletions client/canary_config_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import (
"fmt"
)

// ErrCanaryConfigNotFound config not found
var ErrCanaryConfigNotFound = errors.New("Could not find canary config")

// CreateCanaryConfigResponse canary config response
type CreateCanaryConfigResponse struct {
CanaryConfigId string `json:"canaryConfigId"`
}

// CanaryConfigService config service
type CanaryConfigService struct {
*Client
}

// GetCanaryConfigs get configs
func (service *CanaryConfigService) GetCanaryConfigs() (*[]*CanaryConfig, error) {
path := "/v2/canaryConfig"
req, err := service.NewRequest("GET", path)
Expand All @@ -31,6 +35,7 @@ func (service *CanaryConfigService) GetCanaryConfigs() (*[]*CanaryConfig, error)
return &configs, nil
}

// GetCanaryConfig get config by id
func (service *CanaryConfigService) GetCanaryConfig(id string) (*CanaryConfig, error) {
path := fmt.Sprintf("/v2/canaryConfig/%s", id)
req, err := service.NewRequest("GET", path)
Expand All @@ -44,7 +49,7 @@ func (service *CanaryConfigService) GetCanaryConfig(id string) (*CanaryConfig, e
}

// CreateCanaryConfig create an canary config
func (service *CanaryConfigService) CreateCanaryConfig(config *CanaryConfig) (configId string, err error) {
func (service *CanaryConfigService) CreateCanaryConfig(config *CanaryConfig) (configID string, err error) {
path := "/v2/canaryConfig"
req, err := service.NewRequestWithBody("POST", path, config)
if err != nil {
Expand All @@ -56,6 +61,7 @@ func (service *CanaryConfigService) CreateCanaryConfig(config *CanaryConfig) (co
return response.CanaryConfigId, err
}

// UpdateCanaryConfig update config
func (service *CanaryConfigService) UpdateCanaryConfig(config *CanaryConfig) error {
path := fmt.Sprintf("/v2/canaryConfig/%s", config.Id)
req, err := service.NewRequestWithBody("PUT", path, config)
Expand All @@ -67,8 +73,9 @@ func (service *CanaryConfigService) UpdateCanaryConfig(config *CanaryConfig) err
return err
}

func (service *CanaryConfigService) DeleteCanaryConfig(configId string) error {
path := fmt.Sprintf("/v2/canaryConfig/%s", configId)
// DeleteCanaryConfig deleete config
func (service *CanaryConfigService) DeleteCanaryConfig(configID string) error {
path := fmt.Sprintf("/v2/canaryConfig/%s", configID)
req, err := service.NewRequest("DELETE", path)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions client/check_preconditions_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ func init() {
stageFactories[CheckPreconditionsStageType] = parseCheckPreconditionsStage
}

// CheckPreconditionsStage preconditions stage
type CheckPreconditionsStage struct {
BaseStage `mapstructure:",squash"`

Preconditions []Precondition `json:"preconditions"`
}

// NewCheckPreconditionsStage new stage
func NewCheckPreconditionsStage() *CheckPreconditionsStage {
return &CheckPreconditionsStage{
BaseStage: *newBaseStage(CheckPreconditionsStageType),
Expand Down
8 changes: 4 additions & 4 deletions client/check_preconditions_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ func TestCheckPreconditionsStageSerialize(t *testing.T) {
t.Fatal(err)
}
result := string(b)
if result != checkPreconditionsJson {
if result != checkPreconditionsJSON {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(checkPreconditionsJson, result, true)
diffs := dmp.DiffMain(checkPreconditionsJSON, result, true)
t.Fatalf("Check Preconditions not as expected: %s", dmp.DiffPrettyText(diffs))
}
}

func TestCheckPreconditionsStageDeserialize(t *testing.T) {
var stageMap map[string]interface{}
err := json.Unmarshal([]byte(checkPreconditionsJson), &stageMap)
err := json.Unmarshal([]byte(checkPreconditionsJSON), &stageMap)
if err != nil {
t.Fatal(err)
}
Expand All @@ -67,7 +67,7 @@ func TestCheckPreconditionsStageDeserialize(t *testing.T) {
}
}

var checkPreconditionsJson = `{
var checkPreconditionsJSON = `{
"name": "Check Preconditions",
"refId": "",
"type": "checkPreconditions",
Expand Down
5 changes: 3 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
Auth *Auth
}

// NewConfig new config
func NewConfig() *Config {
return &Config{
Auth: NewAuth(),
Expand All @@ -40,7 +41,7 @@ func NewClient(config *Config) *Client {

var httpClient *http.Client
if config.Auth.Enabled {
httpClient = newTlsHttpClient(config)
httpClient = newTLSHTTPClient(config)
} else {
httpClient = http.DefaultClient
}
Expand All @@ -51,7 +52,7 @@ func NewClient(config *Config) *Client {
}
}

func newTlsHttpClient(config *Config) *http.Client {
func newTLSHTTPClient(config *Config) *http.Client {
homeDir, err := os.UserHomeDir()
if err != nil {
log.Fatal("[ERROR]", err)
Expand Down
1 change: 1 addition & 0 deletions client/client_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Auth struct {
Insecure bool
}

// NewAuth new auth
func NewAuth() *Auth {
return &Auth{
Enabled: true,
Expand Down
13 changes: 9 additions & 4 deletions client/delete_manifest_mode.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
package client

import (
"errors"
"fmt"
)

// DeleteManifestMode delete manfiest mode
type DeleteManifestMode int

const (
// DeleteManifestModeUnknown unknown
DeleteManifestModeUnknown DeleteManifestMode = iota
// DeleteManifestModeStatic static
DeleteManifestModeStatic
)

func (t DeleteManifestMode) String() string {
return [...]string{"unknown", "static"}[t]
func (m DeleteManifestMode) String() string {
return [...]string{"unknown", "static"}[m]
}

// ParseDeleteManifestMode mode
func ParseDeleteManifestMode(s string) (DeleteManifestMode, error) {
switch s {
default:
return DeleteManifestModeUnknown, errors.New(fmt.Sprintf("Unknown Mode %s", s))
return DeleteManifestModeUnknown, fmt.Errorf("Unknown Mode %s", s)
case "static":
return DeleteManifestModeStatic, nil
}
}

// MarshalText marshal text
func (m DeleteManifestMode) MarshalText() ([]byte, error) {
return []byte(m.String()), nil
}

// UnmarshalText unmarshal text
func (m *DeleteManifestMode) UnmarshalText(text []byte) error {
mode, err := ParseDeleteManifestMode(string(text))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions client/delete_manifest_options.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package client

// DeleteManifestOptions options
type DeleteManifestOptions struct {
Cascading bool `json:"cascading"`
}

// NewDeleteManifestOptions new options
func NewDeleteManifestOptions() *DeleteManifestOptions {
return &DeleteManifestOptions{
Cascading: true,
Expand Down
2 changes: 2 additions & 0 deletions client/delete_manifest_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func init() {
stageFactories[DeleteManifestStageType] = parseDeleteManifestStage
}

// DeleteManifestStage stage
type DeleteManifestStage struct {
BaseStage `mapstructure:",squash"`

Expand All @@ -25,6 +26,7 @@ type DeleteManifestStage struct {
Options *DeleteManifestOptions `json:"options"`
}

// NewDeleteManifestStage new stage
func NewDeleteManifestStage() *DeleteManifestStage {
return &DeleteManifestStage{
BaseStage: *newBaseStage(DeleteManifestStageType),
Expand Down

0 comments on commit 6eed4de

Please sign in to comment.