Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
80 changes: 80 additions & 0 deletions .ci/hack/component_descriptor
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

# Configuration Options:
#
# COMPONENT_PREFIXES: Set the image prefix that should be used to
# determine if an image is defined by another component.
# Defaults to "europe-docker.pkg.dev/gardener-project/releases/gardener"
#
# COMPONENT_CLI_ARGS: Set all component-cli arguments.
# This should be used with care as all defaults are overwritten.
#

set -e

repo_root_dir="$1"
repo_name="${2:-github.com/gardener/gardener}"
descriptor_out_file="${COMPONENT_DESCRIPTOR_PATH}"

resources_file="$repo_root_dir/.ci/resources.yaml"
if [[ -f ${resources_file} ]]; then
echo "Adding additional resources from ${resources_file}"

# component-cli expects a directory where the component descriptor file is named component-descriptor.yaml.
# however the pre-rendered component descriptors of the pipeline have different filenames.
# therefore create a tempdir and copy the pre-rendered component descriptor to it with the correct filename.
tmp_dir="$(mktemp -d)"
tmp_cd="${tmp_dir}/component-descriptor.yaml"
cp "${BASE_DEFINITION_PATH}" "${tmp_cd}"
echo "${tmp_cd}"

# read the component version.
if [[ -z ${EFFECTIVE_VERSION} ]]; then
echo "The env variable EFFECTIVE_VERSION must be set"
exit 1
fi

# adds all resources defined in the resources file to the component descriptor.
component-cli component-archive resources add ${tmp_dir} ${resources_file} -v=3 -- COMPONENT_VERSION=${EFFECTIVE_VERSION}

# move modified component descriptor back to the original file.
mv "${tmp_cd}" "${BASE_DEFINITION_PATH}"
else
echo "Resources file ${resources_file} not found. Skip adding additional resources."
fi

echo "Enriching component descriptor from ${BASE_DEFINITION_PATH}"

image_vector_path=""
if [[ -f "$repo_root_dir/charts/images.yaml" ]]; then
image_vector_path="$repo_root_dir/charts/images.yaml"
elif [[ -f "$repo_root_dir/imagevector/images.yaml" ]]; then
image_vector_path="$repo_root_dir/imagevector/images.yaml"
elif [[ -f "$repo_root_dir/imagevector/containers.yaml" ]]; then
image_vector_path="$repo_root_dir/imagevector/containers.yaml"
fi

if [[ ! -z "$image_vector_path" ]]; then
# default environment variables
if [[ -z "${COMPONENT_PREFIXES}" ]]; then
COMPONENT_PREFIXES="europe-docker.pkg.dev/gardener-project/releases/gardener,europe-docker.pkg.dev/gardener-project/snapshots/gardener"
fi

if [[ -z "${COMPONENT_CLI_ARGS}" ]]; then
COMPONENT_CLI_ARGS="
--comp-desc ${BASE_DEFINITION_PATH} \
--image-vector "$image_vector_path" \
--component-prefixes "${COMPONENT_PREFIXES}" \
"
fi

# translates all images defined the containers.yaml into component descriptor resources.
# For detailed documentation see https://github.com/gardener/component-cli/blob/main/docs/reference/components-cli_image-vector_add.md
component-cli image-vector add ${COMPONENT_CLI_ARGS}
fi

cp "${BASE_DEFINITION_PATH}" "${descriptor_out_file}"
8 changes: 8 additions & 0 deletions .ci/hack/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
*
* SPDX-License-Identifier: Apache-2.0
*/

// This package imports CI related scripts - it is to force `go mod` to see them as dependencies.
package ci
89 changes: 89 additions & 0 deletions .ci/hack/prepare_release
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env sh
#
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

set -e

repo_root_dir="$(realpath $1)"
repo_base="$2"
repo_name="$3"

apk update
apk add --no-cache \
ca-certificates \
make \
bash \
git \
curl \
openssl \
tar \
gzip \
sed \
jq

# create virtual package with the dev tools
echo "Installing dev tools in a virtual package"
apk add --no-cache --virtual .build-deps \
gcc \
go \
musl-dev

GOLANG_VERSION="$(sed -rn 's/FROM (eu\.gcr\.io\/gardener-project\/3rd\/golang|golang):([^ ]+).*/\2/p' < "$repo_root_dir/Dockerfile")"

# As we cannot expect alpine to provide and maintain all golang versions via apk, we need to find another way to install the required golang version.
# Alpine is using musl-libc instead of glibc, therefore we cannot use the available pre-built binaries from golang, but have to build them ourselves from source.
# refs:
# - https://stackoverflow.com/a/45987284
# - https://github.com/docker-library/golang/blob/f300e60ca19c3b98cfcf01ca112af2ac10104320/1.16/alpine3.14/Dockerfile
echo "Downloading go src $GOLANG_VERSION"
rm -rf /usr/local/go
wget -q -O - "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz" | tar zx -C /usr/local

# Configure golang environment
echo "Building and installing go $GOLANG_VERSION"
export \
PATH="/usr/local/go/bin":$PATH \
GOARCH="$(go env GOARCH)" \
GOOS="$(go env GOOS)" \
GOROOT_BOOTSTRAP="$(go env GOROOT)"
export GOHOSTOS="$GOOS" \
GOHOSTARCH="$GOARCH"
cd /usr/local/go/src
echo "Executing make on go $GOLANG_VERSION"
./make.bash

echo "Deleting the virtual package for go"
apk del --no-network .build-deps

export GOROOT="/usr/local/go"
export GOPATH="$(mktemp -d)"
export GOBIN="$GOPATH/bin"
export PATH="$GOBIN:$PATH"

REPO_BASE="$GOPATH/src/$repo_base"
mkdir -p "$REPO_BASE"
REPO_PATH="$REPO_BASE/$repo_name"
cp -R "$repo_root_dir" "$REPO_PATH"

current_dir="$(pwd)"
cd "$REPO_PATH"

if make -n install-requirements &>/dev/null; then
make install-requirements
else
echo "skipping optional 'make install-requirements' as it is not present"
fi

cd "$current_dir"

echo "$EFFECTIVE_VERSION" > "$REPO_PATH/VERSION"
cur_dir="$(pwd)"
cd "$REPO_PATH"
if ! make generate; then
cd "$cur_dir"
exit 1
fi
cd "$cur_dir"
cp -RT "$REPO_PATH/" "$repo_root_dir/"
132 changes: 132 additions & 0 deletions .ci/hack/set_dependency_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/usr/bin/env python3
#
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

import json
import pathlib
import sys

import ci.util


dependency_type = ci.util.check_env('DEPENDENCY_TYPE')
if not dependency_type == 'component':
ci.util.fail(
"don't know how to upgrade dependency type: "
f'{dependency_type}'
)

dependency_name = ci.util.check_env('DEPENDENCY_NAME')
dependency_version = ci.util.check_env('DEPENDENCY_VERSION')

images_file = pathlib.Path(
ci.util.check_env('REPO_DIR'),
'imagevector',
'images.yaml',
)


class ImagesParser(object):
'''
a naive YAML-parser crafted for the special case of processing
gardener's images.yaml file; crafted that way to preserve
comments/empty lines
'''
def __init__(
self,
images_file,
names,
target_version,
):
self.images_file = images_file
self.lines = images_file.read_text().split('\n')
self.names = names
self.target_version = target_version
self._line_idx = 0

def _line(self):
return self.lines[self._line_idx]

def _next_line(self):
self._line_idx += 1
return self._line()

def _skip_to_next_entry(self, names):
while not self._line().startswith('-'):
self._next_line()
name = self._line().strip().split(':')[-1].strip()

if name not in names:
self._next_line()
return self._skip_to_next_entry(names)

# found one of the entries:
return name

def _skip_to_next_tag(self):
self._next_line()
while not self._line().startswith('-'):
if self._line().strip().startswith('tag:'):
return
self._next_line()
raise RuntimeError('did not find tag attribute')

def set_versions(self):
while self.names:
try:
name = self._skip_to_next_entry(self.names)
except IndexError:
print(str(self.names))
ci.util.fail('don\'t know how to update ' + str(self.names))
self.names.remove(name)
self._skip_to_next_tag()
tag_line = self._line()
indent = len(tag_line) - len(tag_line.lstrip())
patched_line = ' ' * indent + 'tag: "{version}"'.format(
version=self.target_version,
)
self.lines[self._line_idx] = patched_line

def write_updated_file(self):
self.images_file.write_text(
'\n'.join(self.lines)
)


# optionally load special cases from first argument given as JSON
injectedSpecialCases = {}
if len(sys.argv) == 2:
injectedSpecialCases = json.loads(sys.argv[1])

# handle special cases
name = dependency_name.split('/')[-1]
if name in injectedSpecialCases:
names = injectedSpecialCases[name]
elif name == 'autoscaler':
names = ['cluster-autoscaler']
elif name == 'vpn2':
names = ['vpn-server', 'vpn-client']
elif name == 'external-dns-management':
names = ['dns-controller-manager']
elif name == 'logging':
names = ['fluent-bit-plugin-installer', 'vali-curator', 'telegraf', 'event-logger', 'tune2fs']
elif name == 'etcd-custom-image':
names = ['etcd']
elif name == 'egress-filter-refresher':
names = ['egress-filter']
elif name == 'apiserver-proxy':
names = ['apiserver-proxy-sidecar']
else:
names = [name]


parser = ImagesParser(
images_file=images_file,
names=names,
target_version=dependency_version,
)

parser.set_versions()
parser.write_updated_file()
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug Report
about: Report a bug encountered while working with this Gardener extension

---

**How to categorize this issue?**
<!--
Please select area, kind, and priority for this issue. This helps the community categorizing it.
Replace below TODOs or exchange the existing identifiers with those that fit best in your opinion.
If multiple identifiers make sense you can also state the commands multiple times, e.g.
/area control-plane
/area auto-scaling
...

"/area" identifiers: audit-logging|auto-scaling|backup|certification|control-plane-migration|control-plane|cost|delivery|dev-productivity|disaster-recovery|documentation|high-availability|logging|metering|monitoring|networking|open-source|ops-productivity|os|performance|quality|robustness|scalability|security|storage|testing|usability|user-management
"/kind" identifiers: api-change|bug|cleanup|discussion|enhancement|epic|impediment|poc|post-mortem|question|regression|task|technical-debt|test
-->
/area TODO
/kind bug
/platform openstack

**What happened**:

**What you expected to happen**:

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know?**:

**Environment**:

- Gardener version (if relevant):
- Extension version:
- Kubernetes version (use `kubectl version`):
- Cloud provider or hardware configuration:
- Others:
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Enhancement Request
about: Suggest an enhancement for this extension

---

**How to categorize this issue?**
<!--
Please select area, kind, and priority for this issue. This helps the community categorizing it.
Replace below TODOs or exchange the existing identifiers with those that fit best in your opinion.
If multiple identifiers make sense you can also state the commands multiple times, e.g.
/area control-plane
/area auto-scaling
...

"/area" identifiers: audit-logging|auto-scaling|backup|certification|control-plane-migration|control-plane|cost|delivery|dev-productivity|disaster-recovery|documentation|high-availability|logging|metering|monitoring|networking|open-source|ops-productivity|os|performance|quality|robustness|scalability|security|storage|testing|usability|user-management
"/kind" identifiers: api-change|bug|cleanup|discussion|enhancement|epic|impediment|poc|post-mortem|question|regression|task|technical-debt|test
-->
/area TODO
/kind enhancement
/platform openstack

**What would you like to be added**:

**Why is this needed**:
Loading