Repository: grafana/tanka
Pull request #843 (2023-04-25 10:34:59)

Bump typescript from 4.7.4 to 4.9.5 in /docs
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.4 to 4.9.5.
<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 4.9.5</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/">release announcement</a>.</p>
<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>Changes:</h2>
<ul>
<li>69e88ef5513a81acf69ec78f4af1f927da0d0584 Port ignore deprecations to 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/52419">#52419</a>)</li>
<li>daf4e817a18def96b70ac34703b158ff0e6d58df Port timestamp fix to 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/52426">#52426</a>)</li>
</ul>
<h2>TypeScript 4.9.4</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-9">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+4.9.4%22+is%3Aclosed+">fixed issues query for Typescript v4.9.4</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>Changes:</h2>
<ul>
<li>e2868216f637e875a74c675845625eb15dcfe9a2 Bump version to 4.9.4 and LKG.</li>
<li>eb5419fc8d980859b98553586dfb5f40d811a745 Cherry-pick <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51704">#51704</a> to release 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51712">#51712</a>)</li>
<li>b4d382b9b12460adf2da4cc0d1429cf19f8dc8be Cherry-pick changes for narrowing to tagged literal types.</li>
<li>e7a02f43fce47e1a39259ada5460bcc33c8e98b5 Port of <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51626">#51626</a> and <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51689">#51689</a> to release-4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51627">#51627</a>)</li>
<li>1727912f0437a7f367d90040fc4b0b4f3efd017a Cherry-pick fix around <code>visitEachChild</code> to release-4.9. (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51544">#51544</a>)</li>
</ul>
<p>This list of changes was <a href="https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_release?releaseId=117&amp;_a=release-summary">auto generated</a>.</p>
<h2>TypeScript 4.9</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/">release announcement</a>.</p>
<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>Changes:</h2>
<ul>
<li>93bd577458d55cd720b2677705feab5c91eb12ce Bump version to 4.9.3 and LKG.</li>
<li>107f832b80df2dc97748021cb00af2b6813db75b Update LKG.</li>
<li>31bee5682df130a14ffdd5742f994dbe7313dd0e Cherry-pick PR <a href="https://redirect.github.com/Microsoft/TypeScript/issues/50977">#50977</a> into release-4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51363">#51363</a>) [ <a href="https://redirect.github.com/Microsoft/TypeScript/issues/50872">#50872</a> ]</li>
<li>1e2fa7ae15f8530910fef8b916ec8a4ed0b59c45 Update version to 4.9.2-rc and LKG.</li>
<li>7ab89e5c6e401d161f31f28a6c555a3ba530910e Merge remote-tracking branch 'origin/main' into release-4.9</li>
<li>e5cd686defb1a4cbdb36bd012357ba5bed28f371 Update package-lock.json</li>
<li>8d40dc15d1b9945837e7860320fdccfe27c40cad Update package-lock.json</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/commit/ccf3d3c5f9b4bc2883d700870ed2dac454050f1f"><code>ccf3d3c</code></a> Bump version to '4.9.5' and LKG.</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/69e88ef5513a81acf69ec78f4af1f927da0d0584"><code>69e88ef</code></a> Port ignore deprecations to 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/52419">#52419</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/daf4e817a18def96b70ac34703b158ff0e6d58df"><code>daf4e81</code></a> Port timestamp fix to 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/52426">#52426</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/e2868216f637e875a74c675845625eb15dcfe9a2"><code>e286821</code></a> Bump version to 4.9.4 and LKG.</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/eb5419fc8d980859b98553586dfb5f40d811a745"><code>eb5419f</code></a> Cherry-pick <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51704">#51704</a> to release 4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51712">#51712</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/b4d382b9b12460adf2da4cc0d1429cf19f8dc8be"><code>b4d382b</code></a> Cherry-pick changes for narrowing to tagged literal types.</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/e7a02f43fce47e1a39259ada5460bcc33c8e98b5"><code>e7a02f4</code></a> Port of <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51626">#51626</a> and <a href="https://redirect.github.com/Microsoft/TypeScript/issues/51689">#51689</a> to release-4.9 (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51627">#51627</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/1727912f0437a7f367d90040fc4b0b4f3efd017a"><code>1727912</code></a> Cherry-pick fix around <code>visitEachChild</code> to release-4.9. (<a href="https://redirect.github.com/Microsoft/TypeScript/issues/51544">#51544</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/93bd577458d55cd720b2677705feab5c91eb12ce"><code>93bd577</code></a> Bump version to 4.9.3 and LKG.</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/107f832b80df2dc97748021cb00af2b6813db75b"><code>107f832</code></a> Update LKG.</li>
<li>Additional commits viewable in <a href="https://github.com/Microsoft/TypeScript/compare/v4.7.4...v4.9.5">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=4.7.4&new-version=4.9.5)](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 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>


Patch:
diff --git a/docs/docs/helm.mdx b/docs/docs/helm.mdx
index 1881de3a..b138dae2 100644
--- a/docs/docs/helm.mdx
+++ b/docs/docs/helm.mdx
@@ -223,6 +223,26 @@ $ tk tool charts vendor
 
 Optionally, you can also pass the `--prune` flag to remove vendored charts that are no longer in the chartfile.
 
+#### OCI Registry Support
+
+Tanka supports pulling charts from OCI registries. To use one, the chart name must be split into two parts: the registry and the chart name. 
+
+As example, if you wanted to pull the `oci://public.ecr.aws/karpenter/karpenter:v0.27.3` image, your chartfile would look like this:
+
+```yaml
+version: 1
+directory: charts
+repositories:
+- name: karpenter
+  url: oci://public.ecr.aws/karpenter
+requires:
+- chart: karpenter/karpenter
+  directory: v0.27.3
+  version: v0.27.3
+```
+
+_Registry login is not supported yet._
+
 ## Troubleshooting
 
 ### Helm executable missing
diff --git a/docs/package.json b/docs/package.json
index e364409b..d196e2df 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -24,7 +24,7 @@
     "react-helmet": "^5.2.1",
     "typeface-fira-mono": "^0.0.72",
     "typeface-source-sans-pro": "^0.0.75",
-    "typescript": "^4.0.0"
+    "typescript": "^4.9.5"
   },
   "devDependencies": {
     "prettier": "^1.19.1"
diff --git a/docs/yarn.lock b/docs/yarn.lock
index ef3f4ad3..1b4f442a 100644
--- a/docs/yarn.lock
+++ b/docs/yarn.lock
@@ -15958,10 +15958,10 @@ typeface-source-sans-pro@^0.0.75:
   resolved "https://registry.yarnpkg.com/typeface-source-sans-pro/-/typeface-source-sans-pro-0.0.75.tgz#33e60ea079738c2dbdb2d0aa28f899f565e1646e"
   integrity sha512-8aI6ywe+5py1MoMQjdnuQKepOATSLpFoyatVMweF6JNUD8cu+sWaVEfZBN08CRxPrSC4KYTArf6prrQzcqpyQA==
 
-typescript@^4.0.0:
-  version "4.7.4"
-  resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
-  integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
+typescript@^4.9.5:
+  version "4.9.5"
+  resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
+  integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
 
 typography-breakpoint-constants@^0.16.19:
   version "0.16.19"
diff --git a/pkg/helm/charts.go b/pkg/helm/charts.go
index da8f015a..ee27907e 100644
--- a/pkg/helm/charts.go
+++ b/pkg/helm/charts.go
@@ -1,14 +1,12 @@
 package helm
 
 import (
-	"errors"
 	"fmt"
 	"os"
 	"path/filepath"
 	"regexp"
 	"strings"
 
-	"github.com/Masterminds/semver"
 	"github.com/rs/zerolog/log"
 	"sigs.k8s.io/yaml"
 )
@@ -75,8 +73,8 @@ type Charts struct {
 
 // chartManifest represents a Helm chart's Chart.yaml
 type chartManifest struct {
-	Name    string         `yaml:"name"`
-	Version semver.Version `yaml:"version"`
+	Name    string `yaml:"name"`
+	Version string `yaml:"version"`
 }
 
 // ChartDir returns the directory pulled charts are saved in
@@ -137,7 +135,7 @@ func (c Charts) Vendor(prune bool) error {
 				return fmt.Errorf("unmarshalling chart manifest: %w", err)
 			}
 
-			if chartYAML.Version.String() == r.Version.String() {
+			if chartYAML.Version == r.Version {
 				log.Info().Msgf("%s exists", r)
 				continue
 			}
@@ -165,7 +163,7 @@ func (c Charts) Vendor(prune bool) error {
 		if repoName := parseReqRepo(r.Chart); !c.Manifest.Repositories.HasName(repoName) {
 			return fmt.Errorf("repository %q not found for chart %q", repoName, r.Chart)
 		}
-		err := c.Helm.Pull(r.Chart, r.Version.String(), PullOpts{
+		err := c.Helm.Pull(r.Chart, r.Version, PullOpts{
 			Destination:      dir,
 			ExtractDirectory: r.Directory,
 			Opts:             Opts{Repositories: c.Manifest.Repositories},
@@ -174,7 +172,7 @@ func (c Charts) Vendor(prune bool) error {
 			return err
 		}
 
-		log.Info().Msgf("%s@%s downloaded", r.Chart, r.Version.String())
+		log.Info().Msgf("%s@%s downloaded", r.Chart, r.Version)
 	}
 
 	if prune {
@@ -307,14 +305,7 @@ func parseReq(s string) (*Requirement, error) {
 		return nil, fmt.Errorf("not of form 'repo/chart@version(:path)' where repo contains no special characters")
 	}
 
-	chart := matches[1]
-
-	ver, err := semver.NewVersion(matches[2])
-	if errors.Is(err, semver.ErrInvalidSemVer) {
-		return nil, fmt.Errorf("version is invalid: %s", matches[2])
-	} else if err != nil {
-		return nil, fmt.Errorf("error parsing semver: %s", err)
-	}
+	chart, ver := matches[1], matches[2]
 
 	directory := ""
 	if len(matches) == 4 {
@@ -323,7 +314,7 @@ func parseReq(s string) (*Requirement, error) {
 
 	return &Requirement{
 		Chart:     chart,
-		Version:   *ver,
+		Version:   ver,
 		Directory: directory,
 	}, nil
 }
diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go
index edaa7631..407cd6be 100644
--- a/pkg/helm/helm.go
+++ b/pkg/helm/helm.go
@@ -7,8 +7,10 @@ import (
 	"os"
 	"os/exec"
 	"path/filepath"
+	"strings"
 
 	"github.com/grafana/tanka/pkg/kubernetes/manifest"
+	"github.com/rs/zerolog/log"
 )
 
 // Helm provides high level access to some Helm operations
@@ -60,7 +62,18 @@ func (e ExecHelm) Pull(chart, version string, opts PullOpts) error {
 	}
 	defer os.RemoveAll(tempDir)
 
-	cmd := e.cmd("pull", chart,
+	chartPullPath := chart
+	chartRepoName, chartName := parseReqRepo(chart), parseReqName(chart)
+	for _, configuredRepo := range opts.Repositories {
+		if configuredRepo.Name == chartRepoName {
+			// OCI images are pulled with their full path
+			if strings.HasPrefix(configuredRepo.URL, "oci://") {
+				chartPullPath = fmt.Sprintf("%s/%s", configuredRepo.URL, chartName)
+			}
+		}
+	}
+
+	cmd := e.cmd("pull", chartPullPath,
 		"--version", version,
 		"--repository-config", repoFile,
 		"--destination", tempDir,
@@ -71,8 +84,6 @@ func (e ExecHelm) Pull(chart, version string, opts PullOpts) error {
 		return err
 	}
 
-	chartName := parseReqName(chart)
-
 	if opts.ExtractDirectory == "" {
 		opts.ExtractDirectory = chartName
 	}
@@ -121,6 +132,7 @@ func (e ExecHelm) ChartExists(chart string, opts *JsonnetOpts) (string, error) {
 func (e ExecHelm) cmd(action string, args ...string) *exec.Cmd {
 	argv := []string{action}
 	argv = append(argv, args...)
+	log.Debug().Strs("argv", argv).Msg("running helm")
 
 	cmd := helmCmd(argv...)
 	cmd.Stderr = os.Stderr
diff --git a/pkg/helm/spec.go b/pkg/helm/spec.go
index 9092d72c..edd449c1 100644
--- a/pkg/helm/spec.go
+++ b/pkg/helm/spec.go
@@ -3,8 +3,6 @@ package helm
 import (
 	"fmt"
 	"strings"
-
-	"github.com/Masterminds/semver"
 )
 
 const (
@@ -73,9 +71,9 @@ func (r Repos) HasName(repoName string) bool {
 // Requirement describes a single required Helm Chart.
 // Both, Chart and Version are required
 type Requirement struct {
-	Chart     string         `json:"chart"`
-	Version   semver.Version `json:"version"`
-	Directory string         `json:"directory,omitempty"`
+	Chart     string `json:"chart"`
+	Version   string `json:"version"`
+	Directory string `json:"directory,omitempty"`
 }
 
 func (r Requirement) String() string {
@@ -83,7 +81,7 @@ func (r Requirement) String() string {
 	if dir == "" {
 		dir = parseReqName(r.Chart)
 	}
-	return fmt.Sprintf("%s@%s (dir: %s)", r.Chart, r.Version.String(), dir)
+	return fmt.Sprintf("%s@%s (dir: %s)", r.Chart, r.Version, dir)
 }
 
 // Requirements is an aggregate of all required Charts
@@ -115,7 +113,7 @@ func (r Requirements) Validate() error {
 			dir = parseReqName(req.Chart)
 		}
 		if previous, ok := outputDirs[dir]; ok {
-			errs = append(errs, fmt.Sprintf(`output directory %q is used twice, by charts "%s@%s" and "%s@%s"`, dir, previous.Chart, previous.Version.String(), req.Chart, req.Version.String()))
+			errs = append(errs, fmt.Sprintf(`output directory %q is used twice, by charts "%s@%s" and "%s@%s"`, dir, previous.Chart, previous.Version, req.Chart, req.Version))
 		}
 		outputDirs[dir] = req
 	}


Test patch:
diff --git a/pkg/helm/charts_test.go b/pkg/helm/charts_test.go
index b5a1f9c9..834a45cf 100644
--- a/pkg/helm/charts_test.go
+++ b/pkg/helm/charts_test.go
@@ -7,7 +7,6 @@ import (
 	"path/filepath"
 	"testing"
 
-	"github.com/Masterminds/semver"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 )
@@ -24,21 +23,16 @@ func TestParseReq(t *testing.T) {
 			input: "stable/package@1.0.0",
 			expected: &Requirement{
 				Chart:     "stable/package",
-				Version:   *semver.MustParse("1.0.0"),
+				Version:   "1.0.0",
 				Directory: "",
 			},
 		},
-		{
-			name:  "invalid-semver",
-			input: "stable/package@not-semver",
-			err:   fmt.Errorf("version is invalid: not-semver"),
-		},
 		{
 			name:  "with-path",
 			input: "stable/package-name@1.0.0:my-path",
 			expected: &Requirement{
 				Chart:     "stable/package-name",
-				Version:   *semver.MustParse("1.0.0"),
+				Version:   "1.0.0",
 				Directory: "my-path",
 			},
 		},
@@ -47,7 +41,7 @@ func TestParseReq(t *testing.T) {
 			input: "stable/package@v1.24.0:my weird-path_test",
 			expected: &Requirement{
 				Chart:     "stable/package",
-				Version:   *semver.MustParse("v1.24.0"),
+				Version:   "v1.24.0",
 				Directory: "my weird-path_test",
 			},
 		},
@@ -126,6 +120,24 @@ func TestAdd(t *testing.T) {
 	assert.Contains(t, string(chartContent), `version: 11.12.0`)
 }
 
+func TestAddOCI(t *testing.T) {
+	tempDir := t.TempDir()
+	c, err := InitChartfile(filepath.Join(tempDir, Filename))
+	require.NoError(t, err)
+
+	err = c.AddRepos(Repo{Name: "karpenter", URL: "oci://public.ecr.aws/karpenter"})
+	assert.NoError(t, err)
+
+	err = c.Add([]string{"karpenter/karpenter@v0.27.1"})
+	assert.NoError(t, err)
+
+	// Check file contents
+	listResult, err := os.ReadDir(filepath.Join(tempDir, "charts"))
+	assert.NoError(t, err)
+	assert.Equal(t, 1, len(listResult))
+	assert.Equal(t, "karpenter", listResult[0].Name())
+}
+
 func TestRevendorDeletedFiles(t *testing.T) {
 	tempDir := t.TempDir()
 	c, err := InitChartfile(filepath.Join(tempDir, Filename))
@@ -202,7 +214,7 @@ func TestInvalidChartName(t *testing.T) {
 
 	c.Manifest.Requires = append(c.Manifest.Requires, Requirement{
 		Chart:   "noslash",
-		Version: *semver.MustParse("1.0.0"),
+		Version: "1.0.0",
 	})
 
 	err = c.Vendor(false)