Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cstrans-df-run: improve matching of comments #148

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cstrans-df-run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class DockerFileTransformer {
const RE reLineRunExec_ = RE("^RUN *\\[(.*)\\] *$");

/// match ... in ... BS-NL
const RE reLineCont_ = RE("(^.*[^\\\\])\\\\$");
const RE reLineCont_ = RE("(^.*[^\\\\])\\\\ *$");

/// match in-line comments
const RE reComment_ = RE("^ *#.*$");
const RE reComment_ = RE("^\\s*#.*$");
};

/// parse serialized list in the form: "item1", "item2", ...
Expand Down
49 changes: 49 additions & 0 deletions tests/cstrans-df-run/0010-stdin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#@follow_tag(registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14)
FROM registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14 AS builder

COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
WORKDIR $REMOTE_SOURCE_DIR/app
USER root
RUN dnf install -y --setopt=tsflags=nodocs git
RUN sed -i 's/CGO_ENABLED=0 //;s/containers_image_openpgp/& strictfipsruntime/' Makefile
RUN go mod vendor && \
GOEXPERIMENT=strictfipsruntime make build VERSION=${CI_CONTAINER_VERSION}

#@follow_tag(registry.redhat.io/ubi8/podman)
FROM registry.redhat.io/ubi8/podman:8.8-14.1697647490

LABEL com.redhat.component="quay-builder-container"
LABEL name="quay/quay-builder-rhel8"
LABEL version=${CI_CONTAINER_VERSION}
LABEL io.k8s.display-name="Red Hat Quay - Builder"
LABEL io.k8s.description="Red Hat Quay image builder"
LABEL summary="Red Hat Quay image builder"
LABEL maintainer "hgovinda@redhat.com"

COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/quay-builder /usr/local/bin/quay-builder
COPY --from=builder $REMOTE_SOURCE_DIR/app/buildpack/ssh-git.sh /ssh-git.sh
COPY --from=builder $REMOTE_SOURCE_DIR/app/entrypoint.sh /home/podman/entrypoint.sh

RUN set -ex\
; dnf install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git wget \
; dnf -y update && dnf -y -q clean all

# Rootless/unprivileged buildah configurations
# https://github.com/containers/buildah/blob/main/docs/tutorials/05-openshift-rootless-build.md
RUN touch /etc/subgid /etc/subuid && \
chmod g=u /etc/subgid /etc/subuid /etc/passwd && \
echo 'podman:100000:65536' > /etc/subuid && echo 'podman:100000:65536' > /etc/subgid && \
# Set driver to VFS, which doesn't require host modifications compared to overlay
# Set shortname aliasing to permissive - https://www.redhat.com/sysadmin/container-image-short-names
mkdir -p /home/podman/.config/containers && \
(echo '[storage]';echo 'driver = "vfs"') > /home/podman/.config/containers/storage.conf && \
sed -i 's/short-name-mode="enforcing"/short-name-mode="permissive"/g' /etc/containers/registries.conf && \
mkdir /certs /home/podman/.config/cni && chown podman:podman /certs /home/podman/.config/cni

VOLUME ["/tmp", "/certs"]

WORKDIR /home/podman

USER podman

ENTRYPOINT ["sh", "/home/podman/entrypoint.sh"]
38 changes: 38 additions & 0 deletions tests/cstrans-df-run/0010-stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#@follow_tag(registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14)
FROM registry-proxy.engineering.redhat.com/rh-osbs/openshift-golang-builder:v1.19.10-202306161322.el8.g42c8e14 AS builder

COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
WORKDIR $REMOTE_SOURCE_DIR/app
USER root
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "dnf install -y --setopt=tsflags=nodocs git"]
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "sed -i 's/CGO_ENABLED=0 //;s/containers_image_openpgp/& strictfipsruntime/' Makefile"]
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "go mod vendor && GOEXPERIMENT=strictfipsruntime make build VERSION=${CI_CONTAINER_VERSION}"]

#@follow_tag(registry.redhat.io/ubi8/podman)
FROM registry.redhat.io/ubi8/podman:8.8-14.1697647490

LABEL com.redhat.component="quay-builder-container"
LABEL name="quay/quay-builder-rhel8"
LABEL version=${CI_CONTAINER_VERSION}
LABEL io.k8s.display-name="Red Hat Quay - Builder"
LABEL io.k8s.description="Red Hat Quay image builder"
LABEL summary="Red Hat Quay image builder"
LABEL maintainer "hgovinda@redhat.com"

COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/quay-builder /usr/local/bin/quay-builder
COPY --from=builder $REMOTE_SOURCE_DIR/app/buildpack/ssh-git.sh /ssh-git.sh
COPY --from=builder $REMOTE_SOURCE_DIR/app/entrypoint.sh /home/podman/entrypoint.sh

RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "set -ex\t; dnf install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False git wget \t; dnf -y update && dnf -y -q clean all"]

# Rootless/unprivileged buildah configurations
# https://github.com/containers/buildah/blob/main/docs/tutorials/05-openshift-rootless-build.md
RUN ["/opt/cov-sa-2019.09/bin/cov-build", "--dir=/cov", "--append-log", "sh", "-c", "touch /etc/subgid /etc/subuid && chmod g=u /etc/subgid /etc/subuid /etc/passwd && echo 'podman:100000:65536' > /etc/subuid && echo 'podman:100000:65536' > /etc/subgid && \tmkdir -p /home/podman/.config/containers && (echo '[storage]';echo 'driver = \"vfs\"') > /home/podman/.config/containers/storage.conf && sed -i 's/short-name-mode=\"enforcing\"/short-name-mode=\"permissive\"/g' /etc/containers/registries.conf && \tmkdir /certs /home/podman/.config/cni && chown podman:podman /certs /home/podman/.config/cni"]

VOLUME ["/tmp", "/certs"]

WORKDIR /home/podman

USER podman

ENTRYPOINT ["sh", "/home/podman/entrypoint.sh"]
1 change: 1 addition & 0 deletions tests/cstrans-df-run/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ tests_cstrans_df_run(0006)
tests_cstrans_df_run(0007)
tests_cstrans_df_run(0008)
tests_cstrans_df_run(0009)
tests_cstrans_df_run(0010)