-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * update tests * wip * reimplement image aliases * update aspect_bazel_lib
- Loading branch information
1 parent
16bd84e
commit 29dc880
Showing
18 changed files
with
153 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ spec: | |
spec: | ||
containers: | ||
- name: myapp | ||
image: //skylib/kustomize/tests:image | ||
image: testimage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- name: myapp | ||
image: //skylib/kustomize/tests:image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: gcr.io/bs-dev/test_image@sha256:1abae145a9069d0f4fdf9a0527ff5aec503ec02c3df783e25172895745dd2172 | ||
name: myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Implementation of the wrapper that would add an alias to a pushed image. | ||
Provides a legacy interface for using short aliases for images instead of the full bazel target path. | ||
Using aliases in new code is not recommended, as it creates a unnecessary level of indirection. | ||
""" | ||
|
||
load("//gitops:provider.bzl", "AliasInfo", "GitopsPushInfo") | ||
|
||
def _push_alias_impl(ctx): | ||
default_info = ctx.attr.pushed_image[DefaultInfo] | ||
files = default_info.files | ||
new_executable = None | ||
original_executable = default_info.files_to_run.executable | ||
runfiles = default_info.default_runfiles | ||
|
||
new_executable = ctx.outputs.executable | ||
|
||
ctx.actions.symlink( | ||
output = new_executable, | ||
target_file = original_executable, | ||
is_executable = True, | ||
) | ||
files = depset(direct = [new_executable], transitive = [files]) | ||
runfiles = runfiles.merge(ctx.runfiles([new_executable])) | ||
|
||
return [ | ||
DefaultInfo( | ||
files = files, | ||
runfiles = runfiles, | ||
executable = new_executable, | ||
), | ||
ctx.attr.pushed_image[GitopsPushInfo], | ||
AliasInfo( | ||
alias = ctx.attr.alias, | ||
), | ||
] | ||
|
||
pushed_image_alias = rule( | ||
implementation = _push_alias_impl, | ||
attrs = { | ||
"pushed_image": attr.label(mandatory = True, providers = (GitopsPushInfo,), doc = "The pushed image like k8s_image_push"), | ||
"alias": attr.string(mandatory = True, doc = "The alias to be added to the pushed image"), | ||
}, | ||
executable = True, | ||
) |