1
0
mirror of synced 2026-02-13 13:06:56 +00:00

Allow to pull/push artifacts without TLS

If applied, this commit will introduce a new `--insecure-repository`
flag to the following commands: `push artifacts`, `pull artifact`,
`diff artifact` and `list artifacts`. When used the flag will lead to
the option `crane.Insecure` being passed to the `crane` client allowing
the use of insecure repositories.

Signed-off-by: Matthieu Mottet <m.mottet@outlook.com>
This commit is contained in:
Matthieu Mottet
2025-04-11 17:30:56 +02:00
committed by Matthieu Mottet
parent 7b551b0d35
commit 3f4743037b
4 changed files with 36 additions and 3 deletions

View File

@@ -115,6 +115,7 @@ type pushArtifactFlags struct {
output string
debug bool
reproducible bool
insecure bool
}
var pushArtifactArgs = newPushArtifactFlags()
@@ -137,6 +138,7 @@ func init() {
"the format in which the artifact digest should be printed, can be 'json' or 'yaml'")
pushArtifactCmd.Flags().BoolVarP(&pushArtifactArgs.debug, "debug", "", false, "display logs from underlying library")
pushArtifactCmd.Flags().BoolVar(&pushArtifactArgs.reproducible, "reproducible", false, "ensure reproducible image digests by setting the created timestamp to '1970-01-01T00:00:00Z'")
pushArtifactCmd.Flags().BoolVar(&pushArtifactArgs.insecure, "insecure-registry", false, "allows artifacts to be pushed without TLS")
pushCmd.AddCommand(pushArtifactCmd)
}
@@ -266,6 +268,10 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("pushing artifact to %s", url)
}
if pushArtifactArgs.insecure {
opts = append(opts, crane.Insecure)
}
ociClient := client.NewClient(opts)
digestURL, err := ociClient.Push(ctx, url, path,
client.WithPushMetadata(meta),