Skip to content

Commit

Permalink
fixup! Config: Version Management
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Oct 12, 2024
1 parent aee2f5b commit 8cf5f2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions config/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
errRegisteringVersion = errors.New("error registering config version")
errVersionIncompatible = errors.New("version does not implement ConfigVersion or ExchangeVersion")
errVersionSequence = errors.New("version registered out of sequence")
errModifiyingExchange = errors.New("error modifying exchange config")
errModifyingExchange = errors.New("error modifying exchange config")
errNoVersions = errors.New("error retrieving latest config version: No config versions are registered")
errApplyingVersion = errors.New("error applying version")
)
Expand Down Expand Up @@ -134,7 +134,7 @@ func exchangeDeploy(ctx context.Context, patch ExchangeVersion, method func(Exch
defer func() { i++ }()
name, err := jsonparser.GetString(exchOrig, "name")
if err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w: %w `name`: %w", errModifiyingExchange, common.ErrGettingField, err))
errs = common.AppendError(errs, fmt.Errorf("%w: %w `name`: %w", errModifyingExchange, common.ErrGettingField, err))
return
}
for _, want := range wanted {
Expand All @@ -143,12 +143,12 @@ func exchangeDeploy(ctx context.Context, patch ExchangeVersion, method func(Exch
}
exchNew, err := method(patch, ctx, exchOrig)
if err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w: %w", errModifiyingExchange, err))
errs = common.AppendError(errs, fmt.Errorf("%w: %w", errModifyingExchange, err))
continue
}
if !bytes.Equal(exchNew, exchOrig) {
if j, err = jsonparser.Set(j, exchNew, "exchanges", "["+strconv.Itoa(i)+"]"); err != nil {
errs = common.AppendError(errs, fmt.Errorf("%w: %w `exchanges.[%d]`: %w", errModifiyingExchange, common.ErrSettingField, i, err))
errs = common.AppendError(errs, fmt.Errorf("%w: %w `exchanges.[%d]`: %w", errModifyingExchange, common.ErrSettingField, i, err))
}
}
}
Expand All @@ -158,7 +158,7 @@ func exchangeDeploy(ctx context.Context, patch ExchangeVersion, method func(Exch
case errors.Is(err, jsonparser.KeyPathNotFoundError), dataType != jsonparser.Array:
return j, nil
case err != nil:
return j, fmt.Errorf("%w: %w `exchanges`: %w", errModifiyingExchange, common.ErrGettingField, err)
return j, fmt.Errorf("%w: %w `exchanges`: %w", errModifyingExchange, common.ErrGettingField, err)
}
if _, err := jsonparser.ArrayEach(bytes.Clone(v), eFunc); err != nil {
return j, err
Expand Down
2 changes: 1 addition & 1 deletion config/versions/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestExchangeDeploy(t *testing.T) {
v := &v9998.Version{}
in := []byte(`{"version":0,"exchanges":[{}]}`)
_, err = exchangeDeploy(context.Background(), v, ExchangeVersion.UpgradeExchange, in)
require.ErrorIs(t, err, errModifiyingExchange)
require.ErrorIs(t, err, errModifyingExchange)
require.ErrorIs(t, err, common.ErrGettingField)
require.ErrorIs(t, err, jsonparser.KeyPathNotFoundError)
require.ErrorContains(t, err, "`name`")
Expand Down

0 comments on commit 8cf5f2d

Please sign in to comment.