Skip to content

Commit

Permalink
Merge pull request #996 from dmage/local-dev
Browse files Browse the repository at this point in the history
NO-JIRA: Add hack/local-dev.sh
  • Loading branch information
openshift-merge-bot[bot] committed Feb 14, 2024
2 parents 4cd367a + 930f96b commit eec6091
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/cluster-image-registry-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (

const metricsPort = 60000

var filesToWatch []string
var (
kubeconfig string
filesToWatch []string
)

func printVersion() {
klog.Infof("Cluster Image Registry Operator Version: %s", version.Version)
Expand Down Expand Up @@ -64,6 +67,8 @@ func main() {
go metrics.RunServer(metricsPort)
return operator.RunOperator(ctx, cctx.KubeConfig)
},
).WithKubeConfigFile(
kubeconfig, nil,
).WithLeaderElection(
configv1.LeaderElection{},
defaults.ImageRegistryOperatorNamespace,
Expand All @@ -78,6 +83,7 @@ func main() {
},
}

cmd.Flags().StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster")
cmd.Flags().StringArrayVar(&filesToWatch, "files", []string{}, "List of files to watch")

if err := cmd.Execute(); err != nil {
Expand Down
16 changes: 16 additions & 0 deletions hack/local-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -eu
HACKDIR="$(dirname "$0")"
"$HACKDIR/add-cvo-overrides.sh"
oc scale --replicas=0 deploy/cluster-image-registry-operator -n openshift-image-registry
ENV=$(
oc -n openshift-image-registry get deploy cluster-image-registry-operator -o json |
jq -r '
.spec.template.spec.containers[0].env[] |
if .valueFrom.fieldRef.fieldPath == "metadata.namespace" then del(.valueFrom) | .value = "openshift-image-registry"
elif .valueFrom.fieldRef.fieldPath == "metadata.name" then del(.valueFrom) | .value = "cluster-image-registry-operator"
else . end |
"\(.name)=\(.value)"
'
)
"$HACKDIR/build/build.sh"
exec env $ENV "$HACKDIR/../tmp/_output/bin/cluster-image-registry-operator" --kubeconfig="${KUBECONFIG:-$HOME/.kube/config}"

0 comments on commit eec6091

Please sign in to comment.