• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sapslaj / mid / 30932682460

04 Aug 2026 05:10PM UTC coverage: 62.834% (-3.7%) from 66.574%
30932682460

Pull #41

github

web-flow
chore(deps): bump brace-expansion from 5.0.7 to 5.0.9 in /sdk/nodejs

Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 5.0.7 to 5.0.9.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v5.0.7...v5.0.9)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 5.0.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #41: chore(deps): bump brace-expansion from 5.0.7 to 5.0.9 in /sdk/nodejs

8164 of 12993 relevant lines covered (62.83%)

374.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.08
/pkg/pdiff/pdiff.go
1
package pdiff
2

3
import (
4
        "maps"
5
        "reflect"
6
        "slices"
7

8
        "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
9
        "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
10
        "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
11

12
        p "github.com/sapslaj/mid/pkg/providerfw"
13
        "github.com/sapslaj/mid/pkg/providerfw/ende"
14
        "github.com/sapslaj/mid/pkg/providerfw/introspect"
15
)
16

17
// DiffAttributes performs deep equality on two structs only for the attributes
18
// provided and returns a DiffResponse
19
func DiffAttributes(inputs any, state any, attributes []string) p.DiffResponse {
38✔
20
        inputProps, err := introspect.FindProperties(reflect.TypeOf(inputs))
38✔
21
        contract.AssertNoErrorf(err, "could not get properties")
38✔
22

38✔
23
        encoder := &ende.Encoder{}
38✔
24

38✔
25
        inputsMap, err := encoder.Encode(inputs)
38✔
26
        contract.AssertNoErrorf(err, "could not diff inputs")
38✔
27

38✔
28
        stateMap, err := encoder.Encode(state)
38✔
29
        contract.AssertNoErrorf(err, "could not diff state")
38✔
30

38✔
31
        // Olds is an Output, but news is an Input. Output should be a superset of
38✔
32
        // Input, so we need to filter out fields that are in Output but not Input.
38✔
33
        oldInputsMap := resource.PropertyMap{}
38✔
34
        for k := range inputsMap {
145✔
35
                oldInputsMap[k] = stateMap[k]
107✔
36
        }
107✔
37

38
        objDiff := oldInputsMap.Diff(inputsMap)
38✔
39
        pluginDiff := plugin.NewDetailedDiffFromObjectDiff(objDiff, true)
38✔
40
        diff := map[string]p.PropertyDiff{}
38✔
41

38✔
42
        for k, v := range pluginDiff {
78✔
43
                propertyPath, err := resource.ParsePropertyPath(k)
40✔
44
                contract.AssertNoErrorf(err, "could not parse generated property path")
40✔
45

40✔
46
                selected := false
40✔
47
                for i := range attributes {
539✔
48
                        attributePropertyPath, err := resource.ParsePropertyPath(attributes[i])
499✔
49
                        contract.AssertNoErrorf(err, "could not parse attribute property path")
499✔
50

499✔
51
                        if attributePropertyPath.Contains(propertyPath) {
515✔
52
                                selected = true
16✔
53
                        }
16✔
54
                }
55
                if !selected {
64✔
56
                        continue
24✔
57
                }
58

59
                set := func(kind p.DiffKind) {
32✔
60
                        diff[k] = p.PropertyDiff{
16✔
61
                                Kind:      kind,
16✔
62
                                InputDiff: v.InputDiff,
16✔
63
                        }
16✔
64
                }
16✔
65

66
                fieldTag := inputProps[k]
16✔
67
                if fieldTag.ReplaceOnChanges {
20✔
68
                        v.Kind = v.Kind.AsReplace()
4✔
69
                }
4✔
70

71
                switch v.Kind {
16✔
72
                case plugin.DiffAdd:
×
73
                        set(p.Add)
×
74
                case plugin.DiffAddReplace:
×
75
                        set(p.AddReplace)
×
76
                case plugin.DiffDelete:
×
77
                        set(p.Delete)
×
78
                case plugin.DiffDeleteReplace:
×
79
                        set(p.DeleteReplace)
×
80
                case plugin.DiffUpdate:
12✔
81
                        set(p.Update)
12✔
82
                case plugin.DiffUpdateReplace:
4✔
83
                        set(p.UpdateReplace)
4✔
84
                }
85
        }
86
        return p.DiffResponse{
38✔
87
                HasChanges:   len(diff) > 0,
38✔
88
                DetailedDiff: diff,
38✔
89
        }
38✔
90
}
91

92
// DiffAllAttributesExcept performs a deep equality on two structs for all
93
// attributes except the list provided and returns a diff response.
94
func DiffAllAttributesExcept(inputs any, state any, exceptAttributes []string) p.DiffResponse {
32✔
95
        inputProps, err := introspect.FindProperties(reflect.TypeOf(inputs))
32✔
96
        contract.AssertNoErrorf(err, "could not get properties")
32✔
97

32✔
98
        attributes := []string{}
32✔
99
        for prop := range inputProps {
656✔
100
                if !slices.Contains(exceptAttributes, prop) {
1,182✔
101
                        attributes = append(attributes, prop)
558✔
102
                }
558✔
103
        }
104

105
        return DiffAttributes(inputs, state, attributes)
32✔
106
}
107

108
// DiffAllAttributes performs a deep equality on two structs for all attributes
109
func DiffAllAttributes(inputs any, state any) p.DiffResponse {
6✔
110
        return DiffAllAttributesExcept(inputs, state, []string{})
6✔
111
}
6✔
112

113
// ForceDiffReplace changes all of the properties in the DiffResponse to be the
114
// "-replace" equivalent to trigger a resource replacement.
115
func ForceDiffReplace(diff p.DiffResponse) p.DiffResponse {
1✔
116
        for key, propdiff := range diff.DetailedDiff {
8✔
117
                switch propdiff.Kind {
7✔
118
                case p.Add:
1✔
119
                        propdiff.Kind = p.AddReplace
1✔
120
                case p.Delete:
1✔
121
                        propdiff.Kind = p.DeleteReplace
1✔
122
                case p.Update:
1✔
123
                        propdiff.Kind = p.UpdateReplace
1✔
124
                }
125
                diff.DetailedDiff[key] = propdiff
7✔
126
        }
127
        return diff
1✔
128
}
129

130
// MergeDiffResponses will merge an arbitrary number of DiffResponses together
131
// with the last taking the highest precedence. Any DiffResponse that has
132
// `HasChanges` or `DeleteBeforeReplace` set will result in the returned
133
// DiffResponse to have those set as well.
134
func MergeDiffResponses(drs ...p.DiffResponse) p.DiffResponse {
23✔
135
        diff := p.DiffResponse{
23✔
136
                HasChanges:   false,
23✔
137
                DetailedDiff: map[string]p.PropertyDiff{},
23✔
138
        }
23✔
139
        for _, dr := range drs {
91✔
140
                if dr.HasChanges {
80✔
141
                        diff.HasChanges = true
12✔
142
                }
12✔
143
                if dr.DeleteBeforeReplace {
89✔
144
                        diff.DeleteBeforeReplace = true
21✔
145
                }
21✔
146
                maps.Copy(diff.DetailedDiff, dr.DetailedDiff)
68✔
147
        }
148
        return diff
23✔
149
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc