diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 07c937b4..7f79e777 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: name: - description: 'Release name' + description: "Release name, eg '1.0.1'" default: "" required: true @@ -14,24 +14,29 @@ jobs: runs-on: ubuntu-latest steps: + - name: Verify that the current branch has a name that starts with 'release-' + run: | + CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + if [[ "$CURRENT_BRANCH" == release-* ]]; then + echo "Branch name starts with 'release-'." + else + echo "Branch name does not start with 'release-'." + exit 1 + fi + + - name: Verify, that an image with the target release version as a tag, does not exis + run: ./scripts/no_image_exists ${{ github.event.inputs.name }} + - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Check tag - run: ./scripts/check_release_tag.sh ${{ github.event.inputs.name }} + - name: Check that the image tag defined in the sec-scanner-config is the same as the release version (${{ github.event.inputs.name }}) + run: ./scripts/check_image.sh ${{ github.event.inputs.name }} - - name: Check image - run: ./scripts/check_image.sh ${{ github.ref_name }} + - name: Run unit tests + run: make test - - name: Verify - run: ./scripts/verify-status.sh ${{ github.ref_name }} - - # run-unit-tests: - # name: Unit tests - # needs: verify-head-status - # uses: "./.github/workflows/run-unit-tests.yaml" + - run: make build create-draft: name: Create draft release @@ -57,19 +62,19 @@ jobs: RELEASE_ID=$(./scripts/create_draft_release.sh ${{ github.event.inputs.name }}) echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT + # This will trigger the prow release jobs. The value for github.event.inputs_name will be awailable as the env var PULL_BASE_REF. - name: Create lightweight tag run: | git tag ${{ github.event.inputs.name }} git push origin ${{ github.event.inputs.name }} + - name: Check if the release image was build and can be found in image registery + run: | + ./scripts/image_exists.sh + outputs: release_id: ${{ steps.create-draft.outputs.release_id }} - # devOps-Insights: - # name: DevOps Insights - # needs: [verify-head-status, create-draft, run-unit-tests] - # uses: "./.github/workflows/metrics.yaml" - publish-release: name: Publish release needs: [verify-head-status, create-draft] diff --git a/internal/controller/nats/mocks/controller.go b/internal/controller/nats/mocks/controller.go index 7cc68336..ecb91c2e 100644 --- a/internal/controller/nats/mocks/controller.go +++ b/internal/controller/nats/mocks/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -35,6 +35,10 @@ func (_m *Controller) EXPECT() *Controller_Expecter { func (_m *Controller) GetLogger() logr.Logger { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLogger") + } + var r0 logr.Logger if rf, ok := ret.Get(0).(func() logr.Logger); ok { r0 = rf() @@ -76,6 +80,10 @@ func (_c *Controller_GetLogger_Call) RunAndReturn(run func() logr.Logger) *Contr func (_m *Controller) Reconcile(_a0 context.Context, _a1 reconcile.Request) (reconcile.Result, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for Reconcile") + } + var r0 reconcile.Result var r1 error if rf, ok := ret.Get(0).(func(context.Context, reconcile.Request) (reconcile.Result, error)); ok { @@ -129,6 +137,10 @@ func (_c *Controller_Reconcile_Call) RunAndReturn(run func(context.Context, reco func (_m *Controller) Start(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -178,6 +190,10 @@ func (_m *Controller) Watch(src source.Source, eventhandler handler.EventHandler _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Watch") + } + var r0 error if rf, ok := ret.Get(0).(func(source.Source, handler.EventHandler, ...predicate.Predicate) error); ok { r0 = rf(src, eventhandler, predicates...) diff --git a/internal/controller/nats/mocks/manager.go b/internal/controller/nats/mocks/manager.go index 5f61310d..12739e00 100644 --- a/internal/controller/nats/mocks/manager.go +++ b/internal/controller/nats/mocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -48,6 +48,10 @@ func (_m *Manager) EXPECT() *Manager_Expecter { func (_m *Manager) Add(_a0 manager.Runnable) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Add") + } + var r0 error if rf, ok := ret.Get(0).(func(manager.Runnable) error); ok { r0 = rf(_a0) @@ -90,6 +94,10 @@ func (_c *Manager_Add_Call) RunAndReturn(run func(manager.Runnable) error) *Mana func (_m *Manager) AddHealthzCheck(name string, check healthz.Checker) error { ret := _m.Called(name, check) + if len(ret) == 0 { + panic("no return value specified for AddHealthzCheck") + } + var r0 error if rf, ok := ret.Get(0).(func(string, healthz.Checker) error); ok { r0 = rf(name, check) @@ -133,6 +141,10 @@ func (_c *Manager_AddHealthzCheck_Call) RunAndReturn(run func(string, healthz.Ch func (_m *Manager) AddReadyzCheck(name string, check healthz.Checker) error { ret := _m.Called(name, check) + if len(ret) == 0 { + panic("no return value specified for AddReadyzCheck") + } + var r0 error if rf, ok := ret.Get(0).(func(string, healthz.Checker) error); ok { r0 = rf(name, check) @@ -176,6 +188,10 @@ func (_c *Manager_AddReadyzCheck_Call) RunAndReturn(run func(string, healthz.Che func (_m *Manager) Elected() <-chan struct{} { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Elected") + } + var r0 <-chan struct{} if rf, ok := ret.Get(0).(func() <-chan struct{}); ok { r0 = rf() @@ -219,6 +235,10 @@ func (_c *Manager_Elected_Call) RunAndReturn(run func() <-chan struct{}) *Manage func (_m *Manager) GetAPIReader() client.Reader { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAPIReader") + } + var r0 client.Reader if rf, ok := ret.Get(0).(func() client.Reader); ok { r0 = rf() @@ -262,6 +282,10 @@ func (_c *Manager_GetAPIReader_Call) RunAndReturn(run func() client.Reader) *Man func (_m *Manager) GetCache() cache.Cache { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCache") + } + var r0 cache.Cache if rf, ok := ret.Get(0).(func() cache.Cache); ok { r0 = rf() @@ -305,6 +329,10 @@ func (_c *Manager_GetCache_Call) RunAndReturn(run func() cache.Cache) *Manager_G func (_m *Manager) GetClient() client.Client { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetClient") + } + var r0 client.Client if rf, ok := ret.Get(0).(func() client.Client); ok { r0 = rf() @@ -348,6 +376,10 @@ func (_c *Manager_GetClient_Call) RunAndReturn(run func() client.Client) *Manage func (_m *Manager) GetConfig() *rest.Config { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConfig") + } + var r0 *rest.Config if rf, ok := ret.Get(0).(func() *rest.Config); ok { r0 = rf() @@ -391,6 +423,10 @@ func (_c *Manager_GetConfig_Call) RunAndReturn(run func() *rest.Config) *Manager func (_m *Manager) GetControllerOptions() config.Controller { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetControllerOptions") + } + var r0 config.Controller if rf, ok := ret.Get(0).(func() config.Controller); ok { r0 = rf() @@ -432,6 +468,10 @@ func (_c *Manager_GetControllerOptions_Call) RunAndReturn(run func() config.Cont func (_m *Manager) GetEventRecorderFor(name string) record.EventRecorder { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetEventRecorderFor") + } + var r0 record.EventRecorder if rf, ok := ret.Get(0).(func(string) record.EventRecorder); ok { r0 = rf(name) @@ -476,6 +516,10 @@ func (_c *Manager_GetEventRecorderFor_Call) RunAndReturn(run func(string) record func (_m *Manager) GetFieldIndexer() client.FieldIndexer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFieldIndexer") + } + var r0 client.FieldIndexer if rf, ok := ret.Get(0).(func() client.FieldIndexer); ok { r0 = rf() @@ -519,6 +563,10 @@ func (_c *Manager_GetFieldIndexer_Call) RunAndReturn(run func() client.FieldInde func (_m *Manager) GetHTTPClient() *http.Client { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHTTPClient") + } + var r0 *http.Client if rf, ok := ret.Get(0).(func() *http.Client); ok { r0 = rf() @@ -562,6 +610,10 @@ func (_c *Manager_GetHTTPClient_Call) RunAndReturn(run func() *http.Client) *Man func (_m *Manager) GetLogger() logr.Logger { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLogger") + } + var r0 logr.Logger if rf, ok := ret.Get(0).(func() logr.Logger); ok { r0 = rf() @@ -603,6 +655,10 @@ func (_c *Manager_GetLogger_Call) RunAndReturn(run func() logr.Logger) *Manager_ func (_m *Manager) GetRESTMapper() meta.RESTMapper { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRESTMapper") + } + var r0 meta.RESTMapper if rf, ok := ret.Get(0).(func() meta.RESTMapper); ok { r0 = rf() @@ -646,6 +702,10 @@ func (_c *Manager_GetRESTMapper_Call) RunAndReturn(run func() meta.RESTMapper) * func (_m *Manager) GetScheme() *runtime.Scheme { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetScheme") + } + var r0 *runtime.Scheme if rf, ok := ret.Get(0).(func() *runtime.Scheme); ok { r0 = rf() @@ -689,6 +749,10 @@ func (_c *Manager_GetScheme_Call) RunAndReturn(run func() *runtime.Scheme) *Mana func (_m *Manager) GetWebhookServer() webhook.Server { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWebhookServer") + } + var r0 webhook.Server if rf, ok := ret.Get(0).(func() webhook.Server); ok { r0 = rf() @@ -732,6 +796,10 @@ func (_c *Manager_GetWebhookServer_Call) RunAndReturn(run func() webhook.Server) func (_m *Manager) Start(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) diff --git a/pkg/k8s/chart/mocks/renderer.go b/pkg/k8s/chart/mocks/renderer.go index 09317e12..4f73adc8 100644 --- a/pkg/k8s/chart/mocks/renderer.go +++ b/pkg/k8s/chart/mocks/renderer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -24,6 +24,10 @@ func (_m *Renderer) EXPECT() *Renderer_Expecter { func (_m *Renderer) RenderManifest(_a0 *chart.ReleaseInstance) (string, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for RenderManifest") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(*chart.ReleaseInstance) (string, error)); ok { @@ -76,6 +80,10 @@ func (_c *Renderer_RenderManifest_Call) RunAndReturn(run func(*chart.ReleaseInst func (_m *Renderer) RenderManifestAsUnstructured(_a0 *chart.ReleaseInstance) (*chart.ManifestResources, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for RenderManifestAsUnstructured") + } + var r0 *chart.ManifestResources var r1 error if rf, ok := ret.Get(0).(func(*chart.ReleaseInstance) (*chart.ManifestResources, error)); ok { diff --git a/pkg/k8s/mocks/client.go b/pkg/k8s/mocks/client.go index 53d61583..001ccb31 100644 --- a/pkg/k8s/mocks/client.go +++ b/pkg/k8s/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -33,6 +33,10 @@ func (_m *Client) EXPECT() *Client_Expecter { func (_m *Client) Delete(_a0 context.Context, _a1 *unstructured.Unstructured) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for Delete") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *unstructured.Unstructured) error); ok { r0 = rf(_a0, _a1) @@ -76,6 +80,10 @@ func (_c *Client_Delete_Call) RunAndReturn(run func(context.Context, *unstructur func (_m *Client) DeletePVCsWithLabel(_a0 context.Context, _a1 string, _a2 string, _a3 string) error { ret := _m.Called(_a0, _a1, _a2, _a3) + if len(ret) == 0 { + panic("no return value specified for DeletePVCsWithLabel") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { r0 = rf(_a0, _a1, _a2, _a3) @@ -121,6 +129,10 @@ func (_c *Client_DeletePVCsWithLabel_Call) RunAndReturn(run func(context.Context func (_m *Client) DestinationRuleCRDExists(_a0 context.Context) (bool, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for DestinationRuleCRDExists") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context) (bool, error)); ok { @@ -173,6 +185,10 @@ func (_c *Client_DestinationRuleCRDExists_Call) RunAndReturn(run func(context.Co func (_m *Client) GetCRD(_a0 context.Context, _a1 string) (*v1.CustomResourceDefinition, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for GetCRD") + } + var r0 *v1.CustomResourceDefinition var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*v1.CustomResourceDefinition, error)); ok { @@ -228,6 +244,10 @@ func (_c *Client_GetCRD_Call) RunAndReturn(run func(context.Context, string) (*v func (_m *Client) GetSecret(_a0 context.Context, _a1 string, _a2 string) (*corev1.Secret, error) { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for GetSecret") + } + var r0 *corev1.Secret var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, string) (*corev1.Secret, error)); ok { @@ -284,6 +304,10 @@ func (_c *Client_GetSecret_Call) RunAndReturn(run func(context.Context, string, func (_m *Client) GetStatefulSet(_a0 context.Context, _a1 string, _a2 string) (*appsv1.StatefulSet, error) { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for GetStatefulSet") + } + var r0 *appsv1.StatefulSet var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, string) (*appsv1.StatefulSet, error)); ok { @@ -340,6 +364,10 @@ func (_c *Client_GetStatefulSet_Call) RunAndReturn(run func(context.Context, str func (_m *Client) PatchApply(_a0 context.Context, _a1 *unstructured.Unstructured) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for PatchApply") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *unstructured.Unstructured) error); ok { r0 = rf(_a0, _a1) diff --git a/pkg/manager/mocks/manager.go b/pkg/manager/mocks/manager.go index 9b6af3f5..7e193ef7 100644 --- a/pkg/manager/mocks/manager.go +++ b/pkg/manager/mocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -31,6 +31,10 @@ func (_m *Manager) EXPECT() *Manager_Expecter { func (_m *Manager) DeleteInstance(_a0 context.Context, _a1 *chart.ReleaseInstance) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for DeleteInstance") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *chart.ReleaseInstance) error); ok { r0 = rf(_a0, _a1) @@ -74,6 +78,10 @@ func (_c *Manager_DeleteInstance_Call) RunAndReturn(run func(context.Context, *c func (_m *Manager) DeployInstance(_a0 context.Context, _a1 *chart.ReleaseInstance) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for DeployInstance") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *chart.ReleaseInstance) error); ok { r0 = rf(_a0, _a1) @@ -124,6 +132,10 @@ func (_m *Manager) GenerateNATSResources(_a0 *chart.ReleaseInstance, _a1 ...mana _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for GenerateNATSResources") + } + var r0 *chart.ManifestResources var r1 error if rf, ok := ret.Get(0).(func(*chart.ReleaseInstance, ...manager.Option) (*chart.ManifestResources, error)); ok { @@ -186,6 +198,10 @@ func (_c *Manager_GenerateNATSResources_Call) RunAndReturn(run func(*chart.Relea func (_m *Manager) GenerateOverrides(_a0 *v1alpha1.NATSSpec, _a1 bool, _a2 bool) map[string]interface{} { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for GenerateOverrides") + } + var r0 map[string]interface{} if rf, ok := ret.Get(0).(func(*v1alpha1.NATSSpec, bool, bool) map[string]interface{}); ok { r0 = rf(_a0, _a1, _a2) @@ -232,6 +248,10 @@ func (_c *Manager_GenerateOverrides_Call) RunAndReturn(run func(*v1alpha1.NATSSp func (_m *Manager) IsNATSStatefulSetReady(_a0 context.Context, _a1 *chart.ReleaseInstance) (bool, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for IsNATSStatefulSetReady") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(context.Context, *chart.ReleaseInstance) (bool, error)); ok { diff --git a/pkg/nats/mocks/client.go b/pkg/nats/mocks/client.go index 9dedba9e..cfc51e26 100644 --- a/pkg/nats/mocks/client.go +++ b/pkg/nats/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.37.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -57,6 +57,10 @@ func (_c *Client_Close_Call) RunAndReturn(run func()) *Client_Close_Call { func (_m *Client) ConsumersExist(streamName string) (bool, error) { ret := _m.Called(streamName) + if len(ret) == 0 { + panic("no return value specified for ConsumersExist") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(string) (bool, error)); ok { @@ -109,6 +113,10 @@ func (_c *Client_ConsumersExist_Call) RunAndReturn(run func(string) (bool, error func (_m *Client) GetStreams() ([]*nats_go.StreamInfo, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStreams") + } + var r0 []*nats_go.StreamInfo var r1 error if rf, ok := ret.Get(0).(func() ([]*nats_go.StreamInfo, error)); ok { @@ -162,6 +170,10 @@ func (_c *Client_GetStreams_Call) RunAndReturn(run func() ([]*nats_go.StreamInfo func (_m *Client) Init() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Init") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -203,6 +215,10 @@ func (_c *Client_Init_Call) RunAndReturn(run func() error) *Client_Init_Call { func (_m *Client) StreamExists() (bool, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for StreamExists") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func() (bool, error)); ok { diff --git a/scripts/check_image.sh b/scripts/check_image.sh index cc3683b7..b6c8be93 100755 --- a/scripts/check_image.sh +++ b/scripts/check_image.sh @@ -1,16 +1,15 @@ #!/usr/bin/env bash -REF_NAME="${1:-"main"}" -SHORT_EXPECTED_SHA=$(git rev-parse --short=8 "${REF_NAME}~") -DATE="v$(git show ${SHORT_EXPECTED_SHA} --date=format:'%Y%m%d' --format=%ad -q)" -EXPECTED_TAG="${DATE}-${SHORT_EXPECTED_SHA}" +# This script will check if the tag for the nats-manager image is the one we define as the semantinc release version. -IMAGE_TO_CHECK="${2:-europe-docker.pkg.dev/kyma-project/prod/nats-manager}" +EXPECTED_TAG=${1:-latest} + +IMAGE_TO_CHECK=${2:-europe-docker.pkg.dev/kyma-project/prod/nats-manager} BUMPED_IMAGE_TAG=$(cat sec-scanners-config.yaml | grep "${IMAGE_TO_CHECK}" | cut -d : -f 2) if [[ "$BUMPED_IMAGE_TAG" != "$EXPECTED_TAG" ]]; then - echo "Tags are not correct: wanted $EXPECTED_TAG but got $BUMPED_IMAGE_TAG" - exit 1 + echo "Tags are not correct: wanted $EXPECTED_TAG but got $BUMPED_IMAGE_TAG" + exit 1 fi echo "Tags are correct" exit 0 diff --git a/scripts/check_release_tag.sh b/scripts/check_release_tag.sh deleted file mode 100755 index 9ba0892b..00000000 --- a/scripts/check_release_tag.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -ue - -DESIRED_TAG=$1 - -source .version -MODULE_VERSION="v${MODULE_VERSION}" - -if [[ "$DESIRED_TAG" != "$MODULE_VERSION" ]]; then - echo "Tags mismatch: expected ${MODULE_VERSION}, got $DESIRED_TAG" - exit 1 -fi -echo "Tags are correct" -exit 0 diff --git a/scripts/image_exists.sh b/scripts/image_exists.sh new file mode 100755 index 00000000..adc395ac --- /dev/null +++ b/scripts/image_exists.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# This script checks with a timeout, if a defined image with a defined can be found. + +TIMEOUT=${1:-600} +INTERVAL=${2:-20} +TAG=${3:-latest} +IMAGE=${4:-europe-docker.pkg.dev/kyma-project/prod/nats-manager} + +start_time=$(date +%s) +end_time=$((start_time + TIMEOUT)) + +while true; do + docker manifest inspect $IMAGE:$TAG + # Check the exit status + if [ $? -eq 0 ]; then + echo "Image found." + exit 0 + else + echo "Image not found, yet." + fi + + current_time=$(date +%s) + + # Check if the TIMEOUT has been reached + if [ $current_time -ge $end_time ]; then + echo "TIMEOUT reached. Image was not found in time." + exit 1 + fi + + sleep $INTERVAL +done diff --git a/scripts/no_image_exists.sh b/scripts/no_image_exists.sh new file mode 100755 index 00000000..1887b7bd --- /dev/null +++ b/scripts/no_image_exists.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# This script will verify that a defined image with a defined tag cannot be found. + +TAG=${1:-latest} +IMAGE=${2:-europe-docker.pkg.dev/kyma-project/prod/nats-manager} + +docker manifest inspect $IMAGE:$TAG + +if [ $? -eq 0 ]; then + echo "Error: image ${IMAGE}:${TAG} found." + exit 1 +else + echo "Image not found." + exit 0 +fi diff --git a/scripts/verify-status.sh b/scripts/verify-status.sh deleted file mode 100755 index 970c366f..00000000 --- a/scripts/verify-status.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - - - -echo "Checking status of POST Jobs for NATS-Manager" - -REF_NAME="${1:-"main"}" -STATUS_URL="https://api.github.com/repos/kyma-project/nats-manager/commits/${REF_NAME}/status" -fullstatus=`curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL} | head -n 2 ` - -sleep 10 -echo $fullstatus - -if [[ "$fullstatus" == *"success"* ]]; then - echo "All jobs succeeded" -else - echo "Jobs failed or pending - Check Prow status" - exit 1 -fi