Add ability to fetch preflights from OCI registry to standard out (#1117)

* add oci-fetch command
This commit is contained in:
danj-replicated
2023-04-14 00:25:42 +01:00
committed by GitHub
parent f692635054
commit 285631446e
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package cli
import (
"fmt"
"github.com/replicatedhq/troubleshoot/pkg/oci"
"github.com/spf13/cobra"
)
func OciFetchCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "oci-fetch [URI]",
Args: cobra.MinimumNArgs(1),
Short: "Fetch a preflight from an OCI registry and print it to standard out",
RunE: func(cmd *cobra.Command, args []string) error {
uri := args[0]
data, err := oci.PullPreflightFromOCI(uri)
if err != nil {
return err
}
fmt.Println(string(data))
return nil
},
}
return cmd
}

View File

@@ -60,6 +60,7 @@ that a cluster meets the requirements to run an application.`,
cobra.OnInitialize(initConfig)
cmd.AddCommand(VersionCmd())
cmd.AddCommand(OciFetchCmd())
preflight.AddFlags(cmd.PersistentFlags())
k8sutil.AddFlags(cmd.Flags())