Skip to content

Commit

Permalink
Change default value for ephemral preference
Browse files Browse the repository at this point in the history
For not it assumes default value for ephemeral 'false'.
It future  releases we might change it 'true'. But for now we should
play it safe and keep the old behaviour. We are not sure about all the
consequences that this can have.
  • Loading branch information
kadel committed Jan 14, 2021
1 parent f236382 commit 7c06bcf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/preference/preference.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const (

// EphemeralSetting specifies if ephemeral volumes needs to be used as source volume.
EphemeralSetting = "Ephemeral"

// DefaultEphemeralSettings is a default value for Ephemeral preference
DefaultEphemeralSettings = true
)

// TimeoutSettingDescription is human-readable description for the timeout setting
Expand All @@ -102,7 +105,7 @@ var BuildTimeoutSettingDescription = fmt.Sprintf("BuildTimeout (in seconds) for
var RegistryCacheTimeDescription = fmt.Sprintf("For how long (in minutes) odo will cache information from Devfile registry (Default: %d)", DefaultRegistryCacheTime)

// EphemeralDescription adds a description for EphemeralSourceVolume
var EphemeralDescription = fmt.Sprintf("If true odo will create a emptyDir volume to store source code(Default: %t)", false)
var EphemeralDescription = fmt.Sprintf("If true odo will create a emptyDir volume to store source code (Default: %t)", DefaultEphemeralSettings)

// This value can be provided to set a seperate directory for users 'homedir' resolution
// note for mocking purpose ONLY
Expand Down Expand Up @@ -501,7 +504,7 @@ func (c *PreferenceInfo) GetUpdateNotification() bool {
// GetEphemeralSourceVolume returns the value of ephemeral from preferences
// and if absent then returns default
func (c *PreferenceInfo) GetEphemeralSourceVolume() bool {
return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, false)
return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSettings)
}

// GetNamePrefix returns the value of Prefix from preferences
Expand Down
41 changes: 41 additions & 0 deletions tests/integration/devfile/cmd_devfile_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,47 @@ var _ = Describe("odo devfile storage command tests", func() {

helper.CmdShouldPass("odo", "push", "--context", commonVar.Context)

// Verify the pvc size
PVCs := commonVar.CliRunner.GetAllPVCNames(commonVar.Project)

Expect(len(PVCs)).To(Equal(0))
})
})

Context("When ephemeral is set to false in preference.yaml", func() {
It("should create a pvc to store source code", func() {

helper.CmdShouldPass("odo", "preference", "set", "ephemeral", "false")

args := []string{"create", "nodejs", cmpName, "--context", commonVar.Context, "--project", commonVar.Project}
helper.CmdShouldPass("odo", args...)

helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))

helper.CmdShouldPass("odo", "push", "--context", commonVar.Context)

// Verify the pvc size
PVCs := commonVar.CliRunner.GetAllPVCNames(commonVar.Project)

Expect(len(PVCs)).To(Not(Equal(0)))
})
})

Context("When ephemeral is not set in preference.yaml", func() {
It("should not create a pvc to store source code (default is ephemeral=false)", func() {

args := []string{"create", "nodejs", cmpName, "--context", commonVar.Context, "--project", commonVar.Project}
helper.CmdShouldPass("odo", args...)

helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))

helper.CmdShouldPass("odo", "push", "--context", commonVar.Context)

helper.CmdShouldPass("odo", "preference","view")


// Verify the pvc size
PVCs := commonVar.CliRunner.GetAllPVCNames(commonVar.Project)

Expand Down

0 comments on commit 7c06bcf

Please sign in to comment.