Skip to content

Commit

Permalink
feat: add interface groups
Browse files Browse the repository at this point in the history
Change-Id: I84104a062671e2589aa4c9c720dba6d0020ec56e
  • Loading branch information
fionera committed Dec 17, 2023
1 parent 300481f commit c40ffa0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions deploy/single-node/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ _deviceAddressTest: {

// Human-readable interface description to show in the frontend
description: string

// Groups in which this interface should take place
groups: [...string]
}

vlan: [ID=string]: {
Expand Down
1 change: 1 addition & 0 deletions deploy/single-node/k8s/clickhouse/clickhouse.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
interface: [string]: {
id: int
description: string
groups: [...string]
}
vlan: [string]: {
id: int
Expand Down
2 changes: 1 addition & 1 deletion deploy/single-node/k8s/clickhouse/files.cue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ClickHouseInstallation: netmeta: spec: configuration: files: {
// Dictionary for user-defined interface name lookup
_files: InterfaceNames: {
data: strings.Join([ for s in #Config.sampler for i in s.interface {
strings.Join([s.device, "\(i.id)", i.description], "\t")
strings.Join([s.device, "\(i.id)", i.description, "[\(strings.Join([for s in i.groups {"'\(s)'"}], ","))]"], "\t")
}], "\n")

cfg: {
Expand Down
20 changes: 18 additions & 2 deletions deploy/single-node/tests/base.cue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test: "clickhouse: sampler with interface": T={
}

}
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."InterfaceNames.tsv" == "::ffff:100.0.0.1\t858\tTRANSIT-ABC"
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."InterfaceNames.tsv" == "::ffff:100.0.0.1\t858\tTRANSIT-ABC\t[]"
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."SamplerConfig.tsv" == "::ffff:100.0.0.1\tNULL\tNULL\tfalse"
}

Expand All @@ -109,6 +109,22 @@ test: "clickhouse: sampler with desc and interfaces": T={
}
}

asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."InterfaceNames.tsv" == "::ffff:100.0.0.1\t858\tTRANSIT-ABC"
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."InterfaceNames.tsv" == "::ffff:100.0.0.1\t858\tTRANSIT-ABC\t[]"
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."SamplerConfig.tsv" == "::ffff:100.0.0.1\tNULL\tfoo\tfalse"
}


test: "clickhouse: sampler with desc,interfaces,groups": T={
config: {
_requiredDefaults
letsencryptMode: "off"

sampler: "::ffff:100.0.0.1": {
description: "foo"
interface: "858": {description: "TRANSIT-ABC", groups: ["A", "B"]}
}
}

asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."InterfaceNames.tsv" == "::ffff:100.0.0.1\t858\tTRANSIT-ABC\t['A','B']"
asserts: T.out.k8s.ClickHouseInstallation.netmeta.spec.configuration.files."SamplerConfig.tsv" == "::ffff:100.0.0.1\tNULL\tfoo\tfalse"
}

0 comments on commit c40ffa0

Please sign in to comment.