Skip to content

Commit

Permalink
Format go files using go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom authored and tekton-robot committed Jul 9, 2019
1 parent 578a426 commit 2c9bbc5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/imagedigestexporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

var (
images = flag.String("images", "", "List of images resources built by task in json format")
images = flag.String("images", "", "List of images resources built by task in json format")
terminationMessagePath = flag.String("terminationMessagePath", "", "Location of file containing termination message")
)

Expand Down
14 changes: 7 additions & 7 deletions cmd/pullrequest-init/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestGitHubParseURL(t *testing.T) {
wantRepo := "repo"
wantPR := 1

for _, tt := range []struct{
for _, tt := range []struct {
url string
wantHost string
}{
Expand Down Expand Up @@ -112,10 +112,10 @@ func TestGitHubParseURL_errors(t *testing.T) {
func TestNewGitHubHandler(t *testing.T) {
ctx := context.Background()

for _, tt := range []struct{
for _, tt := range []struct {
in string
out string
} {
}{
{"https://github.com/tektoncd/pipeline/pull/1", "api.github.com"},
{"https://github.tekton.dev/tektoncd/pipeline/pull/1", "github.tekton.dev"},
} {
Expand Down Expand Up @@ -325,16 +325,16 @@ func diffFile(t *testing.T, path string, want interface{}, got interface{}) {
}

func TestParseGitHubURL(t *testing.T) {
good := []struct{
url string
good := []struct {
url string
wantHost string
} {
}{
{fmt.Sprintf("https://github.com/%s/%s/pull/%d", owner, repo, prNum), "https://github.com"},
{fmt.Sprintf("https://github.com/%s/%s/foo/%d", owner, repo, prNum), "https://github.com"},
{fmt.Sprintf("http://github.com/%s/%s/pull/%d", owner, repo, prNum), "http://github.com"},
{fmt.Sprintf("tacocat://github.com/%s/%s/pull/%d", owner, repo, prNum), "tacocat://github.com"},
{fmt.Sprintf("https://example.com/%s/%s/pull/%d", owner, repo, prNum), "https://example.com"},
{fmt.Sprintf("https://github.com/%s/%s/pull/%d/foo", owner, repo, prNum), "https://github.com"},
{fmt.Sprintf("https://github.com/%s/%s/pull/%d/foo", owner, repo, prNum), "https://github.com"},
{fmt.Sprintf("github.com/%s/%s/pull/%d/foo", owner, repo, prNum), "://"},
}
for _, u := range good {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ type ParamSpec struct {
type Param struct {
Name string `json:"name"`
Value string `json:"value"`
}
}
30 changes: 15 additions & 15 deletions pkg/reconciler/v1alpha1/taskrun/resources/image_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func TestAddOutputImageDigestExporter(t *testing.T) {
Name: "step1",
},
{
Name: "image-digest-exporter-step1-9l9zj",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
Name: "image-digest-exporter-step1-9l9zj",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
TerminationMessagePath: TerminationMessagePath,
TerminationMessagePolicy: "FallbackToLogsOnError",
}},
Expand Down Expand Up @@ -154,21 +154,21 @@ func TestAddOutputImageDigestExporter(t *testing.T) {
Name: "step1",
},
{
Name: "image-digest-exporter-step1-9l9zj",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
Name: "image-digest-exporter-step1-9l9zj",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
TerminationMessagePath: TerminationMessagePath,
TerminationMessagePolicy: "FallbackToLogsOnError",
}, {
Name: "step2",
}, {
Name: "image-digest-exporter-step2-mz4c7",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
Name: "image-digest-exporter-step2-mz4c7",
Image: "override-with-imagedigest-exporter-image:latest",
Command: []string{"/ko-app/imagedigestexporter"},
Args: []string{"-images", fmt.Sprintf("[{\"name\":\"source-image-1\",\"type\":\"image\",\"url\":\"gcr.io/some-image-1\",\"digest\":\"\",\"OutputImageDir\":\"%s\"}]", currentDir),
"-terminationMessagePath", "/builder/home/image-outputs/termination-log"},
TerminationMessagePath: TerminationMessagePath,
TerminationMessagePolicy: "FallbackToLogsOnError",
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/status/stepstatesorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
package status

import (
"sort"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
corev1 "k8s.io/api/core/v1"
"sort"
)


// StepStateSorter implements a sorting mechanism to align the order of the steps in TaskRun
// with the spec steps in Task.
type StepStateSorter struct {
taskRunSteps []v1alpha1.StepState
mapForSort map[string]int
mapForSort map[string]int
}

func (trt *StepStateSorter) Init(taskRunSteps []v1alpha1.StepState, taskSpecSteps []corev1.Container) {
Expand Down Expand Up @@ -62,7 +62,7 @@ func (trt *StepStateSorter) Swap(i, j int) {
trt.changeIndex(j)
// The index j is unable to reach the last index.
// When i reaches the end of the array, we need to check whether the last one needs a swap.
if (i == trt.Len() - 1 ) {
if i == trt.Len()-1 {
trt.changeIndex(i)
}
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/status/stepstatesorter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package status

import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tb "github.com/tektoncd/pipeline/test/builder"
corev1 "k8s.io/api/core/v1"
"testing"
)

func TestSortTaskRunStepOrder(t *testing.T) {
Expand All @@ -42,7 +43,6 @@ func TestSortTaskRunStepOrder(t *testing.T) {
},
},
Name: "world",

}, {
ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
Expand All @@ -59,7 +59,6 @@ func TestSortTaskRunStepOrder(t *testing.T) {
},
},
Name: "hello",

}, {

ContainerState: corev1.ContainerState{
Expand All @@ -73,7 +72,7 @@ func TestSortTaskRunStepOrder(t *testing.T) {

SortTaskRunStepOrder(taskRunStatusSteps, task.Spec.Steps)
actualStepOrder := []string{}
for _, state := range(taskRunStatusSteps) {
for _, state := range taskRunStatusSteps {
actualStepOrder = append(actualStepOrder, state.Name)
}

Expand Down

0 comments on commit 2c9bbc5

Please sign in to comment.