-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct handling of deps runtimes (#109)
* +use images or image pushes in k8s_deploy images parameter +use dict {"name": ":image" } or [ ":image" ] for images parameter +more tests * correct handling of dependency runtimes * test fixes * use template to generate expected file * cleanup * buildifier * buildifier nit * explain execution_requirements rationale * buildifier Co-authored-by: Konstantin Zadorozhny <[email protected]>
- Loading branch information
1 parent
5659063
commit 041ba72
Showing
13 changed files
with
413 additions
and
29 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
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: | ||
- name: myapp | ||
image: //gitops/testing:external_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,17 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
namespace: ci | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: gcr.io/repo/someimage@sha:1234567890 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
namespace: ci | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: gcr.io/repo/imagethere@{{imports.digest}} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
namespace: ci | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: docker.io/skylib/kustomize/tests/image@{{imports.digest}} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: myapp | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- name: myapp | ||
image: img | ||
|
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,40 @@ | ||
""" | ||
Implementation of external image information provider suitable for injection into manifests | ||
""" | ||
|
||
load(":push.bzl", "K8sPushInfo") | ||
|
||
def _external_image_impl(ctx): | ||
sv = ctx.attr.image.split("@", 1) | ||
if (len(sv) == 1) and (not ctx.attr.digest): | ||
fail("digest must be specified either in image or as a separate attribute") | ||
s = sv[0].split(":", 1)[0] #drop tag | ||
registry, repository = s.split("/", 1) | ||
|
||
#write digest to a file | ||
digest_file = ctx.actions.declare_file(ctx.label.name + ".digest") | ||
ctx.actions.write( | ||
output = digest_file, | ||
content = ctx.attr.digest, | ||
) | ||
return [ | ||
DefaultInfo( | ||
files = depset([digest_file]), | ||
), | ||
K8sPushInfo( | ||
image_label = ctx.label, | ||
legacy_image_name = ctx.attr.image_name, | ||
registry = registry, | ||
repository = repository, | ||
digestfile = digest_file, | ||
), | ||
] | ||
|
||
external_image = rule( | ||
implementation = _external_image_impl, | ||
attrs = { | ||
"image": attr.string(mandatory = True, doc = "The image location, e.g. gcr.io/foo/bar:baz"), | ||
"image_name": attr.string(doc = "Image name, e.g. exernalserver. DEPRECATED: Use full target label instead, e.g. //images:externalserver"), | ||
"digest": attr.string(mandatory = True, doc = "The image digest, e.g. sha256:deadbeef"), | ||
}, | ||
) |
Oops, something went wrong.