Skip to content

Commit

Permalink
Update property name to atlasNodeIPAccessStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
r0zbot committed Sep 11, 2023
1 parent 2e9468f commit 4483ec3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/mongodbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type MongoDBClusterSpec struct {
// If this is set, Atlas API will be used instead of the regular mongo auth path.
UseAtlasApi bool `json:"useAtlasApi,omitempty"`

// If this is set, along with useAtlasApi, all the kubernetes nodes on the cluster will be added to the Atlas firewall, using the rke.cattle.io/external-ip annotation.
AllowOnAtlasFirewall bool `json:"allowOnAtlasFirewall,omitempty"`
// If this is set, along with useAtlasApi, all the kubernetes nodes on the cluster will be added to the Atlas firewall. The only available value right now is "rancher-annotation", which uses the rke.cattle.io/external-ip annotation.
AtlasNodeIPAccessStrategy string `json:"atlasNodeIPAccessStrategy,omitempty"`

Check failure on line 53 in api/v1alpha1/mongodbcluster_types.go

View workflow job for this annotation

GitHub Actions / lint

json(camel): got 'atlasNodeIPAccessStrategy' want 'atlasNodeIpAccessStrategy' (tagliatelle)
}

// MongoDBClusterStatus defines the observed state of MongoDBCluster
Expand Down
13 changes: 7 additions & 6 deletions config/crd/bases/airlock.cloud.rocket.chat_mongodbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ spec:
type: object
spec:
properties:
allowOnAtlasFirewall:
description: If this is set, all the kubernetes nodes on the cluster
will be added to the Atlas firewall, using rke.cattle.io/external-ip
annotation.
type: boolean
atlasNodeIPAccessStrategy:
description: If this is set, along with useAtlasApi, all the kubernetes
nodes on the cluster will be added to the Atlas firewall. The only
available value right now is "rancher-annotation", which uses the
rke.cattle.io/external-ip annotation.
type: string
connectionSecret:
description: Secret in which Airlock will look for a ConnectionString
or Atlas credentials, that will be used to connect to the cluster.
Expand Down Expand Up @@ -75,7 +76,7 @@ spec:
type: boolean
userNamePrefix:
description: Append this prefix to all default/generated usernames
for this cluster. Will be overriden if "username" is specified.
for this cluster. Will be overridden if "username" is specified.
type: string
required:
- connectionSecret
Expand Down
4 changes: 2 additions & 2 deletions config/samples/airlock_v1alpha1_mongodbcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ spec:
# Optional. Append this prefix to all default/generated usernames for this cluster. Will be ignored if "username" is already set on the access request.
userNamePrefix: test-use1-

# Optional. If this is set, along with useAtlasApi, all the kubernetes nodes on the cluster will be added to the Atlas firewall, using the rke.cattle.io/external-ip annotation.
allowOnAtlasFirewall: true
# Optional. If this is set, along with useAtlasApi, all the kubernetes nodes on the cluster will be added to the Atlas firewall. The only available value right now is "rancher-annotation", which uses the rke.cattle.io/external-ip annotation.
atlasNodeIPAccessStrategy: rancher-annotation

---
apiVersion: v1
Expand Down
4 changes: 2 additions & 2 deletions controllers/mongodbcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *MongoDBClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

// Add nodes to Atlas firewall
if mongodbClusterCR.Spec.AllowOnAtlasFirewall {
if mongodbClusterCR.Spec.AtlasNodeIPAccessStrategy == "rancher-annotation" {
err = r.reconcileAtlasFirewall(ctx, mongodbClusterCR, secret)
if err != nil {
meta.SetStatusCondition(&mongodbClusterCR.Status.Conditions,
Expand Down Expand Up @@ -231,7 +231,7 @@ func (r *MongoDBClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {

requests := make([]reconcile.Request, 0)
for _, item := range mongodbClusterCR.Items {
if item.Spec.AllowOnAtlasFirewall {
if item.Spec.AtlasNodeIPAccessStrategy != "" {
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: item.GetName(),
Expand Down

0 comments on commit 4483ec3

Please sign in to comment.