Skip to content

Commit

Permalink
feat: generate extensions descriptions file as part of extensions image
Browse files Browse the repository at this point in the history
Add all authors and descriptions to the `descriptions.yaml` file, then
add this file to the published `extensions` docker image.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
  • Loading branch information
Unix4ever committed Dec 25, 2023
1 parent 3104df1 commit 57503cc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 406 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-12-19T16:28:49Z by kres latest.
# Generated on 2023-12-25T14:50:46Z by kres latest.

name: default
concurrency:
Expand Down Expand Up @@ -90,9 +90,6 @@ jobs:
})
return resp.data.labels.map(label => label.name)
- name: check-dirty
run: |
make check-dirty
- name: extensions
if: github.event_name != 'pull_request'
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-11-02T15:50:53Z by kres latest.
# Generated on 2023-12-25T17:44:28Z by kres latest.

_out
internal/extensions/image-digests
internal/extensions/descriptions.yaml
36 changes: 15 additions & 21 deletions .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ kind: common.Build
spec:
ignoredPaths:
- "internal/extensions/image-digests"
- "internal/extensions/descriptions.yaml"
---
kind: auto.CustomSteps
spec:
Expand All @@ -58,6 +59,8 @@ spec:
toplevel: true
- name: internal/extensions/image-digests
toplevel: true
- name: internal/extensions/descriptions.yaml
toplevel: true
- name: sign-images
toplevel: true
- name: extensions-info
Expand All @@ -75,7 +78,7 @@ spec:
- name: PKGS
defaultValue: v1.7.0-alpha.0-7-g4c59641
depends:
- internal/extensions/image-digests
- internal/extensions/descriptions.yaml
script:
- |
@$(MAKE) docker-$@ TARGET_ARGS="--tag=$(EXTENSIONS_IMAGE_REF) --push=$(PUSH)"
Expand All @@ -100,42 +103,33 @@ spec:
@$(foreach target,$(NONFREE_TARGETS),echo $(REGISTRY)/$(USERNAME)/$(target):$(shell $(ARTIFACTS)/bldr eval --target $(target) --build-arg TAG=$(TAG) '{{.VERSION}}' 2>/dev/null) >> _out/extensions-metadata;)
---
kind: custom.Step
name: extensions-info
spec:
makefile:
enabled: true
phony: true
depends:
- $(ARTIFACTS)/bldr
script:
- |
@find ./ -name "manifest.yaml" -print0 | env LC_ALL=en_US sort -z | xargs -r0 -I{} sh -c 'echo "---\\n$$(cat {})"' > extensions.yaml
---
kind: custom.Step
name: check-dirty
name: internal/extensions/image-digests
spec:
makefile:
enabled: true
phony: true
depends:
- extensions-info
- extensions-metadata
script:
- |
@if test -n "`git status --porcelain`"; then echo "Source tree is dirty"; git status; git diff; exit 1 ; fi
ghaction:
enabled: true
@echo "Generating image digests..."
@cat _out/extensions-metadata | xargs -I{} sh -c 'echo {}@$$(crane digest {})' > internal/extensions/image-digests
---
kind: custom.Step
name: internal/extensions/image-digests
name: internal/extensions/descriptions.yaml
spec:
makefile:
enabled: true
phony: true
depends:
- extensions-metadata
- internal/extensions/image-digests
script:
- |
@cat _out/extensions-metadata | xargs -I{} sh -c 'echo {}@$$(crane digest {})' > internal/extensions/image-digests
@echo "Generating image descriptions..."
@echo -n "" > internal/extensions/descriptions.yaml
@for image in $(shell cat internal/extensions/image-digests); do \
crane export $$image - | tar x -O --occurrence=1 manifest.yaml | yq -r ". += {\"$$image\": {\"author\": .metadata.author, \"description\": .metadata.description}} | del(.metadata, .version)" - >> internal/extensions/descriptions.yaml; \
done
---
kind: custom.Step
name: sign-images
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-12-19T15:09:45Z by kres latest.
# Generated on 2023-12-25T18:19:39Z by kres latest.

# common variables

Expand Down Expand Up @@ -163,12 +163,8 @@ $(ARTIFACTS)/bldr: $(ARTIFACTS) ## Downloads bldr binary.
deps.png: ## Generates a dependency graph of the Pkgfile.
@$(BLDR) graph | dot -Tpng -o deps.png

.PHONY: check-dirty
check-dirty: extensions-info
@if test -n "`git status --porcelain`"; then echo "Source tree is dirty"; git status; git diff; exit 1 ; fi

.PHONY: extensions
extensions: internal/extensions/image-digests
extensions: internal/extensions/descriptions.yaml
@$(MAKE) docker-$@ TARGET_ARGS="--tag=$(EXTENSIONS_IMAGE_REF) --push=$(PUSH)"

.PHONY: extensions-metadata
Expand All @@ -179,8 +175,17 @@ extensions-metadata: $(ARTIFACTS)/bldr

.PHONY: internal/extensions/image-digests
internal/extensions/image-digests: extensions-metadata
@echo "Generating image digests..."
@cat _out/extensions-metadata | xargs -I{} sh -c 'echo {}@$$(crane digest {})' > internal/extensions/image-digests

.PHONY: internal/extensions/descriptions.yaml
internal/extensions/descriptions.yaml: internal/extensions/image-digests
@echo "Generating image descriptions..."
@echo -n "" > internal/extensions/descriptions.yaml
@for image in $(shell cat internal/extensions/image-digests); do \
crane export $$image - | tar x -O --occurrence=1 manifest.yaml | yq -r ". += {\"$$image\": {\"author\": .metadata.author, \"description\": .metadata.description}} | del(.metadata, .version)" - >> internal/extensions/descriptions.yaml; \
done

.PHONY: sign-images
sign-images:
@for image in $(shell crane export $(EXTENSIONS_IMAGE_REF) | tar x --to-stdout image-digests) $(EXTENSIONS_IMAGE_REF)@$$(crane digest $(EXTENSIONS_IMAGE_REF)); do \
Expand All @@ -189,10 +194,6 @@ sign-images:
cosign sign --yes $$image; \
done

.PHONY: extensions-info
extensions-info: $(ARTIFACTS)/bldr
@find ./ -name "manifest.yaml" -print0 | env LC_ALL=en_US sort -z | xargs -r0 -I{} sh -c 'echo "---\\n$$(cat {})"' > extensions.yaml

.PHONY: rekres
rekres:
@docker pull $(KRES_IMAGE)
Expand Down
Loading

0 comments on commit 57503cc

Please sign in to comment.