Skip to content

Commit 229eafa

Browse files
committed
Merge commit '5d8080c3becc' into release/v2.13-ent
2 parents 40ee808 + 5d8080c commit 229eafa

29 files changed

Lines changed: 853 additions & 257 deletions

File tree

‎.github/workflows/create-rancher-pr.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: Create Rancher PR
22

3-
# This workflow triggers on a push to the main branch. It updates the
3+
# This workflow triggers on a push to the release/v2.13 branch. It updates the
44
# rancher/shepherd dependency in the rancher/rancher repository and opens a PR.
55
on:
66
push:
77
branches:
8-
- main
8+
- release/v2.13
99
env:
1010
INPUT_SOURCE_URL: ${{ github.event.inputs.source_url }}
1111
INPUT_SOURCE_AUTHOR: ${{ github.event.inputs.source_author }}
@@ -21,29 +21,29 @@ jobs:
2121
steps:
2222
# Checkout the current repo (shepherd) to get the commit SHA
2323
- name: Checkout shepherd
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2525

2626
- name: Get short SHA
2727
id: sha
2828
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2929

3030
- name: Retrieve token from vault
31-
uses: rancher-eio/read-vault-secrets@main
31+
uses: rancher-eio/read-vault-secrets@0da85151ad1f19ed7986c41587e45aac1ace74b6 # v3
3232
with:
3333
secrets: |
3434
github/token/rancher--rancher--pull_requests--write token | GH_TOKEN
3535
3636
# Checkout the target repo (rancher/rancher) where the PR will be created
3737
- name: Checkout rancher/rancher
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3939
with:
4040
repository: rancher/rancher
4141
path: rancher
42-
ref: main
42+
ref: release/v2.13
4343
token: ${{ env.GH_TOKEN }}
4444

4545
- name: Setup Go
46-
uses: actions/setup-go@v5
46+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
4747
with:
4848
go-version-file: 'rancher/go.mod'
4949

@@ -78,7 +78,7 @@ jobs:
7878
- name: Create Pull Request
7979
if: env.changes_exist == 'true'
8080
id: cpr
81-
uses: actions/github-script@v7
81+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
8282
with:
8383
github-token: ${{ env.GH_TOKEN }}
8484
script: |
@@ -92,11 +92,11 @@ jobs:
9292
}
9393
9494
const { data: pr } = await github.rest.pulls.create({
95-
title: "[main] shepherd-githubaction: Update rancher/shepherd to latest version",
95+
title: "[v2.13] shepherd-githubaction: Update rancher/shepherd to latest version",
9696
body: body,
9797
owner: "rancher",
9898
repo: "rancher",
99-
base: "main",
99+
base: "release/v2.13",
100100
head: "${{ steps.update_and_push.outputs.branch_name }}"
101101
});
102102
await github.rest.issues.addLabels({

‎.github/workflows/stale-prs.yml‎

Lines changed: 0 additions & 118 deletions
This file was deleted.

‎CODEOWNERS‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# RAFT Team
2-
* @caliskanugur @bmdepesa @igomez06
1+
# QAOps Team
2+
clients/ @caliskanugur @igomez06

‎clients/dynamic/dynamic.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ func (c *ResourceClient) Create(ctx context.Context, obj *unstructured.Unstructu
104104

105105
if needsCleanup(obj) {
106106
c.ts.RegisterCleanupFunc(func() error {
107-
err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{}, subresources...)
107+
// Using this policy avoids a flood of useless warnings on test logs.
108+
orphanPolicy := metav1.DeletePropagationOrphan
109+
err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{PropagationPolicy: &orphanPolicy}, subresources...)
108110
if errors.IsNotFound(err) {
109111
return nil
110112
}

‎clients/helm/helm.go‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package helm
22

33
import (
4+
"encoding/json"
45
"os/exec"
56

67
"github.com/pkg/errors"
@@ -104,3 +105,66 @@ func AddHelmRepo(name, url string) error {
104105

105106
return nil
106107
}
108+
109+
// UpdateHelmRepo updates the specified helm repository using the helm repo update command.
110+
func UpdateHelmRepo(name string) error {
111+
msg, err := exec.Command(helmCmd, "repo", "update", name).CombinedOutput()
112+
if err != nil {
113+
return errors.Wrap(err, "UpdateHelmRepo: "+string(msg))
114+
}
115+
116+
return nil
117+
}
118+
119+
// IsReleaseExists checks if a Helm release with the given releaseName exists in the specified namespace.
120+
func IsReleaseExists(releaseName, namespace string) (bool, string, error) {
121+
122+
commandArgs := []string{
123+
"list",
124+
"--namespace",
125+
namespace,
126+
"--filter",
127+
releaseName,
128+
"--output",
129+
"json",
130+
}
131+
132+
msg, err := exec.Command(helmCmd, commandArgs...).CombinedOutput()
133+
if err != nil {
134+
return false, "", errors.Wrap(err, "IsReleaseExists: "+string(msg))
135+
}
136+
137+
if string(msg) == "[]" || len(msg) == 0 {
138+
return false, "", nil
139+
}
140+
141+
return true, string(msg), nil
142+
}
143+
144+
// GetAppVersion gets the app version of a given releaseName in the specified namespace
145+
func GetAppVersion(releaseName, namespace string) (string, error) {
146+
exists, msg, err := IsReleaseExists(releaseName, namespace)
147+
if err != nil {
148+
return "", err
149+
}
150+
if !exists {
151+
return "", errors.New("release does not exist")
152+
}
153+
154+
var releases []struct {
155+
Name string `json:"name"`
156+
AppVersion string `json:"app_version"`
157+
}
158+
159+
if err := json.Unmarshal([]byte(msg), &releases); err != nil {
160+
return "", errors.Wrap(err, "GetAppVersion: failed to unmarshal json")
161+
}
162+
163+
for _, r := range releases {
164+
if r.Name == releaseName {
165+
return r.AppVersion, nil
166+
}
167+
}
168+
169+
return "", errors.New("release not found in list output")
170+
}

0 commit comments

Comments
 (0)