Skip to content

Commit

Permalink
Remove error return from Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 15, 2023
1 parent f70951d commit c9662ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
8 changes: 3 additions & 5 deletions sdk/resource/internal/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func Version(schemaURL string) (*semver.Version, error) {
//
// If schemaURL is version already greater than target, no upgrade will be
// performed on attrs.
func Upgrade(from, to *semver.Version, attrs []attribute.KeyValue) error {
return upgrade(slice(transforms, from, to), attrs)
func Upgrade(from, to *semver.Version, attrs []attribute.KeyValue) {
upgrade(slice(transforms, from, to), attrs)
}

func upgrade(tforms []transform, attrs []attribute.KeyValue) error {
func upgrade(tforms []transform, attrs []attribute.KeyValue) {
a := newAttributes(attrs)
for _, t := range tforms {
// Transformations in section "all" always are applied first.
Expand All @@ -83,8 +83,6 @@ func upgrade(tforms []transform, attrs []attribute.KeyValue) error {
}
}
}

return nil
}

type transform struct {
Expand Down
3 changes: 1 addition & 2 deletions sdk/resource/internal/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ func TestUpgrade(t *testing.T) {
attribute.Bool("foo", true),
attribute.Bool("untouched", true),
}
err := upgrade(tforms, attr)
require.NoError(t, err)
upgrade(tforms, attr)

want := []attribute.KeyValue{
attribute.Bool("qux", true),
Expand Down
8 changes: 2 additions & 6 deletions sdk/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,13 @@ func Merge(a, b *Resource) (*Resource, error) {
schemaURL = b.SchemaURL()

attrs := a.Attributes()
if err := schema.Upgrade(aVer, bVer, attrs); err != nil {
return Empty(), err
}
schema.Upgrade(aVer, bVer, attrs)
a = NewWithAttributes(a.schemaURL, attrs...)
} else {
schemaURL = a.schemaURL

attrs := b.Attributes()
if err := schema.Upgrade(bVer, aVer, attrs); err != nil {
return Empty(), err
}
schema.Upgrade(bVer, aVer, attrs)
b = NewWithAttributes(b.schemaURL, attrs...)
}
}
Expand Down

0 comments on commit c9662ae

Please sign in to comment.