<commit_before>#!/usr/bin/env bash

# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# variables used:
# - KO_DOCKER_REPO (required)
# - UUID (default: latest)
# - SKIP_PUSH (default: false) --> images will not be pushed to remote registry, nor to kind local registry

source "$(pwd)"/hack/label.sh

readonly SKIP_PUSH=${SKIP_PUSH:-false}

readonly DATA_PLANE_DIR=data-plane
readonly DATA_PLANE_CONFIG_DIR=${DATA_PLANE_DIR}/config

# Source config
readonly SOURCE_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/source
# Temporary Sourcev2 config
readonly SOURCEV2_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/sourcev2
# Broker config
readonly BROKER_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/broker
# Sink config
readonly SINK_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/sink
# Channel config
readonly CHANNEL_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/channel

# The BASE_IMAGE must have system libraries (libc, zlib, etc) compatible with the JAVA_IMAGE because
# Jlink generates a jdk linked to the same system libraries available on the base images.
readonly BASE_IMAGE=${BASE_IMAGE:-"gcr.io/distroless/java-debian11:base-nonroot"} # Based on debian:buster
readonly JAVA_IMAGE=${JAVA_IMAGE:-"docker.io/eclipse-temurin:17-jdk-centos7"}     # Based on centos7

readonly RECEIVER_JAR="receiver-1.0-SNAPSHOT.jar"
readonly RECEIVER_DIRECTORY=receiver

readonly DISPATCHER_JAR="dispatcher-1.0-SNAPSHOT.jar"
readonly DISPATCHER_DIRECTORY=dispatcher

# Checks whether the given function exists.
function function_exists() {
  [[ "$(type -t $1)" == "function" ]]
}

if ! function_exists header; then
  function header() {
    echo "$@"
  }
fi

function image_push() {
  if ${SKIP_PUSH}; then
    return
  fi
  if [ "$KO_DOCKER_REPO" = "kind.local" ]; then
    kind load docker-image "$1"
  else
    docker push "$1"<commit_msg>use builtin MacOS sed in data-plane script (#2174)<commit_after>#!/usr/bin/env bash

# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# variables used:
# - KO_DOCKER_REPO (required)
# - UUID (default: latest)
# - SKIP_PUSH (default: false) --> images will not be pushed to remote registry, nor to kind local registry

source "$(pwd)"/hack/label.sh

readonly SKIP_PUSH=${SKIP_PUSH:-false}

readonly DATA_PLANE_DIR=data-plane
readonly DATA_PLANE_CONFIG_DIR=${DATA_PLANE_DIR}/config

# Source config
readonly SOURCE_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/source
# Temporary Sourcev2 config
readonly SOURCEV2_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/sourcev2
# Broker config
readonly BROKER_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/broker
# Sink config
readonly SINK_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/sink
# Channel config
readonly CHANNEL_DATA_PLANE_CONFIG_DIR=${DATA_PLANE_CONFIG_DIR}/channel

# The BASE_IMAGE must have system libraries (libc, zlib, etc) compatible with the JAVA_IMAGE because
# Jlink generates a jdk linked to the same system libraries available on the base images.
readonly BASE_IMAGE=${BASE_IMAGE:-"gcr.io/distroless/java-debian11:base-nonroot"} # Based on debian:buster
readonly JAVA_IMAGE=${JAVA_IMAGE:-"docker.io/eclipse-temurin:17-jdk-centos7"}     # Based on centos7

readonly RECEIVER_JAR="receiver-1.0-SNAPSHOT.jar"
readonly RECEIVER_DIRECTORY=receiver

readonly DISPATCHER_JAR="dispatcher-1.0-SNAPSHOT.jar"
readonly DISPATCHER_DIRECTORY=dispatcher

# Checks whether the given function exists.
function function_exists() {
  [[ "$(type -t $1)" == "function" ]]
}

if ! function_exists header; then
  function header() {
    echo "$@"
  }
fi

# Use GNU tools on macOS. Requires the 'grep' and 'gnu-sed' Homebrew formulae.
if [ "$(uname)" == "Darwin" ]; then
  sed=gsed
  grep=ggrep
fi

function image_push() {
  if ${SKIP_PUSH}; then
    return
  fi
  if [ "$KO_DOCKER_REPO" = "kind.local" ]; then
    kind load docker-image "$1"
  else
    docker push "$1"
{'fraction_non_alphanumeric': 0.09674796747967479, 'fraction_numerical': 0.01056910569105691, 'mean_word_length': 5.276785714285714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '305787', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1585, 'n_words': 471}