Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ help: ## Display this help.
##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
cd details/operator-sdk && $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
cd details/operator-sdk && $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

fmt: ## Run go fmt against code.
go fmt ./...
Expand Down Expand Up @@ -119,17 +119,17 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla
##@ Deployment

install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
cd details/operator-sdk && $(KUSTOMIZE) build config/crd | kubectl apply -f -
$(KUSTOMIZE) build config/crd | kubectl apply -f -

uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
cd details/operator-sdk && $(KUSTOMIZE) build config/crd | kubectl delete -f -
$(KUSTOMIZE) build config/crd | kubectl delete -f -

deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd details/operator-sdk/config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd details/operator-sdk && $(KUSTOMIZE) build config/default | kubectl apply -f -
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
cd details/operator-sdk && $(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build config/default | kubectl delete -f -


CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
Expand Down Expand Up @@ -170,8 +170,8 @@ endef
.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
operator-sdk generate kustomize manifests -q
cd details/operator-sdk/config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd details/operator-sdk && $(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle

.PHONY: opm
Expand Down Expand Up @@ -225,12 +225,12 @@ image-tar:
release: kustomize
rm -rf build
mkdir build
cd details/operator-sdk/config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd details/operator-sdk && $(KUSTOMIZE) build config/default > $(BUILD_DIR)/only_astraconnector_operator.yaml
cat $(MAKEFILE_DIR)/details/operator-sdk/config/samples/neptune.yaml > $(BUILD_DIR)/astraconnector_operator.yaml
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/default > $(BUILD_DIR)/only_astraconnector_operator.yaml
cat $(MAKEFILE_DIR)/config/samples/neptune.yaml > $(BUILD_DIR)/astraconnector_operator.yaml
echo "---" >> $(BUILD_DIR)/astraconnector_operator.yaml
cat $(BUILD_DIR)/only_astraconnector_operator.yaml >> $(BUILD_DIR)/astraconnector_operator.yaml
cp $(MAKEFILE_DIR)/details/operator-sdk/config/samples/astra_v1_astraconnector.yaml $(BUILD_DIR)/astra_v1_astraconnector.yaml
cp $(MAKEFILE_DIR)/config/samples/astra_v1_astraconnector.yaml $(BUILD_DIR)/astra_v1_astraconnector.yaml

.PHONY: generate-mocks
generate-mocks: install-mockery
Expand Down
2 changes: 1 addition & 1 deletion details/operator-sdk/PROJECT → PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resources:
domain: netapp.io
group: astra
kind: AstraConnector
path: github.com/NetApp-Polaris/astra-connector-operator/details/operator-sdk/api/v1
path: github.com/NetApp-Polaris/astra-connector-operator/api/v1
version: v1
webhooks:
defaulting: true
Expand Down
78 changes: 78 additions & 0 deletions api/v1/astraconnector_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2024. NetApp, Inc. All Rights Reserved.
*/

package v1

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

// AstraConnectorSpec defines the desired state of AstraConnector
type AstraConnectorSpec struct {
AccountId string `json:"accountId"`
ApiTokenSecretRef string `json:"apiTokenSecretRef,omitempty"`
AstraControlUrl string `json:"astraControlUrl,omitempty"`
// +kubebuilder:validation:Optional
CloudId string `json:"cloudId"`
// +kubebuilder:validation:Optional
ClusterId string `json:"clusterId"`
// +kubebuilder:validation:Optional
SkipTLSValidation bool `json:"skipTLSValidation,omitempty"`

Image string `json:"image,omitempty"`
// +kubebuilder:validation:Optional
HostAliasIP string `json:"hostAliasIP,omitempty"`
// +kubebuilder:default:=1
Replicas int32 `json:"replicas,omitempty"`

ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"`

// SkipPreCheck determines if you want to skip pre-checks and go ahead with the installation.
// +kubebuilder:default:=false
SkipPreCheck bool `json:"skipPreCheck"`

// Labels any additional labels wanted to be added to resources
Labels map[string]string `json:"labels"`
}

// AstraConnectorStatus defines the observed state of AstraConnector
type AstraConnectorStatus struct {
Version string `json:"version"`
Status string `json:"status"`
}

// +kubebuilder:validation:Optional

type ImageRegistry struct {
Name string `json:"name,omitempty"`
Secret string `json:"secret,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="AstraConnectorVersion",type=string,JSONPath=`.status.version`
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`

// AstraConnector is the Schema for the astraconnectors API
// +kubebuilder:subresource:status
type AstraConnector struct {
metaV1.TypeMeta `json:",inline"`
metaV1.ObjectMeta `json:"metadata,omitempty"`

Spec AstraConnectorSpec `json:"spec,omitempty"`
Status AstraConnectorStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&AstraConnector{}, &AstraConnectorList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
package v1_test

import (
"github.com/NetApp-Polaris/astra-connector-operator/api/v1"
"testing"

"github.com/stretchr/testify/assert"

v1 "github.com/NetApp-Polaris/astra-connector-operator/details/operator-sdk/api/v1"
)

func TestAstraConnector_ValidateCreateAstraConnector(t *testing.T) {
Expand Down
75 changes: 75 additions & 0 deletions api/v1/astraneptune_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2024. NetApp, Inc. All Rights Reserved.
*/

package v1

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

// AutoSupport defines how the customer interacts with NetApp ActiveIQ.
type AutoSupport struct {
// Enrolled determines if you want to send anonymous data to NetApp for support purposes.
// +kubebuilder:default:=true
Enrolled bool `json:"enrolled"`

// URL determines where the anonymous data will be sent
// +kubebuilder:default:="https://stagesupport.netapp.com/put/AsupPut"
URL string `json:"url,omitempty"`
}

// AstraNeptuneSpec defines the desired state of AstraNeptune
type AstraNeptuneSpec struct {
ImageRegistry ImageRegistry `json:"imageRegistry,omitempty"`
Image string `json:"image,omitempty"`

// AutoSupport indicates willingness to participate in NetApp's proactive support application, NetApp Active IQ.
// An internet connection is required (port 442) and all support data is anonymized.
// The default election is true and indicates support data will be sent to NetApp.
// An empty or blank election is the same as a default election.
// Air gapped installations should enter false.
// +kubebuilder:default={"enrolled":true, "url":"https://stagesupport.netapp.com/put/AsupPut"}
AutoSupport AutoSupport `json:"autoSupport"`

// SkipPreCheck determines if you want to skip pre-checks and go ahead with the installation.
// +kubebuilder:default:=false
SkipPreCheck bool `json:"skipPreCheck"`

// Labels any additional labels wanted to be added to resources
Labels map[string]string `json:"labels"`
}

// AstraNeptuneStatus defines the observed state of AstraNeptune
type AstraNeptuneStatus struct {
Version string `json:"version"`
Status string `json:"status"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="AstraNeptuneVersion",type=string,JSONPath=`.status.version`
//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`

// AstraNeptune is the Schema for the astraneptunes API
// +kubebuilder:subresource:status
type AstraNeptune struct {
metaV1.TypeMeta `json:",inline"`
metaV1.ObjectMeta `json:"metadata,omitempty"`

Spec AstraNeptuneSpec `json:"spec,omitempty"`
Status AstraNeptuneStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// AstraNeptuneList contains a list of AstraNeptune
type AstraNeptuneList struct {
metaV1.TypeMeta `json:",inline"`
metaV1.ListMeta `json:"metadata,omitempty"`
Items []AstraConnector `json:"items"`
}

func init() {
SchemeBuilder.Register(&AstraNeptune{}, &AstraNeptuneList{})
}
Loading