1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Use fluxcd/pkg/oci/client

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2022-08-03 12:55:50 +03:00
parent 08401f62b2
commit 7c7e76f9f0
21 changed files with 88 additions and 972 deletions

View File

@@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/oci"
oci "github.com/fluxcd/pkg/oci/client"
)
var buildArtifactCmd = &cobra.Command{
@@ -59,7 +59,8 @@ func buildArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("building artifact from %s", buildArtifactArgs.path)
if err := oci.Build(buildArtifactArgs.output, buildArtifactArgs.path); err != nil {
ociClient := oci.NewLocalClient()
if err := ociClient.Build(buildArtifactArgs.output, buildArtifactArgs.path); err != nil {
return fmt.Errorf("bulding artifact failed, error: %w", err)
}

View File

@@ -19,9 +19,12 @@ package main
import (
"context"
"fmt"
"github.com/fluxcd/flux2/internal/oci"
"github.com/fluxcd/flux2/pkg/printers"
"github.com/spf13/cobra"
oci "github.com/fluxcd/pkg/oci/client"
"github.com/fluxcd/flux2/pkg/printers"
)
var listArtifactsCmd = &cobra.Command{
@@ -48,12 +51,13 @@ func listArtifactsCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
ociClient := oci.NewLocalClient()
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
}
metas, err := oci.List(ctx, url)
metas, err := ociClient.List(ctx, url)
if err != nil {
return err
}
@@ -69,5 +73,4 @@ func listArtifactsCmdRun(cmd *cobra.Command, args []string) error {
}
return nil
}

View File

@@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/oci"
oci "github.com/fluxcd/pkg/oci/client"
)
var pullArtifactCmd = &cobra.Command{
@@ -62,6 +62,7 @@ func pullArtifactCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("invalid output path %s", pullArtifactArgs.output)
}
ociClient := oci.NewLocalClient()
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
@@ -72,7 +73,7 @@ func pullArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("pulling artifact from %s", url)
meta, err := oci.Pull(ctx, url, pullArtifactArgs.output)
meta, err := ociClient.Pull(ctx, url, pullArtifactArgs.output)
if err != nil {
return err
}

View File

@@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/oci"
oci "github.com/fluxcd/pkg/oci/client"
)
var pushArtifactCmd = &cobra.Command{
@@ -73,6 +73,7 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("invalid path %q", pushArtifactArgs.path)
}
ociClient := oci.NewLocalClient()
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
@@ -92,7 +93,7 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("pushing artifact to %s", url)
digest, err := oci.Push(ctx, url, pushArtifactArgs.path, meta)
digest, err := ociClient.Push(ctx, url, pushArtifactArgs.path, meta)
if err != nil {
return fmt.Errorf("pushing artifact failed: %w", err)
}

View File

@@ -19,8 +19,10 @@ package main
import (
"context"
"fmt"
"github.com/fluxcd/flux2/internal/oci"
"github.com/spf13/cobra"
oci "github.com/fluxcd/pkg/oci/client"
)
var tagArtifactCmd = &cobra.Command{
@@ -55,6 +57,7 @@ func tagArtifactCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("--tag is required")
}
ociClient := oci.NewLocalClient()
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
@@ -66,7 +69,7 @@ func tagArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("tagging artifact")
for _, tag := range tagArtifactArgs.tags {
img, err := oci.Tag(ctx, url, tag)
img, err := ociClient.Tag(ctx, url, tag)
if err != nil {
return fmt.Errorf("tagging artifact failed: %w", err)
}