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

Add oci:// prefix

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2022-07-06 19:02:39 +03:00
parent adc7981f22
commit 8049634e4d
13 changed files with 100 additions and 23 deletions

View File

@@ -32,7 +32,7 @@ var pushArtifactCmd = &cobra.Command{
Long: `The push artifact command creates a tarball from the given directory and uploads the artifact to a OCI repository.
The push command uses the credentials from '~/.docker/config.json'.`,
Example: `# Push the local manifests to GHCR
flux push artifact ghcr.io/org/manifests/app:v0.0.1 \
flux push artifact oci://ghcr.io/org/manifests/app:v0.0.1 \
--path="./path/to/local/manifests" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git branch --show-current)/$(git rev-parse HEAD)"
@@ -57,9 +57,9 @@ func init() {
func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("artifact name is required")
return fmt.Errorf("artifact URL is required")
}
url := args[0]
ociURL := args[0]
if pushArtifactArgs.source == "" {
return fmt.Errorf("--source is required")
@@ -73,6 +73,11 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("invalid path %q", pushArtifactArgs.path)
}
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
}
if fs, err := os.Stat(pushArtifactArgs.path); err != nil || !fs.IsDir() {
return fmt.Errorf("invalid path %q", pushArtifactArgs.path)
}