Skip to content

Commit b73379d

Browse files
authored
remove adobe_rules_gitops (#18)
1 parent d553846 commit b73379d

File tree

6 files changed

+42
-193
lines changed

6 files changed

+42
-193
lines changed

WORKSPACE

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ workspace(
44
)
55
# gazelle:repo bazel_gazelle
66

7-
# optionally override the default version of rules_gitops with a local copy
8-
# local_repository(
9-
# name = "com_adobe_rules_gitops",
10-
# path = "../rules_gitops",
11-
# )
12-
137
#Fetch deps needed for local development"
148
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
159

@@ -20,20 +14,6 @@ http_archive(
2014
url = "https://github.com/bazel-contrib/rules_oci/releases/download/v1.7.4/rules_oci-v1.7.4.tar.gz",
2115
)
2216

23-
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
24-
25-
rules_oci_dependencies()
26-
27-
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
28-
29-
oci_register_toolchains(
30-
name = "oci",
31-
crane_version = LATEST_CRANE_VERSION,
32-
# Uncommenting the zot toolchain will cause it to be used instead of crane for some tasks.
33-
# Note that it does not support docker-format images.
34-
# zot_version = LATEST_ZOT_VERSION,
35-
)
36-
3717
http_archive(
3818
name = "io_bazel_rules_go",
3919
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
@@ -76,29 +56,50 @@ http_archive(
7656

7757
http_archive(
7858
name = "aspect_bazel_lib",
79-
sha256 = "44f4f6d1ea1fc5a79ed6ca83f875038fee0a0c47db4f9c9beed097e56f8fad03",
80-
strip_prefix = "bazel-lib-1.34.0",
81-
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.34.0/bazel-lib-v1.34.0.tar.gz",
59+
sha256 = "6d758a8f646ecee7a3e294fbe4386daafbe0e5966723009c290d493f227c390b",
60+
strip_prefix = "bazel-lib-2.7.7",
61+
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.7/bazel-lib-v2.7.7.tar.gz",
8262
)
8363

8464
load("//mirror:repositories.bzl", "rules_mirror_dependencies")
8565

8666
# Fetch dependencies which users need as well
8767
rules_mirror_dependencies()
8868

69+
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
70+
71+
rules_oci_dependencies()
72+
73+
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
74+
75+
oci_register_toolchains(
76+
name = "oci",
77+
crane_version = LATEST_CRANE_VERSION,
78+
# Uncommenting the zot toolchain will cause it to be used instead of crane for some tasks.
79+
# Note that it does not support docker-format images.
80+
# zot_version = LATEST_ZOT_VERSION,
81+
)
82+
8983
# For running our own unit tests
9084
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
9185

9286
bazel_skylib_workspace()
9387

94-
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
88+
# load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
89+
90+
# Required bazel-lib dependencies
9591

96-
aspect_bazel_lib_dependencies()
92+
# aspect_bazel_lib_dependencies()
93+
94+
# Register bazel-lib toolchains
95+
96+
#aspect_bazel_lib_register_toolchains()
97+
98+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
9799

98100
############################################
99101
# Gazelle, for generating bzl_library targets
100102
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
101-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
102103
load("//:go_repositories.bzl", "go_dependencies")
103104

104105
# gazelle:repository_macro go_repositories.bzl%go_dependencies
@@ -111,37 +112,19 @@ go_register_toolchains(version = "1.19.3")
111112
gazelle_dependencies()
112113

113114
############################################
114-
# Setup for com_adobe_rules_gitops
115-
load("@com_adobe_rules_gitops//gitops:deps.bzl", "rules_gitops_dependencies")
115+
# Setup for rules_gitops
116+
load("@rules_gitops//gitops:deps.bzl", "rules_gitops_dependencies")
116117

117118
rules_gitops_dependencies()
118119

119-
load("@com_adobe_rules_gitops//gitops:repositories.bzl", "rules_gitops_repositories")
120+
load("@rules_gitops//gitops:repositories.bzl", "rules_gitops_repositories")
120121

121122
rules_gitops_repositories()
122123

123-
load("@com_adobe_rules_gitops//skylib:k8s.bzl", "kubeconfig")
124+
load("@rules_gitops//skylib:k8s.bzl", "kubeconfig")
124125

125126
kubeconfig(
126127
name = "k8s_test",
127128
cluster = "dummy",
128129
use_host_config = True,
129130
)
130-
131-
############################################
132-
# Setup for rules_gitops
133-
load("@rules_gitops//gitops:deps.bzl", rg_dependencies = "rules_gitops_dependencies")
134-
135-
rg_dependencies()
136-
137-
load("@rules_gitops//gitops:repositories.bzl", rg_repositories = "rules_gitops_repositories")
138-
139-
rg_repositories()
140-
141-
load("@rules_gitops//skylib:k8s.bzl", rg_kubeconfig = "kubeconfig")
142-
143-
rg_kubeconfig(
144-
name = "rg_remote_test",
145-
cluster = "dummy",
146-
use_host_config = True,
147-
)

mirror/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ bzl_library(
2323
name = "defs",
2424
srcs = ["defs.bzl"],
2525
visibility = ["//visibility:public"],
26-
# deps = ["@com_adobe_rules_gitops//skylib:push"],
2726
)

mirror/defs.bzl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"Public API"
22

33
load("@rules_gitops//gitops:provider.bzl", "GitopsPushInfo")
4-
load("@com_adobe_rules_gitops//skylib:push.bzl", "K8sPushInfo")
54
load("@rules_gitops//skylib:runfile.bzl", "get_runfile_path")
65

76
def _replace_colon_except_last_segment(input_string):
@@ -61,22 +60,13 @@ def _mirror_image_impl(ctx):
6160
is_executable = True,
6261
)
6362

64-
dst_registry, dst_repository = dst_without_hash.split("/", 1)
65-
6663
runfiles = ctx.runfiles(files = pusher_input).merge(ctx.attr.mirror_tool[DefaultInfo].default_runfiles)
6764

6865
return [
6966
DefaultInfo(
7067
runfiles = runfiles,
7168
executable = ctx.outputs.executable,
7269
),
73-
K8sPushInfo(
74-
image_label = ctx.label,
75-
legacy_image_name = ctx.attr.image_name,
76-
registry = dst_registry,
77-
repository = dst_repository,
78-
digestfile = digest_file,
79-
),
8070
GitopsPushInfo(
8171
image_label = ctx.label,
8272
repository = dst_without_hash,
@@ -92,7 +82,7 @@ mirror_image_rule = rule(
9282
doc = "The image to mirror",
9383
),
9484
"image_name": attr.string(
95-
doc = "The name that could be referred in manifests. This field is deprecated and used only in legacy com_adobe_rules_gitops.",
85+
doc = "The name that could be referred in manifests. This field is deprecated and unused.",
9686
),
9787
"digest": attr.string(
9888
mandatory = False,

mirror/repositories.bzl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,16 @@ def rules_mirror_dependencies():
2121
],
2222
)
2323

24-
http_archive(
25-
name = "com_adobe_rules_gitops",
26-
sha256 = "83124a8056b1e0f555c97adeef77ec6dff387eb3f5bc58f212b376ba06d070dd",
27-
strip_prefix = "rules_gitops-0.17.2",
28-
urls = ["https://github.com/adobe/rules_gitops/archive/refs/tags/v0.17.2.tar.gz"],
29-
)
30-
31-
http_archive(
32-
name = "io_bazel_rules_docker",
33-
sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
34-
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
35-
)
36-
3724
http_archive(
3825
name = "rules_oci",
3926
sha256 = "176e601d21d1151efd88b6b027a24e782493c5d623d8c6211c7767f306d655c8",
4027
strip_prefix = "rules_oci-1.2.0",
4128
url = "https://github.com/bazel-contrib/rules_oci/releases/download/v1.2.0/rules_oci-v1.2.0.tar.gz",
4229
)
4330

44-
RULES_GITOPS_COMMIT = "aa6320b36aec9beacd0af9c3ad3bb479e41f3bce"
45-
4631
http_archive(
4732
name = "rules_gitops",
48-
sha256 = "694cad4247a0d4919fa5d41d17770d9aab0d9858ef03ca5658787de70557889a",
49-
strip_prefix = "rules_gitops-%s" % RULES_GITOPS_COMMIT,
50-
urls = ["https://github.com/fasterci/rules_gitops/archive/%s.tar.gz" % RULES_GITOPS_COMMIT],
33+
sha256 = "37be3b22375a91b0839385364882938a972564c5510b6c6ca92f6bfc0221fe79",
34+
strip_prefix = "rules_gitops-0.31.6",
35+
urls = ["https://github.com/fasterci/rules_gitops/releases/download/v0.31.6/rules_gitops-v0.31.6.tar.gz"],
5136
)

mirror/tests/BUILD.bazel

Lines changed: 7 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
2-
load("@com_adobe_rules_gitops//skylib/kustomize:kustomize.bzl", "kustomize")
3-
load("@com_adobe_rules_gitops//gitops:defs.bzl", "k8s_deploy", "k8s_test_setup")
4-
load("//mirror:defs.bzl", "mirror_image")
5-
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
62
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
7-
load("@rules_gitops//skylib/kustomize:kustomize.bzl", kustomize_rg = "kustomize")
8-
load("@rules_gitops//gitops:defs.bzl", k8s_deploy_rg = "k8s_deploy", k8s_test_setup_rg = "k8s_test_setup")
3+
load("@rules_gitops//gitops:defs.bzl", "k8s_deploy", "k8s_test_setup")
4+
load("@rules_gitops//skylib/kustomize:kustomize.bzl", "kustomize")
5+
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
6+
load("//mirror:defs.bzl", "mirror_image")
97

108
# create a simple image for testing
119

@@ -41,10 +39,10 @@ mirror_image(
4139
name = "image_mirror",
4240
digest = "sha256:b812c0570a7c369b2863c64e22760dc1b1dbc025a739f02db376bac62862f4cc",
4341
dst_prefix = "localhost:1338/mirror",
42+
push_timeout = "60s",
4443
src_image = "localhost:1338/image",
4544
tags = ["manual"], # test should be tagged manual since it requires a running registry
4645
visibility = ["//visibility:public"],
47-
push_timeout = "60s",
4846
)
4947

5048
mirror_image(
@@ -67,40 +65,15 @@ kustomize(
6765
namespace = "",
6866
)
6967

70-
kustomize_rg(
71-
name = "kustomize2",
72-
images = [
73-
":image_mirror",
74-
],
75-
manifests = [
76-
"deployment.yaml",
77-
],
78-
namespace = "",
79-
)
80-
8168
write_source_files(
8269
name = "write_golden_files",
8370
files = {
8471
"kustomize1.golden": ":kustomize1",
85-
"kustomize2.golden": ":kustomize2",
8672
},
8773
)
8874

8975
# use k8s_deploy with mirrored image
9076
k8s_deploy(
91-
name = "adobe_gitops_deploy",
92-
cluster = "dummy",
93-
images = [
94-
":image_mirror",
95-
],
96-
manifests = [
97-
"deployment.yaml",
98-
"service.yaml",
99-
],
100-
namespace = "{BUILD_USER}",
101-
)
102-
103-
k8s_deploy_rg(
10477
name = "fasterci_gitops_deploy",
10578
cluster = "dummy",
10679
images = [
@@ -113,12 +86,6 @@ k8s_deploy_rg(
11386
namespace = "{BUILD_USER}",
11487
)
11588

116-
assert_contains(
117-
name = "adobe_gitops_deploy_has_mirrored_image",
118-
actual = ":adobe_gitops_deploy",
119-
expected = "image: localhost:1338/mirror/localhost1338/image@sha256:b812c0570a7c369b2863c64e22760dc1b1dbc025a739f02db376bac62862f4cc",
120-
)
121-
12289
assert_contains(
12390
name = "fasterci_gitops_deploy_has_mirrored_image",
12491
actual = ":fasterci_gitops_deploy",
@@ -130,68 +97,11 @@ exports_files([
13097
"kubeconfig.yaml",
13198
])
13299

133-
# Execution of this setup should push the mirrored image to the registry
134-
k8s_test_setup(
135-
name = "adobe_gitops.setup",
136-
kubeconfig = ":kubeconfig.yaml",
137-
kubectl = ":kubectl",
138-
objects = [
139-
":adobe_gitops_deploy",
140-
],
141-
)
142-
143-
# run the setup and verify the mirrored image is pushed
144-
sh_test(
145-
name = "adobe_gitops_setup_test",
146-
srcs = ["gitops_setup_test.sh"],
147-
args = [
148-
"$(location :adobe_gitops.setup) localhost:1338/mirror/localhost/1338/image@sha256:b812c0570a7c369b2863c64e22760dc1b1dbc025a739f02db376bac62862f4cc",
149-
],
150-
data = [
151-
":adobe_gitops.setup",
152-
":kubectl",
153-
":push_image",
154-
"@com_github_google_go_containerregistry//cmd/crane",
155-
"@com_github_google_go_containerregistry//cmd/registry",
156-
],
157-
env = {
158-
"KUBECTL": "$(location :kubectl)",
159-
"PUSH_IMAGE": "$(location :push_image)",
160-
"CRANE_BIN": "$(location @com_github_google_go_containerregistry//cmd/crane)",
161-
"REGISTRY_BIN": "$(location @com_github_google_go_containerregistry//cmd/registry)",
162-
},
163-
tags = [
164-
"exclusive",
165-
"manual",
166-
], # this test starts a registry on fixed port 1338
167-
)
168-
169-
sh_test(
170-
name = "adobe_gitops_apply_test",
171-
srcs = ["gitops_setup_test.sh"],
172-
args = [
173-
"$(location :adobe_gitops_deploy.apply) localhost:1338/mirror/localhost1338/image@sha256:b812c0570a7c369b2863c64e22760dc1b1dbc025a739f02db376bac62862f4cc",
174-
],
175-
data = [
176-
":adobe_gitops_deploy.apply",
177-
":kubectl",
178-
":push_image",
179-
"@com_github_google_go_containerregistry//cmd/crane",
180-
"@com_github_google_go_containerregistry//cmd/registry",
181-
],
182-
env = {
183-
"KUBECTL": "$(location :kubectl)",
184-
"PUSH_IMAGE": "$(location :push_image)",
185-
"CRANE_BIN": "$(location @com_github_google_go_containerregistry//cmd/crane)",
186-
"REGISTRY_BIN": "$(location @com_github_google_go_containerregistry//cmd/registry)",
187-
},
188-
tags = ["exclusive"], # this test starts a registry on fixed port 1338
189-
)
190-
191100
# very it works with fasterci too
192101
# Execution of this setup should push the mirrored image to the registry
193-
k8s_test_setup_rg(
102+
k8s_test_setup(
194103
name = "fasterci_gitops.setup",
104+
cluster = "@k8s_test//:cluster",
195105
kubeconfig = ":kubeconfig.yaml",
196106
kubectl = ":kubectl",
197107
objects = [

mirror/tests/kustomize2.golden

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)