Skip to content

Commit

Permalink
Merge branch 'main' into remove-latest-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanxin authored Oct 18, 2024
2 parents 90e523c + 95297df commit 8907322
Show file tree
Hide file tree
Showing 18 changed files with 472 additions and 383 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Build Image
on:
push:
branches:
- main # This will get tagged with `latest` and `v{{DATE}}-{{COMMIT_HASH_SHORT}}`
- main
workflow_call:
inputs:
tag:
description: 'Additional tag for built images'
description: 'Additional tag for built image'
required: false
type: string
default: ""
Expand All @@ -18,31 +18,33 @@ permissions:
contents: read # This is required for actions/checkout

jobs:
compute-tag:
get-custom-tags:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
tags: ${{ steps.get_custom_tags.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the latest tag
id: get_tag
- name: Get tags
id: get_custom_tags
run: |
if [[ "${{ inputs.tag }}" != "" ]]; then
echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
{
echo 'tag<<TAGS'
echo 'PR-${{ github.event.pull_request.number }}'
echo '${{ github.event.pull_request.head.sha }}'
echo 'TAGS'
} >> "$GITHUB_OUTPUT"
tags=""
if [[ "${{ github.event_name }}" == "push" ]]; then
tags="latest"
elif [[ "${{ github.event_name }}" == "workflow_call" ]]; then
tags="${{ inputs.tag }}"
elif [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
tags="${{ github.event.pull_request.head.sha }}"
fi
echo "Using custom tags: '$tags'"
echo "tags=$tags" >> $GITHUB_OUTPUT
build-image:
needs: compute-tag
needs: get-custom-tags
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: lifecycle-manager
dockerfile: Dockerfile
context: .
tags: ${{ needs.compute-tag.outputs.tag }}
# tags are additional tags that will be added to the image on top of the default ones
# default tags are documented here: https://github.com/kyma-project/test-infra/tree/main/cmd/image-builder#default-tags
tags: ${{ needs.get-custom-tags.outputs.tags }}
3 changes: 2 additions & 1 deletion internal/controller/kyma/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/kyma-project/lifecycle-manager/internal/manifest/parser"
"github.com/kyma-project/lifecycle-manager/internal/pkg/metrics"
"github.com/kyma-project/lifecycle-manager/internal/remote"
"github.com/kyma-project/lifecycle-manager/pkg/common"
"github.com/kyma-project/lifecycle-manager/pkg/log"
"github.com/kyma-project/lifecycle-manager/pkg/module/sync"
"github.com/kyma-project/lifecycle-manager/pkg/queue"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu

if r.SyncKymaEnabled(kyma) {
err := r.SkrContextFactory.Init(ctx, kyma.GetNamespacedName())
if !kyma.DeletionTimestamp.IsZero() && errors.Is(err, remote.ErrAccessSecretNotFound) {
if !kyma.DeletionTimestamp.IsZero() && errors.Is(err, common.ErrAccessSecretNotFound) {
return r.handleDeletedSkr(ctx, kyma)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/controller/manifest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ func NewReconciler(mgr manager.Manager,
declarativev2.WithCustomStateCheck(statecheck.NewManagerStateCheck(statefulChecker, deploymentChecker)),
declarativev2.WithRemoteTargetCluster(lookup.ConfigResolver),
manifest.WithClientCacheKey(),
declarativev2.WithPostRun{manifest.PostRunCreateCR},
declarativev2.WithPreDelete{manifest.PreDeleteDeleteCR},
)
}
33 changes: 0 additions & 33 deletions internal/declarative/v2/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ type Options struct {
CustomStateCheck StateCheck

PostRenderTransforms []ObjectTransform

PostRuns []PostRun
PreDeletes []PreDelete
}

type Option interface {
Expand Down Expand Up @@ -112,36 +109,6 @@ func (o PostRenderTransformOption) Apply(options *Options) {
options.PostRenderTransforms = append(options.PostRenderTransforms, o.ObjectTransforms...)
}

// Hook defines a Hook into the declarative reconciliation
// skr is the runtime cluster
// kcp is the control-plane cluster
// obj is guaranteed to be the reconciled object and also to always preside in kcp.
type Hook func(ctx context.Context, skr Client, kcp client.Client, obj Object) error

// WARNING: DO NOT USE THESE HOOKS IF YOU DO NOT KNOW THE RECONCILIATION LIFECYCLE OF THE DECLARATIVE API.
// IT CAN BREAK YOUR RECONCILIATION AND IF YOU ADJUST THE OBJECT, ALSO LEAD TO
// INVALID STATES.
type (
// PostRun is executed after every successful render+reconciliation of the manifest.
PostRun Hook
// PreDelete is executed before any deletion of resources calculated from the status.
PreDelete Hook
)

// WithPostRun applies PostRun.
type WithPostRun []PostRun

func (o WithPostRun) Apply(options *Options) {
options.PostRuns = append(options.PostRuns, o...)
}

// WithPreDelete applies PreDelete.
type WithPreDelete []PreDelete

func (o WithPreDelete) Apply(options *Options) {
options.PreDeletes = append(options.PreDeletes, o...)
}

type WithSingletonClientCacheOption struct {
ClientCache
}
Expand Down
Loading

0 comments on commit 8907322

Please sign in to comment.