String returns human-readable representation of PublishedRepo
()
| 544 | |
| 545 | // String returns human-readable representation of PublishedRepo |
| 546 | func (p *PublishedRepo) String() string { |
| 547 | var sources = []string{} |
| 548 | |
| 549 | for _, component := range p.Components() { |
| 550 | var source string |
| 551 | |
| 552 | item := p.sourceItems[component] |
| 553 | if item.snapshot != nil { |
| 554 | source = item.snapshot.String() |
| 555 | } else if item.localRepo != nil { |
| 556 | source = item.localRepo.String() |
| 557 | } else { |
| 558 | panic("no snapshot/localRepo") |
| 559 | } |
| 560 | |
| 561 | sources = append(sources, fmt.Sprintf("{%s: %s}", component, source)) |
| 562 | } |
| 563 | |
| 564 | var extras []string |
| 565 | var extra string |
| 566 | |
| 567 | if p.Origin != "" { |
| 568 | extras = append(extras, fmt.Sprintf("origin: %s", p.Origin)) |
| 569 | } |
| 570 | |
| 571 | if p.NotAutomatic != "" { |
| 572 | extras = append(extras, fmt.Sprintf("notautomatic: %s", p.NotAutomatic)) |
| 573 | } |
| 574 | |
| 575 | if p.ButAutomaticUpgrades != "" { |
| 576 | extras = append(extras, fmt.Sprintf("butautomaticupgrades: %s", p.ButAutomaticUpgrades)) |
| 577 | } |
| 578 | |
| 579 | if p.Label != "" { |
| 580 | extras = append(extras, fmt.Sprintf("label: %s", p.Label)) |
| 581 | } |
| 582 | |
| 583 | if p.Suite != "" { |
| 584 | extras = append(extras, fmt.Sprintf("suite: %s", p.Suite)) |
| 585 | } |
| 586 | |
| 587 | if p.Codename != "" { |
| 588 | extras = append(extras, fmt.Sprintf("codename: %s", p.Codename)) |
| 589 | } |
| 590 | |
| 591 | extra = strings.Join(extras, ", ") |
| 592 | |
| 593 | if extra != "" { |
| 594 | extra = " (" + extra + ")" |
| 595 | } |
| 596 | |
| 597 | return fmt.Sprintf("%s/%s%s [%s] publishes %s", p.StoragePrefix(), p.Distribution, extra, strings.Join(p.Architectures, ", "), |
| 598 | strings.Join(sources, ", ")) |
| 599 | } |
| 600 | |
| 601 | // StoragePrefix returns combined storage & prefix for the repo |
| 602 | func (p *PublishedRepo) StoragePrefix() string { |