Skip to content

Commit

Permalink
Enable auto vendoring of MCM dependency (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh-11 authored Feb 24, 2023
1 parent 6849298 commit 710ce17
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .ci/component_descriptor
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -eu

if [ -z "${MAIN_REPO_DIR:-}" ]; then
export MAIN_REPO_DIR="$(readlink -f "$(dirname "${0}")/..")"
fi
MCM_VERSION_FILEPATH="${MAIN_REPO_DIR}/MCM_VERSION"

export VERSION="$(cat "${MCM_VERSION_FILEPATH}")"

${ADD_DEPENDENCIES_CMD} \
--component-dependencies "{\"name\":\"github.com/gardener/machine-controller-manager\",\"version\":\"$VERSION\"}"

mv "${BASE_DEFINITION_PATH}" "${COMPONENT_DESCRIPTOR_PATH}"
42 changes: 29 additions & 13 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ machine-controller-manager-provider-alicloud:
template: 'default'
base_definition:
repo: ~
traits:
version:
preprocess:
'inject-commit-hash'
inject_effective_version: true
inherit:
publish_template: &publish_anchor
publish:
dockerimages:
machine-controller-manager-provider-alicloud:
Expand All @@ -17,24 +14,43 @@ machine-controller-manager-provider-alicloud:
build: ~
registry: 'gcr-readwrite'
image: 'eu.gcr.io/gardener-project/gardener/machine-controller-manager-provider-alicloud'
steps:
check:
image: 'golang:1.19.5'
build:
image: 'golang:1.19.5'
output_dir: 'binary'
test:
image: 'eu.gcr.io/gardener-project/gardener/testmachinery/base-step:stable'
steps_template: &steps_anchor
steps:
check:
image: 'golang:1.19.5'
build:
image: 'golang:1.19.5'
output_dir: 'binary'
test:
image: 'eu.gcr.io/gardener-project/gardener/testmachinery/base-step:stable'
version_template: &version_anchor
version:
inject_effective_version: true
jobs:
head-update:
<<: *steps_anchor
traits:
<<: *version_anchor
component_descriptor: ~
draft_release: ~
<<: *publish_anchor
pull-request:
<<: *steps_anchor
traits:
<<: *version_anchor
pull-request: ~
<<: *publish_anchor
create-upgrade-prs:
traits:
component_descriptor: ~
version: ~
cronjob:
interval: '24h'
update_component_deps: ~
release:
<<: *steps_anchor
traits:
<<: *publish_anchor
version:
preprocess: 'finalize'
release:
Expand Down
40 changes: 40 additions & 0 deletions .ci/set_dependency_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -eu

if [ -z "${MAIN_REPO_DIR:-}" ]; then
export MAIN_REPO_DIR="$(readlink -f "$(dirname "${0}")/..")"
fi

echo "repo-dir: ${MAIN_REPO_DIR}"

if [ "${DEPENDENCY_NAME}" != "github.com/gardener/machine-controller-manager" ]; then
echo "error: do not know how to upgrade ${DEPENDENCY_NAME}"
exit 1
fi

if [ -z "${DEPENDENCY_VERSION:-}" ]; then
echo "env var DEPENDENCY_VERSION must be set"
exit 1
fi

# for now, we only know how to upgrade github.com/gardener/machine-controller-manager, as checked above

MCM_FILEPATH="${MAIN_REPO_DIR}/MCM_VERSION"

if [ ! -f "${MCM_FILEPATH}" ]; then
echo "error: no such file: {MCM_FILEPATH}"
exit 1
fi

echo -n "${DEPENDENCY_VERSION}" > "${MCM_FILEPATH}"
echo "set dependency-version of ${DEPENDENCY_NAME} to ${DEPENDENCY_VERSION}"

cd ${MAIN_REPO_DIR}
old_version=$(cat go.mod | grep "github.com/gardener/machine-controller-manager v" | xargs)
new_version="github.com/gardener/machine-controller-manager ${DEPENDENCY_VERSION}"
sed -i -- 's#'"${old_version}"'#'"${new_version}"'#g' go.mod

#apk add --no-cache go make

make revendor
1 change: 1 addition & 0 deletions MCM_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.48.1

0 comments on commit 710ce17

Please sign in to comment.