Skip to content

Commit 26eab0c

Browse files
synaretephlogistonjohn
authored andcommitted
planner: use 'pl' for Planner variable name
Use 'pl' for Planner variable, and avoid confusion to the naive reader with the (now obsolete) 'sl' name. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 316bab9 commit 26eab0c

File tree

3 files changed

+67
-67
lines changed

3 files changed

+67
-67
lines changed

internal/planner/configuration.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ import (
2222
"github.com/samba-in-kubernetes/samba-operator/internal/smbcc"
2323
)
2424

25-
func (sp *Planner) instanceID() smbcc.Key {
26-
return smbcc.Key(sp.InstanceName())
25+
func (pl *Planner) instanceID() smbcc.Key {
26+
return smbcc.Key(pl.InstanceName())
2727
}
2828

29-
func (sp *Planner) shareName() string {
29+
func (pl *Planner) shareName() string {
3030
// todo: make sure this is smb-conf clean, otherwise we need to
3131
// fix up the name value(s).
32-
if sp.SmbShare.Spec.ShareName != "" {
33-
return sp.SmbShare.Spec.ShareName
32+
if pl.SmbShare.Spec.ShareName != "" {
33+
return pl.SmbShare.Spec.ShareName
3434
}
3535
// It was not named explicitly. Name it after the CR.
3636
// todo: may need massaging too.
37-
return sp.SmbShare.Name
37+
return pl.SmbShare.Name
3838
}
3939

40-
func (sp *Planner) idmapOptions() smbcc.SmbOptions {
41-
if sp.SecurityConfig == nil || len(sp.SecurityConfig.Spec.Domains) == 0 {
40+
func (pl *Planner) idmapOptions() smbcc.SmbOptions {
41+
if pl.SecurityConfig == nil || len(pl.SecurityConfig.Spec.Domains) == 0 {
4242
// default idmap config
4343
return smbcc.SmbOptions{
4444
"idmap config * : backend": "autorid",
@@ -51,7 +51,7 @@ func (sp *Planner) idmapOptions() smbcc.SmbOptions {
5151
o := smbcc.SmbOptions{}
5252
doms := []api.SmbSecurityDomainSpec{}
5353
userDefault := false
54-
for _, d := range sp.SecurityConfig.Spec.Domains {
54+
for _, d := range pl.SecurityConfig.Spec.Domains {
5555
doms = append(doms, d)
5656
if d.Name == "*" {
5757
userDefault = true
@@ -80,61 +80,61 @@ func (sp *Planner) idmapOptions() smbcc.SmbOptions {
8080

8181
// Update the held configuration based on the state of the instance
8282
// configuration.
83-
func (sp *Planner) Update() (changed bool, err error) {
84-
globals, found := sp.ConfigState.Globals[smbcc.Globals]
83+
func (pl *Planner) Update() (changed bool, err error) {
84+
globals, found := pl.ConfigState.Globals[smbcc.Globals]
8585
if !found {
8686
globalOptions := smbcc.NewGlobalOptions()
87-
globalOptions.SmbPort = sp.GlobalConfig.SmbdPort
87+
globalOptions.SmbPort = pl.GlobalConfig.SmbdPort
8888
globals = smbcc.NewGlobals(globalOptions)
89-
sp.ConfigState.Globals[smbcc.Globals] = globals
89+
pl.ConfigState.Globals[smbcc.Globals] = globals
9090
changed = true
9191
}
92-
shareKey := smbcc.Key(sp.shareName())
93-
share, found := sp.ConfigState.Shares[shareKey]
92+
shareKey := smbcc.Key(pl.shareName())
93+
share, found := pl.ConfigState.Shares[shareKey]
9494
if !found {
95-
share = smbcc.NewSimpleShare(sp.Paths().Share())
96-
if !sp.SmbShare.Spec.Browseable {
95+
share = smbcc.NewSimpleShare(pl.Paths().Share())
96+
if !pl.SmbShare.Spec.Browseable {
9797
share.Options[smbcc.BrowseableParam] = smbcc.No
9898
}
99-
if sp.SmbShare.Spec.ReadOnly {
99+
if pl.SmbShare.Spec.ReadOnly {
100100
share.Options[smbcc.ReadOnlyParam] = smbcc.Yes
101101
}
102-
sp.ConfigState.Shares[shareKey] = share
102+
pl.ConfigState.Shares[shareKey] = share
103103
changed = true
104104
}
105-
cfgKey := sp.instanceID()
106-
cfg, found := sp.ConfigState.Configs[cfgKey]
105+
cfgKey := pl.instanceID()
106+
cfg, found := pl.ConfigState.Configs[cfgKey]
107107
if !found || cfg.Shares[0] != shareKey {
108108
cfg = smbcc.ConfigSection{
109109
Shares: []smbcc.Key{shareKey},
110110
Globals: []smbcc.Key{smbcc.Globals},
111-
InstanceName: sp.InstanceName(),
111+
InstanceName: pl.InstanceName(),
112112
}
113-
if sp.SecurityMode() == ADMode {
114-
realmKey := smbcc.Key(sp.Realm())
113+
if pl.SecurityMode() == ADMode {
114+
realmKey := smbcc.Key(pl.Realm())
115115
cfg.Globals = append(cfg.Globals, realmKey)
116116
}
117-
if sp.IsClustered() {
117+
if pl.IsClustered() {
118118
cfg.InstanceFeatures = []smbcc.FeatureFlag{smbcc.CTDB}
119119
}
120-
sp.ConfigState.Configs[cfgKey] = cfg
120+
pl.ConfigState.Configs[cfgKey] = cfg
121121
changed = true
122122
}
123-
if len(sp.ConfigState.Users) == 0 {
124-
sp.ConfigState.Users = smbcc.NewDefaultUsers()
123+
if len(pl.ConfigState.Users) == 0 {
124+
pl.ConfigState.Users = smbcc.NewDefaultUsers()
125125
changed = true
126126
}
127-
if sp.SecurityMode() == ADMode {
128-
realmKey := smbcc.Key(sp.Realm())
129-
_, found := sp.ConfigState.Globals[realmKey]
127+
if pl.SecurityMode() == ADMode {
128+
realmKey := smbcc.Key(pl.Realm())
129+
_, found := pl.ConfigState.Globals[realmKey]
130130
if !found {
131-
opts := sp.idmapOptions()
131+
opts := pl.idmapOptions()
132132
// security mode
133133
opts["security"] = "ads"
134134
// workgroup and realm
135-
opts["workgroup"] = sp.Workgroup()
136-
opts["realm"] = sp.Realm()
137-
sp.ConfigState.Globals[realmKey] = smbcc.GlobalConfig{
135+
opts["workgroup"] = pl.Workgroup()
136+
opts["realm"] = pl.Realm()
137+
pl.ConfigState.Globals[realmKey] = smbcc.GlobalConfig{
138138
Options: opts,
139139
}
140140
changed = true

internal/planner/misc.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ type UserSecuritySource struct {
3232

3333
// UserSecuritySource returns the UserSecuritySource type for the
3434
// particular instance.
35-
func (sp *Planner) UserSecuritySource() UserSecuritySource {
35+
func (pl *Planner) UserSecuritySource() UserSecuritySource {
3636
s := UserSecuritySource{}
37-
if sp.SecurityMode() != UserMode {
37+
if pl.SecurityMode() != UserMode {
3838
return s
3939
}
40-
if sp.SecurityConfig == nil || sp.SecurityConfig.Spec.Users == nil {
40+
if pl.SecurityConfig == nil || pl.SecurityConfig.Spec.Users == nil {
4141
return s
4242
}
4343
s.Configured = true
44-
s.Namespace = sp.SecurityConfig.Namespace
45-
s.Secret = sp.SecurityConfig.Spec.Users.Secret
46-
s.Key = sp.SecurityConfig.Spec.Users.Key
44+
s.Namespace = pl.SecurityConfig.Namespace
45+
s.Secret = pl.SecurityConfig.Spec.Users.Secret
46+
s.Key = pl.SecurityConfig.Spec.Users.Key
4747
return s
4848
}
4949

@@ -63,10 +63,10 @@ const (
6363
)
6464

6565
// DNSRegister returns a DNSRegister type for this instance.
66-
func (sp *Planner) DNSRegister() DNSRegister {
66+
func (pl *Planner) DNSRegister() DNSRegister {
6767
reg := DNSRegisterNever
68-
if sp.SecurityMode() == ADMode && sp.SecurityConfig.Spec.DNS != nil {
69-
reg = DNSRegister(sp.SecurityConfig.Spec.DNS.Register)
68+
if pl.SecurityMode() == ADMode && pl.SecurityConfig.Spec.DNS != nil {
69+
reg = DNSRegister(pl.SecurityConfig.Spec.DNS.Register)
7070
}
7171
switch reg {
7272
// allowed values
@@ -82,27 +82,27 @@ func (sp *Planner) DNSRegister() DNSRegister {
8282

8383
// ServiceType returns the value that should be used for a Service fronting
8484
// the SMB port for this instance.
85-
func (sp *Planner) ServiceType() string {
86-
if sp.CommonConfig != nil && sp.CommonConfig.Spec.Network.Publish == "external" {
85+
func (pl *Planner) ServiceType() string {
86+
if pl.CommonConfig != nil && pl.CommonConfig.Spec.Network.Publish == "external" {
8787
return "LoadBalancer"
8888
}
8989
return "ClusterIP"
9090
}
9191

9292
// SambaContainerDebugLevel returns a string that can be passed to Samba
9393
// tools for debugging.
94-
func (sp *Planner) SambaContainerDebugLevel() string {
95-
return sp.GlobalConfig.SambaDebugLevel
94+
func (pl *Planner) SambaContainerDebugLevel() string {
95+
return pl.GlobalConfig.SambaDebugLevel
9696
}
9797

9898
// MayCluster returns true if the operator is permitted to create clustered
9999
// instances.
100-
func (sp *Planner) MayCluster() bool {
101-
return sp.GlobalConfig.ClusterSupport == "ctdb-is-experimental"
100+
func (pl *Planner) MayCluster() bool {
101+
return pl.GlobalConfig.ClusterSupport == "ctdb-is-experimental"
102102
}
103103

104104
// NodeSpread returns true if pods are required to be spread over multiple
105105
// nodes.
106-
func (sp *Planner) NodeSpread() bool {
107-
return sp.SmbShare.Annotations[nodeSpreadKey] != nodeSpreadDisable
106+
func (pl *Planner) NodeSpread() bool {
107+
return pl.SmbShare.Annotations[nodeSpreadKey] != nodeSpreadDisable
108108
}

internal/planner/properties.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ const (
4141
)
4242

4343
// InstanceName returns the instance's name.
44-
func (sp *Planner) InstanceName() string {
44+
func (pl *Planner) InstanceName() string {
4545
// for now, its the name of the Server Group
46-
return sp.SmbShare.Status.ServerGroup
46+
return pl.SmbShare.Status.ServerGroup
4747
}
4848

4949
// SecurityMode returns the high level security mode to be used.
50-
func (sp *Planner) SecurityMode() SecurityMode {
51-
if sp.SecurityConfig == nil {
50+
func (pl *Planner) SecurityMode() SecurityMode {
51+
if pl.SecurityConfig == nil {
5252
return UserMode
5353
}
54-
m := SecurityMode(sp.SecurityConfig.Spec.Mode)
54+
m := SecurityMode(pl.SecurityConfig.Spec.Mode)
5555
if m != UserMode && m != ADMode {
5656
// this shouldn't normally be possible unless kube validation
5757
// fails or is out of sync.
@@ -61,30 +61,30 @@ func (sp *Planner) SecurityMode() SecurityMode {
6161
}
6262

6363
// Realm returns the name of the realm (domain).
64-
func (sp *Planner) Realm() string {
65-
return strings.ToUpper(sp.SecurityConfig.Spec.Realm)
64+
func (pl *Planner) Realm() string {
65+
return strings.ToUpper(pl.SecurityConfig.Spec.Realm)
6666
}
6767

6868
// Workgroup returns the name of the workgroup. This may be automatically
6969
// derived from the realm.
70-
func (sp *Planner) Workgroup() string {
70+
func (pl *Planner) Workgroup() string {
7171
// todo: this is a big hack. needs thought and cleanup
72-
parts := strings.SplitN(sp.Realm(), ".", 2)
72+
parts := strings.SplitN(pl.Realm(), ".", 2)
7373
return parts[0]
7474
}
7575

7676
// IsClustered returns true if the instance is configured for clustering.
77-
func (sp *Planner) IsClustered() bool {
78-
if sp.SmbShare.Spec.Scaling == nil {
77+
func (pl *Planner) IsClustered() bool {
78+
if pl.SmbShare.Spec.Scaling == nil {
7979
return false
8080
}
81-
return sp.SmbShare.Spec.Scaling.AvailabilityMode == "clustered"
81+
return pl.SmbShare.Spec.Scaling.AvailabilityMode == "clustered"
8282
}
8383

8484
// ClusterSize returns the (minimum) size of the cluster.
85-
func (sp *Planner) ClusterSize() int32 {
86-
if sp.SmbShare.Spec.Scaling == nil {
85+
func (pl *Planner) ClusterSize() int32 {
86+
if pl.SmbShare.Spec.Scaling == nil {
8787
return 1
8888
}
89-
return int32(sp.SmbShare.Spec.Scaling.MinClusterSize)
89+
return int32(pl.SmbShare.Spec.Scaling.MinClusterSize)
9090
}

0 commit comments

Comments
 (0)