Skip to content

Commit

Permalink
use getter method for namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
xu zhao committed Jan 8, 2019
1 parent 39d0987 commit 18f067f
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 87 deletions.
4 changes: 2 additions & 2 deletions cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func main() {
stopCh := signals.SetupSignalHandler()

// Open a websocket connection to the autoscaler
autoscalerEndpoint := fmt.Sprintf("ws://%s.%s.svc.cluster.local:%s", "autoscaler", system.Namespace, "8080")
autoscalerEndpoint := fmt.Sprintf("ws://%s.%s.svc.cluster.local:%s", "autoscaler", system.Namespace(), "8080")
logger.Infof("Connecting to autoscaler at %s", autoscalerEndpoint)
statSink = websocket.NewDurableSendingConnection(autoscalerEndpoint)
go statReporter(stopCh)
Expand All @@ -168,7 +168,7 @@ func main() {
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())
configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, component))
// Watch the observability config map and dynamically update metrics exporter.
configMapWatcher.Watch(metrics.ObservabilityConfigName, metrics.UpdateExporterFromConfigMap(component, logger))
Expand Down
2 changes: 1 addition & 1 deletion cmd/autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func main() {
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClientSet, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClientSet, system.Namespace())
configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, component))
// Watch the observability config map and dynamically update metrics exporter.
configMapWatcher.Watch(metrics.ObservabilityConfigName, metrics.UpdateExporterFromConfigMap(component, logger))
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func main() {
logger.Fatalf("Error building caching clientset: %v", err)
}

configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())

opt := reconciler.Options{
KubeClientSet: kubeClient,
Expand Down
2 changes: 1 addition & 1 deletion cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func main() {
}()

// Open a websocket connection to the autoscaler
autoscalerEndpoint := fmt.Sprintf("ws://%s.%s:%d", servingAutoscaler, system.Namespace, servingAutoscalerPort)
autoscalerEndpoint := fmt.Sprintf("ws://%s.%s:%d", servingAutoscaler, system.Namespace(), servingAutoscalerPort)
logger.Infof("Connecting to autoscaler at %s", autoscalerEndpoint)
statSink = websocket.NewDurableSendingConnection(autoscalerEndpoint)
go statReporter()
Expand Down
4 changes: 2 additions & 2 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())
configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, component))
if err = configMapWatcher.Start(stopCh); err != nil {
logger.Fatalf("failed to start configuration manager: %v", err)
Expand All @@ -79,7 +79,7 @@ func main() {
options := webhook.ControllerOptions{
ServiceName: "webhook",
DeploymentName: "webhook",
Namespace: system.Namespace,
Namespace: system.Namespace(),
Port: 443,
SecretName: "webhook-certs",
WebhookName: "webhook.serving.knative.dev",
Expand Down
12 changes: 6 additions & 6 deletions pkg/logging/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestNewLogger(t *testing.T) {
func TestNewConfigNoEntry(t *testing.T) {
c, err := NewConfigFromConfigMap(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
})
Expand All @@ -139,7 +139,7 @@ func TestNewConfig(t *testing.T) {
wantLevel := zapcore.InfoLevel
c, err := NewConfigFromConfigMap(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
Data: map[string]string{
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestNewLoggerFromConfig(t *testing.T) {
func TestEmptyLevel(t *testing.T) {
c, err := NewConfigFromConfigMap(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
Data: map[string]string{
Expand All @@ -207,7 +207,7 @@ func TestInvalidLevel(t *testing.T) {
wantCfg := "{\"level\": \"error\",\n\"outputPaths\": [\"stdout\"],\n\"errorOutputPaths\": [\"stderr\"],\n\"encoding\": \"json\"}"
_, err := NewConfigFromConfigMap(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
Data: map[string]string{
Expand All @@ -225,7 +225,7 @@ func getTestConfig() (*logging.Config, string, string) {
wantLevel := "debug"
c, _ := NewConfigFromConfigMap(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
Data: map[string]string{
Expand All @@ -245,7 +245,7 @@ func TestUpdateLevelFromConfigMap(t *testing.T) {

cm := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: "config-logging",
},
Data: map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/v1alpha1/autoscaling/kpa/kpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
func newConfigWatcher() configmap.Watcher {
return configmap.NewStaticWatcher(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: autoscaler.ConfigName,
},
Data: configMapData,
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/v1alpha1/clusteringress/clusteringress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestReconcile(t *testing.T) {
&v1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
Name: "reconcile-virtualservice",
Namespace: system.Namespace,
Namespace: system.Namespace(),
Labels: map[string]string{
networking.IngressLabelKey: "reconcile-virtualservice",
serving.RouteLabelKey: "test-route",
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestReconcile(t *testing.T) {
}},
WantEvents: []string{
Eventf(corev1.EventTypeNormal, "Updated", "Updated status for VirtualService %q/%q",
system.Namespace, "reconcile-virtualservice"),
system.Namespace(), "reconcile-virtualservice"),
},
Key: "reconcile-virtualservice",
}}
Expand Down Expand Up @@ -286,7 +286,7 @@ func newTestSetup(t *testing.T, configs ...*corev1.ConfigMap) (
{
ObjectMeta: metav1.ObjectMeta{
Name: config.IstioConfigName,
Namespace: system.Namespace,
Namespace: system.Namespace(),
},
Data: originGateways,
},
Expand All @@ -295,7 +295,7 @@ func newTestSetup(t *testing.T, configs ...*corev1.ConfigMap) (
cms = append(cms, cm)
}

configMapWatcher = &configmap.ManualWatcher{Namespace: system.Namespace}
configMapWatcher = &configmap.ManualWatcher{Namespace: system.Namespace()}
sharedClient = fakesharedclientset.NewSimpleClientset()
servingClient = fakeclientset.NewSimpleClientset()

Expand Down Expand Up @@ -389,7 +389,7 @@ func TestGlobalResyncOnUpdateGatewayConfigMap(t *testing.T) {
domainConfig := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: config.IstioConfigName,
Namespace: system.Namespace,
Namespace: system.Namespace(),
},
Data: newGateways,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/v1alpha1/clusteringress/config/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGatewayConfiguration(t *testing.T) {
wantIstio: (*Istio)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: IstioConfigName,
},
}}, {
Expand All @@ -56,7 +56,7 @@ func TestGatewayConfiguration(t *testing.T) {
wantIstio: (*Istio)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: IstioConfigName,
},
Data: map[string]string{
Expand All @@ -74,7 +74,7 @@ func TestGatewayConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: IstioConfigName,
},
Data: map[string]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// K8sGatewayFullname is the fully-qualified name of Knative shared gateway.
var K8sGatewayFullname = reconciler.GetK8sServiceFullname(
"knative-shared-gateway",
system.Namespace)
system.Namespace())

// VirtualService returns the name of the VirtualService child resource for given ClusterIngress.
func VirtualService(i *v1alpha1.ClusterIngress) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func MakeVirtualService(ci *v1alpha1.ClusterIngress, gateways []string) *v1alpha
vs := &v1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
Name: names.VirtualService(ci),
Namespace: system.Namespace,
Namespace: system.Namespace(),
OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(ci)},
Annotations: ci.ObjectMeta.Annotations,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestMakeVirtualServiceSpec_CorrectMetadata(t *testing.T) {
}
expected := metav1.ObjectMeta{
Name: "test-ingress",
Namespace: system.Namespace,
Namespace: system.Namespace(),
Labels: map[string]string{
networking.IngressLabelKey: "test-ingress",
serving.RouteLabelKey: "test-route",
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/v1alpha1/configuration/queueing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func newTestController(t *testing.T, servingObjects ...runtime.Object) (
configMapWatcher := configmap.NewStaticWatcher(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: gc.ConfigName,
Namespace: system.Namespace,
Namespace: system.Namespace(),
},
Data: map[string]string{},
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/v1alpha1/revision/config/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestControllerConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: ControllerConfigName,
},
Data: map[string]string{
Expand All @@ -74,7 +74,7 @@ func TestControllerConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: ControllerConfigName,
},
Data: map[string]string{
Expand All @@ -88,7 +88,7 @@ func TestControllerConfiguration(t *testing.T) {
wantController: (*Controller)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: ControllerConfigName,
},
Data: map[string]string{},
Expand Down
28 changes: 14 additions & 14 deletions pkg/reconciler/v1alpha1/revision/config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: &Network{},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
}}, {
Expand All @@ -56,7 +56,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -68,7 +68,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: &Network{},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -80,7 +80,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -92,7 +92,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -104,7 +104,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -116,7 +116,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -128,7 +128,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: (*Network)(nil),
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -140,7 +140,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: &Network{},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -152,7 +152,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: &Network{},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -164,7 +164,7 @@ func TestNetworkConfiguration(t *testing.T) {
wantController: &Network{},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -178,7 +178,7 @@ func TestNetworkConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -192,7 +192,7 @@ func TestNetworkConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand All @@ -206,7 +206,7 @@ func TestNetworkConfiguration(t *testing.T) {
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: NetworkConfigName,
},
Data: map[string]string{
Expand Down
Loading

0 comments on commit 18f067f

Please sign in to comment.