Repository: grafana/tanka
Pull request #1035 (2024-05-27 08:37:51)

Bump alpine from 3.18 to 3.20
Bumps alpine from 3.18 to 3.20.


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=alpine&package-manager=docker&previous-version=3.18&new-version=3.20)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

github-actions[bot]: [PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.4.7
:---:
:rocket: Deployed preview to https://grafana.github.io/tanka/pr-preview/pr-1035/
on branch [`gh-pages`](https://github.com/grafana/tanka/tree/gh-pages) at 2024-05-27 08:38 UTC
<!-- Sticky Pull Request Commentpr-preview -->

Patch:
diff --git a/.github/workflows/publish-page.yml b/.github/workflows/publish-page.yml
index f707038a..554e9e65 100644
--- a/.github/workflows/publish-page.yml
+++ b/.github/workflows/publish-page.yml
@@ -25,7 +25,7 @@ jobs:
       - name: Checkout
         uses: actions/checkout@v4
       - name: Install pnpm
-        uses: pnpm/action-setup@v3
+        uses: pnpm/action-setup@v4
         with:
           version: 9
       - uses: actions/setup-node@v4
diff --git a/Dockerfile b/Dockerfile
index 562df022..8a09fecc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -45,7 +45,7 @@ COPY . .
 RUN make static
 
 # assemble final container
-FROM alpine:3.18
+FROM alpine:3.20
 RUN apk add --no-cache coreutils diffutils less git openssh-client
 COPY --from=build /app/tk /usr/local/bin/tk
 COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
diff --git a/docs/src/content/docs/helm.mdx b/docs/src/content/docs/helm.mdx
index 797882c2..3a674f47 100644
--- a/docs/src/content/docs/helm.mdx
+++ b/docs/src/content/docs/helm.mdx
@@ -305,7 +305,7 @@ To handle this, pass a custom name format, e.g. to also include the namespace:
 
 ```jsonnet
 custom: helm.template('foo', './charts/foo', {
-  nameFormat: '{{ print .namespace "_" .kind "_" .metadata.name | snakecase }}'
+  nameFormat: '{{ print .metadata.namespace "_" .kind "_" .metadata.name | snakecase }}'
 })
 ```
 
diff --git a/go.mod b/go.mod
index b8bb2ab8..983e9001 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
 	github.com/karrick/godirwalk v1.17.0
 	github.com/pkg/errors v0.9.1
 	github.com/posener/complete v1.2.3
-	github.com/rs/zerolog v1.32.0
+	github.com/rs/zerolog v1.33.0
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/objx v0.5.2
 	github.com/stretchr/testify v1.9.0
@@ -25,7 +25,7 @@ require (
 	gopkg.in/yaml.v3 v3.0.1
 	k8s.io/apimachinery v0.28.3
 	k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
-	sigs.k8s.io/yaml v1.3.0
+	sigs.k8s.io/yaml v1.4.0
 )
 
 require (
diff --git a/go.sum b/go.sum
index 494b2775..eff1a547 100644
--- a/go.sum
+++ b/go.sum
@@ -22,6 +22,7 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV
 github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
 github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/go-jsonnet v0.20.0 h1:WG4TTSARuV7bSm4PMB4ohjxe33IHT5WVTrJSU33uT4g=
@@ -61,8 +62,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
 github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
 github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
-github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
-github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
+github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
+github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
 github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
 github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
@@ -134,5 +135,5 @@ k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
 k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
 k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
 k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
-sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
-sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
+sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
+sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
diff --git a/pkg/kubernetes/manifest/manifest.go b/pkg/kubernetes/manifest/manifest.go
index 629131c3..4f9a20bd 100644
--- a/pkg/kubernetes/manifest/manifest.go
+++ b/pkg/kubernetes/manifest/manifest.go
@@ -203,6 +203,14 @@ func (m Metadata) Name() string {
 	return name.(string)
 }
 
+func (m Metadata) GenerateName() string {
+	generateName, ok := m["generateName"]
+	if !ok {
+		return ""
+	}
+	return generateName.(string)
+}
+
 // HasNamespace returns whether the manifest has a namespace set
 func (m Metadata) HasNamespace() bool {
 	return m2o(m).Get("namespace").IsStr()
diff --git a/pkg/process/sort.go b/pkg/process/sort.go
index 84533922..226aebd5 100644
--- a/pkg/process/sort.go
+++ b/pkg/process/sort.go
@@ -82,7 +82,10 @@ func Sort(list manifest.List) {
 			return list[i].Metadata().Namespace() < list[j].Metadata().Namespace()
 		}
 
-		// Otherwise, order the objects by name.
-		return list[i].Metadata().Name() < list[j].Metadata().Name()
+		if list[i].Metadata().Name() != list[j].Metadata().Name() {
+			return list[i].Metadata().Name() < list[j].Metadata().Name()
+		}
+
+		return list[i].Metadata().GenerateName() < list[j].Metadata().GenerateName()
 	})
 }


Test patch:
diff --git a/pkg/process/sort_test.go b/pkg/process/sort_test.go
index 486c4f41..e8c90968 100644
--- a/pkg/process/sort_test.go
+++ b/pkg/process/sort_test.go
@@ -78,6 +78,19 @@ func TestSort(t *testing.T) {
 				mkobj("CustomResourceDefinition", "crd2", ""),
 			},
 		},
+		{
+			// sorting by the generate name prefix if everything else is the same
+			raw: manifest.List{
+				mkGenerateObj("CustomResourceDefinition", "crd2-", ""),
+				mkGenerateObj("CustomResourceDefinition", "crd-", ""),
+				mkGenerateObj("CustomResourceDefinition", "crd1-", ""),
+			},
+			state: manifest.List{
+				mkGenerateObj("CustomResourceDefinition", "crd-", ""),
+				mkGenerateObj("CustomResourceDefinition", "crd1-", ""),
+				mkGenerateObj("CustomResourceDefinition", "crd2-", ""),
+			},
+		},
 		{
 			raw: manifest.List{
 				mkobj("Deployment", "b", "a"),
@@ -130,3 +143,9 @@ func mkobj(kind string, name string, ns string) map[string]interface{} {
 
 	return ret
 }
+
+func mkGenerateObj(kind string, generateName string, ns string) map[string]interface{} {
+	result := mkobj(kind, "", ns)
+	result["metadata"].(map[string]interface{})["generateName"] = generateName
+	return result
+}