-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from replicatedhq/collector-job
Run cluster-info in a collector pod
- Loading branch information
Showing
41 changed files
with
1,671 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ bin | |
*.swp | ||
*.swo | ||
*~ | ||
|
||
dist |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cli | ||
|
||
import ( | ||
"io/ioutil" | ||
|
||
"github.com/replicatedhq/troubleshoot/pkg/collect" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func Run() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "run", | ||
Short: "run a single collector", | ||
Long: `...`, | ||
PreRun: func(cmd *cobra.Command, args []string) { | ||
viper.BindPFlag("collector", cmd.Flags().Lookup("collector")) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
v := viper.GetViper() | ||
|
||
specContents, err := ioutil.ReadFile(v.GetString("collector")) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
collector := collect.Collector{ | ||
Spec: string(specContents), | ||
} | ||
if err := collector.RunCollectorSync(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().String("collector", "", "path to a single collector spec to collect") | ||
|
||
cmd.MarkFlagRequired("collector") | ||
|
||
viper.BindPFlags(cmd.Flags()) | ||
|
||
return cmd | ||
} |
21 changes: 18 additions & 3 deletions
21
cmd/collector/cli/collect.go → cmd/collector/cli/server.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func RootCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "troubleshoot", | ||
Short: "Generate and manage support bundles", | ||
Long: `A support bundle is an archive of files, output, metrics and state | ||
from a server that can be used to assist when troubleshooting a server.`, | ||
SilenceUsage: true, | ||
} | ||
|
||
cobra.OnInitialize(initConfig) | ||
|
||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) | ||
return cmd | ||
} | ||
|
||
func InitAndExecute() { | ||
if err := RootCmd().Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func initConfig() { | ||
viper.SetEnvPrefix("TROUBLESHOOT") | ||
viper.AutomaticEnv() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/replicatedhq/troubleshoot/cmd/preflight/cli" | ||
|
||
func main() { | ||
cli.InitAndExecute() | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.