Skip to content

Commit

Permalink
build: Remove the need for docker.io creds env vars (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson authored Feb 19, 2024
1 parent debc636 commit c93883e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
28 changes: 14 additions & 14 deletions hack/kind/create-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail
IFS=$'\n\t'

SCRIPT_NAME="$(basename "$0")"
SCRIPT_NAME="$(basename "${0}")"
readonly SCRIPT_NAME

function print_usage {
Expand All @@ -22,11 +22,11 @@ EOF
}

function assert_not_empty {
local -r arg_name="$1"
local -r arg_value="$2"
local -r arg_name="${1}"
local -r arg_value="${2}"

if [[ -z $arg_value ]]; then
echo "The value for '$arg_name' cannot be empty"
if [[ -z ${arg_value} ]]; then
echo "The value for '${arg_name}' cannot be empty"
print_usage
exit 1
fi
Expand All @@ -41,7 +41,7 @@ function run_cmd() {
# read options
while [[ $# -gt 0 ]]; do
local key="$1"
case "$key" in
case "${key}" in
--cluster-name)
cluster_name="$2"
shift
Expand All @@ -67,21 +67,21 @@ function run_cmd() {
done

# validate parameters
assert_not_empty "--cluster-name" "$cluster_name"
assert_not_empty "--output-dir" "$output_dir"
assert_not_empty "--base-config" "$base_config"
assert_not_empty "--kindest-image" "$kindest_image"
assert_not_empty "--cluster-name" "${cluster_name}"
assert_not_empty "--output-dir" "${output_dir}"
assert_not_empty "--base-config" "${base_config}"
assert_not_empty "--kindest-image" "${kindest_image}"

local cluster_config="$output_dir/kind-config.yaml"
local cluster_config="${output_dir}/kind-config.yaml"

# make sure output directory exist
mkdir -p "$output_dir"
mkdir -p "${output_dir}"

# create/override base config
export KINDEST_IMAGE="${kindest_image}"
envsubst -no-unset <"$base_config" >"$cluster_config"
envsubst -i "${base_config}" -o "${cluster_config}"

kind create cluster --name "$cluster_name" --config "$cluster_config"
kind create cluster --name "${cluster_name}" --config "${cluster_config}"
}

run_cmd "$@"
4 changes: 2 additions & 2 deletions hack/kind/kind-base-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.configs."registry-1.docker.io".auth]
username = "${DOCKER_HUB_USERNAME}"
password = "${DOCKER_HUB_PASSWORD}"
username = "${DOCKER_HUB_USERNAME:-}"
password = "${DOCKER_HUB_PASSWORD:-}"
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["${DOCKER_HUB_MIRROR:-https://registry-1.docker.io}"]
Expand Down
1 change: 0 additions & 1 deletion make/all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include $(INCLUDE_DIR)repo.mk
include $(INCLUDE_DIR)pre-commit.mk
include $(INCLUDE_DIR)go.mk
include $(INCLUDE_DIR)goreleaser.mk
include $(INCLUDE_DIR)docker.mk
include $(INCLUDE_DIR)tag.mk
include $(INCLUDE_DIR)addons.mk
include $(INCLUDE_DIR)kind.mk
Expand Down
10 changes: 0 additions & 10 deletions make/docker.mk

This file was deleted.

0 comments on commit c93883e

Please sign in to comment.