-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: fix sink retain ordering and ignore custom runtime options server set vals #112
Changes from all commits
725be64
9d758ae
9da8d4e
864a7e2
16a8b21
1d35a88
b3cf455
90fbd8f
f38da50
3c17ed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,4 @@ gen | |
.DS_Store | ||
|
||
.vscode/ | ||
.terraform.lock.hcl |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -327,19 +351,19 @@ func resourcePulsarFunction() *schema.Resource { | |
resourceFunctionCPUKey: { | ||
Type: schema.TypeFloat, | ||
Optional: true, | ||
Default: 0.5, | ||
Computed: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the default value is removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the resources will be returned by worker service apis and it may changed by the worker service, so it should be marked as |
||
Description: resourceFunctionDescriptions[resourceFunctionCPUKey], | ||
}, | ||
resourceFunctionRAMKey: { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 128, | ||
Computed: true, | ||
Description: resourceFunctionDescriptions[resourceFunctionRAMKey], | ||
}, | ||
resourceFunctionDiskKey: { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 128, | ||
Computed: true, | ||
Description: resourceFunctionDescriptions[resourceFunctionDiskKey], | ||
}, | ||
resourceFunctionUserConfig: { | ||
|
@@ -822,9 +846,16 @@ func unmarshalFunctionConfig(functionConfig utils.FunctionConfig, d *schema.Reso | |
} | ||
|
||
if functionConfig.CustomRuntimeOptions != "" { | ||
err = d.Set(resourceFunctionCustomRuntimeOptionsKey, functionConfig.CustomRuntimeOptions) | ||
if err != nil { | ||
return err | ||
orig, ok := d.GetOk(resourceFunctionCustomRuntimeOptionsKey) | ||
if ok { | ||
s, err := ignoreServerSetCustomRuntimeOptions(orig.(string), functionConfig.CustomRuntimeOptions) | ||
if err != nil { | ||
return err | ||
} | ||
err = d.Set(resourceFunctionCustomRuntimeOptionsKey, s) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems can use a common method for functions/sins both