From 61838e11c2d4812b7d12c93e04f862780bd8000a Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Wed, 5 Feb 2020 12:01:28 -0800 Subject: [PATCH] boskos: move main packages into cmd/ --- boskos/BUILD.bazel | 73 ++++--------------- boskos/cleaner/BUILD.bazel | 5 +- boskos/cmd/boskos/BUILD.bazel | 67 +++++++++++++++++ boskos/{ => cmd/boskos}/boskos.go | 0 boskos/{ => cmd/boskos}/boskos_test.go | 0 boskos/{ => cmd/boskos}/server_client_test.go | 0 boskos/{ => cmd/boskos}/storage_test.go | 0 .../{cleaner/cmd => cmd/cleaner}/BUILD.bazel | 2 +- .../cleaner}/example-deployment.yaml | 0 boskos/{cleaner/cmd => cmd/cleaner}/main.go | 0 boskos/{mason => cmd}/fake-mason/BUILD.bazel | 2 +- boskos/{mason => cmd}/fake-mason/main.go | 0 boskos/{ => cmd}/janitor/BUILD.bazel | 2 +- boskos/{ => cmd}/janitor/gcp_janitor.py | 0 boskos/{ => cmd}/janitor/janitor.go | 0 boskos/{ => cmd}/janitor/janitor_test.go | 0 boskos/{ => cmd}/metrics/BUILD.bazel | 2 +- boskos/{ => cmd}/metrics/metrics.go | 0 boskos/{ => cmd}/reaper/BUILD.bazel | 2 +- boskos/{ => cmd}/reaper/reaper.go | 0 boskos/mason/BUILD.bazel | 5 +- .../jobs/kubernetes/test-infra/janitors.yaml | 2 +- scenarios/kubernetes_janitor.py | 2 +- 23 files changed, 89 insertions(+), 75 deletions(-) create mode 100644 boskos/cmd/boskos/BUILD.bazel rename boskos/{ => cmd/boskos}/boskos.go (100%) rename boskos/{ => cmd/boskos}/boskos_test.go (100%) rename boskos/{ => cmd/boskos}/server_client_test.go (100%) rename boskos/{ => cmd/boskos}/storage_test.go (100%) rename boskos/{cleaner/cmd => cmd/cleaner}/BUILD.bazel (94%) rename boskos/{cleaner/cmd => cmd/cleaner}/example-deployment.yaml (100%) rename boskos/{cleaner/cmd => cmd/cleaner}/main.go (100%) rename boskos/{mason => cmd}/fake-mason/BUILD.bazel (94%) rename boskos/{mason => cmd}/fake-mason/main.go (100%) rename boskos/{ => cmd}/janitor/BUILD.bazel (96%) rename boskos/{ => cmd}/janitor/gcp_janitor.py (100%) rename boskos/{ => cmd}/janitor/janitor.go (100%) rename boskos/{ => cmd}/janitor/janitor_test.go (100%) rename boskos/{ => cmd}/metrics/BUILD.bazel (95%) rename boskos/{ => cmd}/metrics/metrics.go (100%) rename boskos/{ => cmd}/reaper/BUILD.bazel (93%) rename boskos/{ => cmd}/reaper/reaper.go (100%) diff --git a/boskos/BUILD.bazel b/boskos/BUILD.bazel index 0f023cdef0d6..38f4afd15241 100644 --- a/boskos/BUILD.bazel +++ b/boskos/BUILD.bazel @@ -1,73 +1,23 @@ package(default_visibility = ["//visibility:public"]) load("//def:image.bzl", "tags") -load("//prow:def.bzl", "prow_image", "prow_push") -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") - -go_binary( - name = "boskos", - embed = [":go_default_library"], - pure = "on", -) - -prow_image( - name = "image", - visibility = ["//visibility:public"], -) +load("//prow:def.bzl", "prow_push") prow_push( name = "push", images = tags(targets = { "{STABLE_PROW_REPO}/boskos/aws-janitor": "//boskos/aws-janitor:image", "{STABLE_PROW_REPO}/boskos/aws-janitor-boskos": "//boskos/aws-janitor/cmd/aws-janitor-boskos:image", - "{STABLE_PROW_REPO}/boskos/boskos": "//boskos:image", - "{STABLE_PROW_REPO}/boskos/fake-mason": "//boskos/mason/fake-mason:image", - "{STABLE_PROW_REPO}/boskos/cleaner": "//boskos/cleaner/cmd:image", - "{STABLE_PROW_REPO}/boskos/janitor": "//boskos/janitor:image", - "{STABLE_PROW_REPO}/boskos/metrics": "//boskos/metrics:image", - "{STABLE_PROW_REPO}/boskos/reaper": "//boskos/reaper:image", + "{STABLE_PROW_REPO}/boskos/boskos": "//boskos/cmd/boskos:image", + "{STABLE_PROW_REPO}/boskos/fake-mason": "//boskos/cmd/fake-mason:image", + "{STABLE_PROW_REPO}/boskos/cleaner": "//boskos/cmd/cleaner:image", + "{STABLE_PROW_REPO}/boskos/janitor": "//boskos/cmd/janitor:image", + "{STABLE_PROW_REPO}/boskos/metrics": "//boskos/cmd/metrics:image", + "{STABLE_PROW_REPO}/boskos/reaper": "//boskos/cmd/reaper:image", "{STABLE_PROW_REPO}/boskos/cli": "//boskos/cmd/cli:image", }), ) -go_test( - name = "go_default_test", - srcs = [ - "boskos_test.go", - "server_client_test.go", - "storage_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//boskos/client:go_default_library", - "//boskos/common:go_default_library", - "//boskos/crds:go_default_library", - "//boskos/ranch:go_default_library", - "//boskos/storage:go_default_library", - ], -) - -go_library( - name = "go_default_library", - srcs = ["boskos.go"], - importpath = "k8s.io/test-infra/boskos", - deps = [ - "//boskos/common:go_default_library", - "//boskos/crds:go_default_library", - "//boskos/ranch:go_default_library", - "//prow/config:go_default_library", - "//prow/interrupts:go_default_library", - "//prow/logrusutil:go_default_library", - "//prow/metrics:go_default_library", - "//prow/pjutil:go_default_library", - "//prow/simplifypath:go_default_library", - "@com_github_fsnotify_fsnotify//:go_default_library", - "@com_github_prometheus_client_golang//prometheus:go_default_library", - "@com_github_sirupsen_logrus//:go_default_library", - "@com_github_spf13_viper//:go_default_library", - ], -) - filegroup( name = "package-srcs", srcs = glob(["**"]), @@ -82,14 +32,17 @@ filegroup( "//boskos/aws-janitor:all-srcs", "//boskos/cleaner:all-srcs", "//boskos/client:all-srcs", + "//boskos/cmd/boskos:all-srcs", + "//boskos/cmd/cleaner:all-srcs", "//boskos/cmd/cli:all-srcs", + "//boskos/cmd/fake-mason:all-srcs", + "//boskos/cmd/janitor:all-srcs", + "//boskos/cmd/metrics:all-srcs", + "//boskos/cmd/reaper:all-srcs", "//boskos/common:all-srcs", "//boskos/crds:all-srcs", - "//boskos/janitor:all-srcs", "//boskos/mason:all-srcs", - "//boskos/metrics:all-srcs", "//boskos/ranch:all-srcs", - "//boskos/reaper:all-srcs", "//boskos/storage:all-srcs", ], tags = ["automanaged"], diff --git a/boskos/cleaner/BUILD.bazel b/boskos/cleaner/BUILD.bazel index 1b576fb88b41..4875b4a6c7b3 100644 --- a/boskos/cleaner/BUILD.bazel +++ b/boskos/cleaner/BUILD.bazel @@ -21,10 +21,7 @@ filegroup( filegroup( name = "all-srcs", - srcs = [ - ":package-srcs", - "//boskos/cleaner/cmd:all-srcs", - ], + srcs = [":package-srcs"], tags = ["automanaged"], visibility = ["//visibility:public"], ) diff --git a/boskos/cmd/boskos/BUILD.bazel b/boskos/cmd/boskos/BUILD.bazel new file mode 100644 index 000000000000..de432680d4bf --- /dev/null +++ b/boskos/cmd/boskos/BUILD.bazel @@ -0,0 +1,67 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("//prow:def.bzl", "prow_image") + +go_binary( + name = "boskos", + embed = [":go_default_library"], + pure = "on", + visibility = ["//visibility:public"], +) + +prow_image( + name = "image", + visibility = ["//visibility:public"], +) + +go_library( + name = "go_default_library", + srcs = ["boskos.go"], + importpath = "k8s.io/test-infra/boskos/cmd/boskos", + visibility = ["//visibility:private"], + deps = [ + "//boskos/common:go_default_library", + "//boskos/crds:go_default_library", + "//boskos/ranch:go_default_library", + "//prow/config:go_default_library", + "//prow/interrupts:go_default_library", + "//prow/logrusutil:go_default_library", + "//prow/metrics:go_default_library", + "//prow/pjutil:go_default_library", + "//prow/simplifypath:go_default_library", + "@com_github_fsnotify_fsnotify//:go_default_library", + "@com_github_prometheus_client_golang//prometheus:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", + "@com_github_spf13_viper//:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "boskos_test.go", + "server_client_test.go", + "storage_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//boskos/client:go_default_library", + "//boskos/common:go_default_library", + "//boskos/crds:go_default_library", + "//boskos/ranch:go_default_library", + "//boskos/storage:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/boskos/boskos.go b/boskos/cmd/boskos/boskos.go similarity index 100% rename from boskos/boskos.go rename to boskos/cmd/boskos/boskos.go diff --git a/boskos/boskos_test.go b/boskos/cmd/boskos/boskos_test.go similarity index 100% rename from boskos/boskos_test.go rename to boskos/cmd/boskos/boskos_test.go diff --git a/boskos/server_client_test.go b/boskos/cmd/boskos/server_client_test.go similarity index 100% rename from boskos/server_client_test.go rename to boskos/cmd/boskos/server_client_test.go diff --git a/boskos/storage_test.go b/boskos/cmd/boskos/storage_test.go similarity index 100% rename from boskos/storage_test.go rename to boskos/cmd/boskos/storage_test.go diff --git a/boskos/cleaner/cmd/BUILD.bazel b/boskos/cmd/cleaner/BUILD.bazel similarity index 94% rename from boskos/cleaner/cmd/BUILD.bazel rename to boskos/cmd/cleaner/BUILD.bazel index f7376b725289..c4f684f6b5b2 100644 --- a/boskos/cleaner/cmd/BUILD.bazel +++ b/boskos/cmd/cleaner/BUILD.bazel @@ -4,7 +4,7 @@ load("//prow:def.bzl", "prow_image") go_library( name = "go_default_library", srcs = ["main.go"], - importpath = "k8s.io/test-infra/boskos/cleaner/cmd", + importpath = "k8s.io/test-infra/boskos/cmd/cleaner", visibility = ["//visibility:private"], deps = [ "//boskos/cleaner:go_default_library", diff --git a/boskos/cleaner/cmd/example-deployment.yaml b/boskos/cmd/cleaner/example-deployment.yaml similarity index 100% rename from boskos/cleaner/cmd/example-deployment.yaml rename to boskos/cmd/cleaner/example-deployment.yaml diff --git a/boskos/cleaner/cmd/main.go b/boskos/cmd/cleaner/main.go similarity index 100% rename from boskos/cleaner/cmd/main.go rename to boskos/cmd/cleaner/main.go diff --git a/boskos/mason/fake-mason/BUILD.bazel b/boskos/cmd/fake-mason/BUILD.bazel similarity index 94% rename from boskos/mason/fake-mason/BUILD.bazel rename to boskos/cmd/fake-mason/BUILD.bazel index 825b42e23f92..eb1b0f989613 100644 --- a/boskos/mason/fake-mason/BUILD.bazel +++ b/boskos/cmd/fake-mason/BUILD.bazel @@ -4,7 +4,7 @@ load("//prow:def.bzl", "prow_image") go_library( name = "go_default_library", srcs = ["main.go"], - importpath = "k8s.io/test-infra/boskos/mason/fake-mason", + importpath = "k8s.io/test-infra/boskos/cmd/fake-mason", visibility = ["//visibility:private"], deps = [ "//boskos/client:go_default_library", diff --git a/boskos/mason/fake-mason/main.go b/boskos/cmd/fake-mason/main.go similarity index 100% rename from boskos/mason/fake-mason/main.go rename to boskos/cmd/fake-mason/main.go diff --git a/boskos/janitor/BUILD.bazel b/boskos/cmd/janitor/BUILD.bazel similarity index 96% rename from boskos/janitor/BUILD.bazel rename to boskos/cmd/janitor/BUILD.bazel index ad725a3920b3..f9a5baf6605c 100644 --- a/boskos/janitor/BUILD.bazel +++ b/boskos/cmd/janitor/BUILD.bazel @@ -19,7 +19,7 @@ go_binary( go_library( name = "go_default_library", srcs = ["janitor.go"], - importpath = "k8s.io/test-infra/boskos/janitor", + importpath = "k8s.io/test-infra/boskos/cmd/janitor", deps = [ "//boskos/client:go_default_library", "//boskos/common:go_default_library", diff --git a/boskos/janitor/gcp_janitor.py b/boskos/cmd/janitor/gcp_janitor.py similarity index 100% rename from boskos/janitor/gcp_janitor.py rename to boskos/cmd/janitor/gcp_janitor.py diff --git a/boskos/janitor/janitor.go b/boskos/cmd/janitor/janitor.go similarity index 100% rename from boskos/janitor/janitor.go rename to boskos/cmd/janitor/janitor.go diff --git a/boskos/janitor/janitor_test.go b/boskos/cmd/janitor/janitor_test.go similarity index 100% rename from boskos/janitor/janitor_test.go rename to boskos/cmd/janitor/janitor_test.go diff --git a/boskos/metrics/BUILD.bazel b/boskos/cmd/metrics/BUILD.bazel similarity index 95% rename from boskos/metrics/BUILD.bazel rename to boskos/cmd/metrics/BUILD.bazel index 90f53a23c09d..3351d760be32 100644 --- a/boskos/metrics/BUILD.bazel +++ b/boskos/cmd/metrics/BUILD.bazel @@ -19,7 +19,7 @@ go_binary( go_library( name = "go_default_library", srcs = ["metrics.go"], - importpath = "k8s.io/test-infra/boskos/metrics", + importpath = "k8s.io/test-infra/boskos/cmd/metrics", deps = [ "//boskos/client:go_default_library", "//boskos/common:go_default_library", diff --git a/boskos/metrics/metrics.go b/boskos/cmd/metrics/metrics.go similarity index 100% rename from boskos/metrics/metrics.go rename to boskos/cmd/metrics/metrics.go diff --git a/boskos/reaper/BUILD.bazel b/boskos/cmd/reaper/BUILD.bazel similarity index 93% rename from boskos/reaper/BUILD.bazel rename to boskos/cmd/reaper/BUILD.bazel index 216c4d4cdf09..ef700fe9da8d 100644 --- a/boskos/reaper/BUILD.bazel +++ b/boskos/cmd/reaper/BUILD.bazel @@ -12,7 +12,7 @@ go_binary( go_library( name = "go_default_library", srcs = ["reaper.go"], - importpath = "k8s.io/test-infra/boskos/reaper", + importpath = "k8s.io/test-infra/boskos/cmd/reaper", deps = [ "//boskos/client:go_default_library", "//boskos/common:go_default_library", diff --git a/boskos/reaper/reaper.go b/boskos/cmd/reaper/reaper.go similarity index 100% rename from boskos/reaper/reaper.go rename to boskos/cmd/reaper/reaper.go diff --git a/boskos/mason/BUILD.bazel b/boskos/mason/BUILD.bazel index 7684309ede22..e00dc17ce485 100644 --- a/boskos/mason/BUILD.bazel +++ b/boskos/mason/BUILD.bazel @@ -44,10 +44,7 @@ filegroup( filegroup( name = "all-srcs", - srcs = [ - ":package-srcs", - "//boskos/mason/fake-mason:all-srcs", - ], + srcs = [":package-srcs"], tags = ["automanaged"], visibility = ["//visibility:public"], ) diff --git a/config/jobs/kubernetes/test-infra/janitors.yaml b/config/jobs/kubernetes/test-infra/janitors.yaml index 995de9febf03..47670cebde3a 100644 --- a/config/jobs/kubernetes/test-infra/janitors.yaml +++ b/config/jobs/kubernetes/test-infra/janitors.yaml @@ -39,7 +39,7 @@ periodics: - experiment/ci-janitor/main.go - --config-path=config/prow/config.yaml - --job-config-path=config/jobs - - --janitor-path=boskos/janitor/gcp_janitor.py + - --janitor-path=boskos/cmd/janitor/gcp_janitor.py image: gcr.io/k8s-testimages/kubekins-e2e:v20200205-602500d-master resources: requests: diff --git a/scenarios/kubernetes_janitor.py b/scenarios/kubernetes_janitor.py index c3ed9b9467a1..a76f76551d58 100755 --- a/scenarios/kubernetes_janitor.py +++ b/scenarios/kubernetes_janitor.py @@ -63,7 +63,7 @@ def clean_project(project, hours=24, dryrun=False, ratelimit=None, filt=None): return CHECKED.add(project) - cmd = ['python', test_infra('boskos/janitor/gcp_janitor.py'), '--project=%s' % project] + cmd = ['python', test_infra('boskos/cmd/janitor/gcp_janitor.py'), '--project=%s' % project] cmd.append('--hour=%d' % hours) if dryrun: cmd.append('--dryrun')