Skip to content

Commit fa342ff

Browse files
fix: set kind runs in container to default (#61)
* fix(accessrequest): using `Cluster` namespace reference * fix: kind runs in container to default * docs(readme): add note for local setup * chore: update .gitignore * feat: release v0.0.9 * docs: revert changes
1 parent 3a1686d commit fa342ff

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ go.work
3030

3131
# VS Code Go debug binaries
3232
bin/debug_bin*
33+
34+
*.env

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ go run ./cmd/cluster-provider-kind/main.go init
5252

5353
4. **Run the operator**:
5454
```shell
55-
go run ./cmd/cluster-provider-kind/main.go run
55+
KIND_ON_LOCAL_HOST=true go run ./cmd/cluster-provider-kind/main.go run
5656
```
5757

58+
> **Note**: When running the operator outside the cluster (locally), you must set the `KIND_ON_LOCAL_HOST` environment variable to `true`. This tells the operator to use the local Docker socket configuration instead of the in-cluster configuration.
59+
5860
## Usage Examples
5961

6062
### Creating a Cluster

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.0.8-dev
1+
v0.0.9

internal/controller/accessrequest_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func (r *AccessRequestReconciler) Reconcile(ctx context.Context, req ctrl.Reques
6767
return ctrl.Result{}, err
6868
}
6969

70-
ar.Status.Phase = clustersv1alpha1.AccessRequestPending
70+
ar.Status.Phase = clustersv1alpha1.AccessRequestPending // TODO: could be removed?! openmcp-operator might set this value as well
7171

7272
defer r.Status().Update(ctx, ar) //nolint:errcheck
7373

7474
if ar.Spec.ClusterRef == nil {
7575
return ctrl.Result{}, fmt.Errorf("AccessRequest %q/%q has no Cluster reference", ar.Namespace, ar.Name)
7676
}
7777

78-
clusterRef := types.NamespacedName{Name: ar.Spec.ClusterRef.Name, Namespace: ar.Namespace}
78+
clusterRef := types.NamespacedName{Name: ar.Spec.ClusterRef.Name, Namespace: ar.Spec.ClusterRef.Namespace}
7979
cluster := &clustersv1alpha1.Cluster{}
8080
if err := r.Get(ctx, clusterRef, cluster); err != nil {
8181
// TODO: report event or status condition?

pkg/kind/provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (p *kindProvider) DeleteCluster(name string) error {
7474

7575
// KubeConfig implements Provider.
7676
func (p *kindProvider) KubeConfig(name string) (string, error) {
77-
kubeconfigStr, err := p.internal.KubeConfig(name, runsInContainer())
77+
kubeconfigStr, err := p.internal.KubeConfig(name, !runsOnLocalHost())
7878
if err != nil {
7979
return "", err
8080
}
@@ -89,9 +89,9 @@ func (p *kindProvider) KubeConfig(name string) (string, error) {
8989
return strings.ReplaceAll(kubeconfigStr, "https://"+containerName, "https://"+containerIP.String()), nil
9090
}
9191

92-
// runsInContainer returns true if the KIND_IN_CONTAINER environment variable is set to "true".
93-
func runsInContainer() bool {
94-
return os.Getenv("KIND_IN_CONTAINER") == "true"
92+
// runsOnLocalHost returns true if the KIND_ON_LOCAL_HOST environment variable is set to "true".
93+
func runsOnLocalHost() bool {
94+
return os.Getenv("KIND_ON_LOCAL_HOST") == "true"
9595
}
9696

9797
func (p *kindProvider) controlPlaneContainer(name string) string {

0 commit comments

Comments
 (0)