Skip to content

Commit

Permalink
Update tkn, pac ConsoleCLIDownload links to 0.23.1
Browse files Browse the repository at this point in the history
This commit updates the link that ConsoleCLIDownload exposes to 0.23.1
and introduces `tkn-pac` binaries to the list as well.
  • Loading branch information
concaf authored and tekton-robot committed Apr 5, 2022
1 parent d08464a commit 038bbad
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,4 @@ metadata:
name: tkn
spec:
description: The OpenShift Pipeline client `tkn` is a CLI tool that allows you to manage OpenShift Pipeline resources.
displayName: tkn - OpenShift Pipeline Command Line Interface (CLI)
links:
- href: https://mirror.openshift.com/pub/openshift-v4/clients/pipeline/0.17.2/tkn-linux-amd64-0.17.2.tar.gz
text: Download tkn for Linux
- href: https://mirror.openshift.com/pub/openshift-v4/clients/pipeline/0.17.2/tkn-macos-amd64-0.17.2.tar.gz
text: Download tkn for Mac
- href: https://mirror.openshift.com/pub/openshift-v4/clients/pipeline/0.17.2/tkn-windows-amd64-0.17.2.zip
text: Download tkn for Windows
- href: https://mirror.openshift.com/pub/openshift-v4/clients/pipeline/0.17.2/tkn-linux-ppc64le-0.17.2.tar.gz
text: Download tkn for IBM Power
- href: https://mirror.openshift.com/pub/openshift-v4/clients/pipeline/0.17.2/tkn-linux-s390x-0.17.2.tar.gz
text: Download tkn for IBM Z
displayName: tkn - OpenShift Pipeline Command Line Interface (CLI)
4 changes: 3 additions & 1 deletion pkg/reconciler/openshift/tektonaddon/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,16 @@ func addonTransform(ctx context.Context, manifest *mf.Manifest, comp v1alpha1.Te
}

func consoleCLITransform(ctx context.Context, manifest *mf.Manifest, baseURL string) error {
tknVersion := "0.23.1"

if baseURL == "" {
return fmt.Errorf("route url should not be empty")
}
logger := logging.FromContext(ctx)
logger.Debug("Transforming manifest")

transformers := []mf.Transformer{
replaceURLCCD(baseURL),
replaceURLCCD(baseURL, tknVersion),
}

transformManifest, err := manifest.Transform(transformers...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ spec:
description: The OpenShift Pipeline client `tkn` is a CLI tool that allows you to manage OpenShift Pipeline resources.
displayName: tkn - OpenShift Pipeline Command Line Interface (CLI)
links:
- href: https://testserver.com/tkn/tkn-linux-amd64-0.21.0.tar.gz
- href: https://testserver.com/tkn/tkn-linux-amd64-1.2.3.tar.gz
text: Download tkn for Linux
- href: https://testserver.com/tkn/tkn-linux-ppc64le-0.21.0.tar.gz
- href: https://testserver.com/tkn/tkn-pac-linux-amd64-1.2.3.tar.gz
text: Download tkn-pac for Linux
- href: https://testserver.com/tkn/tkn-linux-ppc64le-1.2.3.tar.gz
text: Download tkn for IBM Power
- href: https://testserver.com/tkn/tkn-linux-s390x-0.21.0.tar.gz
- href: https://testserver.com/tkn/tkn-pac-linux-ppc64le-1.2.3.tar.gz
text: Download tkn-pac for IBM Power
- href: https://testserver.com/tkn/tkn-linux-s390x-1.2.3.tar.gz
text: Download tkn for IBM Z
- href: https://testserver.com/tkn/tkn-macos-amd64-0.21.0.tar.gz
- href: https://testserver.com/tkn/tkn-pac-linux-s390x-1.2.3.tar.gz
text: Download tkn-pac for IBM Z
- href: https://testserver.com/tkn/tkn-macos-amd64-1.2.3.tar.gz
text: Download tkn for Mac
- href: https://testserver.com/tkn/tkn-windows-amd64-0.21.0.zip
- href: https://testserver.com/tkn/tkn-pac-macos-amd64-1.2.3.tar.gz
text: Download tkn-pac for Mac
- href: https://testserver.com/tkn/tkn-windows-amd64-1.2.3.zip
text: Download tkn for Windows
- href: https://testserver.com/tkn/tkn-pac-windows-amd64-1.2.3.zip
text: Download tkn-pac for Windows
61 changes: 45 additions & 16 deletions pkg/reconciler/openshift/tektonaddon/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,52 @@ func itemInSlice(item string, items []string) bool {
return false
}

func getlinks(baseURL string) []console.CLIDownloadLink {
platforms := []struct {
key string
value string
func getlinks(baseURL, tknVersion string) []console.CLIDownloadLink {
platformURLs := []struct {
platform string
tknURL string
tknPacURL string
}{
{"Linux", "tkn/tkn-linux-amd64-0.21.0.tar.gz"},
{"IBM Power", "tkn/tkn-linux-ppc64le-0.21.0.tar.gz"},
{"IBM Z", "tkn/tkn-linux-s390x-0.21.0.tar.gz"},
{"Mac", "tkn/tkn-macos-amd64-0.21.0.tar.gz"},
{"Windows", "tkn/tkn-windows-amd64-0.21.0.zip"},
{
"Linux",
fmt.Sprintf("tkn/tkn-linux-amd64-%s.tar.gz", tknVersion),
fmt.Sprintf("tkn/tkn-pac-linux-amd64-%s.tar.gz", tknVersion),
},
{
"IBM Power",
fmt.Sprintf("tkn/tkn-linux-ppc64le-%s.tar.gz", tknVersion),
fmt.Sprintf("tkn/tkn-pac-linux-ppc64le-%s.tar.gz", tknVersion),
},
{
"IBM Z",
fmt.Sprintf("tkn/tkn-linux-s390x-%s.tar.gz", tknVersion),
fmt.Sprintf("tkn/tkn-pac-linux-s390x-%s.tar.gz", tknVersion),
},
{
"Mac",
fmt.Sprintf("tkn/tkn-macos-amd64-%s.tar.gz", tknVersion),
fmt.Sprintf("tkn/tkn-pac-macos-amd64-%s.tar.gz", tknVersion),
},
{
"Windows",
fmt.Sprintf("tkn/tkn-windows-amd64-%s.zip", tknVersion),
fmt.Sprintf("tkn/tkn-pac-windows-amd64-%s.zip", tknVersion),
},
}
links := []console.CLIDownloadLink{}
for _, platform := range platforms {
links = append(links, console.CLIDownloadLink{
Href: getURL(baseURL, platform.value),
Text: fmt.Sprintf("Download tkn for %s", platform.key),
})
for _, platformURL := range platformURLs {
links = append(links,
// tkn
console.CLIDownloadLink{
Href: getURL(baseURL, platformURL.tknURL),
Text: fmt.Sprintf("Download tkn for %s", platformURL.platform),
},
// tkn-pac
console.CLIDownloadLink{
Href: getURL(baseURL, platformURL.tknPacURL),
Text: fmt.Sprintf("Download tkn-pac for %s", platformURL.platform),
},
)
}
return links
}
Expand All @@ -105,7 +134,7 @@ func getURL(baseURL string, path string) string {
return fmt.Sprintf("https://%s/%s", baseURL, path)
}

func replaceURLCCD(baseURL string) mf.Transformer {
func replaceURLCCD(baseURL, tknVersion string) mf.Transformer {
return func(u *unstructured.Unstructured) error {
if u.GetKind() != "ConsoleCLIDownload" {
return nil
Expand All @@ -115,7 +144,7 @@ func replaceURLCCD(baseURL string) mf.Transformer {
if err != nil {
return err
}
ccd.Spec.Links = getlinks(baseURL)
ccd.Spec.Links = getlinks(baseURL, tknVersion)
unstrObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(ccd)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/openshift/tektonaddon/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestUpdateConsoleCLIDownload(t *testing.T) {
expectedManifest, err := mf.ManifestFrom(mf.Recursive(testData))
assert.NilError(t, err)

newManifest, err := manifest.Transform(replaceURLCCD("testserver.com"))
newManifest, err := manifest.Transform(replaceURLCCD("testserver.com", "1.2.3"))
assert.NilError(t, err)

got := &console.ConsoleCLIDownload{}
Expand Down

0 comments on commit 038bbad

Please sign in to comment.