Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip requirement of kubeconfig for e2e & gen #438

Merged
merged 2 commits into from
Jun 8, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Skip requirement of kubeconfig for e2e & gen
Earlier `kubeconfig` was needed to use the sub-commands `e2e` and `gen`
which is unnecessary since using these sub-commands does not require
communication to Kubernetes server.

This commit removes that necessity.

Signed-off-by: Suraj Deshmukh <surajd.service@gmail.com>
  • Loading branch information
surajssd committed Jun 6, 2018
commit 674e53c55e5142c64440f97f41047dfc0b563205
15 changes: 8 additions & 7 deletions cmd/sonobuoy/app/e2e.go
Original file line number Diff line number Diff line change
@@ -75,12 +75,10 @@ func e2es(cmd *cobra.Command, args []string) {
os.Exit(1)
}
defer gzr.Close()
restConfig, err := e2eflags.kubecfg.Get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a slightly deeper change than I originally expected. Since e2e does many things (oops) it will need the config later on. Would you be able to move this down below if !e2eflags.rerun { this line?

There is a flag, which needs rethinking, --rerun which allows users to rerun the failed tests if an error is detected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, rather than moving it down I have added a check.

Moving down was causing the initiation of client twice, so added a check rather.

if err != nil {
errlog.LogError(errors.Wrap(err, "couldn't get REST client"))
os.Exit(1)
}
sonobuoy, err := client.NewSonobuoyClient(restConfig)

// Passing in `nil` and no `kubeconfig` because it is not required by the method
// for generating any manifests
sonobuoy, err := client.NewSonobuoyClient(nil)
if err != nil {
errlog.LogError(errors.Wrap(err, "could not create sonobuoy client"))
os.Exit(1)
@@ -105,7 +103,10 @@ func e2es(cmd *cobra.Command, args []string) {
}

if !e2eflags.skipPreflight {
if errs := sonobuoy.PreflightChecks(&client.PreflightConfig{e2eflags.namespace}); len(errs) > 0 {
errs := sonobuoy.PreflightChecks(&client.PreflightConfig{
Namespace: e2eflags.namespace,
})
if len(errs) > 0 {
errlog.LogError(errors.New("Preflight checks failed"))
for _, err := range errs {
errlog.LogError(err)
9 changes: 3 additions & 6 deletions cmd/sonobuoy/app/gen.go
Original file line number Diff line number Diff line change
@@ -95,12 +95,9 @@ func genManifest(cmd *cobra.Command, args []string) {
errlog.LogError(err)
os.Exit(1)
}
kubeCfg, err := genflags.kubecfg.Get()
if err != nil {
errlog.LogError(errors.Wrap(err, "couldn't get kubernetes config"))
os.Exit(1)
}
sbc, err := client.NewSonobuoyClient(kubeCfg)
// Passing in `nil` and no `kubeconfig` because it is not required by the method
// for generating any manifests
sbc, err := client.NewSonobuoyClient(nil)
if err != nil {
errlog.LogError(errors.Wrap(err, "could not create sonobuoy client"))
os.Exit(1)
2 changes: 1 addition & 1 deletion pkg/client/e2e.go
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ import (
)

// GetTests extracts the junit results from a sonobuoy archive and returns the requested tests.
func (c *SonobuoyClient) GetTests(reader io.Reader, show string) ([]reporters.JUnitTestCase, error) {
func (*SonobuoyClient) GetTests(reader io.Reader, show string) ([]reporters.JUnitTestCase, error) {
read := results.NewReaderWithVersion(reader, "irrelevant")
junitResults := reporters.JUnitTestSuite{}
err := read.WalkFiles(func(path string, info os.FileInfo, err error) error {
2 changes: 1 addition & 1 deletion pkg/client/gen.go
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ type templateValues struct {
}

// GenerateManifest fills in a template with a Sonobuoy config
func (c *SonobuoyClient) GenerateManifest(cfg *GenConfig) ([]byte, error) {
func (*SonobuoyClient) GenerateManifest(cfg *GenConfig) ([]byte, error) {
marshalledConfig, err := json.Marshal(cfg.Config)
if err != nil {
return nil, errors.Wrap(err, "couldn't marshall selector")