| 230 | } |
| 231 | |
| 232 | func GetDependencyID(source *latest.SourceConfig) (string, error) { |
| 233 | // check if source is there |
| 234 | if source == nil { |
| 235 | return "", fmt.Errorf("source is missing") |
| 236 | } |
| 237 | |
| 238 | // get id for git |
| 239 | if source.Git != "" { |
| 240 | id := source.Git |
| 241 | if source.Branch != "" { |
| 242 | id += "@" + source.Branch |
| 243 | } else if source.Tag != "" { |
| 244 | id += "@tag:" + source.Tag |
| 245 | } else if source.Revision != "" { |
| 246 | id += "@revision:" + source.Revision |
| 247 | } |
| 248 | |
| 249 | return encoding.Convert(id), nil |
| 250 | } else if source.Path != "" { |
| 251 | return source.Path, nil |
| 252 | } |
| 253 | |
| 254 | return "", fmt.Errorf("unexpected dependency config, both source.git and source.path are missing") |
| 255 | } |
| 256 | |
| 257 | func isURL(path string) bool { |
| 258 | return strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") |