func()

in teamcity/project_param.go [277:309]


func (r *paramResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
	// Only consider Create operations (no prior state)
	if !req.State.Raw.IsNull() || req.Plan.Raw.IsNull() {
		return
	}

	var plan paramResourceModel
	diags := req.Plan.Get(ctx, &plan)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}

	// Only warn for password-type parameters, and only if server indicates
	// that a secure parameter with this name already exists (TeamCity returns 400 on GET).
	if isSecureParam(plan) {
		willReplace, err := r.willReplaceSecureOnCreate(ctx, plan.ProjectId.ValueString(), plan.Name.ValueString())
		if err != nil {
			// Do not fail plan on pre-check errors; just skip the warning.
			return
		}
		if willReplace {
			// Pure informational warning; does not mutate the plan
			resp.Diagnostics.AddWarning(
				"Existing secure parameter will be updated",
				fmt.Sprintf(
					"A secure project parameter named %q already exists in project %q. Creating this resource will update (overwrite) the existing secure parameter value. TeamCity does not return secure project parameters, the previous secure value will be lost.",
					plan.Name.ValueString(), plan.ProjectId.ValueString(),
				),
			)
		}
	}
}