func()

in teamcity/connection.go [206:274]


func (r *connectionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
	var plan connectionResourceModel
	diags := req.Plan.Get(ctx, &plan)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	var oldState connectionResourceModel
	diags = req.State.Get(ctx, &oldState)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	var newState connectionResourceModel
	newState.ProjectId = plan.ProjectId
	newState.FeatureId = plan.FeatureId
	projectId := plan.ProjectId.ValueString()
	featureId := plan.FeatureId.ValueString()

	if result, ok := r.setFieldString(projectId, featureId, "displayName", oldState.GithubApp.DisplayName, plan.GithubApp.DisplayName, &resp.Diagnostics); ok {
		newState.GithubApp.DisplayName = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "gitHubApp.ownerUrl", oldState.GithubApp.OwnerUrl, plan.GithubApp.OwnerUrl, &resp.Diagnostics); ok {
		newState.GithubApp.OwnerUrl = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "gitHubApp.appId", oldState.GithubApp.AppId, plan.GithubApp.AppId, &resp.Diagnostics); ok {
		newState.GithubApp.AppId = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "gitHubApp.clientId", oldState.GithubApp.ClientId, plan.GithubApp.ClientId, &resp.Diagnostics); ok {
		newState.GithubApp.ClientId = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "secure:gitHubApp.clientSecret", oldState.GithubApp.ClientSecret, plan.GithubApp.ClientSecret, &resp.Diagnostics); ok {
		newState.GithubApp.ClientSecret = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "secure:gitHubApp.privateKey", oldState.GithubApp.PrivateKey, plan.GithubApp.PrivateKey, &resp.Diagnostics); ok {
		newState.GithubApp.PrivateKey = result
	} else {
		return
	}

	if result, ok := r.setFieldString(projectId, featureId, "secure:gitHubApp.webhookSecret", oldState.GithubApp.WebhookSecret, plan.GithubApp.WebhookSecret, &resp.Diagnostics); ok {
		newState.GithubApp.WebhookSecret = result
	} else {
		return
	}

	diags = resp.State.Set(ctx, newState)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}
}