Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run tests and generate coverage report
run: make build/cover.out
- name: Archive code coverage results
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v6
with:
name: code-coverage
path: build/cover.out
5 changes: 5 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
# SPDX-License-Identifier: Apache-2.0

[default.extend-words]
Adress = "Adress"
HPE = "HPE"
Reponse = "Reponse"
nd = "nd"

[files]
extend-exclude = [
"go.mod",
"hack/**",
]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ mv "$(1)" "$(1)-$(3)" ;\
} ;\
ln -sf "$(1)-$(3)" "$(1)"
endef

install-goimports: FORCE
@if ! hash goimports 2>/dev/null; then printf "\e[1;36m>> Installing goimports (this may take a while)...\e[0m\n"; go install golang.org/x/tools/cmd/goimports@latest; fi

Expand Down
12 changes: 11 additions & 1 deletion Makefile.maker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ reuse:
SPDX-FileCopyrightText: SAP SE
SPDX-License-Identifier: Apache-2.0

typos:
enabled: true
extendExcludes:
- hack/**
extendWords:
nd: nd
HPE: HPE
Reponse: Reponse # typo in the module
Adress: Adress # typo in the module

verbatim: |
tilt: FORCE helm-build-local-image
tilt up --stream -- --BININFO_VERSION $(BININFO_VERSION) --BININFO_COMMIT_HASH $(BININFO_COMMIT_HASH) --BININFO_BUILD_DATE $(BININFO_BUILD_DATE)
Expand Down Expand Up @@ -333,4 +343,4 @@ verbatim: |
mv "$(1)" "$(1)-$(3)" ;\
} ;\
ln -sf "$(1)-$(3)" "$(1)"
endef
endef
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ resources:
kind: Update
path: https:/github.com/sapcc/argora/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cloud.sap
group: argora
kind: IPPoolImport
path: https:/github.com/sapcc/argora/api/v1alpha1
version: v1alpha1
version: "3"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ credentials:

crd:
enable: true

netboxURL: <netbox-url>
```

**Run on dev cluster**
Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ type ClusterSelector struct {
// +kubebuilder:validation:Optional
Type string `json:"type,omitempty"`
}

type IPPoolSelector struct {
// +kubebuilder:validation:Optional
NamePrefix string `json:"namePrefix,omitempty"`
// +kubebuilder:validation:Optional
Region string `json:"region,omitempty"`
// +kubebuilder:validation:Optional
Role string `json:"role,omitempty"`
// +kubebuilder:validation:Optional
ExcludeMask *int `json:"excludeMask,omitempty"`
}
8 changes: 8 additions & 0 deletions api/v1alpha1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const (
ConditionReasonClusterImportSucceededMessage = "ClusterImport succeeded"
ConditionReasonClusterImportFailed ConditionReason = "ClusterImportFailed"
ConditionReasonClusterImportFailedMessage = "ClusterImport failed"

ConditionReasonIPPoolImportSucceeded ConditionReason = "IPPoolImportSucceeded"
ConditionReasonIPPoolImportSucceededMessage = "IPPoolImport succeeded"
ConditionReasonIPPoolImportFailed ConditionReason = "IPPoolImportFailed"
ConditionReasonIPPoolImportFailedMessage = "IPPoolImport failed"
)

var conditionReasons = map[ConditionReason]conditionMeta{
Expand All @@ -32,6 +37,9 @@ var conditionReasons = map[ConditionReason]conditionMeta{

ConditionReasonClusterImportSucceeded: {Type: ConditionTypeReady, Status: metav1.ConditionTrue, Message: ConditionReasonClusterImportSucceededMessage},
ConditionReasonClusterImportFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonClusterImportFailedMessage},

ConditionReasonIPPoolImportSucceeded: {Type: ConditionTypeReady, Status: metav1.ConditionTrue, Message: ConditionReasonIPPoolImportSucceededMessage},
ConditionReasonIPPoolImportFailed: {Type: ConditionTypeReady, Status: metav1.ConditionFalse, Message: ConditionReasonIPPoolImportFailedMessage},
}

type ReasonWithMessage struct {
Expand Down
48 changes: 48 additions & 0 deletions api/v1alpha1/ippoolimport_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

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

// IPPoolImportSpec defines the desired state of IPPoolImport
type IPPoolImportSpec struct {
IPPools []*IPPoolSelector `json:"ippools,omitempty"`
}

// IPPoolImportStatus defines the observed state of IPPoolImport.
type IPPoolImportStatus struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=Ready;Error
State State `json:"state"`
Conditions *[]metav1.Condition `json:"conditions,omitempty"`
Description string `json:"description,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:JSONPath=".status.state",name="State",type="string"

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

Spec IPPoolImportSpec `json:"spec,omitempty"`
Status IPPoolImportStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&IPPoolImport{}, &IPPoolImportList{})
}
133 changes: 132 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"os"
"time"

ipamv1alpha2 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.

Expand Down Expand Up @@ -82,6 +84,7 @@ func init() {

utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
utilruntime.Must(ipamv1alpha2.AddToScheme(scheme))
utilruntime.Must(metal3v1alpha1.AddToScheme(scheme))
utilruntime.Must(ironcorev1alpha1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
Expand Down Expand Up @@ -187,6 +190,10 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "update")
os.Exit(1)
}
if err = controller.NewIPPoolImportReconciler(mgr, creds, status.NewIPPoolImportStatusHandler(mgr.GetClient()), netbox.NewNetbox(flagVar.netboxURL), flagVar.reconcileInterval).SetupWithManager(mgr, rateLimiter); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "IPPoolImport")
os.Exit(1)
}
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading