diff --git a/cmd/crc/cmd/version.go b/cmd/crc/cmd/version.go index d9d8595b6c..36d057854f 100644 --- a/cmd/crc/cmd/version.go +++ b/cmd/crc/cmd/version.go @@ -34,16 +34,18 @@ func runPrintVersion(writer io.Writer, version *version, outputFormat string) er } type version struct { - Version string `json:"version"` - Commit string `json:"commit"` - OpenshiftVersion string `json:"openshiftVersion"` + Version string `json:"version"` + Commit string `json:"commit"` + OpenshiftVersion string `json:"openshiftVersion"` + MicroshiftVersion string `json:"microshiftVersion"` } func defaultVersion() *version { return &version{ - Version: crcversion.GetCRCVersion(), - Commit: crcversion.GetCommitSha(), - OpenshiftVersion: crcversion.GetBundleVersion(crcPreset.OpenShift), + Version: crcversion.GetCRCVersion(), + Commit: crcversion.GetCommitSha(), + OpenshiftVersion: crcversion.GetBundleVersion(crcPreset.OpenShift), + MicroshiftVersion: crcversion.GetBundleVersion(crcPreset.Microshift), } } @@ -60,5 +62,6 @@ func (v *version) lines() []string { return []string{ fmt.Sprintf("CRC version: %s+%s\n", v.Version, v.Commit), fmt.Sprintf("OpenShift version: %s\n", v.OpenshiftVersion), + fmt.Sprintf("MicroShift version: %s\n", v.MicroshiftVersion), } } diff --git a/cmd/crc/cmd/version_test.go b/cmd/crc/cmd/version_test.go index a17d82df61..87896da2e1 100644 --- a/cmd/crc/cmd/version_test.go +++ b/cmd/crc/cmd/version_test.go @@ -10,23 +10,26 @@ import ( func TestPlainVersion(t *testing.T) { out := new(bytes.Buffer) assert.NoError(t, runPrintVersion(out, &version{ - Version: "1.13", - Commit: "aabbcc", - OpenshiftVersion: "4.5.4", + Version: "1.13", + Commit: "aabbcc", + OpenshiftVersion: "4.5.4", + MicroshiftVersion: "4.16.0", }, "")) assert.Equal(t, `CRC version: 1.13+aabbcc OpenShift version: 4.5.4 +MicroShift version: 4.16.0 `, out.String()) } func TestJsonVersion(t *testing.T) { out := new(bytes.Buffer) assert.NoError(t, runPrintVersion(out, &version{ - Version: "1.13", - Commit: "aabbcc", - OpenshiftVersion: "4.5.4", + Version: "1.13", + Commit: "aabbcc", + OpenshiftVersion: "4.5.4", + MicroshiftVersion: "4.16.0", }, "json")) - expected := `{"version": "1.13", "commit": "aabbcc", "openshiftVersion": "4.5.4"}` + expected := `{"version": "1.13", "commit": "aabbcc", "openshiftVersion": "4.5.4", "microshiftVersion": "4.16.0"}` assert.JSONEq(t, expected, out.String()) } diff --git a/pkg/crc/api/api_client_test.go b/pkg/crc/api/api_client_test.go index f3c7128677..fc2951a559 100644 --- a/pkg/crc/api/api_client_test.go +++ b/pkg/crc/api/api_client_test.go @@ -48,9 +48,10 @@ func TestVersion(t *testing.T) { assert.Equal( t, apiClient.VersionResult{ - CrcVersion: version.GetCRCVersion(), - OpenshiftVersion: version.GetBundleVersion(preset.OpenShift), - CommitSha: version.GetCommitSha(), + CrcVersion: version.GetCRCVersion(), + OpenshiftVersion: version.GetBundleVersion(preset.OpenShift), + MicroshiftVersion: version.GetBundleVersion(preset.Microshift), + CommitSha: version.GetCommitSha(), }, vr, ) diff --git a/pkg/crc/api/api_http_test.go b/pkg/crc/api/api_http_test.go index b2a7521b84..f8219bf2ec 100644 --- a/pkg/crc/api/api_http_test.go +++ b/pkg/crc/api/api_http_test.go @@ -265,7 +265,7 @@ var testCases = []testCase{ // version { request: get("version"), - response: jSon(fmt.Sprintf(`{"CrcVersion":"%s","CommitSha":"%s","OpenshiftVersion":"%s"}`, version.GetCRCVersion(), version.GetCommitSha(), version.GetBundleVersion(preset.OpenShift))), + response: jSon(fmt.Sprintf(`{"CrcVersion":"%s","CommitSha":"%s","OpenshiftVersion":"%s","MicroshiftVersion":"%s"}`, version.GetCRCVersion(), version.GetCommitSha(), version.GetBundleVersion(preset.OpenShift), version.GetBundleVersion(preset.Microshift))), }, // version never fails diff --git a/pkg/crc/api/client/types.go b/pkg/crc/api/client/types.go index 590f1e9b97..776270888c 100644 --- a/pkg/crc/api/client/types.go +++ b/pkg/crc/api/client/types.go @@ -7,9 +7,10 @@ import ( ) type VersionResult struct { - CrcVersion string - CommitSha string - OpenshiftVersion string + CrcVersion string + CommitSha string + OpenshiftVersion string + MicroshiftVersion string } type StartResult struct { diff --git a/pkg/crc/api/handlers.go b/pkg/crc/api/handlers.go index 35e1658a0a..5588184647 100644 --- a/pkg/crc/api/handlers.go +++ b/pkg/crc/api/handlers.go @@ -136,9 +136,10 @@ func getStartConfig(cfg crcConfig.Storage, args client.StartConfig) types.StartC func (h *Handler) GetVersion(c *context) error { return c.JSON(http.StatusOK, &client.VersionResult{ - CrcVersion: version.GetCRCVersion(), - CommitSha: version.GetCommitSha(), - OpenshiftVersion: version.GetBundleVersion(preset.OpenShift), + CrcVersion: version.GetCRCVersion(), + CommitSha: version.GetCommitSha(), + OpenshiftVersion: version.GetBundleVersion(preset.OpenShift), + MicroshiftVersion: version.GetBundleVersion(preset.Microshift), }) } diff --git a/test/integration/testsuite_test.go b/test/integration/testsuite_test.go index 52c1115375..5268d03283 100644 --- a/test/integration/testsuite_test.go +++ b/test/integration/testsuite_test.go @@ -17,9 +17,10 @@ import ( ) type VersionAnswer struct { - Version string `json:"version"` - Commit string `json:"commit"` - OpenshiftVersion string `json:"openshiftVersion"` + Version string `json:"version"` + Commit string `json:"commit"` + OpenshiftVersion string `json:"openshiftVersion"` + MicroshiftVersion string `json:"microshiftVersion"` } var credPath string