Skip to content

Commit

Permalink
Fix mismatch messaging during podman preset
Browse files Browse the repository at this point in the history
Currently most of the places still have `Openshift cluster` as part of
string and show as message to user when perform different operation like
`delete`, `setup` ..etc. This PR tries to fix it by just using `instance`
instead of runtime.

fixes: #2863
  • Loading branch information
praveenkumar committed Feb 15, 2022
1 parent d6808d0 commit e2a76bb
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 32 deletions.
13 changes: 7 additions & 6 deletions cmd/crc/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ var clearCache bool

func init() {
deleteCmd.Flags().BoolVarP(&clearCache, "clear-cache", "", false,
fmt.Sprintf("Clear the OpenShift cluster cache at: %s", constants.MachineCacheDir))
fmt.Sprintf("Clear the instance cache at: %s", constants.MachineCacheDir))
addOutputFormatFlag(deleteCmd)
addForceFlag(deleteCmd)
rootCmd.AddCommand(deleteCmd)
}

var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete the OpenShift cluster",
Long: "Delete the OpenShift cluster",
Short: "Delete the instance",
Long: "Delete the instance",
RunE: func(cmd *cobra.Command, args []string) error {
return runDelete(os.Stdout, newMachine(), clearCache, constants.MachineCacheDir, outputFormat != jsonFormat, globalForce, outputFormat)
},
Expand All @@ -38,7 +38,7 @@ func deleteMachine(client machine.Client, clearCache bool, cacheDir string, inte
if !interactive && !force {
return false, errors.New("non-interactive deletion requires --force")
}
yes := input.PromptUserForYesOrNo("Do you want to delete the OpenShift cluster cache", force)
yes := input.PromptUserForYesOrNo("Do you want to delete the instance cache", force)
if yes {
_ = os.RemoveAll(cacheDir)
}
Expand All @@ -52,7 +52,8 @@ func deleteMachine(client machine.Client, clearCache bool, cacheDir string, inte
return false, errors.New("non-interactive deletion requires --force")
}

yes := input.PromptUserForYesOrNo("Do you want to delete the OpenShift cluster", force)
yes := input.PromptUserForYesOrNo("Do you want to delete the instance",
force)
if yes {
defer logging.BackupLogFile()
return true, client.Delete()
Expand Down Expand Up @@ -80,7 +81,7 @@ func (s *deleteResult) prettyPrintTo(writer io.Writer) error {
return s.Error
}
if s.machineDeleted {
if _, err := fmt.Fprintln(writer, "Deleted the OpenShift cluster"); err != nil {
if _, err := fmt.Fprintln(writer, "Deleted the instance"); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestPlainDelete(t *testing.T) {

out := new(bytes.Buffer)
assert.NoError(t, runDelete(out, fakemachine.NewClient(), true, cacheDir, true, true, ""))
assert.Equal(t, "Deleted the OpenShift cluster\n", out.String())
assert.Equal(t, "Deleted the instance\n", out.String())

_, err = os.Stat(cacheDir)
assert.True(t, os.IsNotExist(err))
Expand Down
9 changes: 5 additions & 4 deletions cmd/crc/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ var (

func init() {
setupCmd.Flags().Bool(crcConfig.ExperimentalFeatures, false, "Allow the use of experimental features")
setupCmd.Flags().StringP(crcConfig.Bundle, "b", constants.GetDefaultBundlePath(crcConfig.GetPreset(config)), "Bundle to use for VM")
setupCmd.Flags().StringP(crcConfig.Bundle, "b", constants.GetDefaultBundlePath(crcConfig.GetPreset(config)), "Bundle to use for instance")
setupCmd.Flags().BoolVar(&checkOnly, "check-only", false, "Only run the preflight checks, don't try to fix any misconfiguration")
addOutputFormatFlag(setupCmd)
rootCmd.AddCommand(setupCmd)
}

var setupCmd = &cobra.Command{
Use: "setup",
Short: "Set up prerequisites for the OpenShift cluster",
Long: "Set up local virtualization and networking infrastructure for the OpenShift cluster",
Short: "Set up prerequisites for using CodeReady Containers",
Long: "Set up local virtualization and networking infrastructure for using CodeReady Containers",
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindFlagSet(cmd.Flags()); err != nil {
return err
Expand Down Expand Up @@ -86,6 +86,7 @@ func (s *setupResult) prettyPrintTo(writer io.Writer) error {
if s.Error != nil {
return s.Error
}
_, err := fmt.Fprintf(writer, "Your system is correctly setup for using CodeReady Containers, you can now run 'crc start' to start the OpenShift cluster\n")
_, err := fmt.Fprintln(writer, "Your system is correctly setup for using CodeReady Containers. "+
"Use 'crc start' to start the instance")
return err
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestSetupRenderActionPlainSuccess(t *testing.T) {
assert.NoError(t, render(&setupResult{
Success: true,
}, out, ""))
assert.Equal(t, "Your system is correctly setup for using CodeReady Containers, you can now run 'crc start' to start the OpenShift cluster\n", out.String())
assert.Equal(t, "Your system is correctly setup for using CodeReady Containers. Use 'crc start' to start the instance\n", out.String())
}

func TestSetupRenderActionPlainFailure(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/crc/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ func init() {
addOutputFormatFlag(startCmd)

flagSet := pflag.NewFlagSet("start", pflag.ExitOnError)
flagSet.StringP(crcConfig.Bundle, "b", constants.GetDefaultBundlePath(crcConfig.GetPreset(config)), "The system bundle used for deployment of the OpenShift cluster")
flagSet.StringP(crcConfig.Bundle, "b", constants.GetDefaultBundlePath(crcConfig.GetPreset(config)), "The system bundle used to provision the instance")
flagSet.StringP(crcConfig.PullSecretFile, "p", "", fmt.Sprintf("File path of image pull secret (download from %s)", constants.CrcLandingPageURL))
flagSet.IntP(crcConfig.CPUs, "c", constants.GetDefaultCPUs(crcConfig.GetPreset(config)), "Number of CPU cores to allocate to the OpenShift cluster")
flagSet.IntP(crcConfig.Memory, "m", constants.GetDefaultMemory(crcConfig.GetPreset(config)), "MiB of memory to allocate to the OpenShift cluster")
flagSet.UintP(crcConfig.DiskSize, "d", constants.DefaultDiskSize, "Total size in GiB of the disk used by the OpenShift cluster")
flagSet.StringP(crcConfig.NameServer, "n", "", "IPv4 address of nameserver to use for the OpenShift cluster")
flagSet.IntP(crcConfig.CPUs, "c", constants.GetDefaultCPUs(crcConfig.GetPreset(config)), "Number of CPU cores to allocate to the instance")
flagSet.IntP(crcConfig.Memory, "m", constants.GetDefaultMemory(crcConfig.GetPreset(config)), "MiB of memory to allocate to the instance")
flagSet.UintP(crcConfig.DiskSize, "d", constants.DefaultDiskSize, "Total size in GiB of the disk used by the instance")
flagSet.StringP(crcConfig.NameServer, "n", "", "IPv4 address of nameserver to use for the instance")
flagSet.Bool(crcConfig.DisableUpdateCheck, false, "Don't check for update")

startCmd.Flags().AddFlagSet(flagSet)
}

var startCmd = &cobra.Command{
Use: "start",
Short: "Start the OpenShift cluster",
Long: "Start the OpenShift cluster",
Short: "Start the instance",
Long: "Start the instance",
RunE: func(cmd *cobra.Command, args []string) error {
if err := viper.BindFlagSet(cmd.Flags()); err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/crc/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func init() {

var stopCmd = &cobra.Command{
Use: "stop",
Short: "Stop the OpenShift cluster",
Long: "Stop the OpenShift cluster",
Short: "Stop the instance",
Long: "Stop the instance",
RunE: func(cmd *cobra.Command, args []string) error {
return runStop(os.Stdout, newMachine(), outputFormat != jsonFormat, globalForce, outputFormat)
},
Expand Down Expand Up @@ -74,9 +74,9 @@ func (s *stopResult) prettyPrintTo(writer io.Writer) error {
return s.Error
}
if s.Forced {
_, err := fmt.Fprintln(writer, "Forcibly stopped the OpenShift cluster")
_, err := fmt.Fprintln(writer, "Forcibly stopped the instance")
return err
}
_, err := fmt.Fprintln(writer, "Stopped the OpenShift cluster")
_, err := fmt.Fprintln(writer, "Stopped the instance")
return err
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func TestStopPlainSuccess(t *testing.T) {
out := new(bytes.Buffer)
assert.NoError(t, runStop(out, fakemachine.NewClient(), true, false, ""))
assert.Equal(t, "Stopped the OpenShift cluster\n", out.String())
assert.Equal(t, "Stopped the instance\n", out.String())
}

func TestStopPlainError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/machine/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (client *client) Stop() (state.State, error) {
logging.Debugf("%v", err)
}
}
logging.Info("Stopping the OpenShift cluster, this may take a few minutes...")
logging.Info("Stopping the instance, this may take a few minutes...")
if err := vm.Stop(); err != nil {
status, stateErr := vm.State()
if stateErr != nil {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: Basic test
And stderr should contain "Checking if NetworkManager service is running"
And stderr should contain "Using root access: Executing systemctl daemon-reload command"
And stderr should contain "Using root access: Executing systemctl reload NetworkManager"
And stdout should contain "Your system is correctly setup for using CodeReady Containers, you can now run 'crc start' to start the OpenShift cluster"
And stdout should contain "Your system is correctly setup for using CodeReady Containers. Use 'crc start' to start the instance"

@linux
Scenario: Missing CRC setup
Expand Down Expand Up @@ -152,7 +152,7 @@ Feature: Basic test
@darwin @windows
Scenario: CRC stop
When executing "crc stop"
Then stdout should match "(.*)[Ss]topped the OpenShift cluster"
Then stdout should match "(.*)[Ss]topped the instance"
And executing "oc whoami" fails

@darwin @linux @windows
Expand All @@ -168,7 +168,7 @@ Feature: Basic test
@darwin @linux @windows
Scenario: CRC delete
When executing "crc delete -f" succeeds
Then stdout should contain "Deleted the OpenShift cluster"
Then stdout should contain "Deleted the instance"

@linux
Scenario: CRC starts with generated bundle
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/features/cert_rotation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Feature: Certificate rotation test

Scenario: CRC delete and cleanup
When executing "crc delete -f" succeeds
Then stdout should contain "Deleted the OpenShift cluster"
Then stdout should contain "Deleted the instance"
When executing crc cleanup command succeeds
2 changes: 1 addition & 1 deletion test/e2e/features/proxy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature: Behind proxy test

Scenario: CRC delete and remove proxy settings from config
When executing "crc delete -f" succeeds
Then stdout should contain "Deleted the OpenShift cluster"
Then stdout should contain "Deleted the instance"
And executing "crc config unset http-proxy" succeeds
And executing "crc config unset https-proxy" succeeds
And executing crc cleanup command succeeds
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/features/story_marketplace.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ Feature: Operator from marketplace
@darwin @linux @windows @startstop
Scenario: Clean up
When executing "crc delete -f" succeeds
Then stdout should contain "Deleted the OpenShift cluster"
Then stdout should contain "Deleted the instance"
When executing crc cleanup command succeeds
Then stdout should contain "Cleanup finished"
2 changes: 1 addition & 1 deletion test/e2e/features/story_registry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ Feature: Local image to image-registry
@startstop
Scenario: Clean up
When executing "crc delete -f" succeeds
Then stdout should contain "Deleted the OpenShift cluster"
Then stdout should contain "Deleted the instance"
When executing crc cleanup command succeeds
Then stdout should contain "Cleanup finished"

0 comments on commit e2a76bb

Please sign in to comment.