MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / createCommonVariablePayload

Function createCommonVariablePayload

pkg/cmd/tenant/variables/update/update.go:963–998  ·  view source on GitHub ↗
(variableToUpdate variables.TenantCommonVariable, newValue *core.PropertyValue, allVariables []variables.TenantCommonVariable)

Source from the content-addressed store, hash-verified

961}
962
963func createCommonVariablePayload(variableToUpdate variables.TenantCommonVariable, newValue *core.PropertyValue, allVariables []variables.TenantCommonVariable) (payloads []variables.TenantCommonVariablePayload, isSensitive bool, error error) {
964 var updateVariablePayloads []variables.TenantCommonVariablePayload
965
966 if variableToUpdate.ID == "" {
967 updateVariablePayloads = append(updateVariablePayloads, variables.TenantCommonVariablePayload{
968 ID: variableToUpdate.ID,
969 LibraryVariableSetId: variableToUpdate.LibraryVariableSetId,
970 TemplateID: variableToUpdate.TemplateID,
971 Value: *newValue,
972 Scope: variableToUpdate.Scope,
973 })
974 }
975
976 // All common variables must be included in the request to avoid deletions
977 for _, v := range allVariables {
978 if v.ID == variableToUpdate.ID {
979 updateVariablePayloads = append(updateVariablePayloads, variables.TenantCommonVariablePayload{
980 ID: v.ID,
981 LibraryVariableSetId: v.LibraryVariableSetId,
982 TemplateID: v.TemplateID,
983 Value: *newValue,
984 Scope: v.Scope,
985 })
986 } else {
987 updateVariablePayloads = append(updateVariablePayloads, variables.TenantCommonVariablePayload{
988 ID: v.ID,
989 LibraryVariableSetId: v.LibraryVariableSetId,
990 TemplateID: v.TemplateID,
991 Value: v.Value,
992 Scope: v.Scope,
993 })
994 }
995 }
996
997 return updateVariablePayloads, newValue.IsSensitive, nil
998}
999
1000func updateProjectVariableValueV1(opts *UpdateOptions, vars *variables.TenantVariables, environmentMap map[string]string) (bool, error) {
1001 var environmentId string

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected