parseAquaRef parses an aqua reference string into owner, repo, and version. Format: "owner/repo" or "owner/repo@version"
(ref string)
| 242 | // parseAquaRef parses an aqua reference string into owner, repo, and version. |
| 243 | // Format: "owner/repo" or "owner/repo@version" |
| 244 | func parseAquaRef(ref string) (owner, repo, version string, err error) { |
| 245 | ref = strings.TrimSpace(ref) |
| 246 | |
| 247 | atParts := strings.SplitN(ref, "@", 2) |
| 248 | namePart := atParts[0] |
| 249 | if len(atParts) == 2 { |
| 250 | version = atParts[1] |
| 251 | } |
| 252 | |
| 253 | parts := strings.SplitN(namePart, "/", 2) |
| 254 | if len(parts) != 2 || parts[0] == "" || parts[1] == "" { |
| 255 | return "", "", "", fmt.Errorf("invalid aqua reference %q: expected owner/repo[@version] format", ref) |
| 256 | } |
| 257 | |
| 258 | return parts[0], parts[1], version, nil |
| 259 | } |
no outgoing calls