diff --git a/pkg/diag/validator/pod.go b/pkg/diag/validator/pod.go index 5b6b91ea19f..262745b3df2 100644 --- a/pkg/diag/validator/pod.go +++ b/pkg/diag/validator/pod.go @@ -209,15 +209,15 @@ func processPodEvents(e corev1.EventInterface, pod v1.Pod, ps *podStatus) { } switch recentEvent.Reason { case failedScheduling: - ps.ae.ErrCode = proto.StatusCode_STATUSCHECK_FAILED_SCHEDULING - ps.ae.Message = recentEvent.Message + ps.updateAE(proto.StatusCode_STATUSCHECK_FAILED_SCHEDULING, recentEvent.Message) case unhealthy: - ps.ae.ErrCode = proto.StatusCode_STATUSCHECK_UNHEALTHY - ps.ae.Message = recentEvent.Message + ps.updateAE(proto.StatusCode_STATUSCHECK_UNHEALTHY, recentEvent.Message) default: // TODO: Add unique error codes for reasons - ps.ae.ErrCode = proto.StatusCode_STATUSCHECK_UNKNOWN_EVENT - ps.ae.Message = fmt.Sprintf("%s: %s", recentEvent.Reason, recentEvent.Message) + ps.updateAE( + proto.StatusCode_STATUSCHECK_UNKNOWN_EVENT, + fmt.Sprintf("%s: %s", recentEvent.Reason, recentEvent.Message), + ) } } @@ -226,7 +226,7 @@ type podStatus struct { namespace string phase string logs []string - ae *proto.ActionableErr + ae proto.ActionableErr } func (p *podStatus) isStable() bool { @@ -234,14 +234,20 @@ func (p *podStatus) isStable() bool { } func (p *podStatus) withErrAndLogs(errCode proto.StatusCode, l []string, err error) *podStatus { + var msg string if err != nil { - p.ae.Message = err.Error() + msg = err.Error() } - p.ae.ErrCode = errCode + p.updateAE(errCode, msg) p.logs = l return p } +func (p *podStatus) updateAE(errCode proto.StatusCode, msg string) { + p.ae.ErrCode = errCode + p.ae.Message = msg +} + func (p *podStatus) String() string { switch { case p.isStable(): @@ -279,7 +285,7 @@ func newPodStatus(n string, ns string, p string) *podStatus { name: n, namespace: ns, phase: p, - ae: &proto.ActionableErr{ + ae: proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS, }, } diff --git a/pkg/diag/validator/pod_test.go b/pkg/diag/validator/pod_test.go index 8f36fd06fc6..a6d6b8c0b67 100644 --- a/pkg/diag/validator/pod_test.go +++ b/pkg/diag/validator/pod_test.go @@ -84,7 +84,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "container foo-container is waiting to start: foo-image can't be pulled", ErrCode: proto.StatusCode_STATUSCHECK_IMAGE_PULL_ERR, }, nil)}, @@ -115,7 +115,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "container foo-container is waiting to start: foo-image can't be pulled", ErrCode: proto.StatusCode_STATUSCHECK_IMAGE_PULL_ERR, }, nil)}, @@ -146,7 +146,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "container foo-container is waiting to start: foo-image can't be pulled", ErrCode: proto.StatusCode_STATUSCHECK_IMAGE_PULL_ERR, }, nil)}, @@ -165,7 +165,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Succeeded", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "", ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS, }, nil)}, @@ -190,7 +190,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Running", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "", ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS, }, nil)}, @@ -213,7 +213,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "could not determine", ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, }, nil)}, @@ -237,7 +237,7 @@ func TestRun(t *testing.T) { }, }}, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "Unschedulable: 0/2 nodes available: 1 node has disk pressure, 1 node is unreachable", ErrCode: proto.StatusCode_STATUSCHECK_NODE_DISK_PRESSURE, }, nil)}, @@ -265,7 +265,7 @@ func TestRun(t *testing.T) { output: []byte("main.go:57 \ngo panic"), }, expected: []Resource{NewResource("test", "Pod", "foo", "Running", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "container foo-container terminated with exit code 1", ErrCode: proto.StatusCode_STATUSCHECK_CONTAINER_TERMINATED, }, []string{ @@ -295,7 +295,7 @@ func TestRun(t *testing.T) { err: fmt.Errorf("error"), }, expected: []Resource{NewResource("test", "pod", "foo", "Running", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "container foo-container terminated with exit code 1", ErrCode: proto.StatusCode_STATUSCHECK_CONTAINER_TERMINATED, }, []string{ @@ -327,7 +327,7 @@ func TestRun(t *testing.T) { }, }, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "eventCode: dummy event", ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN_EVENT, }, nil)}, @@ -362,7 +362,7 @@ func TestRun(t *testing.T) { }, }, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "eventCode: dummy event", ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN_EVENT, }, nil)}, @@ -397,7 +397,7 @@ func TestRun(t *testing.T) { }, }, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "eventCode: dummy event", ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN_EVENT, }, nil)}, @@ -432,7 +432,7 @@ func TestRun(t *testing.T) { }, }, expected: []Resource{NewResource("test", "Pod", "foo", "Pending", - &proto.ActionableErr{ + proto.ActionableErr{ Message: "0/1 nodes are available: 1 node(s) had taint {key: value}, that the pod didn't tolerate", ErrCode: proto.StatusCode_STATUSCHECK_FAILED_SCHEDULING, }, nil)}, diff --git a/pkg/diag/validator/resource.go b/pkg/diag/validator/resource.go index dd8f8d19c9f..d8deb951d3f 100644 --- a/pkg/diag/validator/resource.go +++ b/pkg/diag/validator/resource.go @@ -31,7 +31,7 @@ type Resource struct { name string logs []string status Status - ae *proto.ActionableErr + ae proto.ActionableErr } func (r Resource) Kind() string { return r.kind } @@ -45,7 +45,7 @@ func (r Resource) String() string { } return fmt.Sprintf("%s:%s/%s", r.namespace, r.kind, r.name) } -func (r Resource) ActionableError() *proto.ActionableErr { +func (r Resource) ActionableError() proto.ActionableErr { return r.ae } func (r Resource) StatusUpdated(another Resource) bool { @@ -53,7 +53,7 @@ func (r Resource) StatusUpdated(another Resource) bool { } // NewResource creates new Resource of kind -func NewResource(namespace, kind, name string, status Status, ae *proto.ActionableErr, logs []string) Resource { +func NewResource(namespace, kind, name string, status Status, ae proto.ActionableErr, logs []string) Resource { return Resource{namespace: namespace, kind: kind, name: name, status: status, ae: ae, logs: logs} } @@ -64,6 +64,6 @@ type objectWithMetadata interface { } // NewResourceFromObject creates new Resource with fields populated from object metadata. -func NewResourceFromObject(object objectWithMetadata, status Status, ae *proto.ActionableErr, logs []string) Resource { +func NewResourceFromObject(object objectWithMetadata, status Status, ae proto.ActionableErr, logs []string) Resource { return NewResource(object.GetNamespace(), object.GetObjectKind().GroupVersionKind().Kind, object.GetName(), status, ae, logs) } diff --git a/pkg/diag/validator/resource_test.go b/pkg/diag/validator/resource_test.go index 9ed0436cf26..1b7c5134c4f 100644 --- a/pkg/diag/validator/resource_test.go +++ b/pkg/diag/validator/resource_test.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/GoogleContainerTools/skaffold/proto" "github.com/GoogleContainerTools/skaffold/testutil" ) @@ -42,7 +43,7 @@ func TestNewResource(t *testing.T) { Name: "foo", }, }, - expected: Resource{"default", "pod", "foo", nil, Status(""), nil}, + expected: Resource{"default", "pod", "foo", nil, Status(""), proto.ActionableErr{}}, expectedName: "pod/foo", }, { @@ -54,13 +55,13 @@ func TestNewResource(t *testing.T) { Name: "bar", }, }, - expected: Resource{"test", "pod", "bar", nil, Status(""), nil}, + expected: Resource{"test", "pod", "bar", nil, Status(""), proto.ActionableErr{}}, expectedName: "test:pod/bar", }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) { - actual := NewResourceFromObject(test.resource, Status(""), nil, nil) + actual := NewResourceFromObject(test.resource, Status(""), proto.ActionableErr{}, nil) t.CheckDeepEqual(test.expected, actual, cmp.AllowUnexported(Resource{})) t.CheckDeepEqual(test.expectedName, actual.String(), cmp.AllowUnexported(Resource{})) }) diff --git a/pkg/skaffold/deploy/resource/deployment.go b/pkg/skaffold/deploy/resource/deployment.go index b12f33691e9..a33b5f87ced 100644 --- a/pkg/skaffold/deploy/resource/deployment.go +++ b/pkg/skaffold/deploy/resource/deployment.go @@ -63,7 +63,7 @@ func (d *Deployment) Deadline() time.Duration { return d.deadline } -func (d *Deployment) UpdateStatus(ae *proto.ActionableErr) { +func (d *Deployment) UpdateStatus(ae proto.ActionableErr) { updated := newStatus(ae) if d.status.Equal(updated) { d.status.changed = false @@ -81,7 +81,7 @@ func NewDeployment(name string, ns string, deadline time.Duration) *Deployment { name: name, namespace: ns, rType: deploymentType, - status: newStatus(&proto.ActionableErr{}), + status: newStatus(proto.ActionableErr{}), deadline: deadline, podValidator: diag.New(nil), } @@ -174,30 +174,30 @@ func (d *Deployment) cleanupStatus(msg string) string { // $kubectl logs testPod -f // 2020/06/18 17:28:31 service is running // Killed: 9 -func parseKubectlRolloutError(details string, err error) *proto.ActionableErr { +func parseKubectlRolloutError(details string, err error) proto.ActionableErr { switch { case err == nil && strings.Contains(details, rollOutSuccess): - return &proto.ActionableErr{ + return proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS, Message: details, } case err == nil: - return &proto.ActionableErr{ + return proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_ROLLOUT_PENDING, Message: details, } case strings.Contains(err.Error(), connectionErrMsg): - return &proto.ActionableErr{ + return proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_CONNECTION_ERR, Message: MsgKubectlConnection, } case strings.Contains(err.Error(), killedErrMsg): - return &proto.ActionableErr{ + return proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_PID_KILLED, Message: msgKubectlKilled, } default: - return &proto.ActionableErr{ + return proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: err.Error(), } diff --git a/pkg/skaffold/deploy/resource/deployment_test.go b/pkg/skaffold/deploy/resource/deployment_test.go index eb635203358..9fad404809c 100644 --- a/pkg/skaffold/deploy/resource/deployment_test.go +++ b/pkg/skaffold/deploy/resource/deployment_test.go @@ -105,12 +105,12 @@ func TestParseKubectlError(t *testing.T) { description string details string err error - expectedAe *proto.ActionableErr + expectedAe proto.ActionableErr }{ { description: "rollout status connection error", err: errors.New("Unable to connect to the server"), - expectedAe: &proto.ActionableErr{ + expectedAe: proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_CONNECTION_ERR, Message: MsgKubectlConnection, }, @@ -118,7 +118,7 @@ func TestParseKubectlError(t *testing.T) { { description: "rollout status kubectl command killed", err: errors.New("signal: killed"), - expectedAe: &proto.ActionableErr{ + expectedAe: proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_PID_KILLED, Message: msgKubectlKilled, }, @@ -126,7 +126,7 @@ func TestParseKubectlError(t *testing.T) { { description: "rollout status random error", err: errors.New("deployment test not found"), - expectedAe: &proto.ActionableErr{ + expectedAe: proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: "deployment test not found", }, @@ -134,7 +134,7 @@ func TestParseKubectlError(t *testing.T) { { description: "rollout status nil error", details: "successfully rolled out", - expectedAe: &proto.ActionableErr{ + expectedAe: proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS, Message: "successfully rolled out", }, @@ -195,17 +195,17 @@ func TestIsErrAndNotRetriable(t *testing.T) { func TestReportSinceLastUpdated(t *testing.T) { var tests = []struct { description string - ae *proto.ActionableErr + ae proto.ActionableErr expected string }{ { description: "updating an error status", - ae: &proto.ActionableErr{Message: "cannot pull image"}, + ae: proto.ActionableErr{Message: "cannot pull image"}, expected: " - test-ns:deployment/test: cannot pull image", }, { description: "updating a non error status", - ae: &proto.ActionableErr{Message: "waiting for container"}, + ae: proto.ActionableErr{Message: "waiting for container"}, expected: " - test-ns:deployment/test: waiting for container", }, } @@ -251,7 +251,7 @@ func TestReportSinceLastUpdatedMultipleTimes(t *testing.T) { var actual string for i, status := range test.statuses { // update to same status - dep.UpdateStatus(&proto.ActionableErr{ + dep.UpdateStatus(proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_ROLLOUT_PENDING, Message: status, }) diff --git a/pkg/skaffold/deploy/resource/status.go b/pkg/skaffold/deploy/resource/status.go index 07fe294c1b2..3ff71eebaf2 100644 --- a/pkg/skaffold/deploy/resource/status.go +++ b/pkg/skaffold/deploy/resource/status.go @@ -23,7 +23,7 @@ import ( ) type Status struct { - ae *proto.ActionableErr + ae proto.ActionableErr changed bool reported bool } @@ -35,7 +35,7 @@ func (rs Status) Error() error { return fmt.Errorf(rs.ae.Message) } -func (rs Status) ActionableError() *proto.ActionableErr { +func (rs Status) ActionableError() proto.ActionableErr { return rs.ae } @@ -44,13 +44,10 @@ func (rs Status) String() string { } func (rs Status) Equal(other Status) bool { - if rs.ae != nil && other.ae != nil { - return rs.ae.Message == other.ae.Message && rs.ae.ErrCode == other.ae.ErrCode - } - return rs.ae == other.ae + return rs.ae.Message == other.ae.Message && rs.ae.ErrCode == other.ae.ErrCode } -func newStatus(ae *proto.ActionableErr) Status { +func newStatus(ae proto.ActionableErr) Status { return Status{ ae: ae, changed: true, diff --git a/pkg/skaffold/deploy/resource/status_test.go b/pkg/skaffold/deploy/resource/status_test.go index d55e49f7f32..9b9fd7fc19a 100644 --- a/pkg/skaffold/deploy/resource/status_test.go +++ b/pkg/skaffold/deploy/resource/status_test.go @@ -26,22 +26,22 @@ import ( func TestString(t *testing.T) { var tests = []struct { description string - ae *proto.ActionableErr + ae proto.ActionableErr expected string }{ { description: "should return error string if error is set", - ae: &proto.ActionableErr{Message: "some error"}, + ae: proto.ActionableErr{Message: "some error"}, expected: "some error", }, { description: "should return error if both details and error are set", - ae: &proto.ActionableErr{Message: "error happened due to something"}, + ae: proto.ActionableErr{Message: "error happened due to something"}, expected: "error happened due to something", }, { description: "should return empty string if all empty", - ae: &proto.ActionableErr{}, + ae: proto.ActionableErr{}, }, } for _, test := range tests { @@ -61,24 +61,24 @@ func TestEqual(t *testing.T) { }{ { description: "status should be same if error messages are same", - old: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "Waiting for 0/1 replicas to be available..."}}, - new: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "Waiting for 0/1 replicas to be available..."}}, + old: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "Waiting for 0/1 replicas to be available..."}}, + new: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "Waiting for 0/1 replicas to be available..."}}, expected: true, }, { description: "status should be new if error is different", - old: Status{ae: nil}, - new: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "see this error"}}, + old: Status{ae: proto.ActionableErr{}}, + new: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "see this error"}}, }, { description: "status should be new if errcode are different but same message", - old: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "see this error"}}, - new: Status{ae: &proto.ActionableErr{ErrCode: 101, Message: "see this error"}}, + old: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "see this error"}}, + new: Status{ae: proto.ActionableErr{ErrCode: 101, Message: "see this error"}}, }, { description: "status should be new if messages change", - old: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "Waiting for 2/2 replicas to be available..."}}, - new: Status{ae: &proto.ActionableErr{ErrCode: 100, Message: "Waiting for 1/2 replicas to be available..."}}, + old: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "Waiting for 2/2 replicas to be available..."}}, + new: Status{ae: proto.ActionableErr{ErrCode: 100, Message: "Waiting for 1/2 replicas to be available..."}}, }, } for _, test := range tests { diff --git a/pkg/skaffold/deploy/status_check.go b/pkg/skaffold/deploy/status_check.go index e85d578e39c..2dcfd504a74 100644 --- a/pkg/skaffold/deploy/status_check.go +++ b/pkg/skaffold/deploy/status_check.go @@ -144,7 +144,7 @@ func pollDeploymentStatus(ctx context.Context, runCtx *runcontext.RunContext, r select { case <-timeoutContext.Done(): msg := fmt.Sprintf("could not stabilize within %v: %v", r.Deadline(), timeoutContext.Err()) - r.UpdateStatus(&proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, + r.UpdateStatus(proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, Message: msg}) return case <-time.After(pollDuration): diff --git a/pkg/skaffold/deploy/status_check_test.go b/pkg/skaffold/deploy/status_check_test.go index 42de32f8460..e97aa1a7e6f 100644 --- a/pkg/skaffold/deploy/status_check_test.go +++ b/pkg/skaffold/deploy/status_check_test.go @@ -270,7 +270,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace string deployment string pending int32 - ae *proto.ActionableErr + ae proto.ActionableErr expected string }{ { @@ -278,7 +278,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace: "test", deployment: "dep", pending: 0, - ae: &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + ae: proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, expected: " - test:deployment/dep is ready.\n", }, { @@ -286,7 +286,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace: "default", deployment: "dep", pending: 0, - ae: &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + ae: proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, expected: " - deployment/dep is ready.\n", }, { @@ -294,7 +294,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace: "test", deployment: "dep", pending: 0, - ae: &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, Message: "context deadline expired"}, + ae: proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, Message: "context deadline expired"}, expected: " - test:deployment/dep failed. Error: context deadline expired.\n", }, { @@ -302,7 +302,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace: "test", deployment: "dep", pending: 4, - ae: &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + ae: proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, expected: " - test:deployment/dep is ready. [4/10 deployment(s) still pending]\n", }, { @@ -310,7 +310,7 @@ func TestPrintSummaryStatus(t *testing.T) { namespace: "test", deployment: "dep", pending: 8, - ae: &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, Message: "context deadline expired"}, + ae: proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEADLINE_EXCEEDED, Message: "context deadline expired"}, expected: " - test:deployment/dep failed. [8/10 deployment(s) still pending] Error: context deadline expired.\n", }, } @@ -343,7 +343,7 @@ func TestPrintStatus(t *testing.T) { rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), - &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), }, expected: true, @@ -353,7 +353,7 @@ func TestPrintStatus(t *testing.T) { rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), - &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: "error"}, + proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: "error"}, ), }, expected: true, @@ -363,11 +363,11 @@ func TestPrintStatus(t *testing.T) { rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), - &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), withStatus( resource.NewDeployment("r2", "test", 1), - &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_ROLLOUT_PENDING, + proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_ROLLOUT_PENDING, Message: "pending"}, ), }, @@ -378,11 +378,11 @@ func TestPrintStatus(t *testing.T) { rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), - &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, + proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), withStatus( resource.NewDeployment("r2", "test", 1), - &proto.ActionableErr{ + proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_CONNECTION_ERR, Message: resource.MsgKubectlConnection}, ), @@ -402,7 +402,7 @@ func TestPrintStatus(t *testing.T) { } } -func withStatus(d *resource.Deployment, ae *proto.ActionableErr) *resource.Deployment { +func withStatus(d *resource.Deployment, ae proto.ActionableErr) *resource.Deployment { d.UpdateStatus(ae) return d } diff --git a/pkg/skaffold/event/event.go b/pkg/skaffold/event/event.go index 2f7bbed87b2..20e710c4d09 100644 --- a/pkg/skaffold/event/event.go +++ b/pkg/skaffold/event/event.go @@ -217,7 +217,7 @@ func StatusCheckEventInProgress(s string) { }) } -func ResourceStatusCheckEventCompleted(r string, ae *proto.ActionableErr) { +func ResourceStatusCheckEventCompleted(r string, ae proto.ActionableErr) { if ae.ErrCode != proto.StatusCode_STATUSCHECK_SUCCESS { resourceStatusCheckEventFailed(r, ae) return @@ -234,23 +234,23 @@ func resourceStatusCheckEventSucceeded(r string) { }) } -func resourceStatusCheckEventFailed(r string, ae *proto.ActionableErr) { +func resourceStatusCheckEventFailed(r string, ae proto.ActionableErr) { handler.handleResourceStatusCheckEvent(&proto.ResourceStatusCheckEvent{ Resource: r, Status: Failed, Err: ae.Message, StatusCode: ae.ErrCode, - ActionableErr: ae, + ActionableErr: &ae, }) } -func ResourceStatusCheckEventUpdated(r string, ae *proto.ActionableErr) { +func ResourceStatusCheckEventUpdated(r string, ae proto.ActionableErr) { handler.handleResourceStatusCheckEvent(&proto.ResourceStatusCheckEvent{ Resource: r, Status: InProgress, Message: ae.Message, StatusCode: ae.ErrCode, - ActionableErr: ae, + ActionableErr: &ae, }) } diff --git a/pkg/skaffold/event/event_test.go b/pkg/skaffold/event/event_test.go index d279c6b1a3e..819ce028574 100644 --- a/pkg/skaffold/event/event_test.go +++ b/pkg/skaffold/event/event_test.go @@ -221,7 +221,7 @@ func TestResourceStatusCheckEventUpdated(t *testing.T) { } wait(t, func() bool { return handler.getState().StatusCheckState.Status == NotStarted }) - ResourceStatusCheckEventUpdated("ns:pod/foo", &proto.ActionableErr{ + ResourceStatusCheckEventUpdated("ns:pod/foo", proto.ActionableErr{ ErrCode: 509, Message: "image pull error", }) @@ -248,7 +248,7 @@ func TestResourceStatusCheckEventFailed(t *testing.T) { } wait(t, func() bool { return handler.getState().StatusCheckState.Status == NotStarted }) - resourceStatusCheckEventFailed("ns:pod/foo", &proto.ActionableErr{ + resourceStatusCheckEventFailed("ns:pod/foo", proto.ActionableErr{ ErrCode: 309, Message: "one or more deployments failed", })