Documentation
¶
Overview ¶
Example ¶
package main
import (
"bufio"
"fmt"
"strings"
"github.com/docker-library/bashbrew/manifest"
)
func main() {
man, err := manifest.Parse(bufio.NewReader(strings.NewReader(`# RFC 2822
# I LOVE CAKE
Maintainers: InfoSiftr <github@infosiftr.com> (@infosiftr),
Johan Euphrosine <proppy@google.com> (@proppy)
GitFetch: refs/heads/master
GitRepo: https://github.com/docker-library/golang.git
SharedTags: latest
arm64v8-GitRepo: https://github.com/docker-library/golang.git
Architectures: amd64, amd64
# hi
# blasphemer
# Go 1.6
Tags: 1.6.1, 1.6, 1
arm64v8-GitRepo: https://github.com/docker-library/golang.git
Directory: 1.6
GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
Constraints: some-random-build-server
# Go 1.5
Tags: 1.5.3
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
SharedTags: 1.5.3-debian, 1.5-debian
Directory: 1.5
s390x-GitCommit: b6c460e7cd79b595267870a98013ec3078b490df
i386-GitFetch: refs/heads/i386
ppc64le-Directory: 1.5/ppc64le/
Tags: 1.5
SharedTags: 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5
s390x-GitCommit: b6c460e7cd79b595267870a98013ec3078b490df
i386-GitFetch: refs/heads/i386
ppc64le-Directory: 1.5/ppc64le
Tags: 1.5-alpine
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5
File: Dockerfile.alpine
s390x-File: Dockerfile.alpine.s390x.bad-boy
Builder: buildkit
GitFetch: refs/heads/having-a-good-time
SharedTags: raspbian
GitCommit: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
Tags: raspbian-s390x
Architectures: s390x, i386
File: Dockerfile-raspbian
s390x-File: Dockerfile
`)))
if err != nil {
panic(err)
}
fmt.Printf("-------------\n2822:\n%s\n", man)
fmt.Printf("\nShared Tag Groups:\n")
for _, group := range man.GetSharedTagGroups() {
fmt.Printf("\n - %s\n", strings.Join(group.SharedTags, ", "))
for _, entry := range group.Entries {
fmt.Printf(" - %s\n", entry.TagsString())
}
}
fmt.Printf("\n")
}
Output: ------------- 2822: Maintainers: InfoSiftr <github@infosiftr.com> (@infosiftr), Johan Euphrosine <proppy@google.com> (@proppy) SharedTags: latest GitRepo: https://github.com/docker-library/golang.git arm64v8-GitRepo: https://github.com/docker-library/golang.git Tags: 1.6.1, 1.6, 1 GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a Directory: 1.6 Constraints: some-random-build-server Tags: 1.5.3, 1.5 SharedTags: 1.5.3-debian, 1.5-debian GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19 Directory: 1.5 i386-GitFetch: refs/heads/i386 ppc64le-Directory: 1.5/ppc64le s390x-GitCommit: b6c460e7cd79b595267870a98013ec3078b490df Tags: 1.5-alpine GitFetch: refs/heads/having-a-good-time GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19 Directory: 1.5 File: Dockerfile.alpine Builder: buildkit s390x-File: Dockerfile.alpine.s390x.bad-boy Tags: raspbian-s390x SharedTags: raspbian Architectures: i386, s390x GitCommit: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef File: Dockerfile-raspbian s390x-File: Dockerfile Shared Tag Groups: - latest - 1.6.1, 1.6, 1 - 1.5-alpine - 1.5.3-debian, 1.5-debian - 1.5.3, 1.5 - raspbian - raspbian-s390x
Index ¶
- Constants
- Variables
- type Manifest2822
- func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error
- func (manifest Manifest2822) GetAllSharedTags() []string
- func (manifest Manifest2822) GetSharedTag(tag string) []*Manifest2822Entry
- func (manifest Manifest2822) GetSharedTagGroups() []SharedTagGroup
- func (manifest Manifest2822) GetTag(tag string) *Manifest2822Entry
- func (manifest Manifest2822) String() string
- type Manifest2822Entry
- func (entry Manifest2822Entry) ArchBuilder(arch string) string
- func (entry Manifest2822Entry) ArchDirectory(arch string) string
- func (entry Manifest2822Entry) ArchFile(arch string) string
- func (entry Manifest2822Entry) ArchGitCommit(arch string) string
- func (entry Manifest2822Entry) ArchGitFetch(arch string) string
- func (entry Manifest2822Entry) ArchGitRepo(arch string) string
- func (entry Manifest2822Entry) ArchitecturesString() string
- func (entry *Manifest2822Entry) CleanDirectoryValues()
- func (entry Manifest2822Entry) ClearDefaults(defaults Manifest2822Entry) Manifest2822Entry
- func (entry Manifest2822Entry) Clone() Manifest2822Entry
- func (entry Manifest2822Entry) ConstraintsString() string
- func (entry *Manifest2822Entry) DeduplicateArchitectures()
- func (entry *Manifest2822Entry) DeduplicateSharedTags()
- func (entry Manifest2822Entry) HasArchitecture(arch string) bool
- func (entry Manifest2822Entry) HasSharedTag(tag string) bool
- func (entry Manifest2822Entry) HasTag(tag string) bool
- func (entry Manifest2822Entry) InvalidArchitectures() []string
- func (entry Manifest2822Entry) InvalidMaintainers() []string
- func (entry Manifest2822Entry) InvalidTags() []string
- func (entry Manifest2822Entry) MaintainersString() string
- func (a Manifest2822Entry) SameBuildArtifacts(b Manifest2822Entry) bool
- func (entry *Manifest2822Entry) SeedArchValues()
- func (entry *Manifest2822Entry) SetGitCommit(arch string, commit string)
- func (entry *Manifest2822Entry) SetGitRepo(arch string, repo string)
- func (entry Manifest2822Entry) SharedTagsString() string
- func (entry Manifest2822Entry) String() string
- func (entry Manifest2822Entry) TagsString() string
- type Manifest2822Maintainer
- type ManifestNotFoundError
- type SharedTagGroup
- type TagNotFoundError
Examples ¶
Constants ¶
const ( MaintainersNameRegex = `[^\s<>()][^<>()]*` MaintainersEmailRegex = `[^\s<>()]+` MaintainersGitHubRegex = `[^\s<>()]+` MaintainersFormat = `Full Name <contact-email-or-url> (@github-handle) OR Full Name (@github-handle)` )
const StringSeparator2822 = ", "
Variables ¶
var ( GitCommitRegex = regexp.MustCompile(`^([0-9a-f]{40}|[0-9a-f]{64})$`) GitFetchRegex = regexp.MustCompile(`^refs/(heads|tags)/[^*?:]+$`) // https://github.com/docker/distribution/blob/v2.7.1/reference/regexp.go#L37 ValidTagRegex = regexp.MustCompile(`^\w[\w.-]{0,127}$`) )
var ( DefaultArchitecture = "amd64" DefaultManifestEntry = Manifest2822Entry{ Architectures: []string{DefaultArchitecture}, GitFetch: "refs/heads/master", Directory: ".", File: "Dockerfile", } )
var (
MaintainersRegex = regexp.MustCompile(`^(` + MaintainersNameRegex + `)(?:\s+<(` + MaintainersEmailRegex + `)>)?\s+[(]@(` + MaintainersGitHubRegex + `)[)]$`)
)
var Parse = Parse2822
Functions ¶
This section is empty.
Types ¶
type Manifest2822 ¶
type Manifest2822 struct {
Global Manifest2822Entry
Entries []Manifest2822Entry
}
func Fetch ¶
func Fetch(library, repo string) (string, string, *Manifest2822, error)
"library" is the default "library directory" returns the parsed version of (in order):
if "repo" is a URL, the remote contents of that URL if "repo" is a relative path like "./repo", that file the file "library/repo"
(repoName, tagName, man, err)
Example (Local) ¶
package main
import (
"fmt"
"github.com/docker-library/bashbrew/manifest"
)
func main() {
repoName, tagName, man, err := manifest.Fetch("testdata", "bash:4.4")
if err != nil {
panic(err)
}
fmt.Printf("%s:%s\n\n", repoName, tagName)
fmt.Println(man.GetTag(tagName).ClearDefaults(manifest.DefaultManifestEntry).String())
}
Output: bash:4.4 Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon) Tags: 4.4.12, 4.4, 4, latest GitRepo: https://github.com/tianon/docker-bash.git GitCommit: 1cbb5cf49b4c53bd5a986abf7a1afeb9a80eac1e Directory: 4.4
Example (Remote) ¶
package main
import (
"fmt"
"github.com/docker-library/bashbrew/manifest"
)
func main() {
repoName, tagName, man, err := manifest.Fetch("/home/jsmith/docker/official-images/library", "https://github.com/docker-library/official-images/raw/1a3c4cd6d5cd53bd538a6f56a69f94c5b35325a7/library/bash:4.4")
if err != nil {
panic(err)
}
fmt.Printf("%s:%s\n\n", repoName, tagName)
fmt.Println(man.GetTag(tagName).ClearDefaults(manifest.DefaultManifestEntry).String())
}
Output: bash:4.4 Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon) Tags: 4.4.12, 4.4, 4, latest GitRepo: https://github.com/tianon/docker-bash.git GitCommit: 1cbb5cf49b4c53bd5a986abf7a1afeb9a80eac1e Directory: 4.4
func (*Manifest2822) AddEntry ¶
func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error
func (Manifest2822) GetAllSharedTags ¶
func (manifest Manifest2822) GetAllSharedTags() []string
GetAllSharedTags returns a list of the sum of all SharedTags in all entries of this image manifest (in the order they appear in the file).
func (Manifest2822) GetSharedTag ¶
func (manifest Manifest2822) GetSharedTag(tag string) []*Manifest2822Entry
GetSharedTag returns a list of entries with the given tag in entry.SharedTags (or the empty list if there are no entries with the given tag).
func (Manifest2822) GetSharedTagGroups ¶
func (manifest Manifest2822) GetSharedTagGroups() []SharedTagGroup
GetSharedTagGroups returns a map of shared tag groups to the list of entries they share (as described in https://github.com/docker-library/go-dockerlibrary/pull/2#issuecomment-277853597).
func (Manifest2822) GetTag ¶
func (manifest Manifest2822) GetTag(tag string) *Manifest2822Entry
func (Manifest2822) String ¶
func (manifest Manifest2822) String() string
type Manifest2822Entry ¶
type Manifest2822Entry struct {
control.Paragraph
Maintainers []Manifest2822Maintainer `delim:"," strip:"\n\r\t "`
Tags []string `delim:"," strip:"\n\r\t "`
Architectures []string `delim:"," strip:"\n\r\t "`
GitRepo string
GitFetch string
GitCommit string
Directory string
File string
Builder string
// architecture-specific versions of the above fields
ArchValues map[string]string
Constraints []string `delim:"," strip:"\n\r\t "`
}
func (Manifest2822Entry) ArchBuilder ¶ added in v0.1.4
func (entry Manifest2822Entry) ArchBuilder(arch string) string
func (Manifest2822Entry) ArchDirectory ¶
func (entry Manifest2822Entry) ArchDirectory(arch string) string
func (Manifest2822Entry) ArchFile ¶
func (entry Manifest2822Entry) ArchFile(arch string) string
func (Manifest2822Entry) ArchGitCommit ¶
func (entry Manifest2822Entry) ArchGitCommit(arch string) string
func (Manifest2822Entry) ArchGitFetch ¶
func (entry Manifest2822Entry) ArchGitFetch(arch string) string
func (Manifest2822Entry) ArchGitRepo ¶
func (entry Manifest2822Entry) ArchGitRepo(arch string) string
func (Manifest2822Entry) ArchitecturesString ¶
func (entry Manifest2822Entry) ArchitecturesString() string
func (*Manifest2822Entry) CleanDirectoryValues ¶
func (entry *Manifest2822Entry) CleanDirectoryValues()
func (Manifest2822Entry) ClearDefaults ¶
func (entry Manifest2822Entry) ClearDefaults(defaults Manifest2822Entry) Manifest2822Entry
returns a new Entry with any of the values that are equal to the values in "defaults" cleared
func (Manifest2822Entry) Clone ¶
func (entry Manifest2822Entry) Clone() Manifest2822Entry
func (Manifest2822Entry) ConstraintsString ¶
func (entry Manifest2822Entry) ConstraintsString() string
func (*Manifest2822Entry) DeduplicateArchitectures ¶
func (entry *Manifest2822Entry) DeduplicateArchitectures()
DeduplicateArchitectures will remove duplicate values from entry.Architectures and sort the result.
func (*Manifest2822Entry) DeduplicateSharedTags ¶
func (entry *Manifest2822Entry) DeduplicateSharedTags()
DeduplicateSharedTags will remove duplicate values from entry.SharedTags, preserving order.
func (Manifest2822Entry) HasArchitecture ¶
func (entry Manifest2822Entry) HasArchitecture(arch string) bool
HasArchitecture returns true if the given architecture exists in entry.Architectures
func (Manifest2822Entry) HasSharedTag ¶
func (entry Manifest2822Entry) HasSharedTag(tag string) bool
HasSharedTag returns true if the given tag exists in entry.SharedTags.
func (Manifest2822Entry) HasTag ¶
func (entry Manifest2822Entry) HasTag(tag string) bool
func (Manifest2822Entry) InvalidArchitectures ¶
func (entry Manifest2822Entry) InvalidArchitectures() []string
func (Manifest2822Entry) InvalidMaintainers ¶
func (entry Manifest2822Entry) InvalidMaintainers() []string
func (Manifest2822Entry) InvalidTags ¶
func (entry Manifest2822Entry) InvalidTags() []string
func (Manifest2822Entry) MaintainersString ¶
func (entry Manifest2822Entry) MaintainersString() string
func (Manifest2822Entry) SameBuildArtifacts ¶
func (a Manifest2822Entry) SameBuildArtifacts(b Manifest2822Entry) bool
if this method returns "true", then a.Tags and b.Tags can safely be combined (for the purposes of building)
func (*Manifest2822Entry) SeedArchValues ¶
func (entry *Manifest2822Entry) SeedArchValues()
func (*Manifest2822Entry) SetGitCommit ¶
func (entry *Manifest2822Entry) SetGitCommit(arch string, commit string)
func (*Manifest2822Entry) SetGitRepo ¶
func (entry *Manifest2822Entry) SetGitRepo(arch string, repo string)
func (Manifest2822Entry) SharedTagsString ¶
func (entry Manifest2822Entry) SharedTagsString() string
func (Manifest2822Entry) String ¶
func (entry Manifest2822Entry) String() string
func (Manifest2822Entry) TagsString ¶
func (entry Manifest2822Entry) TagsString() string
type Manifest2822Maintainer ¶ added in v0.1.2
func (Manifest2822Maintainer) String ¶ added in v0.1.2
func (maint Manifest2822Maintainer) String() string
func (*Manifest2822Maintainer) UnmarshalControl ¶ added in v0.1.2
func (maint *Manifest2822Maintainer) UnmarshalControl(data string) error
type ManifestNotFoundError ¶ added in v0.1.5
func (ManifestNotFoundError) Error ¶ added in v0.1.5
func (err ManifestNotFoundError) Error() string
type SharedTagGroup ¶
type SharedTagGroup struct {
}
type TagNotFoundError ¶ added in v0.1.5
func (TagNotFoundError) Error ¶ added in v0.1.5
func (err TagNotFoundError) Error() string