From 2a0ee34adb782c6b5f0ff3bcaee1bd430321b1b3 Mon Sep 17 00:00:00 2001 From: Adnan Kobir Date: Wed, 8 Mar 2023 22:06:39 -0500 Subject: [PATCH 1/2] chore: update docs Signed-off-by: Adnan Kobir --- README.md | 20 ++++++++++++++++++++ commands/in.go | 16 ++++++++++++++-- types.go | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index efd17ba..a000309 100644 --- a/README.md +++ b/README.md @@ -446,6 +446,26 @@ Fetches an image at the exact digest specified by the version. needing to download the image you just uploaded. + + repository (Optional) + + Override the repository defined in the source configuration. + Useful when dynamically passing a repo in a job. + + + + insecure (Optional)
Default: false
+ + Allow insecure registry. + + + + tag (Optional) + + Override the tag defined in the source. + Useful when dynamically passing a tag in a job. + + diff --git a/commands/in.go b/commands/in.go index cdf8e8d..44ddc7f 100644 --- a/commands/in.go +++ b/commands/in.go @@ -71,12 +71,24 @@ func (i *In) Execute() error { } } - repo, err := req.Source.NewRepository() + // override source if repository is passed in get param + repo := name.Repository{} + if req.Params.Repository != "" { + repo, err = req.Params.NewRepository() + } else { + repo, err = req.Source.NewRepository() + } if err != nil { return fmt.Errorf("failed to resolve repository: %w", err) } - tag := repo.Tag(req.Version.Tag) + // override source if tag is passed in get param + tag := name.Tag{} + if req.Params.Tag != "" { + tag = repo.Tag(req.Params.Tag.String()) + } else { + tag = repo.Tag(req.Version.Tag) + } if !req.Params.SkipDownload { mirrorSource, hasMirror, err := req.Source.Mirror() diff --git a/types.go b/types.go index 3ff97fd..4ece206 100644 --- a/types.go +++ b/types.go @@ -479,6 +479,9 @@ type MetadataField struct { type GetParams struct { RawFormat string `json:"format"` SkipDownload bool `json:"skip_download"` + Repository string `json:"repository,omitempty"` + Insecure bool `json:"insecure"` + Tag Tag `json:"tag,omitempty"` } func (p GetParams) Format() string { @@ -489,6 +492,18 @@ func (p GetParams) Format() string { return p.RawFormat } +func (p GetParams) NewRepository() (name.Repository, error) { + return name.NewRepository(p.Repository, p.RepositoryOptions()...) +} + +func (p GetParams) RepositoryOptions() []name.Option { + var opts []name.Option + if p.Insecure { + opts = append(opts, name.Insecure) + } + return opts +} + type PutParams struct { // Path to an OCI image tarball to push. Image string `json:"image"` From 5a63038bc3efa4e18c7cf8f81c870bec02e6c4bc Mon Sep 17 00:00:00 2001 From: Adnan Kobir Date: Thu, 9 Mar 2023 06:56:52 -0500 Subject: [PATCH 2/2] chore: clarify usage of param overrides Signed-off-by: Adnan Kobir --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a000309..fd0ff26 100644 --- a/README.md +++ b/README.md @@ -450,7 +450,7 @@ Fetches an image at the exact digest specified by the version. repository (Optional) Override the repository defined in the source configuration. - Useful when dynamically passing a repo in a job. + Useful when dynamically passing a repo in a job. Not intended to be used with `trigger`. @@ -463,7 +463,7 @@ Fetches an image at the exact digest specified by the version. tag (Optional) Override the tag defined in the source. - Useful when dynamically passing a tag in a job. + Useful when dynamically passing a tag in a job. Not intended to be used with `trigger`.