Skip to content

Commit 50315e6

Browse files
praveenkumaranjannath
authored andcommitted
Remove okd build logic and IsOkdBuild function
Since now we have OKD preset to make decision around code flow, better to use preset logic.
1 parent e031382 commit 50315e6

File tree

6 files changed

+19
-39
lines changed

6 files changed

+19
-39
lines changed

Makefile

-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ CONTAINER_RUNTIME ?= podman
1212
TOOLS_DIR := tools
1313
include tools/tools.mk
1414

15-
ifdef OKD_VERSION
16-
OPENSHIFT_VERSION = $(OKD_VERSION)
17-
CRC_VERSION := $(CRC_VERSION)-OKD
18-
endif
19-
2015
# Go and compilation related variables
2116
BUILD_DIR ?= out
2217
SOURCE_DIRS = cmd pkg test
@@ -64,10 +59,6 @@ VERSION_VARIABLES := -X $(REPOPATH)/pkg/crc/version.crcVersion=$(CRC_VERSION) \
6459
-X $(REPOPATH)/pkg/crc/version.commitSha=$(COMMIT_SHA)
6560
RELEASE_VERSION_VARIABLES := -X $(REPOPATH)/pkg/crc/segment.WriteKey=cvpHsNcmGCJqVzf6YxrSnVlwFSAZaYtp
6661

67-
ifdef OKD_VERSION
68-
VERSION_VARIABLES := $(VERSION_VARIABLES) -X $(REPOPATH)/pkg/crc/version.okdBuild=true
69-
endif
70-
7162
# https://golang.org/cmd/link/
7263
LDFLAGS := $(VERSION_VARIABLES) ${GO_EXTRA_LDFLAGS}
7364
# Same build flags are used in the podman remote to cross build it https://github.com/containers/podman/blob/main/Makefile

cmd/crc/cmd/start.go

+11-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"io"
88
"os"
99
"runtime"
10-
"strings"
1110
"text/template"
1211

1312
"github.com/Masterminds/semver/v3"
@@ -156,18 +155,7 @@ func (s *startResult) prettyPrintTo(writer io.Writer) error {
156155
return errors.New("either Error or ClusterConfig is needed")
157156
}
158157

159-
if err := writeTemplatedMessage(writer, s); err != nil {
160-
return err
161-
}
162-
if crcversion.IsOkdBuild() {
163-
_, err := fmt.Fprintln(writer, strings.Join([]string{
164-
"",
165-
"NOTE:",
166-
"This cluster was built from OKD - The Community Distribution of Kubernetes that powers Red Hat OpenShift.",
167-
"If you find an issue, please report it at https://github.com/openshift/okd"}, "\n"))
168-
return err
169-
}
170-
return nil
158+
return writeTemplatedMessage(writer, s)
171159
}
172160

173161
func validateStartFlags() error {
@@ -252,6 +240,10 @@ Use the 'oc' command line interface:
252240
Use the 'podman' command line interface:
253241
{{ .CommandLinePrefix }} {{ .EvalCommandLine }}
254242
{{ .CommandLinePrefix }} {{ .PodmanRemote }} COMMAND
243+
`
244+
startTemplateForOKD = `NOTE:
245+
This cluster was built from OKD - The Community Distribution of Kubernetes that powers Red Hat OpenShift.
246+
If you find an issue, please report it at https://github.com/openshift/okd
255247
`
256248
)
257249

@@ -263,15 +255,19 @@ type templateVariables struct {
263255
}
264256

265257
func writeTemplatedMessage(writer io.Writer, s *startResult) error {
266-
if s.ClusterConfig.ClusterType == preset.OpenShift {
258+
if s.ClusterConfig.ClusterType == preset.OpenShift || s.ClusterConfig.ClusterType == preset.OKD {
267259
return writeOpenShiftTemplatedMessage(writer, s)
268260
}
269261

270262
return writePodmanTemplatedMessage(writer, s)
271263
}
272264

273265
func writeOpenShiftTemplatedMessage(writer io.Writer, s *startResult) error {
274-
parsed, err := template.New("template").Parse(startTemplateForOpenshift)
266+
tmpl := startTemplateForOpenshift
267+
if s.ClusterConfig.ClusterType == preset.OKD {
268+
tmpl = fmt.Sprintf("%s\n\n%s", startTemplateForOpenshift, startTemplateForOKD)
269+
}
270+
parsed, err := template.New("template").Parse(tmpl)
275271
if err != nil {
276272
return err
277273
}

pkg/crc/cluster/pullsecret.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/code-ready/crc/pkg/crc/logging"
1616
"github.com/code-ready/crc/pkg/crc/preset"
1717
"github.com/code-ready/crc/pkg/crc/validation"
18-
crcversion "github.com/code-ready/crc/pkg/crc/version"
1918
crcos "github.com/code-ready/crc/pkg/os"
2019

2120
"github.com/AlecAivazis/survey/v2"
@@ -77,8 +76,8 @@ func NewNonInteractivePullSecretLoader(config crcConfig.Storage, path string) Pu
7776
}
7877

7978
func (loader *nonInteractivePullSecretLoader) Value() (string, error) {
80-
// If crc is built from an OKD bundle or podman bundle is used, then use the fake pull secret in contants.
81-
if crcversion.IsOkdBuild() || crcConfig.GetPreset(loader.config) == preset.Podman {
79+
// If crc is built from an OKD bundle or podman bundle is used, then use the fake pull secret in constants.
80+
if crcConfig.GetPreset(loader.config) == preset.OKD || crcConfig.GetPreset(loader.config) == preset.Podman {
8281
return constants.OkdPullSecret, nil
8382
}
8483

pkg/crc/image/image.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ func getLayerPath(m *v1.Manifest, index int, mediaType string) (string, error) {
8585
}
8686

8787
func getImageName(preset crcpreset.Preset) string {
88-
if preset == crcpreset.Podman {
88+
switch preset {
89+
case crcpreset.Podman:
8990
return "podman-bundle"
90-
}
91-
if version.IsOkdBuild() {
91+
case crcpreset.OKD:
9292
return "okd-bundle"
93+
default:
94+
return "openshift-bundle"
9395
}
94-
return "openshift-bundle"
9596
}
9697

9798
func PullBundle(preset crcpreset.Preset) error {

pkg/crc/preflight/preflight_checks_common.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/code-ready/crc/pkg/crc/machine/bundle"
1414
crcpreset "github.com/code-ready/crc/pkg/crc/preset"
1515
"github.com/code-ready/crc/pkg/crc/validation"
16-
"github.com/code-ready/crc/pkg/crc/version"
1716
"github.com/pkg/errors"
1817
)
1918

@@ -102,7 +101,7 @@ func fixBundleExtracted(bundlePath string, preset crcpreset.Preset) func() error
102101
logging.Infof("Downloading %s", constants.GetDefaultBundle(preset))
103102
// In case of OKD or podman bundle then pull the bundle image from quay
104103
// otherwise use mirror location to download the bundle.
105-
if version.IsOkdBuild() || preset == crcpreset.Podman {
104+
if preset == crcpreset.OKD || preset == crcpreset.Podman {
106105
if err := image.PullBundle(preset); err != nil {
107106
return err
108107
}

pkg/crc/version/version.go

-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ var (
2828
// Podman version for podman specific bundles
2929
podmanVersion = "0.0.0-unset"
3030

31-
okdBuild = "false"
32-
3331
okdVersion = "0.0.0-unset"
3432
// will always be false on linux
3533
// will be true for releases on macos and windows
@@ -83,10 +81,6 @@ func GetAdminHelperVersion() string {
8381
return crcAdminHelperVersion
8482
}
8583

86-
func IsOkdBuild() bool {
87-
return okdBuild == "true"
88-
}
89-
9084
func GetTrayVersion() string {
9185
return crcTrayElectronVersion
9286
}

0 commit comments

Comments
 (0)