Skip to content
4 changes: 4 additions & 0 deletions api/v1/ipaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type IpAddressSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the resource in NetBox.
// Each tag must define exactly one of the `name` or `slug` fields.
Tags []Tag `json:"tags,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
4 changes: 4 additions & 0 deletions api/v1/ipaddressclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ type IpAddressClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the NetBox resource.
// Each tag must define exactly one of the `name` or `slug` fields.
Tags []Tag `json:"tags,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
4 changes: 4 additions & 0 deletions api/v1/iprange_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type IpRangeSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the resource in NetBox.
// Each tag must define exactly one of the `name` or `slug` fields.
Tags []Tag `json:"tags,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
4 changes: 4 additions & 0 deletions api/v1/iprangeclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type IpRangeClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the NetBox resource.
// Each tag must define exactly one of the `name` or `slug` fields.
Tags []Tag `json:"tags,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
7 changes: 7 additions & 0 deletions api/v1/prefix_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ type PrefixSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the resource in NetBox.
// Each tag may contain either the `name` or `slug` field (one of them is required).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's either name or slug we should add a XValidation rule for this. The rule could probably be on the Tag struct.

// Example:
// - name: tag1
// - slug: tag2
Tags []Tag `json:"tags,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
4 changes: 4 additions & 0 deletions api/v1/prefixclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ type PrefixClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// A list of tags that will be assigned to the NetBox resource.
// Each tag must define exactly one of the `name` or `slug` fields.
Tags []Tag `json:"tags,omitempty"`

// Description that should be added to the resource in NetBox
// Field is mutable, not required
Description string `json:"description,omitempty"`
Expand Down
28 changes: 28 additions & 0 deletions api/v1/tag_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2024 Swisscom (Schweiz) AG.

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

// +kubebuilder:validation:XValidation:rule="has(self.name) != has(self.slug)",message="exactly one of name or slug must be specified"
type Tag struct {
// +optional
// Name of the tag
Name string `json:"name,omitempty"`

// +optional
// Slug of the tag
Slug string `json:"slug,omitempty"`
}
45 changes: 45 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.

17 changes: 17 additions & 0 deletions config/crd/bases/netbox.dev_ipaddressclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,23 @@ spec:
recreated in Kubernetes)
Field is mutable, not required
type: boolean
tags:
description: |-
A list of tags that will be assigned to the NetBox resource.
Each tag must define exactly one of the `name` or `slug` fields.
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/netbox.dev_ipaddresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ spec:
recreated in Kubernetes)
Field is mutable, not required
type: boolean
tags:
description: |-
A list of tags that will be assigned to the resource in NetBox.
Each tag must define exactly one of the `name` or `slug` fields.
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/netbox.dev_iprangeclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ spec:
x-kubernetes-validations:
- message: Field 'size' is immutable
rule: self == oldSelf
tags:
description: |-
A list of tags that will be assigned to the NetBox resource.
Each tag must define exactly one of the `name` or `slug` fields.
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/netbox.dev_ipranges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ spec:
x-kubernetes-validations:
- message: Field 'startAddress' is immutable
rule: self == oldSelf
tags:
description: |-
A list of tags that will be assigned to the resource in NetBox.
Each tag must define exactly one of the `name` or `slug` fields.
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/netbox.dev_prefixclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ spec:
x-kubernetes-validations:
- message: Field 'site' is immutable
rule: self == oldSelf
tags:
description: |-
A list of tags that will be assigned to the NetBox resource.
Each tag must define exactly one of the `name` or `slug` fields.
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/netbox.dev_prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ spec:
x-kubernetes-validations:
- message: Field 'site' is required once set
rule: self == oldSelf || self != ''
tags:
description: |-
A list of tags that will be assigned to the resource in NetBox.
Each tag may contain either the `name` or `slug` field (one of them is required).
Example:
- name: tag1
- slug: tag2
items:
properties:
name:
description: Name of the tag
type: string
slug:
description: Slug of the tag
type: string
type: object
x-kubernetes-validations:
- message: exactly one of name or slug must be specified
rule: has(self.name) != has(self.slug)
type: array
tenant:
description: |-
The NetBox Tenant to be assigned to this resource in NetBox. Use the `name` value instead of the `slug` value
Expand Down
2 changes: 2 additions & 0 deletions config/samples/netbox_v1_ipaddress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: host-alpha
ipAddress: "2.0.0.100/32"
2 changes: 2 additions & 0 deletions config/samples/netbox_v1_ipaddressclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: claim-alpha
parentPrefix: "2.0.0.0/16"
2 changes: 2 additions & 0 deletions config/samples/netbox_v1_iprange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: range-alpha
startAddress: "2.0.0.200/32"
endAddress: "2.0.0.202/32"
2 changes: 2 additions & 0 deletions config/samples/netbox_v1_iprangeclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: range-claim-alpha
parentPrefix: "2.0.0.0/16"
size: 3
4 changes: 4 additions & 0 deletions config/samples/netbox_v1_prefix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ spec:
comments: "your comments"
preserveInNetbox: true
prefix: "2.0.0.0/24"
tags:
- name: Alpha
- slug: golf
- name: Bravo
2 changes: 2 additions & 0 deletions config/samples/netbox_v1_prefixclaim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: alpha
parentPrefix: "2.0.0.0/16"
prefixLength: "/28"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: selector-alpha
prefixLength: "/31"
parentPrefixSelector:
tenant: "MY_TENANT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
description: "some description"
comments: "your comments"
preserveInNetbox: true
tags:
- name: selector-bool
prefixLength: "/31"
parentPrefixSelector:
# should return a prefix in 3.0.0.0/24 with the sample data
Expand Down
Loading