Skip to content
Open
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
22 changes: 1 addition & 21 deletions .github/actions/setup-go/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,8 @@ runs:
using: "composite"
steps:
- name: Install go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.25"
go-version-file: "go.mod"
cache: true
cache-dependency-path: go.sum
- id: go-cache-paths
shell: bash
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Mod Cache
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-
- name: Go Build Cache
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/setup-go
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

# Load Golang cache build from GitHub
- name: Load cso Golang cache build from GitHub
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: cache
with:
path: /tmp/.cache/cso
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kubebuilder-markers-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: check for kubebuilder markers
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

# go is required for building controller-gen
- uses: ./.github/actions/setup-go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
password: ${{ secrets.github_token }}
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,31 @@ jobs:
name: Verify Pull Request
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
steps:
- name: Verifier action
id: verifier
uses: kubernetes-sigs/kubebuilder-release-tools@012269a88fa4c034a0acf1ba84c26b195c0dbab4 # v0.4.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR Title Format
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ -z "$TITLE" ]]; then
echo "Error: PR title cannot be empty."
exit 1
fi

if ! [[ "$TITLE" =~ ^($'\u26A0'|$'\u2728'|$'\U0001F41B'|$'\U0001F4D6'|$'\U0001F680'|$'\U0001F331') ]]; then
echo "Error: Invalid PR title format."
echo "Your PR title must start with one of the following indicators:"
echo "- Breaking change: ⚠ (U+26A0)"
echo "- Non-breaking feature: ✨ (U+2728)"
echo "- Patch fix: 🐛 (U+1F41B)"
echo "- Docs: 📖 (U+1F4D6)"
echo "- Release: 🚀 (U+1F680)"
echo "- Infra/Tests/Other: 🌱 (U+1F331)"
exit 1
fi

echo "PR title is valid: '$TITLE'"

- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/setup-go
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule-cache-cleaner-cso-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
# Load Golang cache build from GitHub
- name: Load cso Golang cache build from GitHub
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: cache
with:
path: /tmp/.cache/cso
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule-scan-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
password: ${{ secrets.github_token }}
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Fixup git permissions
# https://github.com/actions/checkout/issues/766
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule-update-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Generate Token
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Coverage result name
id: name
run: |
Expand Down
1 change: 1 addition & 0 deletions internal/clusterstackrelease/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func Summary(csr *csov1alpha1.ClusterStackRelease) (csov1alpha1.ClusterStackRele
summary.Phase = csov1alpha1.ClusterStackReleasePhaseProviderSpecificWork
case conditions.IsFalse(csr, csov1alpha1.ClusterStackReleaseAssetsReadyCondition):
summary.Phase = csov1alpha1.ClusterStackReleasePhaseDownloadingAssets
default:
}

return summary, nil
Expand Down
23 changes: 12 additions & 11 deletions internal/controller/clusteraddon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func (r *ClusterAddonReconciler) getNewReleaseObjects(ctx context.Context, in *t
}
}

helmTemplate, err := helmTemplateClusterAddon(filepath.Join(in.newDestinationClusterAddonChartDir, stage.Name), newBuildTemplate, in.kubernetesVersion)
helmTemplate, err := helmTemplateClusterAddon(ctx, filepath.Join(in.newDestinationClusterAddonChartDir, stage.Name), newBuildTemplate, in.kubernetesVersion)
if err != nil {
return nil, fmt.Errorf("failed to template new helm chart of the latest cluster stack: %w", err)
}
Expand Down Expand Up @@ -568,7 +568,7 @@ func (r *ClusterAddonReconciler) getOldReleaseObjects(ctx context.Context, in *t
return nil, fmt.Errorf("failed to build template from the old cluster stack cluster addon values: %w", err)
}

helmTemplate, err := helmTemplateClusterAddon(oldRelease.ClusterAddonChartPath(), buildTemplate, oldRelease.Meta.Versions.Kubernetes)
helmTemplate, err := helmTemplateClusterAddon(ctx, oldRelease.ClusterAddonChartPath(), buildTemplate, oldRelease.Meta.Versions.Kubernetes)
if err != nil {
return nil, fmt.Errorf("failed to template helm chart: %w", err)
}
Expand Down Expand Up @@ -605,7 +605,7 @@ func (r *ClusterAddonReconciler) getOldReleaseObjects(ctx context.Context, in *t
}
}

helmTemplate, err := helmTemplateClusterAddon(filepath.Join(in.oldDestinationClusterAddonChartDir, stage.Name), newBuildTemplate, oldRelease.Meta.Versions.Kubernetes)
helmTemplate, err := helmTemplateClusterAddon(ctx, filepath.Join(in.oldDestinationClusterAddonChartDir, stage.Name), newBuildTemplate, oldRelease.Meta.Versions.Kubernetes)
if err != nil {
return nil, fmt.Errorf("failed to template new helm chart: %w", err)
}
Expand Down Expand Up @@ -746,7 +746,7 @@ func (r *ClusterAddonReconciler) templateAndApplyClusterAddonHelmChart(ctx conte
return false, fmt.Errorf("failed to build template from cluster addon values: %w", err)
}

helmTemplate, err := helmTemplateClusterAddon(clusterAddonChart, buildTemplate, in.kubernetesVersion)
helmTemplate, err := helmTemplateClusterAddon(ctx, clusterAddonChart, buildTemplate, in.kubernetesVersion)
if err != nil {
return false, fmt.Errorf("failed to template helm chart: %w", err)
}
Expand Down Expand Up @@ -863,7 +863,7 @@ check:
}
// Delete part
logger.V(1).Info("starting to template helm chart", "clusterStack", in.clusterAddon.Spec.ClusterStack, "name", stage.Name, "hook", in.clusterAddon.Spec.Hook)
helmTemplate, err := helmTemplateNewClusterStack(in, stage.Name)
helmTemplate, err := helmTemplateNewClusterStack(ctx, in, stage.Name)
if err != nil {
conditions.MarkFalse(
in.clusterAddon,
Expand Down Expand Up @@ -931,6 +931,7 @@ check:
}

in.clusterAddon.SetStagePhase(stage.Name, stage.Action, csov1alpha1.StagePhaseDone)
default:
}

return false, nil
Expand Down Expand Up @@ -1038,7 +1039,7 @@ func (r *ClusterAddonReconciler) templateNewClusterStackAddonHelmChart(ctx conte
return true, nil, nil, nil
}

oldHelmTemplate, err = helmTemplateClusterAddon(oldClusterStackSubDirPath, oldBuildTemplate, in.oldKubernetesVersion)
oldHelmTemplate, err = helmTemplateClusterAddon(ctx, oldClusterStackSubDirPath, oldBuildTemplate, in.oldKubernetesVersion)
if err != nil {
conditions.MarkFalse(
in.clusterAddon,
Expand Down Expand Up @@ -1082,7 +1083,7 @@ func (r *ClusterAddonReconciler) templateNewClusterStackAddonHelmChart(ctx conte
}
}

newHelmTemplate, err = helmTemplateClusterAddon(newClusterStackSubDirPath, newBuildTemplate, in.kubernetesVersion)
newHelmTemplate, err = helmTemplateClusterAddon(ctx, newClusterStackSubDirPath, newBuildTemplate, in.kubernetesVersion)
if err != nil {
conditions.MarkFalse(
in.clusterAddon,
Expand All @@ -1105,11 +1106,11 @@ func (r *ClusterAddonReconciler) templateNewClusterStackAddonHelmChart(ctx conte
return false, oldHelmTemplate, newHelmTemplate, nil
}

func helmTemplateNewClusterStack(in *templateAndApplyClusterAddonInput, name string) (newTemplate []byte, err error) {
func helmTemplateNewClusterStack(ctx context.Context, in *templateAndApplyClusterAddonInput, name string) (newTemplate []byte, err error) {
var buildTemplate []byte

newClusterStackSubDirPath := filepath.Join(in.newDestinationClusterAddonChartDir, name)
newHelmTemplate, err := helmTemplateClusterAddon(newClusterStackSubDirPath, buildTemplate, in.kubernetesVersion)
newHelmTemplate, err := helmTemplateClusterAddon(ctx, newClusterStackSubDirPath, buildTemplate, in.kubernetesVersion)
if err != nil {
return nil, fmt.Errorf("failed to template new helm chart: %w", err)
}
Expand Down Expand Up @@ -1252,7 +1253,7 @@ func buildTemplateFromClusterAddonValues(ctx context.Context, addonValuePath str
// Then it returns the path of the generated yaml file.
// Example: helm template /tmp/downloads/cluster-stacks/myprovider-myclusterstack-1-26-v2/myprovider-myclusterstack-1-26-v2.tgz
// The return yaml file path will be /tmp/downloads/cluster-stacks/myprovider-myclusterstack-1-26-v2/myprovider-myclusterstack-1-26-v2.tgz.yaml.
func helmTemplateClusterAddon(chartPath string, helmTemplate []byte, kubernetesVersion string) ([]byte, error) {
func helmTemplateClusterAddon(ctx context.Context, chartPath string, helmTemplate []byte, kubernetesVersion string) ([]byte, error) {
helmCommand := "helm"
helmArgs := []string{"template", "--include-crds", "--dependency-update"}

Expand All @@ -1261,7 +1262,7 @@ func helmTemplateClusterAddon(chartPath string, helmTemplate []byte, kubernetesV
var cmdOutput bytes.Buffer

helmArgs = append(helmArgs, "--kube-version", kubernetesVersion, "cluster-addon", filepath.Base(chartPath), "--namespace", clusterAddonNamespace, "-f", "-")
helmTemplateCmd := exec.Command(helmCommand, helmArgs...)
helmTemplateCmd := exec.CommandContext(ctx, helmCommand, helmArgs...)
helmTemplateCmd.Stderr = os.Stderr
helmTemplateCmd.Dir = filepath.Dir(chartPath)
helmTemplateCmd.Stdout = &cmdOutput
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/clusterstackrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (r *ClusterStackReleaseReconciler) reconcileDelete(ctx context.Context, rel
}
}

template, err := r.templateClusterClassHelmChart(releaseAssets, clusterStackReleaseCR.Name, clusterStackReleaseCR.Namespace)
template, err := r.templateClusterClassHelmChart(ctx, releaseAssets, clusterStackReleaseCR.Name, clusterStackReleaseCR.Namespace)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to perform helm template: %w", err)
}
Expand Down Expand Up @@ -297,7 +297,7 @@ func (r *ClusterStackReleaseReconciler) updateProviderClusterStackRelease(ctx co

func (r *ClusterStackReleaseReconciler) templateAndApply(ctx context.Context, releaseAssets *release.Release, clusterStackRelease *csov1alpha1.ClusterStackRelease, kubeClient kube.Client) (bool, error) {
// template helm chart and apply objects
template, err := r.templateClusterClassHelmChart(releaseAssets, clusterStackRelease.Name, clusterStackRelease.Namespace)
template, err := r.templateClusterClassHelmChart(ctx, releaseAssets, clusterStackRelease.Name, clusterStackRelease.Namespace)
if err != nil {
return false, fmt.Errorf("failed to template clusterClass helm chart: %w", err)
}
Expand All @@ -318,7 +318,7 @@ func (r *ClusterStackReleaseReconciler) templateAndApply(ctx context.Context, re
}

// templateClusterClassHelmChart templates the clusterClass helm chart.
func (*ClusterStackReleaseReconciler) templateClusterClassHelmChart(releaseAssets *release.Release, name, namespace string) ([]byte, error) {
func (*ClusterStackReleaseReconciler) templateClusterClassHelmChart(ctx context.Context, releaseAssets *release.Release, name, namespace string) ([]byte, error) {
clusterClassChart, e := releaseAssets.ClusterClassChartPath()
if e != nil {
return nil, fmt.Errorf("failed to template clusterClass helm chart: %w", e)
Expand All @@ -327,22 +327,22 @@ func (*ClusterStackReleaseReconciler) templateClusterClassHelmChart(releaseAsset
splittedName := strings.Split(name, clusterstack.Separator)
releaseName := strings.Join(splittedName[0:4], clusterstack.Separator)

template, err := helmTemplate(clusterClassChart, releaseName, namespace)
template, err := helmTemplate(ctx, clusterClassChart, releaseName, namespace)
if err != nil {
return nil, fmt.Errorf("failed to template clusterClass helm chart: %w", err)
}

return template, nil
}

func helmTemplate(chartPath, releaseName, namespace string) ([]byte, error) {
func helmTemplate(ctx context.Context, chartPath, releaseName, namespace string) ([]byte, error) {
helmCommand := "helm"
helmArgs := []string{"template"}

var cmdOutput bytes.Buffer

helmArgs = append(helmArgs, releaseName, filepath.Base(chartPath), "--namespace", namespace)
helmTemplateCmd := exec.Command(helmCommand, helmArgs...)
helmTemplateCmd := exec.CommandContext(ctx, helmCommand, helmArgs...)
helmTemplateCmd.Stderr = os.Stderr
helmTemplateCmd.Dir = filepath.Dir(chartPath)
helmTemplateCmd.Stdout = &cmdOutput
Expand Down
4 changes: 3 additions & 1 deletion internal/test/helpers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package helpers

import (
"context"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -113,7 +114,8 @@ func (*TestEnvironment) WaitForWebhooks() {
timeout := 1 * time.Second
for {
time.Sleep(1 * time.Second)
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)), timeout)
dialer := &net.Dialer{Timeout: timeout}
conn, err := dialer.DialContext(context.Background(), "tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)))
if err != nil {
klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
continue
Expand Down
2 changes: 2 additions & 0 deletions pkg/kube/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ func setLabel(target *unstructured.Unstructured, key, val string) error {
return fmt.Errorf("error setting labels on .spec.selector for apps/extensions group: %w", err)
}
}
default:
}
default:
}
case "batch":
if gvk.Kind == JobKind {
Expand Down
5 changes: 2 additions & 3 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
// Returns -1 if csv is less than input
// Returns 0 if csv is equal to input
// Returns error if the two versions are not comparable (different channels).
func (csv Version) Compare(input Version) (int, error) {

Check failure on line 186 in pkg/version/version.go

View workflow job for this annotation

GitHub Actions / Lint Pull Request

empty-lines: extra empty line at the end of a block (revive)
if csv.Channel != input.Channel {
return 0, fmt.Errorf("cannot compare versions with different channels %s and %s", csv.Channel, input.Channel)
}
Expand All @@ -193,18 +193,17 @@
return 1, nil
case csv.Major < input.Major:
return -1, nil
case csv.Major == input.Major:
default:
switch {
case csv.Patch > input.Patch:
return 1, nil
case csv.Patch < input.Patch:
return -1, nil
case csv.Patch == input.Patch:
default:
return 0, nil
}
}

Check failure on line 206 in pkg/version/version.go

View workflow job for this annotation

GitHub Actions / Lint Pull Request

File is not properly formatted (gofumpt)
return 0, nil
}

// String converts a Version struct to a string representation.
Expand Down
Loading