Skip to content

Commit 2856314

Browse files
Add ability to fetch preflights from OCI registry to standard out (#1117)
* add oci-fetch command
1 parent f692635 commit 2856314

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

cmd/preflight/cli/oci_fetch.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cli
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/replicatedhq/troubleshoot/pkg/oci"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
func OciFetchCmd() *cobra.Command {
11+
cmd := &cobra.Command{
12+
Use: "oci-fetch [URI]",
13+
Args: cobra.MinimumNArgs(1),
14+
Short: "Fetch a preflight from an OCI registry and print it to standard out",
15+
RunE: func(cmd *cobra.Command, args []string) error {
16+
uri := args[0]
17+
data, err := oci.PullPreflightFromOCI(uri)
18+
if err != nil {
19+
return err
20+
}
21+
fmt.Println(string(data))
22+
return nil
23+
},
24+
}
25+
return cmd
26+
}

cmd/preflight/cli/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ that a cluster meets the requirements to run an application.`,
6060
cobra.OnInitialize(initConfig)
6161

6262
cmd.AddCommand(VersionCmd())
63+
cmd.AddCommand(OciFetchCmd())
6364
preflight.AddFlags(cmd.PersistentFlags())
6465

6566
k8sutil.AddFlags(cmd.Flags())

0 commit comments

Comments
 (0)