Skip to content

Commit

Permalink
feat: removes default initial_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Ludden committed Aug 3, 2022
1 parent 05475a4 commit 928cbbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
**Parameters:**
| Parameter | Type | Description | Required |
| :--- | :---: | :--- | :---: |
| initial_mapping | `string` | a [Bloblang mapping](https://www.benthos.dev/docs/guides/bloblang/about) that can be used to customize the initial version returned by this resource, defaults to `id = ksuid()` | |
| initial_mapping | `string` | a [Bloblang mapping](https://www.benthos.dev/docs/guides/bloblang/about) that can be used to customize the initial version returned by this resource, if not specified, checking is a noop and should be disabled via `check_every: never` | |

## Behavior

Expand Down
13 changes: 5 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,15 @@ type Resource struct{}

// Check is a required resource method, but is a no-op for this resource
func (r *Resource) Check(ctx context.Context, s *Source, v *Version) (versions []Version, err error) {
if v == nil {
m := "id = ksuid()"
if s != nil && s.InitialMapping != "" {
m = s.InitialMapping
}
init, _, err := r.newVersion(ctx, m)
if v != nil {
versions = append(versions, *v)
}
if len(versions) == 0 && s.InitialMapping != "" {
init, _, err := r.newVersion(ctx, s.InitialMapping)
if err != nil {
return nil, err
}
versions = append(versions, *init)
} else {
versions = append(versions, *v)
}
return
}
Expand Down

0 comments on commit 928cbbe

Please sign in to comment.