#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-18 AS builder

ENV GOPATH=/go

RUN echo -e "[go-toolset]\nname=go-toolset\nprofiles=\nstate=enabled\nstream=rhel8" > /etc/dnf/modules.d/go-toolset.module \
    && dnf install -y git sed go-compilers-golang-compiler tar gzip

COPY kubevirt-template-validator-ec31adff3d744a5ff8f34b50c26bff27ed94f4a5.tar.gz /
RUN mkdir -p /go/src/github.com/fromanirh/kubevirt-template-validator && \
    tar -xzf /kubevirt-template-validator-ec31adff3d744a5ff8f34b50c26bff27ed94f4a5.tar.gz --strip-components 1 \
        -C /go/src/github.com/fromanirh/kubevirt-template-validator
WORKDIR ${GOPATH}/src/github.com/fromanirh/kubevirt-template-validator

RUN ./hack/build/build.sh v0.6.6-5-gec31adff

#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-18
RUN mkdir -p /etc/webhook/certs
COPY --from=builder /go/src/github.com/fromanirh/kubevirt-template-validator/cmd/kubevirt-template-validator/kubevirt-template-validator /usr/sbin/kubevirt-template-validator
ENTRYPOINT [ "/usr/sbin/kubevirt-template-validator" ]

LABEL com.redhat.component="kubevirt-template-validator-container" \
      name="container-native-virtualization/kubevirt-template-validator" \
      version="v2.4.9" \
      upstream-version="v0.6.6-5-gec31adff" \
      summary="validating webhook to check templates sent to the cluster" \
      upstream-vcs-type="git" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,template,validation" \
      io.k8s.display-name="kubevirt-template-validator" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="kubevirt-template-validator is a kubevirt addon to check the annotations on templates and reject them if unvalid. It is implemented using a validating webhook."
