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

Method ToPackageOverrideString

pkg/packages/packages.go:192–216  ·  view source on GitHub ↗

ToPackageOverrideString converts the struct back into a string which the server can parse e.g. StepName:Version. This is the inverse of ParsePackageOverrideString

()

Source from the content-addressed store, hash-verified

190// ToPackageOverrideString converts the struct back into a string which the server can parse e.g. StepName:Version.
191// This is the inverse of ParsePackageOverrideString
192func (p *PackageVersionOverride) ToPackageOverrideString() string {
193 components := make([]string, 0, 3)
194
195 // stepNameOrPackageID always comes first if we have it; escape delimiter chars so the server can parse correctly
196 if p.PackageID != "" {
197 components = append(components, escapePackageDelimiters(p.PackageID))
198 } else if p.ActionName != "" { // can't have both PackageID and ActionName; PackageID wins
199 components = append(components, escapePackageDelimiters(p.ActionName))
200 }
201
202 // followed by package reference name if we have it
203 if p.PackageReferenceName != "" {
204 if len(components) == 0 { // if we have an explicit packagereference but no packageId or action, we need to express it with *:ref:version
205 components = append(components, "*")
206 }
207 components = append(components, escapePackageDelimiters(p.PackageReferenceName))
208 }
209
210 if len(components) == 0 { // the server can't deal with just a number by itself; if we want to override everything we must pass *:Version
211 components = append(components, "*")
212 }
213 components = append(components, p.Version)
214
215 return strings.Join(components, ":")
216}
217
218// splitPackageOverrideString splits the input string into components based on delimiter characters (:, /, =).
219// A backslash escapes the next char only when that char is one of : / = \ ; any other "\X" sequence is preserved

Callers 4

AskQuestionsFunction · 0.80
PromptMissingFunction · 0.80

Calls 1

escapePackageDelimitersFunction · 0.85