func()

in teamcity/vcsroot.go [745:780]


func (r *vcsRootResource) setFieldBool(id, name string, state, plan types.Bool, diag *diag.Diagnostics) (types.Bool, bool) {
	if plan.Equal(state) {
		return state, true
	}

	var strVal *string
	if plan.IsNull() {
		strVal = nil
	} else {
		val := strconv.FormatBool(plan.ValueBool())
		strVal = &val
	}

	result, err := r.client.SetField("vcs-roots", id, name, strVal)
	if err != nil {
		diag.AddError(
			"Error setting VCS root field",
			err.Error(),
		)
		return types.Bool{}, false
	}

	if result == "" {
		return types.BoolNull(), true
	}

	val, err := strconv.ParseBool(result)
	if err != nil {
		diag.AddError(
			"Error setting VCS root field",
			err.Error(),
		)
		return types.Bool{}, false
	}
	return types.BoolValue(val), true
}