Skip to content

Commit

Permalink
Keep image content if persistentVolume.enabled is false (#782)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chico de Guzman <pchico83@gmail.com>
  • Loading branch information
pchico83 committed Mar 26, 2020
1 parent 29a14cc commit 3be78fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
12 changes: 6 additions & 6 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,13 @@ func (up *UpContext) devMode(d *appsv1.Deployment, create bool) error {
reporter := make(chan string)
defer close(reporter)
go func() {
message := "Attaching persistent volume"
up.updateStateFile(attaching)
message := "Activating your development environment"
if up.Dev.PersistentVolumeEnabled() {
message = "Attaching persistent volume"
up.updateStateFile(attaching)
}
for {
if up.Dev.PersistentVolumeEnabled() {
spinner.update(fmt.Sprintf("%s...", message))
}

spinner.update(fmt.Sprintf("%s...", message))
message = <-reporter
if message == "" {
return
Expand Down
18 changes: 13 additions & 5 deletions pkg/model/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ func (dev *Dev) validate() error {
if len(dev.Services) > 0 {
return fmt.Errorf("'persistentVolume.enabled' must be set to true to work with services")
}
if len(dev.Volumes) > 0 {
return fmt.Errorf("'persistentVolume.enabled' must be set to true to use volumes")
}
}

if _, err := resource.ParseQuantity(dev.PersistentVolumeSize()); err != nil {
Expand Down Expand Up @@ -450,15 +453,20 @@ func (dev *Dev) ToTranslationRule(main *Dev) *TranslationRule {
Secrets: dev.Secrets,
WorkDir: dev.WorkDir,
PersistentVolume: dev.PersistentVolumeEnabled(),
Volumes: []VolumeMount{
{
Volumes: []VolumeMount{},
SecurityContext: dev.SecurityContext,
Resources: dev.Resources,
}

if dev.PersistentVolumeEnabled() {
rule.Volumes = append(
rule.Volumes,
VolumeMount{
Name: main.GetVolumeName(),
MountPath: dev.MountPath,
SubPath: fullSubPath(0, dev.SubPath),
},
},
SecurityContext: dev.SecurityContext,
Resources: dev.Resources,
)
}

if main == dev {
Expand Down

0 comments on commit 3be78fe

Please sign in to comment.