Skip to content

Commit 8ab171e

Browse files
authored
Merge pull request #2012 from FabianKramm/master
Fix replace pod problem with statefulset and multiple containers
2 parents 21a39a5 + 45dc890 commit 8ab171e

18 files changed

Lines changed: 135 additions & 130 deletions

File tree

helper/server/ignoreparser/ignoreparser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ func CompilePaths(excludePaths []string, log log.Logger) (IgnoreParser, error) {
7070
if !strings.Contains(p, "**") && !strings.Contains(path.Dir(p), "*") {
7171
absoluteNegatePatterns = append(absoluteNegatePatterns, p)
7272
} else {
73-
log.Warnf("Exclude path '%s' uses a ** or * and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead", line)
73+
log.Warnf("Exclude path '%s' uses a ** or * and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead to improve performance", line)
7474
requireFullScan = true
7575
}
7676
} else {
77-
log.Warnf("Exclude path '%s' is not scoped to the directory base and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead", line)
77+
log.Warnf("Exclude path '%s' is not scoped to the directory base and thus requires a full initial scan. Please consider using a path in the form of '!/path/to/my/folder/' instead to improve performance", line)
7878
requireFullScan = true
7979
}
8080
}

pkg/devspace/config/loader/imports.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/loft-sh/devspace/pkg/devspace/config/versions/util"
99
dependencyutil "github.com/loft-sh/devspace/pkg/devspace/dependency/util"
1010
"github.com/loft-sh/devspace/pkg/util/log"
11+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
1112
"github.com/pkg/errors"
12-
"gopkg.in/yaml.v3"
1313
"io/ioutil"
1414
"path/filepath"
1515
)
@@ -82,7 +82,7 @@ func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath st
8282
}
8383

8484
importData := map[string]interface{}{}
85-
err = yaml.Unmarshal(fileContent, &importData)
85+
err = yamlutil.Unmarshal(fileContent, &importData)
8686
if err != nil {
8787
return nil, err
8888
}

pkg/devspace/config/loader/loader.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package loader
22

33
import (
4-
"bytes"
54
"context"
65
"fmt"
76
"github.com/loft-sh/devspace/pkg/devspace/context/values"
87
"github.com/loft-sh/devspace/pkg/util/encoding"
8+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
99
"io/ioutil"
1010
"os"
1111
"path/filepath"
@@ -596,7 +596,7 @@ func (l *configLoader) LoadRaw() (map[string]interface{}, error) {
596596
}
597597

598598
rawMap := map[string]interface{}{}
599-
err = yaml.Unmarshal(fileContent, &rawMap)
599+
err = yamlutil.Unmarshal(fileContent, &rawMap)
600600
if err != nil {
601601
return nil, err
602602
}
@@ -691,7 +691,7 @@ func copyRaw(in map[string]interface{}) (map[string]interface{}, error) {
691691
}
692692

693693
n := map[string]interface{}{}
694-
err = yaml.Unmarshal(o, &n)
694+
err = yamlutil.Unmarshal(o, &n)
695695
if err != nil {
696696
return nil, err
697697
}
@@ -719,9 +719,7 @@ func copyForValidation(profile interface{}) (*latest.ProfileConfig, error) {
719719
}
720720

721721
profileConfig := &latest.ProfileConfig{}
722-
decoder := yaml.NewDecoder(bytes.NewReader(o))
723-
decoder.KnownFields(true)
724-
err = decoder.Decode(profileConfig)
722+
err = yamlutil.UnmarshalStrict(o, profileConfig)
725723
if err != nil {
726724
return nil, err
727725
}

pkg/devspace/config/loader/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package loader
22

33
import (
4+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
45
"gopkg.in/yaml.v3"
56
)
67

@@ -27,7 +28,7 @@ func (co *ConfigOptions) Clone() (*ConfigOptions, error) {
2728
}
2829

2930
newCo := &ConfigOptions{}
30-
err = yaml.Unmarshal(out, newCo)
31+
err = yamlutil.Unmarshal(out, newCo)
3132
if err != nil {
3233
return nil, err
3334
}

pkg/devspace/config/loader/parser.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/loft-sh/devspace/pkg/devspace/config/versions"
88
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
99
"github.com/loft-sh/devspace/pkg/util/log"
10+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
1011
"github.com/pkg/errors"
1112
"gopkg.in/yaml.v3"
1213
)
@@ -77,7 +78,7 @@ func (p *profilesParser) Parse(ctx context.Context, originalRawConfig map[string
7778
if err != nil {
7879
continue
7980
}
80-
err = yaml.Unmarshal(o, profileConfig)
81+
err = yamlutil.Unmarshal(o, profileConfig)
8182
if err != nil {
8283
continue
8384
}

pkg/devspace/config/loader/patch/patch.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package patch
22

33
import (
44
"fmt"
5+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
56

67
"gopkg.in/yaml.v3"
78
)
@@ -11,7 +12,7 @@ type Patch []Operation
1112
// Apply returns a YAML document that has been mutated per patch
1213
func (p Patch) Apply(doc []byte) ([]byte, error) {
1314
var node yaml.Node
14-
err := yaml.Unmarshal(doc, &node)
15+
err := yamlutil.Unmarshal(doc, &node)
1516
if err != nil {
1617
return nil, fmt.Errorf("failed unmarshaling doc: %s\n\n%s", string(doc), err)
1718
}
@@ -33,7 +34,7 @@ func NewNode(raw *interface{}) (*yaml.Node, error) {
3334
}
3435

3536
var node yaml.Node
36-
err = yaml.Unmarshal(doc, &node)
37+
err = yamlutil.Unmarshal(doc, &node)
3738
if err != nil {
3839
return nil, fmt.Errorf("failed unmarshaling doc: %s\n\n%s", string(doc), err)
3940
}

pkg/devspace/config/loader/validate.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package loader
22

33
import (
4-
"bytes"
54
"fmt"
5+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
66

77
jsonyaml "github.com/ghodss/yaml"
88
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
@@ -232,9 +232,7 @@ func ValidateComponentConfig(deployConfig *latest.DeploymentConfig, overwriteVal
232232
}
233233

234234
componentValues := &latest.ComponentConfig{}
235-
decoder := yaml.NewDecoder(bytes.NewReader(b))
236-
decoder.KnownFields(true)
237-
err = decoder.Decode(componentValues)
235+
err = yamlutil.UnmarshalStrict(b, componentValues)
238236
if err != nil {
239237
return errors.Errorf("deployments[%s].helm.componentChart: component values are incorrect: %v", deployConfig.Name, err)
240238
}

pkg/devspace/config/loader/variable/expression/expression.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
8+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
89
"mvdan.cc/sh/v3/interp"
910
"os"
1011
"os/exec"
@@ -13,7 +14,6 @@ import (
1314
"strings"
1415

1516
"github.com/loft-sh/devspace/pkg/devspace/deploy/deployer/kubectl/walk"
16-
"gopkg.in/yaml.v3"
1717
)
1818

1919
// ExpressionMatchRegex is the regex to check if a value matches the devspace var format
@@ -135,14 +135,14 @@ func ResolveExpressions(ctx context.Context, value, dir string) (interface{}, er
135135

136136
// is yaml object?
137137
m := map[string]interface{}{}
138-
err = yaml.Unmarshal([]byte(out), &m)
138+
err = yamlutil.Unmarshal([]byte(out), &m)
139139
if err == nil {
140140
return m, nil
141141
}
142142

143143
// is yaml array?
144144
arr := []interface{}{}
145-
err = yaml.Unmarshal([]byte(out), &arr)
145+
err = yamlutil.Unmarshal([]byte(out), &arr)
146146
if err == nil {
147147
return arr, nil
148148
}

pkg/devspace/config/localcache/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ package localcache
33
import (
44
"encoding/base64"
55
"fmt"
6+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
67
"io/ioutil"
78
"path/filepath"
89

910
"github.com/loft-sh/devspace/pkg/devspace/config/constants"
1011
"github.com/loft-sh/devspace/pkg/util/encryption"
11-
12-
yaml "gopkg.in/yaml.v3"
1312
)
1413

1514
const (
@@ -58,7 +57,7 @@ func (l *cacheLoader) Load(devSpaceFilePath string) (Cache, error) {
5857
loadedConfig = New(cachePath).(*LocalCache)
5958
} else {
6059
loadedConfig = &LocalCache{}
61-
err := yaml.Unmarshal(data, loadedConfig)
60+
err := yamlutil.Unmarshal(data, loadedConfig)
6261
if err != nil {
6362
return nil, err
6463
}

pkg/devspace/config/remotecache/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
88
"github.com/loft-sh/devspace/pkg/util/encoding"
99
"github.com/loft-sh/devspace/pkg/util/encryption"
10-
"gopkg.in/yaml.v3"
10+
"github.com/loft-sh/devspace/pkg/util/yamlutil"
1111
kerrors "k8s.io/apimachinery/pkg/api/errors"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1313
)
@@ -57,7 +57,7 @@ func (c *cacheLoader) Load(ctx context.Context, client kubectl.Client) (Cache, e
5757

5858
remoteCache := &RemoteCache{}
5959
remoteCache.raw = secret.Data["cache"]
60-
err = yaml.Unmarshal(secret.Data["cache"], remoteCache)
60+
err = yamlutil.Unmarshal(secret.Data["cache"], remoteCache)
6161
if err != nil {
6262
return nil, err
6363
}

0 commit comments

Comments
 (0)