go-dockerlibrary: github.com/docker-library/go-dockerlibrary/manifest Index | Examples | Files

package manifest

import "github.com/docker-library/go-dockerlibrary/manifest"

Code:

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)
GitRepo: https://github.com/docker-library/golang.git
GitFetch: refs/heads/master
SharedTags: latest


 # hi


 	 # blasphemer


# Go 1.6
Tags: 1.6.1, 1.6, 1
GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
Directory: 1.6
Constraints: some-random-build-server


# Go 1.5
Tags: 1.5.3
SharedTags: 1.5.3-debian, 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5


Tags: 1.5
SharedTags: 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5


`)))
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")

man, err = manifest.Parse(bufio.NewReader(strings.NewReader(`
# maintainer: InfoSiftr <github@infosiftr.com> (@infosiftr)
# maintainer: John Smith <jsmith@example.com> (@example-jsmith)

# first set
a: b@c d
e: b@c d

 # second set
f: g@h
i: g@h j
`)))
if err != nil {
    panic(err)
}
fmt.Printf("-------------\nline-based:\n%v\n", man)

Output:

-------------
2822:
Maintainers: InfoSiftr <github@infosiftr.com> (@infosiftr), Johan Euphrosine <proppy@google.com> (@proppy)
SharedTags: latest
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: latest, 1.5.3-debian, 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5

Shared Tag Groups:

  - latest
    - 1.6.1, 1.6, 1
    - 1.5.3, 1.5

  - 1.5.3-debian, 1.5-debian
    - 1.5.3, 1.5

-------------
line-based:
Maintainers: InfoSiftr <github@infosiftr.com> (@infosiftr), John Smith <jsmith@example.com> (@example-jsmith)
GitFetch: refs/heads/*

Tags: a, e
GitRepo: b
GitCommit: c
Directory: d

Tags: f
GitRepo: g
GitFetch: refs/tags/h
GitCommit: FETCH_HEAD

Tags: i
GitRepo: g
GitFetch: refs/tags/h
GitCommit: FETCH_HEAD
Directory: j

Index

Examples

Package Files

fetch.go line-based.go parse.go rfc2822.go

Constants

const (
    MaintainersNameRegex   = `[^\s<>()][^<>()]*`
    MaintainersEmailRegex  = `[^\s<>()]+`
    MaintainersGitHubRegex = `[^\s<>()]+`

    MaintainersFormat = `Full Name <contact-email-or-url> (@github-handle) OR Full Name (@github-handle)`
)
const DefaultLineBasedFetch = "refs/heads/*" // backwards compatibility
const StringSeparator2822 = ", "

Variables

var (
    GitCommitRegex = regexp.MustCompile(`^[0-9a-f]{1,40}$`)
    GitFetchRegex  = regexp.MustCompile(`^refs/(heads|tags)/[^*?:]+$`)
)
var DefaultManifestEntry = Manifest2822Entry{
    GitFetch:  "refs/heads/master",
    Directory: ".",
}
var (
    MaintainersRegex = regexp.MustCompile(`^(` + MaintainersNameRegex + `)(?:\s+<(` + MaintainersEmailRegex + `)>)?\s+[(]@(` + MaintainersGitHubRegex + `)[)]$`)
)

func Fetch Uses

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)

Code:

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))

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
GitFetch: refs/heads/master
GitCommit: 1cbb5cf49b4c53bd5a986abf7a1afeb9a80eac1e
Directory: 4.4

Code:

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))

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
GitFetch: refs/heads/master
GitCommit: 1cbb5cf49b4c53bd5a986abf7a1afeb9a80eac1e
Directory: 4.4

type Manifest2822 Uses

type Manifest2822 struct {
    Global  Manifest2822Entry
    Entries []Manifest2822Entry
}

func Parse Uses

func Parse(reader io.Reader) (*Manifest2822, error)

try parsing as a 2822 manifest, but fallback to line-based if that fails

func Parse2822 Uses

func Parse2822(readerIn io.Reader) (*Manifest2822, error)

func ParseLineBased Uses

func ParseLineBased(readerIn io.Reader) (*Manifest2822, error)

func (*Manifest2822) AddEntry Uses

func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error

func (Manifest2822) GetAllSharedTags Uses

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 Uses

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 Uses

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 Uses

func (manifest Manifest2822) GetTag(tag string) *Manifest2822Entry

func (Manifest2822) String Uses

func (manifest Manifest2822) String() string

type Manifest2822Entry Uses

type Manifest2822Entry struct {
    control.Paragraph

    Maintainers []string `delim:"," strip:"\n\r\t "`

    Tags       []string `delim:"," strip:"\n\r\t "`
    SharedTags []string `delim:"," strip:"\n\r\t "`

    GitRepo   string
    GitFetch  string
    GitCommit string
    Directory string

    Constraints []string `delim:"," strip:"\n\r\t "`
}

func ParseLineBasedLine Uses

func ParseLineBasedLine(line string, defaults Manifest2822Entry) (*Manifest2822Entry, error)

TODO write more of a proper parser? (probably not worthwhile given that 2822 is the preferred format)

func (Manifest2822Entry) ClearDefaults Uses

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 Uses

func (entry Manifest2822Entry) Clone() Manifest2822Entry

func (Manifest2822Entry) ConstraintsString Uses

func (entry Manifest2822Entry) ConstraintsString() string

func (*Manifest2822Entry) DeduplicateSharedTags Uses

func (entry *Manifest2822Entry) DeduplicateSharedTags()

DeduplicateSharedTags will remove duplicate values from entry.SharedTags, preserving order.

func (Manifest2822Entry) HasSharedTag Uses

func (entry Manifest2822Entry) HasSharedTag(tag string) bool

HasSharedTag returns true if the given tag exists in entry.SharedTags.

func (Manifest2822Entry) HasTag Uses

func (entry Manifest2822Entry) HasTag(tag string) bool

func (Manifest2822Entry) InvalidMaintainers Uses

func (entry Manifest2822Entry) InvalidMaintainers() []string

func (Manifest2822Entry) MaintainersString Uses

func (entry Manifest2822Entry) MaintainersString() string

func (Manifest2822Entry) SameBuildArtifacts Uses

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) SharedTagsString Uses

func (entry Manifest2822Entry) SharedTagsString() string

func (Manifest2822Entry) String Uses

func (entry Manifest2822Entry) String() string

func (Manifest2822Entry) TagsString Uses

func (entry Manifest2822Entry) TagsString() string

type SharedTagGroup Uses

type SharedTagGroup struct {
    SharedTags []string
    Entries    []*Manifest2822Entry
}

Package manifest imports 12 packages (graph) and is imported by 1 packages. Updated 2017-04-26. Refresh now. Tools for package owners.