Skip to content

Commit 4f92ca6

Browse files
committed
Use Namespace() method from kutil.
1 parent 78f1e7f commit 4f92ca6

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

schedule.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/appscode/go/log"
10+
"github.com/appscode/kutil"
1011
scs "github.com/appscode/stash/client/typed/stash/v1alpha1"
1112
"github.com/appscode/stash/pkg/scheduler"
1213
"github.com/appscode/stash/pkg/util"
@@ -23,7 +24,7 @@ func NewCmdSchedule() *cobra.Command {
2324
kubeconfigPath string
2425
workload string
2526
opt scheduler.Options = scheduler.Options{
26-
Namespace: namespace(),
27+
Namespace: kutil.Namespace(),
2728
ResticName: "",
2829
ScratchDir: "/tmp",
2930
PushgatewayURL: "http://stash-operator.kube-system.svc:56789",
@@ -136,15 +137,3 @@ func NewCmdSchedule() *cobra.Command {
136137

137138
return cmd
138139
}
139-
140-
func namespace() string {
141-
if ns := os.Getenv("OPERATOR_NAMESPACE"); ns != "" {
142-
return ns
143-
}
144-
if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
145-
if ns := strings.TrimSpace(string(data)); len(ns) > 0 {
146-
return ns
147-
}
148-
}
149-
return metav1.NamespaceDefault
150-
}

0 commit comments

Comments
 (0)