Merge pull request #560 from tariq1890/fix_lint

fix issues reported by the linter
This commit is contained in:
Stefan Prodan
2020-04-18 11:12:38 +03:00
committed by GitHub
10 changed files with 23 additions and 48 deletions
+3 -3
View File
@@ -293,7 +293,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {
// check if the canary success rate is above the threshold
// skip check if no traffic is routed or mirrored to canary
if canaryWeight == 0 && cd.Status.Iterations == 0 &&
(cd.GetAnalysis().Mirror == false || mirrored == false) {
!(cd.GetAnalysis().Mirror && mirrored) {
c.recordEventInfof(cd, "Starting canary analysis for %s.%s", cd.Spec.TargetRef.Name, cd.Namespace)
// run pre-rollout web hooks
@@ -354,7 +354,7 @@ func (c *Controller) runCanary(canary *flaggerv1.Canary, canaryController canary
// When mirroring, all requests go to primary and canary, but only responses from
// primary go back to the user.
if canary.GetAnalysis().Mirror && canaryWeight == 0 {
if mirrored == false {
if !mirrored {
mirrored = true
primaryWeight = 100
canaryWeight = 0
@@ -466,7 +466,7 @@ func (c *Controller) runBlueGreen(canary *flaggerv1.Canary, canaryController can
if canary.GetAnalysis().Iterations > canary.Status.Iterations {
// If in "mirror" mode, mirror requests during the entire B/G canary test
if provider != "kubernetes" &&
canary.GetAnalysis().Mirror == true && mirrored == false {
canary.GetAnalysis().Mirror && !mirrored {
if err := meshRouter.SetRoutes(canary, 100, 0, true); err != nil {
c.recordEventWarningf(canary, "%v", err)
}
@@ -613,32 +613,6 @@ func newDaemonSetTestService() *corev1.Service {
return d
}
func newDaemonSetTestServiceV2() *corev1.Service {
d := &corev1.Service{
TypeMeta: metav1.TypeMeta{APIVersion: appsv1.SchemeGroupVersion.String()},
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "podinfo",
},
Spec: corev1.ServiceSpec{
Selector: map[string]string{
"app": "podinfo-v2",
},
Type: corev1.ServiceTypeClusterIP,
Ports: []corev1.ServicePort{
{
Name: "http",
Port: 9898,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromString("http"),
},
},
},
}
return d
}
func newDaemonSetTestMetricTemplate() *flaggerv1.MetricTemplate {
provider := flaggerv1.MetricTemplateProvider{
Type: "prometheus",
+5 -4
View File
@@ -175,12 +175,13 @@ func TestScheduler_DaemonSetPromotion(t *testing.T) {
// detect configs changes
mocks.ctrl.advanceCanary("podinfo", "default")
primaryWeight, canaryWeight, mirrored, err := mocks.router.GetRoutes(mocks.canary)
_, _, _, err = mocks.router.GetRoutes(mocks.canary)
require.NoError(t, err)
primaryWeight = 60
canaryWeight = 40
err = mocks.router.SetRoutes(mocks.canary, primaryWeight, canaryWeight, mirrored)
var mirrored bool
primaryWeight := 60
canaryWeight := 40
err = mocks.router.SetRoutes(mocks.canary, primaryWeight, canaryWeight, false)
require.NoError(t, err)
// advance
+5 -5
View File
@@ -309,12 +309,12 @@ func TestScheduler_DeploymentPromotion(t *testing.T) {
// detect configs changes
mocks.ctrl.advanceCanary("podinfo", "default")
primaryWeight, canaryWeight, mirrored, err := mocks.router.GetRoutes(mocks.canary)
_, _, _, err = mocks.router.GetRoutes(mocks.canary)
require.NoError(t, err)
primaryWeight = 60
canaryWeight = 40
err = mocks.router.SetRoutes(mocks.canary, primaryWeight, canaryWeight, mirrored)
primaryWeight := 60
canaryWeight := 40
err = mocks.router.SetRoutes(mocks.canary, primaryWeight, canaryWeight, false)
require.NoError(t, err)
// advance
@@ -336,7 +336,7 @@ func TestScheduler_DeploymentPromotion(t *testing.T) {
// finalise
mocks.ctrl.advanceCanary("podinfo", "default")
primaryWeight, canaryWeight, mirrored, err = mocks.router.GetRoutes(mocks.canary)
primaryWeight, canaryWeight, mirrored, err := mocks.router.GetRoutes(mocks.canary)
require.NoError(t, err)
assert.Equal(t, 100, primaryWeight)
assert.Equal(t, 0, canaryWeight)
+3 -3
View File
@@ -50,17 +50,17 @@ type ConcordTask struct {
func NewConcordTask(metadata map[string]string, canary string, logger *zap.SugaredLogger) (*ConcordTask, error) {
var pollIntervalInt, pollTimeoutInt int
if _, found := metadata["server"]; found == false {
if _, found := metadata["server"]; !found {
return nil, errors.New("`server` is required with type concord")
}
pURL, err := url.Parse(metadata["server"])
if err != nil {
return nil, errors.New("failed to create base URL from metadata `concord_url`")
}
if _, found := metadata["org"]; found == false {
if _, found := metadata["org"]; !found {
return nil, errors.New("`org` is required with type concord")
}
if _, found := metadata["project"]; found == false {
if _, found := metadata["project"]; !found {
return nil, errors.New("`project` is required with type concord")
}
if _, found := metadata["repo"]; found == false {
-1
View File
@@ -22,7 +22,6 @@ type TaskRunner struct {
todoTasks *sync.Map
runningTasks *sync.Map
totalExecs uint64
logCmdOutput bool
}
func NewTaskRunner(logger *zap.SugaredLogger, timeout time.Duration) *TaskRunner {
+1 -1
View File
@@ -85,7 +85,7 @@ func (cr *Recorder) SetTotal(namespace string, total int) {
// SetStatus sets the last known canary analysis status
func (cr *Recorder) SetStatus(cd *flaggerv1.Canary, phase flaggerv1.CanaryPhase) {
status := 1
var status int
switch phase {
case flaggerv1.CanaryPhaseProgressing:
status = 0
+1
View File
@@ -17,6 +17,7 @@ func Test_postMessage(t *testing.T) {
var payload = make(map[string]string)
err = json.Unmarshal(b, &payload)
require.NoError(t, err)
require.Equal(t, "success", payload["status"])
}))
+1 -1
View File
@@ -47,7 +47,7 @@ func NewMSTeams(hookURL string) (*MSTeams, error) {
func (s *MSTeams) Post(workload string, namespace string, message string, fields []Field, severity string) error {
facts := make([]MSTeamsField, 0, len(fields))
for _, f := range fields {
facts = append(facts, MSTeamsField{f.Name, f.Value})
facts = append(facts, MSTeamsField(f))
}
payload := MSTeamsPayload{
+4 -4
View File
@@ -45,12 +45,12 @@ func TestGlooRouter_SetRoutes(t *testing.T) {
err := router.Reconcile(mocks.canary)
require.NoError(t, err)
p, c, m, err := router.GetRoutes(mocks.canary)
_, _, _, err = router.GetRoutes(mocks.canary)
require.NoError(t, err)
p = 50
c = 50
m = false
p := 50
c := 50
m := false
err = router.SetRoutes(mocks.canary, p, c, m)
require.NoError(t, err)