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:
committed by
Matthieu Mottet
parent
7b551b0d35
commit
3f4743037b
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user