Skip to content

Commit 9e3ad6f

Browse files
committed
Move environment logging into main()
1 parent 8387698 commit 9e3ad6f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ deploy-dev: build-postgres-operator createnamespaces
103103
CRUNCHY_DEBUG=true \
104104
CHECK_FOR_UPGRADES='$(if $(CHECK_FOR_UPGRADES),$(CHECK_FOR_UPGRADES),false)' \
105105
KUBECONFIG=hack/.kube/postgres-operator/pgo \
106+
PGO_NAMESPACE='postgres-operator' \
106107
$(shell $(PGO_KUBE_CLIENT) kustomize ./config/dev | \
107108
sed -ne '/^kind: Deployment/,/^---/ { \
108109
/RELATED_IMAGE_/ { N; s,.*\(RELATED_[^[:space:]]*\).*value:[[:space:]]*\([^[:space:]]*\),\1="\2",; p; }; \
@@ -193,7 +194,7 @@ pgo-base-docker: pgo-base-build
193194
#======== Utility =======
194195
.PHONY: check
195196
check:
196-
PGO_NAMESPACE="postgres-operator" $(GO_TEST) -cover ./...
197+
$(GO_TEST) -cover ./...
197198

198199
# Available versions: curl -s 'https://storage.googleapis.com/kubebuilder-tools/' | grep -o '<Key>[^<]*</Key>'
199200
# - KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true

cmd/postgres-operator/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ limitations under the License.
1616
*/
1717

1818
import (
19-
"context"
2019
"os"
2120
"strings"
2221

@@ -82,7 +81,10 @@ func main() {
8281
mgr, err := runtime.CreateRuntimeManager(os.Getenv("PGO_TARGET_NAMESPACE"), cfg, false)
8382
assertNoError(err)
8483

85-
openshift := isOpenshift(ctx, cfg)
84+
openshift := isOpenshift(cfg)
85+
if openshift {
86+
log.Info("detected OpenShift environment")
87+
}
8688

8789
// add all PostgreSQL Operator controllers to the runtime manager
8890
err = addControllersToManager(mgr, openshift)
@@ -118,9 +120,7 @@ func addControllersToManager(mgr manager.Manager, openshift bool) error {
118120
return r.SetupWithManager(mgr)
119121
}
120122

121-
func isOpenshift(ctx context.Context, cfg *rest.Config) bool {
122-
log := logging.FromContext(ctx)
123-
123+
func isOpenshift(cfg *rest.Config) bool {
124124
const sccGroupName, sccKind = "security.openshift.io", "SecurityContextConstraints"
125125

126126
client, err := discovery.NewDiscoveryClientForConfig(cfg)
@@ -141,7 +141,6 @@ func isOpenshift(ctx context.Context, cfg *rest.Config) bool {
141141
}
142142
for _, r := range resourceList.APIResources {
143143
if r.Kind == sccKind {
144-
log.Info("detected OpenShift environment")
145144
return true
146145
}
147146
}

0 commit comments

Comments
 (0)