Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
freeznet committed Jan 8, 2024
1 parent 864a7e2 commit 16a8b21
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
24 changes: 24 additions & 0 deletions pulsar/resource_pulsar_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,31 @@ func resourcePulsarFunction() *schema.Resource {
resourceFunctionSubscriptionPositionKey: {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: resourceFunctionDescriptions[resourceFunctionSubscriptionPositionKey],
ValidateFunc: func(val interface{}, key string) ([]string, []error) {
v := val.(string)
subscriptionPositionSupported := []string{
SubscriptionPositionEarliest,
SubscriptionPositionLatest,
}

found := false
for _, item := range subscriptionPositionSupported {
if v == item {
found = true
break
}
}
if !found {
return nil, []error{
fmt.Errorf("%s is unsupported, shold be one of %s", v,
strings.Join(subscriptionPositionSupported, ",")),
}
}

return nil, nil
},
},
resourceFunctionCleanupSubscriptionKey: {
Type: schema.TypeBool,
Expand Down
27 changes: 25 additions & 2 deletions pulsar/resource_pulsar_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,31 @@ func resourcePulsarSink() *schema.Resource {
resourceSinkSubscriptionPositionKey: {
Type: schema.TypeString,
Optional: true,
Default: "Earliest",
Default: SubscriptionPositionEarliest,
Description: resourceSinkDescriptions[resourceSinkSubscriptionPositionKey],
ValidateFunc: func(val interface{}, key string) ([]string, []error) {
v := val.(string)
subscriptionPositionSupported := []string{
SubscriptionPositionEarliest,
SubscriptionPositionLatest,
}

found := false
for _, item := range subscriptionPositionSupported {
if v == item {
found = true
break
}
}
if !found {
return nil, []error{
fmt.Errorf("%s is unsupported, shold be one of %s", v,
strings.Join(subscriptionPositionSupported, ",")),
}
}

return nil, nil
},
},
resourceSinkCustomSerdeInputsKey: {
Type: schema.TypeMap,
Expand Down Expand Up @@ -563,7 +586,7 @@ func resourcePulsarSinkRead(ctx context.Context, d *schema.ResourceData, meta in
}

if sinkConfig.SourceSubscriptionPosition != "" {
err = d.Set(resourceFunctionSubscriptionPositionKey, sinkConfig.SourceSubscriptionPosition)
err = d.Set(resourceSinkSubscriptionPositionKey, sinkConfig.SourceSubscriptionPosition)
if err != nil {
return diag.FromErr(err)
}
Expand Down
5 changes: 5 additions & 0 deletions pulsar/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const (
ProcessingGuaranteesEffectivelyOnce = "EFFECTIVELY_ONCE"
)

const (
SubscriptionPositionEarliest = "Earliest"
SubscriptionPositionLatest = "Latest"
)

func isPackageURLSupported(functionPkgURL string) bool {
return strings.HasPrefix(functionPkgURL, "http://") ||
strings.HasPrefix(functionPkgURL, "https://") ||
Expand Down

0 comments on commit 16a8b21

Please sign in to comment.