Skip to content

Commit 5c7f407

Browse files
authored
Merge branch 'master' into jlamillan/add_user_data_support
2 parents 703f290 + c9b2417 commit 5c7f407

2 files changed

Lines changed: 29 additions & 52 deletions

File tree

.github/workflows/release.yaml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,42 @@ jobs:
3434
3535
- name: sign shasum
3636
env:
37-
GPG_KEY: ${{ env.GPG_KEY }}
38-
GPG_KEY_ID: ${{ env.GPG_KEY_ID }}
3937
GPG_PASSPHRASE: ${{ env.GPG_PASSPHRASE }}
38+
GPG_KEY_ID: ${{ env.GPG_KEY_ID }}
39+
GPG_KEY: ${{ env.GPG_KEY }}
4040
run: |
41+
cleanup() {
42+
# clear history just in case
43+
history -c
44+
}
45+
trap cleanup EXIT TERM
46+
47+
# sanitize variables
48+
GPG_PASSPHRASE="$(echo "${GPG_PASSPHRASE}" | xargs)"
49+
GPG_KEY_ID="$(echo "${GPG_KEY_ID}" | xargs)"
50+
GPG_KEY="$(echo -n "${GPG_KEY}" | awk '/-----BEGIN PGP PRIVATE KEY BLOCK-----/,/-----END PGP PRIVATE KEY BLOCK-----/')"
51+
52+
if [ -z "${GPG_PASSPHRASE}" ]; then echo "gpg passphrase empty"; exit 1; fi
53+
if [ -z "${GPG_KEY_ID}" ]; then echo "key id empty"; exit 1; fi
54+
if [ -z "${GPG_KEY}" ]; then echo "key contents empty"; exit 1; fi
55+
4156
echo "Importing gpg key"
42-
echo -n '${{ env.GPG_KEY }}' | gpg --import --batch > /dev/null
57+
echo "${GPG_KEY}" | gpg --import --batch > /dev/null || { echo "Failed to import GPG key"; exit 1; }
4358
44-
echo "signing SHASUM file"
45-
VERSION_NO_V="$(echo ${{ github.ref_name }} | tr -d 'v')"
59+
echo "Signing SHASUM file"
60+
VERSION_NO_V="$(echo "${{ github.ref_name }}" | tr -d 'v')"
4661
SHASUM_FILE="dist/artifacts/${{ github.ref_name }}/terraform-provider-rancher2_${VERSION_NO_V}_SHA256SUMS"
47-
echo '${{ env.GPG_PASSPHRASE }}' | gpg --detach-sig --pinentry-mode loopback --passphrase-fd 0 --local-user "${{ env.GPG_KEY_ID }}" --output "${SHASUM_FILE}.sig" --sign "${SHASUM_FILE}"
4862
49-
echo "Validating signature..."
63+
gpg --detach-sig \
64+
--pinentry-mode loopback \
65+
--passphrase "${GPG_PASSPHRASE}" \
66+
--local-user "${GPG_KEY_ID}" \
67+
--output "${SHASUM_FILE}.sig" \
68+
--sign "${SHASUM_FILE}" || { echo "Failed to sign checksum."; exit 1; }
5069
51-
if ! gpg --verify "${SHASUM_FILE}.sig" "${SHASUM_FILE}"; then
52-
echo "Signature is valid..."
53-
else
54-
echo "Signature verification failed!"
55-
exit 1
56-
fi
70+
echo "Validating signature..."
71+
gpg --verify "${SHASUM_FILE}.sig" "${SHASUM_FILE}" || { echo "Signature verification failed!"; exit 1; }
72+
echo "Signature is valid..."
5773
- name: GH release
5874
env:
5975
GH_TOKEN: ${{ github.token }}

rancher2/config.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ package rancher2
33
import (
44
"context"
55
"fmt"
6-
"sort"
76
"strings"
87
"sync"
98
"time"
109

11-
"github.com/hashicorp/go-version"
1210
"github.com/rancher/norman/clientbase"
1311
"github.com/rancher/norman/types"
1412
clusterClient "github.com/rancher/rancher/pkg/client/generated/cluster/v3"
@@ -148,39 +146,6 @@ func (c *Config) getK8SDefaultVersion() (string, error) {
148146
}
149147
}
150148

151-
func (c *Config) getK8SVersions() ([]string, error) {
152-
if len(c.K8SSupportedVersions) > 0 {
153-
return c.K8SSupportedVersions, nil
154-
}
155-
156-
if c.Client.Management == nil {
157-
_, err := c.ManagementClient()
158-
if err != nil {
159-
return nil, err
160-
}
161-
}
162-
163-
if ok, _ := c.IsRancherVersionLessThan(rancher2RKEK8sSystemImageVersion); ok {
164-
return nil, nil
165-
}
166-
167-
RKEK8sSystemImageCollection, err := c.Client.Management.RkeK8sSystemImage.ListAll(NewListOpts(nil))
168-
if err != nil {
169-
return nil, fmt.Errorf("[ERROR] Listing RKE K8s System Images: %s", err)
170-
}
171-
versions := make([]*version.Version, 0, len(RKEK8sSystemImageCollection.Data))
172-
for _, RKEK8sSystem := range RKEK8sSystemImageCollection.Data {
173-
v, _ := version.NewVersion(RKEK8sSystem.Name)
174-
versions = append(versions, v)
175-
176-
}
177-
sort.Sort(sort.Reverse(version.Collection(versions)))
178-
for i := range versions {
179-
c.K8SSupportedVersions = append(c.K8SSupportedVersions, "v"+versions[i].String())
180-
}
181-
return c.K8SSupportedVersions, nil
182-
}
183-
184149
// Fix breaking API change https://github.com/rancher/rancher/pull/23718
185150
func (c *Config) fixNodeTemplateID(id string) string {
186151
if ok, _ := c.IsRancherVersionGreaterThanOrEqual(rancher2NodeTemplateChangeVersion); ok && len(id) > 0 {
@@ -286,10 +251,6 @@ func (c *Config) ManagementClient() (*managementClient.Client, error) {
286251
if err != nil {
287252
return nil, err
288253
}
289-
rancher2ClusterRKEK8SVersions, err = c.getK8SVersions()
290-
if err != nil {
291-
return nil, err
292-
}
293254

294255
return c.Client.Management, nil
295256
}

0 commit comments

Comments
 (0)