Skip to content

Commit 44da110

Browse files
dpeacheyDan Peachey
andauthored
Add preserveNamespace flag to DiscoveryVendorProfile (#352)
Co-authored-by: Dan Peachey <[email protected]>
1 parent 0fa3a5b commit 44da110

11 files changed

+5044
-13
lines changed

apis/inv/v1alpha1/discoveryvendorprofile_helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ func (r *GnmiDiscoveryVendorProfileParameters) GetEncoding() Encoding {
2323
}
2424
return *r.Encoding
2525
}
26+
27+
func (r *GnmiDiscoveryVendorProfileParameters) GetPreserveNamespace() bool {
28+
if r.PreserveNamespace == nil {
29+
return false
30+
}
31+
return *r.PreserveNamespace
32+
}

apis/inv/v1alpha1/discoveryvendorprofile_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ type GnmiDiscoveryVendorProfileParameters struct {
3636
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="encoding is immutable"
3737
// +kubebuilder:validation:Enum=UNKNOWN;JSON;JSON_IETF;PROTO;ASCII;
3838
// +kubebuilder:default:=JSON_IETF
39-
Encoding *Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty" protobuf:"bytes,5,opt,name=encoding,casttype=Encoding"`
39+
Encoding *Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty" protobuf:"bytes,4,opt,name=encoding,casttype=Encoding"`
40+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="preserveNamespace is immutable"
41+
// +kubebuilder:default:=true
42+
PreserveNamespace *bool `json:"preserveNamespace,omitempty" yaml:"preserveNamespace,omitempty" protobuf:"varint,5,opt,name=preserveNamespace"`
4043
}
4144

4245
type DiscoveryPathDefinition struct {

artifacts/inv.sdcio.dev_discoveryvendorprofiles.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ spec:
8383
- path
8484
type: object
8585
type: array
86+
preserveNamespace:
87+
default: true
88+
type: boolean
89+
x-kubernetes-validations:
90+
- message: preserveNamespace is immutable
91+
rule: self == oldSelf
8692
required:
8793
- organization
8894
- paths

crds/inv.sdcio.dev_discoveryvendorprofiles.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ spec:
8383
- path
8484
type: object
8585
type: array
86+
preserveNamespace:
87+
default: true
88+
type: boolean
89+
x-kubernetes-validations:
90+
- message: preserveNamespace is immutable
91+
rule: self == oldSelf
8692
required:
8793
- organization
8894
- paths

example/discoveryvendor-profile/discoveryvendor-profile-arista.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONCE
1+
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONES
22
# These files have 2 purposes
33
# 1. they serve as unit tests
44
# 2. they can be used as discovery rules examples
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONES
2+
# These files have 2 purposes
3+
# 1. they serve as unit tests
4+
# 2. they can be used as discovery rules examples
5+
####### HEADER END #######
6+
apiVersion: inv.sdcio.dev/v1alpha1
7+
kind: DiscoveryVendorProfile
8+
metadata:
9+
name: iosxr.cisco.sdcio.dev
10+
namespace: default
11+
spec:
12+
gnmi:
13+
organization: "Cisco Systems, Inc."
14+
preserveNamespace: false
15+
paths:
16+
- key: version
17+
path: system/state/software-version
18+
regex: ^(\d+\.\d+\.\d+(?:\.\d+[\.\w]*)?)$
19+
- key: platform
20+
path: components/component[name=Rack 0]/state/part-no
21+
- key: hostname
22+
path: system/state/hostname
23+
- key: serialNumber
24+
path: components/component[name=Rack 0]/state/serial-no
25+
- key: macAddress
26+
path: interfaces/interface[name=MgmtEth0/RP0/CPU0/0]/openconfig-if-ethernet:ethernet/state/mac-address

example/discoveryvendor-profile/discoveryvendor-profile-nokia-srlinux.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONCE
1+
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONES
22
# These files have 2 purposes
33
# 1. they serve as unit tests
44
# 2. they can be used as discovery rules examples

example/discoveryvendor-profile/discoveryvendor-profile-nokia-sros.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONCE
1+
# DO NOT UPDATE THESE FILES OR CHANGE THE NAME, RATHER CREATE NEW ONES
22
# These files have 2 purposes
33
# 1. they serve as unit tests
44
# 2. they can be used as discovery rules examples

0 commit comments

Comments
 (0)