Skip to content

Commit

Permalink
IP Access List CRD
Browse files Browse the repository at this point in the history
  • Loading branch information
helderjs committed Jan 13, 2025
1 parent 9b1d710 commit a86a433
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 0 deletions.
13 changes: 13 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: mongodb.com
layout:
- go.kubebuilder.io/v4
Expand Down Expand Up @@ -113,4 +117,13 @@ resources:
kind: AtlasCustomRole
path: github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mongodb.com
group: atlas
kind: AtlasIPAccessList
path: github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1
version: v1
version: "3"
96 changes: 96 additions & 0 deletions api/v1/atlasipaccesslist_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
Copyright 2025 MongoDB.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/status"
)

func init() {
SchemeBuilder.Register(&AtlasIPAccessList{}, &AtlasIPAccessListList{})
}

// AtlasIPAccessListSpec defines the desired state of AtlasIPAccessList.
type AtlasIPAccessListSpec struct {
// ProjectReference is the dual external or kubernetes reference with access credentials
ProjectDualReference `json:",inline"`
// Entry using an IP address in this access list entry.
// +optional
IPAddress string `json:"ipAddress,omitempty"`
// Range of IP addresses in CIDR notation in this access list entry.
// +optional
CIDRBlock string `json:"cidrBlock,omitempty"`
// Unique identifier of AWS security group in this access list entry.
// +optional
AwsSecurityGroup string `json:"awsSecurityGroup,omitempty"`
// Timestamp in ISO 8601 date and time format in UTC after which Atlas deletes the temporary access list entry.
// +optional
DeleteAfterDate *metav1.Time `json:"deleteAfterDate,omitempty"`
// Comment associated with this access list entry.
// +optional
Comment string `json:"comment,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +groupName:=atlas.mongodb.com
// +kubebuilder:resource:categories=atlas,shortName=aial
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`

// AtlasIPAccessList is the Schema for the atlasipaccesslists API.
type AtlasIPAccessList struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AtlasIPAccessListSpec `json:"spec,omitempty"`
Status status.AtlasIPAccessListStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// AtlasIPAccessListList contains a list of AtlasIPAccessList.
type AtlasIPAccessListList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AtlasIPAccessList `json:"items"`
}

func (ial *AtlasIPAccessList) Credentials() *api.LocalObjectReference {
return ial.Spec.ConnectionSecret
}

func (ial *AtlasIPAccessList) ProjectDualRef() *ProjectDualReference {
return &ial.Spec.ProjectDualReference
}

func (ial *AtlasIPAccessList) GetStatus() api.Status {
return ial.Status
}

func (ial *AtlasIPAccessList) UpdateStatus(conditions []api.Condition, options ...api.Option) {
ial.Status.Conditions = conditions
ial.Status.ObservedGeneration = ial.ObjectMeta.Generation

for _, o := range options {
v := o.(status.AtlasIPAccessListStatusOption)
v(&ial.Status)
}
}
32 changes: 32 additions & 0 deletions api/v1/status/atlasipaccesslist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright 2024 MongoDB.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package status

import (
"github.com/mongodb/mongodb-atlas-kubernetes/v2/api"
)

// AtlasIPAccessListStatus is the most recent observed status of the AtlasIPAccessList cluster. Read-only.
type AtlasIPAccessListStatus struct {
api.Common `json:",inline"`
// Status is the state of the ip access list
Status string `json:"status,omitempty"`
}

// +kubebuilder:object:generate=false

type AtlasIPAccessListStatusOption func(s *AtlasIPAccessListStatus)
16 changes: 16 additions & 0 deletions api/v1/status/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a86a433

Please sign in to comment.