Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds validation for eks-d releases file #2266

Merged
merged 1 commit into from
Jun 27, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ generate-staging-buildspec:
generate: generate-project-list generate-staging-buildspec

.PHONY: validate-generated
validate-generated: generate
validate-generated: generate validate-eksd-releases
@if [ "$$(git status --porcelain -- UPSTREAM_PROJECTS.yaml release/staging-build.yml release/checksums-build.yml **/batch-build.yml | wc -l)" -gt 0 ]; then \
echo "Error: Generated files, UPSTREAM_PROJECTS.yaml release/staging-build.yml release/checksums-build.yml batch-build.yml, do not match expected. Please run `make generate` to update"; \
git diff -- UPSTREAM_PROJECTS.yaml release/staging-build.yml release/checksums-build.yml **/batch-build.yml; \
Expand All @@ -118,3 +118,7 @@ check-project-path-exists:
else \
echo "true"; \
fi

.PHONY: validate-eksd-releases
validate-eksd-releases:
build/lib/validate_eksd_releases.sh
48 changes: 48 additions & 0 deletions build/lib/validate_eksd_releases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# 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.


set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"

source "${SCRIPT_ROOT}/eksd_releases.sh"

FAILED=0
for release_branch in $(cat $SCRIPT_ROOT/../../release/SUPPORTED_RELEASE_BRANCHES); do
YAML_URL=$(build::eksd_releases::get_release_yaml_url $release_branch)
HTTP_CODE=$(curl -I -L -s -o /dev/null -w "%{http_code}" $YAML_URL)
if [[ "$HTTP_CODE" != "200" ]]; then
echo "EKS-D manifest does not exist: $YAML_URL"
FAILED=1
continue
fi

build::eksd_releases::load_release_yaml $release_branch > /dev/null
COMPONENT_VERSION=$(build::eksd_releases::get_eksd_component_version "kubernetes" $release_branch)
COMPONENT_VERSION_FROM_YAML=$(yq e ".releases[] | select(.branch==\"${release_branch}\").kubeVersion" $SCRIPT_ROOT/../../EKSD_LATEST_RELEASES)

if [[ "$COMPONENT_VERSION" != "$COMPONENT_VERSION_FROM_YAML" ]]; then
echo "kubeVersion: $COMPONENT_VERSION_FROM_YAML does not match version from EKS-D release manifest: $COMPONENT_VERSION"
FAILED=1
fi
done

if [[ "$FAILED" == "0" ]]; then
echo "All EKS-D versions validated!"
fi
exit $FAILED