Skip to content

Commit 6f8763b

Browse files
authored
Dockerfile contract is not working for ubi10 (#193)
* Dockerfile contract is not working for ubi10 Use the hardening yaml manifest that uses the opencontainer labels * fix warning and use trim for quoted values * fix * add tests * chore
1 parent 634de34 commit 6f8763b

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ARG BASE_REGISTRY=registry1.dsop.io
2+
ARG BASE_IMAGE=ironbank/redhat/ubi/ubi9
3+
ARG BASE_TAG=9.6
4+
5+
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS prep_files
6+
7+
ARG ELASTIC_PRODUCT=apm-server
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
apiVersion: v1
3+
4+
# The repository name in registry1, excluding /ironbank/
5+
name: "elastic/logstash/logstash"
6+
7+
# List of tags to push for the repository in registry1
8+
# The most specific version should be the first tag and will be shown
9+
# on ironbank.dsop.io
10+
tags:
11+
- "<%= elastic_version %>"
12+
- "latest"
13+
tags:
14+
- "latest"
15+
# Build args passed to Dockerfile ARGs
16+
args:
17+
BASE_IMAGE: "redhat/ubi/ubi9"
18+
BASE_TAG: "9.6"

updatecli/policies/ironbank/templates/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.6.0
4+
5+
* Use containers image version from the `hardening_manifest.yaml`
6+
37
## 0.5.4
48

59
* Fix Ironbank version fetched from a dockerfile

updatecli/policies/ironbank/templates/Policy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ url: "https://github.com/elastic/oblt-updatecli-policies/"
55
changelog: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/ironbank/templates/CHANGELOG.md"
66
documentation: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/ironbank/templates/README.md"
77
source: "https://github.com/elastic/oblt-updatecli-policies/tree/main/updatecli/policies/ironbank/templates/"
8-
version: 0.5.4
8+
version: 0.6.0
99
vendor: Updatecli Project
1010

1111
licenses:

updatecli/policies/ironbank/templates/testdata/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ config:
2323
- path: tests/ironbank/templates/only-manifest
2424
skip_dockerfile: true
2525
- ent_search_ruby: tests/ironbank/templates/ent-search/dod.rb
26+
# TODO: enable when this is merged as it targets the main branch
27+
#- path: tests/ironbank/templates/logstash
28+
# dockerfile: IronbankDockerfile.erb
29+
# manifest: hardening_manifest.yaml.erb
2630

2731
pull_request:
2832
labels:

updatecli/policies/ironbank/templates/updatecli.d/default.tpl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ pipelineid: '{{ .pipelineid }}'
1414
sources:
1515
ubi_version:
1616
name: 'Get ubi version from {{ .ubi_version_path }}'
17-
kind: file
17+
kind: yaml
1818
spec:
19-
file: '{{ .ubi_version_path }}/-/raw/{{ .ubi_version_branch }}/Dockerfile?ref_type=heads'
20-
matchpattern: 'FROM registry.access.redhat.com/ubi\d+:(.+)'
19+
file: '{{ .ubi_version_path }}/-/raw/{{ .ubi_version_branch }}/hardening_manifest.yaml?ref_type=heads'
20+
key: "$.labels.'org.opencontainers.image.version'"
2121
transformers:
22-
- findsubmatch:
23-
pattern: 'FROM .*:(\\d+\\.\\d+)(\\s+(?i)AS .*)?$'
24-
captureindex: 1
22+
- trimprefix: '"'
23+
- trimsuffix: '"'
2524

2625
targets:
2726
# {{ range .config }}
@@ -46,7 +45,7 @@ targets:
4645
kind: file
4746
spec:
4847
file: {{ .path }}/{{ .manifest }}
49-
matchpattern: 'BASE_TAG: ".*"'
48+
matchpattern: 'BASE_TAG: .+'
5049
replacepattern: 'BASE_TAG: "{{ source "ubi_version" }}"'
5150
# {{ end }}
5251
# {{ end }} # end if not .skip_manifest

0 commit comments

Comments
 (0)