Repository: grafana/tanka
Pull request #1072 (2024-06-24 08:04:20)

build(deps): bump typescript from 5.4.5 to 5.5.2 in /docs
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.5 to 5.5.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/Microsoft/TypeScript/releases">typescript's releases</a>.</em></p>
<blockquote>
<h2>TypeScript 5.5</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/">release announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+milestone%3A%22TypeScript+5.5.2%22+is%3Aclosed+">fixed issues query for TypeScript v5.5.2 (Stable)</a>.</li>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+milestone%3A%22TypeScript+5.5.1%22+is%3Aclosed+">fixed issues query for TypeScript v5.5.1 (RC)</a>.</li>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+">fixed issues query for TypeScript v5.5.0 (Beta)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet package</a></li>
</ul>
<h2>TypeScript 5.5 RC</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-rc/">release announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+">fixed issues query for Typescript 5.5.0 (Beta)</a>.</li>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.5.1%22+is%3Aclosed+">fixed issues query for Typescript 5.5.1 (RC)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet package</a></li>
</ul>
<h2>TypeScript 5.5 Beta</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/">release announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.5.0%22+is%3Aclosed+">fixed issues query for Typescript 5.5.0 (Beta)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet package</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/commit/ce2e60e4ea15a65992e54a9e8877d16be9d42abb"><code>ce2e60e</code></a> Update LKG</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/f3b21a2033206e585b2b7b18622104f09eb87f2e"><code>f3b21a2</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58931">#58931</a> (Defer creation of barebonesLibSourc...) into release-5.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/7b1620bea227ea47f8944a2b02a7ed91691c3046"><code>7b1620b</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58811">#58811</a> (fix(58801): &quot;Move to file&quot; on globa...) into release-5.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/5367ae10f58edfacd6d3b1e77bd05576036b8ca2"><code>5367ae1</code></a> Bump version to 5.5.2 and LKG</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/02132e5b8183b0ee73e52d75ff6e28ff0c9fe3d2"><code>02132e5</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58895">#58895</a> (Fix global when typescript.js loade...) into release-5.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/45b1e3c25444c4193cefb4ca97dfd1064f75a561"><code>45b1e3c</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58872">#58872</a> (Fix declaration emit crash) into release-5.5 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/58874">#58874</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/17933ee33af4a3c44233820abf8bdb0ad2bf143a"><code>17933ee</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58810">#58810</a> (Fixed declaration emit issue relate...) into release-5.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/552b07e795ec5db98c37fd4ace730133bbf0e781"><code>552b07e</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58786">#58786</a> (Fixed declaration emit crash relate...) into release-5.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/39c9eebf1707b194b525a4c471b8b6bfe3f52642"><code>39c9eeb</code></a> Pick <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58857">#58857</a> to release-5.5 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/58858">#58858</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/2b0009c6790d66bbc943fc3975eb8bc9e8dec83f"><code>2b0009c</code></a> 🤖 Pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/58846">#58846</a> (Ensure the updates with crashes rev...) into release-5.5 (#...</li>
<li>Additional commits viewable in <a href="https://github.com/Microsoft/TypeScript/compare/v5.4.5...v5.5.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typescript&package-manager=npm_and_yarn&previous-version=5.4.5&new-version=5.5.2)](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-1072/
on branch [`gh-pages`](https://github.com/grafana/tanka/tree/gh-pages) at 2024-06-24 08:05 UTC
<!-- Sticky Pull Request Commentpr-preview -->

Patch:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 1257e695..4965e9f5 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -58,7 +58,7 @@ jobs:
   
       - name: Build and push by digest
         id: build
-        uses: docker/build-push-action@v5
+        uses: docker/build-push-action@v6
         with:
           context: .
           platforms: ${{ matrix.platform }}
diff --git a/cmd/tk/fmt.go b/cmd/tk/fmt.go
index b736c590..c32fd02d 100644
--- a/cmd/tk/fmt.go
+++ b/cmd/tk/fmt.go
@@ -81,7 +81,7 @@ func fmtCmd() *cli.Command {
 		case len(changed) == 0:
 			fmt.Fprintln(os.Stderr, "All discovered files are already formatted. No changes were made")
 		case len(changed) > 0:
-			fmt.Fprintf(os.Stderr, "Formatted %v files", len(changed))
+			fmt.Fprintf(os.Stderr, "Formatted %v files\n", len(changed))
 		}
 
 		return nil
diff --git a/docs/package.json b/docs/package.json
index 970f5add..0a83b70b 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -17,7 +17,7 @@
     "astro": "^4.10.2",
     "sharp": "^0.33.3",
     "tailwindcss": "^3.4.4",
-    "typescript": "^5.4.5"
+    "typescript": "^5.5.2"
   },
   "devDependencies": {
     "prettier": "^3.3.2"
diff --git a/docs/pnpm-lock.yaml b/docs/pnpm-lock.yaml
index 4fd78e9c..6fde0f5b 100644
--- a/docs/pnpm-lock.yaml
+++ b/docs/pnpm-lock.yaml
@@ -7,7 +7,7 @@ settings:
 dependencies:
   '@astrojs/check':
     specifier: ^0.7.0
-    version: 0.7.0(prettier@3.3.2)(typescript@5.4.5)
+    version: 0.7.0(prettier@3.3.2)(typescript@5.5.2)
   '@astrojs/starlight':
     specifier: ^0.24.3
     version: 0.24.3(astro@4.10.2)
@@ -22,7 +22,7 @@ dependencies:
     version: 5.0.18
   astro:
     specifier: ^4.10.2
-    version: 4.10.2(typescript@5.4.5)
+    version: 4.10.2(typescript@5.5.2)
   sharp:
     specifier: ^0.33.3
     version: 0.33.4
@@ -30,8 +30,8 @@ dependencies:
     specifier: ^3.4.4
     version: 3.4.4
   typescript:
-    specifier: ^5.4.5
-    version: 5.4.5
+    specifier: ^5.5.2
+    version: 5.5.2
 
 devDependencies:
   prettier:
@@ -53,17 +53,17 @@ packages:
       '@jridgewell/trace-mapping': 0.3.25
     dev: false
 
-  /@astrojs/check@0.7.0(prettier@3.3.2)(typescript@5.4.5):
+  /@astrojs/check@0.7.0(prettier@3.3.2)(typescript@5.5.2):
     resolution: {integrity: sha512-UTqwOeKNu9IYZmJXEeWnQuTdSd/pX58Hl4TUARsMlT97SVDL//kLBE4T/ctxRz6J573N87oE5ddtW/uOOnQTug==}
     hasBin: true
     peerDependencies:
       typescript: ^5.0.0
     dependencies:
-      '@astrojs/language-server': 2.10.0(prettier@3.3.2)(typescript@5.4.5)
+      '@astrojs/language-server': 2.10.0(prettier@3.3.2)(typescript@5.5.2)
       chokidar: 3.6.0
       fast-glob: 3.3.2
       kleur: 4.1.5
-      typescript: 5.4.5
+      typescript: 5.5.2
       yargs: 17.7.2
     transitivePeerDependencies:
       - prettier
@@ -78,7 +78,7 @@ packages:
     resolution: {integrity: sha512-6B13lz5n6BrbTqCTwhXjJXuR1sqiX/H6rTxzlXx+lN1NnV4jgnq/KJldCQaUWJzPL5SiWahQyinxAbxQtwgPHA==}
     dev: false
 
-  /@astrojs/language-server@2.10.0(prettier@3.3.2)(typescript@5.4.5):
+  /@astrojs/language-server@2.10.0(prettier@3.3.2)(typescript@5.5.2):
     resolution: {integrity: sha512-crHXpqYfA5qWioiuZnZFpTsNItgBlF1f0S9MzDYS7/pfCALkHNJ7K3w9U/j0uMKymsT4hC7BfMaX0DYlfdSzHg==}
     hasBin: true
     peerDependencies:
@@ -92,7 +92,7 @@ packages:
     dependencies:
       '@astrojs/compiler': 2.8.0
       '@jridgewell/sourcemap-codec': 1.4.15
-      '@volar/kit': 2.2.5(typescript@5.4.5)
+      '@volar/kit': 2.2.5(typescript@5.5.2)
       '@volar/language-core': 2.2.5
       '@volar/language-server': 2.2.5
       '@volar/language-service': 2.2.5
@@ -145,7 +145,7 @@ packages:
       '@astrojs/markdown-remark': 5.1.0
       '@mdx-js/mdx': 3.0.1
       acorn: 8.12.0
-      astro: 4.10.2(typescript@5.4.5)
+      astro: 4.10.2(typescript@5.5.2)
       es-module-lexer: 1.5.3
       estree-util-visit: 2.0.0
       github-slugger: 2.0.0
@@ -199,7 +199,7 @@ packages:
       '@pagefind/default-ui': 1.1.0
       '@types/hast': 3.0.4
       '@types/mdast': 4.0.4
-      astro: 4.10.2(typescript@5.4.5)
+      astro: 4.10.2(typescript@5.5.2)
       astro-expressive-code: 0.35.3(astro@4.10.2)
       bcp-47: 2.1.0
       hast-util-from-html: 2.0.1
@@ -225,7 +225,7 @@ packages:
       astro: ^3.0.0 || ^4.0.0
       tailwindcss: ^3.0.24
     dependencies:
-      astro: 4.10.2(typescript@5.4.5)
+      astro: 4.10.2(typescript@5.5.2)
       autoprefixer: 10.4.19(postcss@8.4.38)
       postcss: 8.4.38
       postcss-load-config: 4.0.2(postcss@8.4.38)
@@ -1362,7 +1362,7 @@ packages:
     resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
     dev: false
 
-  /@volar/kit@2.2.5(typescript@5.4.5):
+  /@volar/kit@2.2.5(typescript@5.5.2):
     resolution: {integrity: sha512-Bmn0UCaT43xUGGRwcmFG9lKhiCCLjRT4ScSLLPn5C9ltUcSGnIFFDlbZZa1PreHYHq25/4zkXt9Ap32klAh17w==}
     peerDependencies:
       typescript: '*'
@@ -1370,7 +1370,7 @@ packages:
       '@volar/language-service': 2.2.5
       '@volar/typescript': 2.2.5
       typesafe-path: 0.2.2
-      typescript: 5.4.5
+      typescript: 5.5.2
       vscode-languageserver-textdocument: 1.0.11
       vscode-uri: 3.0.8
     dev: false
@@ -1545,11 +1545,11 @@ packages:
     peerDependencies:
       astro: ^4.0.0-beta || ^3.3.0
     dependencies:
-      astro: 4.10.2(typescript@5.4.5)
+      astro: 4.10.2(typescript@5.5.2)
       rehype-expressive-code: 0.35.3
     dev: false
 
-  /astro@4.10.2(typescript@5.4.5):
+  /astro@4.10.2(typescript@5.5.2):
     resolution: {integrity: sha512-SBdkoOanPsxKlKVU4uu/XG0G7NYAFoqmfBtq9SPMJ34B7Hr1MxVdEugERs8IwYN6UaxdDVcqA++9PvH6Onq2cg==}
     engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'}
     hasBin: true
@@ -1608,7 +1608,7 @@ packages:
       shiki: 1.7.0
       string-width: 7.1.0
       strip-ansi: 7.1.0
-      tsconfck: 3.1.0(typescript@5.4.5)
+      tsconfck: 3.1.0(typescript@5.5.2)
       unist-util-visit: 5.0.0
       vfile: 6.0.1
       vite: 5.3.1
@@ -4390,7 +4390,7 @@ packages:
     resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
     dev: false
 
-  /tsconfck@3.1.0(typescript@5.4.5):
+  /tsconfck@3.1.0(typescript@5.5.2):
     resolution: {integrity: sha512-CMjc5zMnyAjcS9sPLytrbFmj89st2g+JYtY/c02ug4Q+CZaAtCgbyviI0n1YvjZE/pzoc6FbNsINS13DOL1B9w==}
     engines: {node: ^18 || >=20}
     hasBin: true
@@ -4400,7 +4400,7 @@ packages:
       typescript:
         optional: true
     dependencies:
-      typescript: 5.4.5
+      typescript: 5.5.2
     dev: false
 
   /tslib@2.6.2:
@@ -4424,8 +4424,8 @@ packages:
       semver: 7.6.2
     dev: false
 
-  /typescript@5.4.5:
-    resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==}
+  /typescript@5.5.2:
+    resolution: {integrity: sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==}
     engines: {node: '>=14.17'}
     hasBin: true
     dev: false
diff --git a/pkg/kubernetes/client/diff.go b/pkg/kubernetes/client/diff.go
index 9b6e23e7..43e40a1b 100644
--- a/pkg/kubernetes/client/diff.go
+++ b/pkg/kubernetes/client/diff.go
@@ -2,8 +2,8 @@ package client
 
 import (
 	"bytes"
+	"fmt"
 	"os"
-	"os/exec"
 	"regexp"
 	"strings"
 
@@ -12,8 +12,15 @@ import (
 	"github.com/grafana/tanka/pkg/kubernetes/manifest"
 )
 
+// Provides just the parts of `*exec.ExitError` that we need, so we can swap for a fake in the tests
+type exitError interface {
+	error
+	ExitCode() int
+}
+
 // DiffServerSide takes the desired state and computes the differences server-side, returning them in `diff(1)` format
 func (k Kubectl) DiffServerSide(data manifest.List) (*string, error) {
+	fmt.Println(data)
 	return k.diff(data, true)
 }
 
@@ -78,7 +85,7 @@ func (k Kubectl) diff(data manifest.List, serverSide bool) (*string, error) {
 // 0: no error, no differences
 // 1: error OR differences found
 func parseDiffErr(err error, stderr string, version *semver.Version) error {
-	exitErr, ok := err.(*exec.ExitError)
+	exitErr, ok := err.(exitError)
 	if !ok {
 		// this error is not kubectl related
 		return err
@@ -91,7 +98,7 @@ func parseDiffErr(err error, stderr string, version *semver.Version) error {
 
 	// before 1.18 "exit status 1" meant error as well ... so we need to check stderr
 	if version.LessThan(semver.MustParse("1.18.0")) && stderr != "" {
-		return err
+		return fmt.Errorf("diff failed: %w (%s)", err, stderr)
 	}
 
 	// differences found is not an error


Test patch:
diff --git a/pkg/kubernetes/client/diff_test.go b/pkg/kubernetes/client/diff_test.go
new file mode 100644
index 00000000..38ae744c
--- /dev/null
+++ b/pkg/kubernetes/client/diff_test.go
@@ -0,0 +1,70 @@
+package client
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/Masterminds/semver"
+	"github.com/stretchr/testify/require"
+)
+
+func TestParseDiffError(t *testing.T) {
+	tests := map[string]struct {
+		err         error
+		stderr      string
+		version     *semver.Version
+		expectedErr error
+	}{
+		// If this is not an exit error, then we just pass it through:
+		"no-exiterr": {
+			err:         fmt.Errorf("something else"),
+			stderr:      "error-details",
+			version:     semver.MustParse("1.17.0"),
+			expectedErr: fmt.Errorf("something else"),
+		},
+		// If kubectl returns with an exit code other than 1 its an indicator
+		// that it is not an internal error and so we return it as is:
+		"return-internal-as-is": {
+			err: &dummyExitError{
+				exitCode: 123,
+			},
+			stderr:      "error-details",
+			version:     semver.MustParse("1.17.0"),
+			expectedErr: fmt.Errorf("ExitError"),
+		},
+		// If kubectl is is < 1.18.0, then the error should contain then stderr
+		// content:
+		"lt-1.18.0-contains-stderr": {
+			err: &dummyExitError{
+				exitCode: 1,
+			},
+			stderr:      "error-details",
+			version:     semver.MustParse("1.17.0"),
+			expectedErr: fmt.Errorf("diff failed: ExitError (error-details)"),
+		},
+	}
+
+	for testName, test := range tests {
+		t.Run(testName, func(t *testing.T) {
+			err := parseDiffErr(test.err, test.stderr, test.version)
+			if test.expectedErr == nil {
+				require.NoError(t, err)
+				return
+			}
+			require.Error(t, err)
+			require.Equal(t, test.expectedErr.Error(), err.Error())
+		})
+	}
+}
+
+type dummyExitError struct {
+	exitCode int
+}
+
+func (e *dummyExitError) Error() string {
+	return "ExitError"
+}
+
+func (e *dummyExitError) ExitCode() int {
+	return e.exitCode
+}