func()

in teamcity/vcsroot.go [705:743]


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

	var strVal *string
	if plan.IsNull() {
		// modificationCheckInterval is the only usage for now,
		// and it doesn't support DELETE method
		val := ""
		strVal = &val
	} else {
		val := strconv.FormatInt(plan.ValueInt64(), 10)
		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.Int64{}, false
	}

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

	intVal, err := strconv.ParseInt(result, 10, 64)
	if err != nil {
		diag.AddError(
			"Error setting VCS root field",
			err.Error(),
		)
		return types.Int64{}, false
	}
	return types.Int64Value(intVal), true
}