Skip to content

Commit

Permalink
feat: create project if not exists (SumoLogic#86)
Browse files Browse the repository at this point in the history
* feat: create project if not exist

Signed-off-by: Dominik Rosiek <[email protected]>

* chore: fix getting bin directory

Signed-off-by: Dominik Rosiek <[email protected]>

---------

Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
sumo-drosiek authored Jun 3, 2024
1 parent 9efadf9 commit 32cb316
Show file tree
Hide file tree
Showing 22 changed files with 113 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ UPSTREAM_VERSION ?= ""
VERSION := "${VERSION_PREFIX}${UPSTREAM_VERSION}"
IMAGE_NAME ?= ""
PLATFORM ?= "amd64"
BIN="../bin/"
BIN="$(abspath $(CURDIR)/../bin)/"

ifeq ($(UPSTREAM_VERSION),"")
$(error UPSTREAM_VERSION is required)
Expand Down
6 changes: 3 additions & 3 deletions autoinstrumentation-dotnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

LABEL name="Autoinstrumentation-dotnet" \
LABEL name="OpenTelemetry .NET Automatic Instrumentation" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
summary="UBI based OpenTelemetry .NET Automatic Instrumentation " \
description="Kubernetes Operator for OpenTelemetry Collector" \
summary="UBI based OpenTelemetry .NET Automatic Instrumentation image" \
description="OpenTelemetry .NET Automatic Instrumentation adds instrumentation to .NET applications without having to modify their source code." \
maintainer="[email protected]"

ADD https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/v${UPSTREAM_VERSION}/LICENSE \
Expand Down
6 changes: 3 additions & 3 deletions autoinstrumentation-java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

LABEL name="Autoinstrumentation-java" \
LABEL name="OpenTelemetry Java Automatic Instrumentation" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
summary="UBI based OpenTelemetry Java Automatic Instrumentation " \
description="Kubernetes Operator for OpenTelemetry Collector" \
summary="UBI based OpenTelemetry Java Automatic Instrumentation image" \
description="OpenTelemetry Java Automatic Instrumentation provides a Java agent JAR that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks." \
maintainer="[email protected]"

ADD https://raw.githubusercontent.com/open-telemetry/opentelemetry-java-instrumentation/v${UPSTREAM_VERSION}/LICENSE \
Expand Down
6 changes: 3 additions & 3 deletions autoinstrumentation-nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

LABEL name="Autoinstrumentation-nodejs" \
LABEL name="OpenTelemetry Node JS Automatic Instrumentation" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
summary="UBI based OpenTelemetry Node JS Automatic Instrumentation " \
description="Kubernetes Operator for OpenTelemetry Collector" \
summary="UBI based OpenTelemetry Node JS Automatic Instrumentation image" \
description="OpenTelemetry Node JS Automatic Instrumentation adds instrumentation to .NET applications without having to modify their source code." \
maintainer="[email protected]"

ADD https://raw.githubusercontent.com/open-telemetry/opentelemetry-js-contrib/auto-instrumentations-node-v${UPSTREAM_VERSION}/LICENSE \
Expand Down
6 changes: 3 additions & 3 deletions autoinstrumentation-python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

LABEL name="Autoinstrumentation-python" \
LABEL name="OpenTelemetry Python Automatic Instrumentation" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
summary="UBI based OpenTelemetry Python Automatic Instrumentation " \
description="Kubernetes Operator for OpenTelemetry Collector" \
summary="UBI based OpenTelemetry Python Automatic Instrumentation image" \
description="Python auto-instrumentation libraries for OpenTelemetry" \
maintainer="[email protected]"

ADD https://raw.githubusercontent.com/open-telemetry/opentelemetry-python-contrib/v${UPSTREAM_VERSION}/LICENSE \
Expand Down
2 changes: 1 addition & 1 deletion fluent-bit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based Fluent Bit" \
ENV SUMMARY="UBI based Fluent Bit image" \
DESCRIPTION="Fluent Bit is a fast Log Processor and Forwarder"

LABEL name="Fluent Bit" \
Expand Down
4 changes: 2 additions & 2 deletions kube-rbac-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based kube-rbac-proxy" \
ENV SUMMARY="UBI based Kube RBAC Proxy image" \
DESCRIPTION="The kube-rbac-proxy is a small HTTP proxy for a single upstream, that can perform RBAC authorization against the Kubernetes API using SubjectAccessReview."

LABEL name="Kube-rbac-proxy" \
LABEL name="Kube RBAC Proxy" \
vendor="Sumo Logic" \
version="$UPSTREAM_VERSION" \
release="$RELEASE" \
Expand Down
4 changes: 2 additions & 2 deletions kube-state-metrics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based kube-state-metrics" \
ENV SUMMARY="UBI based Kube State Metrics image" \
DESCRIPTION="kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects."

LABEL name="Kube-state-metrics" \
LABEL name="Kube State Metrics" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
4 changes: 2 additions & 2 deletions metrics-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ ARG RELEASE

COPY --from=builder /opt/bitnami /opt/bitnami

ENV SUMMARY="UBI based metrics-server" \
ENV SUMMARY="UBI based Metrics Server image" \
DESCRIPTION="Metrics Server is a cluster-wide aggregator of resource usage data. Metrics Server collects metrics from the Summary API, exposed by Kubelet on each node."

LABEL name="metrics-server" \
LABEL name="Metrics Server" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
4 changes: 2 additions & 2 deletions nginx-unprivileged/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ ARG RELEASE
ARG NGINX_UID=999
ARG NGINX_GID=999

ENV SUMMARY="UBI based Unprivileged NGINX" \
DESCRIPTION="nginx is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server"
ENV SUMMARY="UBI based Unprivileged NGINX image" \
DESCRIPTION="NGINX is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server"

LABEL name="Unprivileged NGINX" \
vendor="Sumo Logic" \
Expand Down
4 changes: 2 additions & 2 deletions node-exporter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based node-exporter" \
ENV SUMMARY="UBI based Prometheus Node Exporter image" \
DESCRIPTION="Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors."

LABEL name="Node-exporter" \
LABEL name="Prometheus Node Exporter" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ ARG RELEASE
WORKDIR /
COPY --from=builder /manager .

ENV SUMMARY="UBI based opentelemetry operator" \
ENV SUMMARY="UBI based OpenTelemetry Operator image" \
DESCRIPTION="OpenTelemetry Operator manages OpenTelemetry Collector and auto-instrumentation of the workloads using OpenTelemetry instrumentation libraries"

LABEL name="opentelemetry-operator" \
LABEL name="OpenTelemetry Operator" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
6 changes: 3 additions & 3 deletions prometheus-config-reloader/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based prometheus-config-reloader" \
DESCRIPTION="Prometheus configuration reloader"
ENV SUMMARY="UBI based Prometheus Configuration Reloader image" \
DESCRIPTION="Prometheus Configuration Reloader automatically reloads Prometheus Configuration"

LABEL name="Prometheus-config-reloader" \
LABEL name="Prometheus Configuration Reloader" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
4 changes: 2 additions & 2 deletions prometheus-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based prometheus-operator" \
ENV SUMMARY="UBI based Prometheus Operator image" \
DESCRIPTION="The Prometheus Operator provides Kubernetes native deployment and management of Prometheus and related monitoring components."

LABEL name="Prometheus-operator" \
LABEL name="Prometheus Operator" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
2 changes: 1 addition & 1 deletion prometheus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based prometheus" \
ENV SUMMARY="UBI based Prometheus image" \
DESCRIPTION="Prometheus, a Cloud Native Computing Foundation project, is a systems and service monitoring system."

LABEL name="Prometheus" \
Expand Down
30 changes: 25 additions & 5 deletions scripts/build-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e

# consts
readonly SUMO_REGISTRY="public.ecr.aws/sumologic/"
## Sumo Logic Helm Operator project id
## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview
readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730

function usage() {
echo "usage: NAME=image name VERSION= PYAXIS_API_TOKEN= ./scripts/build-push.sh
Expand Down Expand Up @@ -34,7 +37,28 @@ function submit(){

if [[ -z ${CONTAINER_PROJECT_ID} ]]; then
echo "Missing project for ${IMAGE_NAME}"
exit 1

## Create new project
readonly IMAGE_DESCRIPTION="$(docker inspect "${IMAGE_NAME}" | jq '.[0].Config.Labels.description' --raw-output)"
readonly IMAGE_SUMMARY="$(docker inspect "${IMAGE_NAME}" | jq '.[0].Config.Labels.summary' --raw-output)"
readonly APPLICATION_NAME="$(docker inspect "${IMAGE_NAME}" | jq '.[0].Config.Labels.name' --raw-output)"
export IMAGE_DESCRIPTION
export IMAGE_SUMMARY
export APPLICATION_NAME
DATA="$(envsubst < scripts/new_project.json)"
RESULT="$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" -H 'Content-Type: application/json' -X POST https://catalog.redhat.com/api/containers/v1/projects/certification --data "${DATA}")"

## Add new project to product
CONTAINER_PROJECT_ID="$(echo ${RESULT} | jq '._id' --raw-output)"

if [[ -z ${CONTAINER_PROJECT_ID} ||"${CONTAINER_PROJECT_ID}" == "null" ]]; then
echo "Error during create project for ${IMAGE_NAME}"
echo $RESULT
exit 1
fi

DATA=$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID} | jq ".cert_projects |= . + [\"${CONTAINER_PROJECT_ID}\"] | {cert_projects}")
RESULT="$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" -H 'Content-Type: application/json' -X PATCH https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID} --data "${DATA}")"
fi

## Fetch key for image registry
Expand Down Expand Up @@ -66,10 +90,6 @@ readonly ACTION_CERTIFY="certify"
readonly ACTION="${ACTION:-${ACTION_BUILD}}"
DEV_SUFFIX=""

## Sumo Logic Helm Operator project id
## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview
readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730

if ! [[ "$ACTION" =~ ${ACTION_BUILD}|${ACTION_PUSH}|${ACTION_CHECK}|${ACTION_CERTIFY} ]]; then
echo "ACTION should be '${ACTION_BUILD}', '${ACTION_PUSH}', '${ACTION_CHECK}' or ${ACTION_CERTIFY}"
exit 1
Expand Down
32 changes: 32 additions & 0 deletions scripts/new_project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"contacts": [
{
"email_address": "[email protected]",
"type": "Technical contact"
}
],
"container": {
"application_categories": [
"Logging & Metrics",
"Monitoring"
],
"auto_publish": true,
"build_categories": "Standalone image",
"distribution_method": "rhcc",
"os_content_type": "Red Hat Universal Base Image (UBI)",
"release_category": "Generally Available",
"repository_description": "${IMAGE_DESCRIPTION}",
"repository_name": "${NAME}",
"short_description": "${IMAGE_SUMMARY}",
"support_platforms": [
"OpenShift Container Platform"
],
"type": "container"
},
"name": "${APPLICATION_NAME}",
"product_listings": [
"6075d88c2b962feb86bea730"
],
"project_status": "active",
"type": "Containers"
}
16 changes: 16 additions & 0 deletions scripts/submit_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

set -e

# consts
## Sumo Logic Helm Operator project id
## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview
readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730

function cleanup() {
if [[ -n ${CONTAINER_PROJECT_ID} && -n ${SUMOLOGIC_IMAGE} ]]; then
readonly APPLICATION_NAME="$(docker inspect ${SUMOLOGIC_IMAGE} | jq '.[0].Config.Labels.name' --raw-output)"
echo "https://connect.redhat.com/component/${OPERATOR_PROJECT_ID}/${CONTAINER_PROJECT_ID}/certification"
echo "Project ID: ${CONTAINER_PROJECT_ID}"
echo "Name of Application: ${APPLICATION_NAME}"
fi
}

trap cleanup EXIT

if [ -z ${CONTAINER_PROJECT_ID} ] || [ -z ${CONTAINER_REGISTRY_KEY} ] || [ -z ${SUMOLOGIC_IMAGE} ] || [ -z ${PYAXIS_API_TOKEN} ]
then
echo "One of required environment variables is missing"
Expand Down
6 changes: 3 additions & 3 deletions sumo-ubi-minimal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:${UPSTREAM_VERSION}
ARG UPSTREAM_VERSION
ARG RELEASE

LABEL name="sumo-ubi9-minimal" \
LABEL name="Sumo Logic Universal Base Image Minimal" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
summary="Provides the latest release of the minimal Red Hat Universal Base Image 8 prepared by Sumo Logic." \
summary="Sumo Logic Universal Base Image Minimal" \
description="The Universal Base Image Minimal is a stripped down image that uses microdnf as a package manager." \
maintainer="[email protected]"

ADD https://www.apache.org/licenses/LICENSE-2.0.txt \
/licenses/LICENSE
/licenses/LICENSE
4 changes: 2 additions & 2 deletions telegraf-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based telegraf-operator" \
ENV SUMMARY="UBI based Telegraf Operator image" \
DESCRIPTION="The telegraf facilitates management of telegraf CRDs in Kubernetes."

LABEL name="telegraf-operator" \
LABEL name="Telegraf Operator" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
4 changes: 2 additions & 2 deletions telegraf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based telegraf" \
ENV SUMMARY="UBI based Telegraf image" \
DESCRIPTION="Telegraf is an agent for collecting metrics and writing them to InfluxDB or other outputs."

LABEL name="telegraf" \
LABEL name="Telegraf" \
vendor="Sumo Logic" \
version="${UPSTREAM_VERSION}" \
release="${RELEASE}" \
Expand Down
2 changes: 1 addition & 1 deletion thanos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4
ARG UPSTREAM_VERSION
ARG RELEASE

ENV SUMMARY="UBI based thanos" \
ENV SUMMARY="UBI based Thanos image" \
DESCRIPTION="Thanos is a set of components that can be composed into a highly available metric system with unlimited storage capacity, which can be added seamlessly on top of existing Prometheus deployments."

LABEL name="Thanos" \
Expand Down

0 comments on commit 32cb316

Please sign in to comment.