Skip to content

Commit

Permalink
Move results path to shared constant in plugin package
Browse files Browse the repository at this point in the history
  • Loading branch information
zubron committed Aug 13, 2019
1 parent c9f06cc commit 3a2ea2e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/sonobuoy/app/gen_plugin_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"github.com/heptio/sonobuoy/pkg/errlog"
"github.com/heptio/sonobuoy/pkg/plugin"
"github.com/heptio/sonobuoy/pkg/plugin/manifest"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -32,7 +33,6 @@ import (
const (
defaultPluginName = "plugin"
defaultPluginDriver = "Job"
defaultMountPath = "/tmp/results"
defaultMountName = "results"
defaultMountReadOnly = false
)
Expand Down Expand Up @@ -107,7 +107,7 @@ func defaultManifest() manifest.Manifest {
m.SonobuoyConfig.Driver = defaultPluginDriver
m.Spec.VolumeMounts = []v1.VolumeMount{
v1.VolumeMount{
MountPath: defaultMountPath,
MountPath: plugin.ResultsDir,
Name: defaultMountName,
ReadOnly: defaultMountReadOnly,
},
Expand Down
11 changes: 5 additions & 6 deletions pkg/client/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ import (
)

const (
e2ePluginName = "e2e"
systemdLogsName = "systemd-logs"
pluginResultsDir = "/tmp/results"
e2ePluginName = "e2e"
systemdLogsName = "systemd-logs"
)

// templateValues are used for direct template substitution for manifest generation.
Expand Down Expand Up @@ -257,7 +256,7 @@ func systemdLogsManifest(cfg *GenConfig) *manifest.Manifest {
ImagePullPolicy: corev1.PullPolicy(cfg.ImagePullPolicy),
Env: []corev1.EnvVar{
{Name: "CHROOT_DIR", Value: "/node"},
{Name: "RESULTS_DIR", Value: pluginResultsDir},
{Name: "RESULTS_DIR", Value: plugin.ResultsDir},
{Name: "NODE_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{FieldPath: "spec.nodeName"},
Expand All @@ -271,7 +270,7 @@ func systemdLogsManifest(cfg *GenConfig) *manifest.Manifest {
{
ReadOnly: false,
Name: "results",
MountPath: pluginResultsDir,
MountPath: plugin.ResultsDir,
}, {
ReadOnly: false,
Name: "root",
Expand Down Expand Up @@ -306,7 +305,7 @@ func e2eManifest(cfg *GenConfig) *manifest.Manifest {
{
ReadOnly: false,
Name: "results",
MountPath: pluginResultsDir,
MountPath: plugin.ResultsDir,
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/plugin/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ package plugin
const (
// GracefulShutdownPeriod is how long plugins have to cleanly finish before they are terminated.
GracefulShutdownPeriod = 60

// ResultsDir is the diectory where results will be available in Sonobuoy plugin containers.
ResultsDir = "/tmp/results"
)
9 changes: 3 additions & 6 deletions pkg/plugin/driver/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ import (
"encoding/pem"
"fmt"

"github.com/heptio/sonobuoy/pkg/plugin"
"github.com/heptio/sonobuoy/pkg/plugin/manifest"
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
resultsDir = "/tmp/results"
)

// Base is the struct that stores state for plugin drivers and contains helper methods.
type Base struct {
Definition manifest.Manifest
Expand Down Expand Up @@ -155,7 +152,7 @@ func (b *Base) workerEnvironment(hostname string, cert *tls.Certificate) []v1.En
},
{
Name: "RESULTS_DIR",
Value: resultsDir,
Value: plugin.ResultsDir,
},
{
Name: "RESULT_TYPE",
Expand Down Expand Up @@ -208,7 +205,7 @@ func (b *Base) CreateWorkerContainerDefintion(hostname string, cert *tls.Certifi
{
Name: "results",
ReadOnly: false,
MountPath: resultsDir,
MountPath: plugin.ResultsDir,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/driver/daemonset/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestCreateDaemonSetDefintion(t *testing.T) {
}

if len(daemonSet.Spec.Template.Spec.Volumes) != 4 {
t.Errorf("Expected 2 volumes defined, got %d", len(daemonSet.Spec.Template.Spec.Volumes))
t.Errorf("Expected 4 volumes defined, got %d", len(daemonSet.Spec.Template.Spec.Volumes))
}

pullSecrets := daemonSet.Spec.Template.Spec.ImagePullSecrets
Expand Down
2 changes: 1 addition & 1 deletion pkg/worker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func setConfigDefaults(ac *plugin.WorkerConfig) {
ac.ResultsDir = "/tmp/results"
ac.ResultsDir = plugin.ResultsDir
}

// LoadConfig loads the configuration for the sonobuoy worker from environment
Expand Down

0 comments on commit 3a2ea2e

Please sign in to comment.