Skip to content

Commit 3c35e2a

Browse files
feat: dont use "v" prefix for --source-version (#4)
Signed-off-by: Mathew Wicks <[email protected]>
1 parent a8b1534 commit 3c35e2a

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The simplest usage of the `deploykf` CLI is to run the following command:
1414

1515
```bash
1616
deploykf \
17-
--source-version v0.1.0 \
17+
--source-version 0.1.0 \
1818
--values ./custom-values.yaml \
1919
--output-dir ./GENERATOR_OUTPUT
2020
```

internal/generate/source.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ func NewSourceHelper(opts ...SourceHelperOptions) *SourceHelper {
4949
return gh
5050
}
5151

52-
// ListReleases lists the available `github.RepositoryRelease` in the source repo.
53-
//func (h *SourceHelper) ListReleases() ([]*github.RepositoryRelease, error) {
54-
// client := github.NewClient(nil)
55-
//
56-
// releases, _, err := client.Repositories.ListReleases(context.Background(), h.GithubOwner, h.GithubRepo, nil)
57-
// if err != nil {
58-
// return nil, err
59-
// }
60-
//
61-
// return releases, nil
62-
//}
63-
6452
// DownloadAndUnpackSource downloads the generator source artifact for the specified version (if it's not already cached),
6553
// unpacks it to the provided folder, then returns the local path of the artifact .zip file.
6654
func (h *SourceHelper) DownloadAndUnpackSource(version string, unpackTargetDir string, out io.Writer) (string, error) {
@@ -167,10 +155,13 @@ func (h *SourceHelper) downloadReleaseAsset(releaseAsset *github.ReleaseAsset, d
167155
func (h *SourceHelper) getReleaseByVersion(version string) (*github.RepositoryRelease, error) {
168156
client := github.NewClient(nil)
169157

170-
release, resp, err := client.Repositories.GetReleaseByTag(context.Background(), h.GithubOwner, h.GithubRepo, version)
158+
// the repo uses a "v" prefix for release tags
159+
tagName := "v" + version
160+
161+
release, resp, err := client.Repositories.GetReleaseByTag(context.Background(), h.GithubOwner, h.GithubRepo, tagName)
171162
if err != nil {
172163
if resp.StatusCode == http.StatusNotFound {
173-
return nil, fmt.Errorf("github release not found for version: %s", version)
164+
return nil, fmt.Errorf("github release not found with tag: %s", tagName)
174165
}
175166
return nil, err
176167
}

0 commit comments

Comments
 (0)