Skip to content

Commit

Permalink
code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Aug 13, 2019
1 parent 7ae27c7 commit e03a889
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
8 changes: 3 additions & 5 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ func (h *HelmDeployer) Deploy(ctx context.Context, out io.Writer, builds []build
labelDeployResults(labels, dRes)

// Collect namespaces in a string
namespaces := make([]string, len(nsMap))
i := 0
for k := range nsMap {
namespaces[i] = k
i++
namespaces := make([]string, 0, len(nsMap))
for ns := range nsMap {
namespaces = append(namespaces, ns)
}

return NewDeploySuccessResult(namespaces)
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (k *KubectlDeployer) Deploy(ctx context.Context, out io.Writer, builds []bu

namespaces, err := manifests.CollectNamespaces()
if err != nil {
event.DeployInfoEvent(errors.Wrap(err, "could not fetch deployed resource namespace."+
event.DeployInfoEvent(errors.Wrap(err, "could not fetch deployed resource namespace. "+
"This might cause port-forward and deploy health-check to fail."))
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/skaffold/deploy/kubectl/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ func (l *ManifestList) CollectNamespaces() ([]string, error) {
if _, err := l.Visit(replacer); err != nil {
return nil, errors.Wrap(err, "collecting namespaces")
}
namespaces := make([]string, len(replacer.namespaces))
i := 0

namespaces := make([]string, 0, len(replacer.namespaces))
for ns := range replacer.namespaces {
namespaces[i] = ns
i++
namespaces = append(namespaces, ns)
}
sort.Strings(namespaces)
return namespaces, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func DeployInProgress() {
handler.handleDeployEvent(&proto.DeployEvent{Status: InProgress})
}

// DeployFailed notifies that a deployment has failed.
// DeployFailed notifies that non-fatal errors were encountered during a deployment.
func DeployFailed(err error) {
handler.handleDeployEvent(&proto.DeployEvent{Status: Failed, Err: err.Error()})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/runner/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type withNotification struct {

func (w withNotification) Deploy(ctx context.Context, out io.Writer, builds []build.Artifact, labellers []deploy.Labeller) *deploy.Result {
dr := w.Deployer.Deploy(ctx, out, builds, labellers)
if isErr, _ := dr.IsError(); isErr {
if isErr, _ := dr.IsError(); !isErr {
fmt.Fprint(out, terminalBell)
}
return dr
Expand Down
6 changes: 2 additions & 4 deletions pkg/skaffold/runner/runcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ func (r *RunContext) UpdateNamespaces(ns []string) {
}

// Update RunContext Namespace
updated := make([]string, len(nsMap))
i := 0
updated := make([]string, 0, len(nsMap))
for k := range nsMap {
updated[i] = k
i++
updated = append(updated, k)
}
sort.Strings(updated)
r.Namespaces = updated
Expand Down

0 comments on commit e03a889

Please sign in to comment.