diff --git a/pkg/cmd/version/testdata/TestGetVersions-deployment_with_pipeline,_chains,_triggers,_dashboard,_hub_and_operator_installed.golden b/pkg/cmd/version/testdata/TestGetVersions-deployment_with_pipeline,_chains,_triggers,_dashboard,_hub_and_operator_installed.golden new file mode 100644 index 000000000..a1c9a0872 --- /dev/null +++ b/pkg/cmd/version/testdata/TestGetVersions-deployment_with_pipeline,_chains,_triggers,_dashboard,_hub_and_operator_installed.golden @@ -0,0 +1,7 @@ +Client version: dev +Chains version: v0.8.0 +Pipeline version: v0.10.0 +Triggers version: v0.5.0 +Dashboard version: v0.7.0 +Operator version: v0.54.0 +Hub version: v1.14.0 diff --git a/pkg/cmd/version/version.go b/pkg/cmd/version/version.go index d5126fd95..dece11f29 100644 --- a/pkg/cmd/version/version.go +++ b/pkg/cmd/version/version.go @@ -98,6 +98,10 @@ func Command(p cli.Params) *cobra.Command { if operatorVersion != "" { fmt.Fprintf(cmd.OutOrStdout(), "Operator version: %s\n", operatorVersion) } + hubVersion, _ := version.GetHubVersion(cs, namespace) + if hubVersion != "" { + fmt.Fprintf(cmd.OutOrStdout(), "Hub version: %s\n", hubVersion) + } case "client": fmt.Fprintf(cmd.OutOrStdout(), "%s\n", clientVersion) case "chains": @@ -130,6 +134,12 @@ func Command(p cli.Params) *cobra.Command { operatorVersion = "unknown" } fmt.Fprintf(cmd.OutOrStdout(), "%s\n", operatorVersion) + case "hub": + hubVersion, _ := version.GetHubVersion(cs, namespace) + if hubVersion == "" { + hubVersion = "unknown" + } + fmt.Fprintf(cmd.OutOrStdout(), "%s\n", hubVersion) default: fmt.Fprintf(cmd.OutOrStdout(), "Invalid component value\n") } diff --git a/pkg/cmd/version/version_test.go b/pkg/cmd/version/version_test.go index 3f257c5d3..b8844fde3 100644 --- a/pkg/cmd/version/version_test.go +++ b/pkg/cmd/version/version_test.go @@ -260,6 +260,7 @@ func TestGetVersions(t *testing.T) { triggersConfigMap := getConfigMapData("triggers-info", "v0.5.0", map[string]string{"app.kubernetes.io/part-of": "tekton-pipelines"}) dashboardConfigMap := getConfigMapData("dashboard-info", "v0.7.0", map[string]string{"app.kubernetes.io/part-of": "tekton-pipelines"}) operatorConfigMap := getConfigMapData("tekton-operator-info", "v0.54.0", map[string]string{"app.kubernetes.io/part-of": "tekton-pipelines"}) + hubConfigMap := getConfigMapData("hub-info", "v1.14.0", map[string]string{"app.kubernetes.io/part-of": "tekton-pipelines"}) testParams := []struct { name string @@ -305,11 +306,11 @@ func TestGetVersions(t *testing.T) { configMap: []*corev1.ConfigMap{pipelineConfigMap, triggersConfigMap, dashboardConfigMap, operatorConfigMap}, goldenFile: true, }, { - name: "deployment with pipeline, chains, triggers, dashboard and operator installed", + name: "deployment with pipeline, chains, triggers, dashboard, hub and operator installed", namespace: "test", userProvidedNamespace: "test", deployment: []*v1.Deployment{}, - configMap: []*corev1.ConfigMap{pipelineConfigMap, chainsConfigMap, triggersConfigMap, dashboardConfigMap, operatorConfigMap}, + configMap: []*corev1.ConfigMap{pipelineConfigMap, chainsConfigMap, triggersConfigMap, dashboardConfigMap, operatorConfigMap, hubConfigMap}, goldenFile: true, }} for _, tp := range testParams { diff --git a/pkg/version/version.go b/pkg/version/version.go index c5125151e..a6cc24bf9 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -38,6 +38,7 @@ const ( triggersInfo string = "triggers-info" dashboardInfo string = "dashboard-info" operatorInfo string = "tekton-operator-info" + hubInfo string = "hub-info" ) var defaultNamespaces = []string{"tekton-pipelines", "openshift-pipelines", "tekton-chains", "tekton-operator", "openshift-operators"} @@ -293,3 +294,12 @@ func GetOperatorVersion(c *cli.Clients, ns string) (string, error) { version := configMap.Data["version"] return version, nil } + +func GetHubVersion(c *cli.Clients, ns string) (string, error) { + configMap, err := getConfigMap(c, hubInfo, ns) + if err != nil { + return "", err + } + version := configMap.Data["version"] + return version, nil +}