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

feat: Replace the environment variable with the CLI parameter #18

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions controllers/fatecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"reflect"
"time"

Expand Down Expand Up @@ -49,6 +48,8 @@ const (
fateClusterFinalizer string = "finalizers.app.kubefate.net"
)

var FateOperatorTest bool

// +kubebuilder:rbac:groups=app.kubefate.net,resources=fateclusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=app.kubefate.net,resources=fateclusters/status,verbs=get;update;patch

Expand Down Expand Up @@ -158,7 +159,7 @@ func (r *FateClusterReconciler) Apply(fateclusterCR *appv1beta1.FateCluster, kub
log := r.Log

serviceurl := fmt.Sprintf("%s-kubefate-%s.%s:8080", PREFIX, kubefateCR.Name, kubefateCR.Namespace)
if os.Getenv("FATE_OPERATOR_TEST") == "true" {
if FateOperatorTest {
serviceurl = kubefateCR.Spec.IngressDomain
}
username := r.kubefateConfigValue(kubefateCR, "FATECLOUD_USER_USERNAME")
Expand Down Expand Up @@ -367,7 +368,7 @@ func (r *FateClusterReconciler) deleteExternalResources(fateclusterCR *appv1beta
kubefateCR := &kubefate

serviceurl := fmt.Sprintf("%s-kubefate-%s.%s:8080", PREFIX, kubefateCR.Name, kubefateCR.Namespace)
if os.Getenv("FATE_OPERATOR_TEST") == "true" {
if FateOperatorTest {
serviceurl = kubefateCR.Spec.IngressDomain
}

Expand Down
7 changes: 2 additions & 5 deletions controllers/fatecluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package controllers
import (
"context"
"fmt"
"os"
"time"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -149,8 +148,7 @@ var _ = Describe("FateCluster", func() {
},
}

os.Setenv("FATE_OPERATOR_TEST", "true")
defer os.Unsetenv("FATE_OPERATOR_TEST")
FateOperatorTest = true
// Create FateCluster
Expect(k8sClient.Create(context.Background(), fateCreated)).Should(Succeed())

Expand Down Expand Up @@ -300,8 +298,7 @@ var _ = Describe("FateCluster", func() {
},
}

os.Setenv("FATE_OPERATOR_TEST", "true")
defer os.Unsetenv("FATE_OPERATOR_TEST")
FateOperatorTest = true
// Create FateCluster
Expect(k8sClient.Create(context.Background(), fateCreated)).Should(Succeed())

Expand Down
4 changes: 1 addition & 3 deletions controllers/fatejob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package controllers
import (
"context"
"fmt"
"os"
"time"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -121,8 +120,7 @@ var _ = Describe("FateCluster", func() {
},
}

os.Setenv("FATE_OPERATOR_TEST", "true")
defer os.Unsetenv("FATE_OPERATOR_TEST")
FateOperatorTest = true
// Create FateCluster
Expect(k8sClient.Create(context.Background(), fateCreated)).Should(Succeed())

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func main() {
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&controllers.FateOperatorTest, "fate-operator-test", false, "Use when you need to test a fate-operator.")
flag.Parse()

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
Expand Down