Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opts package #1217

Merged
merged 11 commits into from
Aug 22, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
74 changes: 41 additions & 33 deletions cluster-provision/gocli/cmd/nodesconfig/nodeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ package nodesconfig

// NodeLinuxConfig type holds the config params that a node can have for its linux system
type NodeLinuxConfig struct {
NodeIdx int
K8sVersion string
FipsEnabled bool
DockerProxy string
EtcdInMemory bool
EtcdSize string
SingleStack bool
EnableAudit bool
GpuAddress string
Realtime bool
PSA bool
NodeIdx int
K8sVersion string
FipsEnabled bool
DockerProxy string
EtcdInMemory bool
EtcdSize string
SingleStack bool
EnableAudit bool
GpuAddress string
Realtime bool
PSA bool
KsmEnabled bool
SwapEnabled bool
KsmPageCount int
KsmScanInterval int
Swappiness int
UnlimitedSwap bool
SwapSize int
}

// NodeK8sConfig type holds the config k8s options for kubevirt cluster
Expand All @@ -23,32 +30,33 @@ type NodeK8sConfig struct {
Grafana bool
Istio bool
NfsCsi bool
CNAO bool
Multus bool
CDI bool
CDIVersion string
AAQ bool
AAQVersion string
}

func NewNodeK8sConfig(ceph, prometheus, alertmanager, grafana, istio, nfsCsi bool) *NodeK8sConfig {
return &NodeK8sConfig{
Ceph: ceph,
Prometheus: prometheus,
Alertmanager: alertmanager,
Grafana: grafana,
Istio: istio,
NfsCsi: nfsCsi,
func NewNodeK8sConfig(confs []K8sConfigFunc) *NodeK8sConfig {
n := &NodeK8sConfig{}

for _, conf := range confs {
conf(n)
}

return n
}

func NewNodeLinuxConfig(nodeIdx int, k8sVersion, dockerProxy, etcdSize, gpuAddress string,
fipsEnabled, etcdInMemory, singleStack, enableAudit, realtime, psa bool) *NodeLinuxConfig {
return &NodeLinuxConfig{
NodeIdx: nodeIdx,
K8sVersion: k8sVersion,
FipsEnabled: fipsEnabled,
DockerProxy: dockerProxy,
EtcdInMemory: etcdInMemory,
EtcdSize: etcdSize,
SingleStack: singleStack,
EnableAudit: enableAudit,
GpuAddress: gpuAddress,
Realtime: realtime,
PSA: psa,
func NewNodeLinuxConfig(nodeIdx int, k8sVersion string, confs []LinuxConfigFunc) *NodeLinuxConfig {
n := &NodeLinuxConfig{
NodeIdx: nodeIdx,
K8sVersion: k8sVersion,
}

for _, conf := range confs {
conf(n)
}

return n
}
197 changes: 197 additions & 0 deletions cluster-provision/gocli/cmd/nodesconfig/opts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package nodesconfig

type LinuxConfigFunc func(n *NodeLinuxConfig)

type K8sConfigFunc func(n *NodeK8sConfig)

func WithNodeIdx(nodeIdx int) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.NodeIdx = nodeIdx
}
}

func WithK8sVersion(k8sVersion string) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.K8sVersion = k8sVersion
}
}

func WithFipsEnabled(fipsEnabled bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.FipsEnabled = fipsEnabled
}
}

func WithDockerProxy(dockerProxy string) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.DockerProxy = dockerProxy
}
}

func WithEtcdInMemory(etcdInMemory bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.EtcdInMemory = etcdInMemory
}
}

func WithEtcdSize(etcdSize string) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.EtcdSize = etcdSize
}
}

func WithSingleStack(singleStack bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.SingleStack = singleStack
}
}

func WithEnableAudit(enableAudit bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.EnableAudit = enableAudit
}
}

func WithGpuAddress(gpuAddress string) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.GpuAddress = gpuAddress
}
}

func WithRealtime(realtime bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.Realtime = realtime
}
}

func WithPSA(psa bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.PSA = psa
}
}

func WithKsm(ksm bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.KsmEnabled = ksm
}
}

func WithSwap(swap bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.SwapEnabled = swap
}
}

func WithKsmEnabled(ksmEnabled bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.KsmEnabled = ksmEnabled
}
}

func WithSwapEnabled(swapEnabled bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.SwapEnabled = swapEnabled
}
}

func WithKsmPageCount(ksmPageCount int) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.KsmPageCount = ksmPageCount
}
}

func WithKsmScanInterval(ksmScanInterval int) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.KsmScanInterval = ksmScanInterval
}
}

func WithSwapiness(swapiness int) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.Swappiness = swapiness
}
}

func WithUnlimitedSwap(unlimitedSwap bool) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.UnlimitedSwap = unlimitedSwap
}
}

func WithSwapSize(swapSize int) LinuxConfigFunc {
return func(n *NodeLinuxConfig) {
n.SwapSize = swapSize
}
}

func WithCeph(ceph bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Ceph = ceph
}
}

func WithPrometheus(prometheus bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Prometheus = prometheus
}
}

func WithAlertmanager(alertmanager bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Alertmanager = alertmanager
}
}

func WithGrafana(grafana bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Grafana = grafana
}
}

func WithIstio(istio bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Istio = istio
}
}

func WithNfsCsi(nfsCsi bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.NfsCsi = nfsCsi
}
}

func WithCnao(cnao bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.CNAO = cnao
}
}

func WithMultus(multus bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.Multus = multus
}
}

func WithCdi(cdi bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.CDI = cdi
}
}

func WithCdiVersion(cdiVersion string) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.CDIVersion = cdiVersion
}
}

func WithAAQ(aaq bool) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.AAQ = aaq
}
}

func WithAAQVersion(aaqVersion string) K8sConfigFunc {
return func(n *NodeK8sConfig) {
n.AAQVersion = aaqVersion
}
}
Loading