Skip to content

Commit

Permalink
Add eks/v1beta2.ExternalNameIfClusterActive value extractor
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed May 30, 2024
1 parent a1860b9 commit 64700dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis/eks/v1beta1/reference.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: CC0-1.0

package v1beta1

import (
Expand Down
26 changes: 26 additions & 0 deletions apis/eks/v1beta2/reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: CC0-1.0

package v1beta2

import (
"github.com/crossplane/crossplane-runtime/pkg/reference"
xpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
"k8s.io/utils/ptr"
)

// ExternalNameIfClusterActive returns the external name only if the EKS cluster
// is in ACTIVE state.
func ExternalNameIfClusterActive() reference.ExtractValueFn {
return func(mr xpresource.Managed) string {
cl, ok := mr.(*Cluster)
if !ok {
return ""
}
if ptr.Deref(cl.Status.AtProvider.Status, "") != "ACTIVE" {
return ""
}
return reference.ExternalName()(mr)
}
}

0 comments on commit 64700dc

Please sign in to comment.