mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
* Add dry-run flag * No traces on dry run * More refactoring * More updates to support bundle binary * More refactoring changes * Different approach of loading specs from URIs * Self review * More changes after review and testing * fix how we parse oci image uri * Remove unnecessary comment * Add missing file * Fix failing tests * Better error check for no collectors * Add default collectors when parsing support bundle specs * Add missed test fixture * Download specs with correct headers * Fix typo
41 lines
865 B
Go
41 lines
865 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/replicatedhq/troubleshoot/pkg/logger"
|
|
"github.com/replicatedhq/troubleshoot/pkg/oci"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
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",
|
|
PreRun: func(cmd *cobra.Command, args []string) {
|
|
v := viper.GetViper()
|
|
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
|
v.BindPFlags(cmd.Flags())
|
|
|
|
logger.SetupLogger(v)
|
|
},
|
|
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
|
|
},
|
|
}
|
|
|
|
// Initialize klog flags
|
|
logger.InitKlogFlags(cmd)
|
|
|
|
return cmd
|
|
}
|