Skip to content

Commit

Permalink
fix: update kafka instance version (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gezi-lzq authored Oct 14, 2024
1 parent df53c76 commit 89e1ef6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions client/api_kafka_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ func (c *Client) GetInstanceConfigs(ctx context.Context, instanceId string) ([]C
return instance.List, nil
}

func (c *Client) UpdateKafkaInstanceBasicInfo(ctx context.Context, instanceId string, updateParam InstanceBasicParam) (*KafkaInstanceResponse, error) {
return c.updateInstance(ctx, instanceId, updateParam, UpdateInstanceBasicInfoPath)
func (c *Client) UpdateKafkaInstanceVersion(ctx context.Context, instanceId string, version string) error {
updateParam := InstanceVersionUpgradeParam{Version: version}
_, err := c.Put(ctx, fmt.Sprintf(UpdateInstanceVersionPath, instanceId, version), updateParam)
if err != nil {
return err
}
return nil
}

func (c *Client) UpdateKafkaInstanceVersion(ctx context.Context, instanceId string, version string) (*KafkaInstanceResponse, error) {
updateParam := InstanceVersionUpgradeParam{Version: version}
return c.updateInstance(ctx, instanceId, updateParam, UpdateInstanceVersionPath)
func (c *Client) UpdateKafkaInstanceBasicInfo(ctx context.Context, instanceId string, updateParam InstanceBasicParam) (*KafkaInstanceResponse, error) {
return c.updateInstance(ctx, instanceId, updateParam, UpdateInstanceBasicInfoPath)
}

func (c *Client) UpdateKafkaInstanceConfig(ctx context.Context, instanceId string, updateParam InstanceConfigParam) (*KafkaInstanceResponse, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (r *KafkaInstanceResource) Update(ctx context.Context, req resource.UpdateR
planVersion := plan.ComputeSpecs.Version.ValueString()
stateVersion := state.ComputeSpecs.Version.ValueString()
if planVersion != "" && planVersion != stateVersion {
_, err = r.client.UpdateKafkaInstanceVersion(ctx, state.InstanceID.ValueString(), planVersion)
err = r.client.UpdateKafkaInstanceVersion(ctx, state.InstanceID.ValueString(), planVersion)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update Kafka instance %q, got error: %s", instanceId, err))
return
Expand Down

0 comments on commit 89e1ef6

Please sign in to comment.