Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use canonical meta types in prowjobs #6199

Merged
merged 4 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hack/update-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rm -f ${TESTINFRA_ROOT}/vendor/k8s.io/apimachinery/pkg/util/sets/BUILD

"${TESTINFRA_ROOT}/hack/go_install_from_commit.sh" \
github.com/bazelbuild/bazel-gazelle/cmd/gazelle \
0.8 \
eaa1e87d2a3ca716780ca6650ef5b9b9663b8773 \
"${TMP_GOPATH}"

touch "${TESTINFRA_ROOT}/vendor/BUILD"
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TMP_GOPATH=$(mktemp -d)

"${TESTINFRA_ROOT}/hack/go_install_from_commit.sh" \
github.com/bazelbuild/bazel-gazelle/cmd/gazelle \
0.8 \
eaa1e87d2a3ca716780ca6650ef5b9b9663b8773 \
"${TMP_GOPATH}"

touch "${TESTINFRA_ROOT}/vendor/BUILD"
Expand Down
1 change: 1 addition & 0 deletions prow/cmd/sinker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ go_test(
"//prow/kube:go_default_library",
"//prow/kube/labels:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)

Expand Down
21 changes: 11 additions & 10 deletions prow/cmd/sinker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/kube"
Expand Down Expand Up @@ -209,7 +210,7 @@ func TestClean(t *testing.T) {
}
prowJobs := []kube.ProwJob{
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-failed",
},
Status: kube.ProwJobStatus{
Expand All @@ -218,7 +219,7 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-succeeded",
},
Status: kube.ProwJobStatus{
Expand All @@ -227,15 +228,15 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-just-complete",
},
Status: kube.ProwJobStatus{
StartTime: time.Now().Add(-maxProwJobAge).Add(-time.Second),
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-complete",
},
Status: kube.ProwJobStatus{
Expand All @@ -244,23 +245,23 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-incomplete",
},
Status: kube.ProwJobStatus{
StartTime: time.Now().Add(-maxProwJobAge).Add(-time.Second),
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "new",
},
Status: kube.ProwJobStatus{
StartTime: time.Now().Add(-time.Second),
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "newer-periodic",
},
Spec: kube.ProwJobSpec{
Expand All @@ -273,7 +274,7 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "older-periodic",
},
Spec: kube.ProwJobSpec{
Expand All @@ -286,7 +287,7 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "oldest-periodic",
},
Spec: kube.ProwJobSpec{
Expand All @@ -299,7 +300,7 @@ func TestClean(t *testing.T) {
},
},
{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "old-failed-trusted",
},
Status: kube.ProwJobStatus{
Expand Down
1 change: 1 addition & 0 deletions prow/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go_test(
deps = [
"//prow/github:go_default_library",
"//prow/kube:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)

Expand Down
4 changes: 3 additions & 1 deletion prow/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"strings"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/test-infra/prow/github"
"k8s.io/test-infra/prow/kube"
)
Expand Down Expand Up @@ -590,7 +592,7 @@ func TestURLTemplate(t *testing.T) {

for _, tc := range testcases {
var pj = kube.ProwJob{
ObjectMeta: kube.ObjectMeta{Name: tc.name},
ObjectMeta: metav1.ObjectMeta{Name: tc.name},
Spec: kube.ProwJobSpec{
Type: tc.jobType,
Job: tc.job,
Expand Down
1 change: 1 addition & 0 deletions prow/jenkins/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ go_test(
"//prow/kube:go_default_library",
"//prow/pjutil:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
13 changes: 7 additions & 6 deletions prow/jenkins/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/github"
Expand Down Expand Up @@ -362,7 +363,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "enqueued",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "foofoo",
},
Spec: kube.ProwJobSpec{
Expand All @@ -382,7 +383,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "finished queue",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "boing",
},
Spec: kube.ProwJobSpec{
Expand All @@ -404,7 +405,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "building",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "firstoutthetrenches",
},
Spec: kube.ProwJobSpec{
Expand All @@ -424,7 +425,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "missing build",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "blabla",
},
Spec: kube.ProwJobSpec{
Expand Down Expand Up @@ -454,7 +455,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "finished, success",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "winwin",
},
Spec: kube.ProwJobSpec{
Expand All @@ -475,7 +476,7 @@ func TestSyncPendingJobs(t *testing.T) {
{
name: "finished, failed",
pj: kube.ProwJob{
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "whatapity",
},
Spec: kube.ProwJobSpec{
Expand Down
1 change: 1 addition & 0 deletions prow/kube/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_library(
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
],
)
Expand Down
13 changes: 8 additions & 5 deletions prow/kube/prowjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"fmt"
"strings"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ProwJobType string
Expand Down Expand Up @@ -68,11 +70,12 @@ const (
)

type ProwJob struct {
APIVersion string `json:"apiVersion,omitempty"`
Kind string `json:"kind,omitempty"`
ObjectMeta ObjectMeta `json:"metadata,omitempty"`
Spec ProwJobSpec `json:"spec,omitempty"`
Status ProwJobStatus `json:"status,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaving type meta as is for now. I will change to metav1.TypeMeta once we switch to use client-go (otherwise, it won't work).

Kind string `json:"kind,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ProwJobSpec `json:"spec,omitempty"`
Status ProwJobStatus `json:"status,omitempty"`
}

type ProwJobSpec struct {
Expand Down
6 changes: 5 additions & 1 deletion prow/pjutil/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_library(
"//prow/kube:go_default_library",
"//vendor/github.com/satori/go.uuid:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)

Expand All @@ -47,5 +48,8 @@ go_test(
embed = [":go_default_library"],
importpath = "k8s.io/test-infra/prow/pjutil",
tags = ["automanaged"],
deps = ["//prow/kube:go_default_library"],
deps = [
"//prow/kube:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
3 changes: 2 additions & 1 deletion prow/pjutil/pjutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/github"
Expand All @@ -34,7 +35,7 @@ func NewProwJob(spec kube.ProwJobSpec, labels map[string]string) kube.ProwJob {
return kube.ProwJob{
APIVersion: "prow.k8s.io/v1",
Kind: "ProwJob",
ObjectMeta: kube.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: uuid.NewV1().String(),
Labels: labels,
},
Expand Down
Loading