@@ -22,23 +22,23 @@ import (
22
22
"github.com/samba-in-kubernetes/samba-operator/internal/smbcc"
23
23
)
24
24
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 ())
27
27
}
28
28
29
- func (sp * Planner ) shareName () string {
29
+ func (pl * Planner ) shareName () string {
30
30
// todo: make sure this is smb-conf clean, otherwise we need to
31
31
// 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
34
34
}
35
35
// It was not named explicitly. Name it after the CR.
36
36
// todo: may need massaging too.
37
- return sp .SmbShare .Name
37
+ return pl .SmbShare .Name
38
38
}
39
39
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 {
42
42
// default idmap config
43
43
return smbcc.SmbOptions {
44
44
"idmap config * : backend" : "autorid" ,
@@ -51,7 +51,7 @@ func (sp *Planner) idmapOptions() smbcc.SmbOptions {
51
51
o := smbcc.SmbOptions {}
52
52
doms := []api.SmbSecurityDomainSpec {}
53
53
userDefault := false
54
- for _ , d := range sp .SecurityConfig .Spec .Domains {
54
+ for _ , d := range pl .SecurityConfig .Spec .Domains {
55
55
doms = append (doms , d )
56
56
if d .Name == "*" {
57
57
userDefault = true
@@ -80,61 +80,61 @@ func (sp *Planner) idmapOptions() smbcc.SmbOptions {
80
80
81
81
// Update the held configuration based on the state of the instance
82
82
// 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 ]
85
85
if ! found {
86
86
globalOptions := smbcc .NewGlobalOptions ()
87
- globalOptions .SmbPort = sp .GlobalConfig .SmbdPort
87
+ globalOptions .SmbPort = pl .GlobalConfig .SmbdPort
88
88
globals = smbcc .NewGlobals (globalOptions )
89
- sp .ConfigState .Globals [smbcc .Globals ] = globals
89
+ pl .ConfigState .Globals [smbcc .Globals ] = globals
90
90
changed = true
91
91
}
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 ]
94
94
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 {
97
97
share .Options [smbcc .BrowseableParam ] = smbcc .No
98
98
}
99
- if sp .SmbShare .Spec .ReadOnly {
99
+ if pl .SmbShare .Spec .ReadOnly {
100
100
share .Options [smbcc .ReadOnlyParam ] = smbcc .Yes
101
101
}
102
- sp .ConfigState .Shares [shareKey ] = share
102
+ pl .ConfigState .Shares [shareKey ] = share
103
103
changed = true
104
104
}
105
- cfgKey := sp .instanceID ()
106
- cfg , found := sp .ConfigState .Configs [cfgKey ]
105
+ cfgKey := pl .instanceID ()
106
+ cfg , found := pl .ConfigState .Configs [cfgKey ]
107
107
if ! found || cfg .Shares [0 ] != shareKey {
108
108
cfg = smbcc.ConfigSection {
109
109
Shares : []smbcc.Key {shareKey },
110
110
Globals : []smbcc.Key {smbcc .Globals },
111
- InstanceName : sp .InstanceName (),
111
+ InstanceName : pl .InstanceName (),
112
112
}
113
- if sp .SecurityMode () == ADMode {
114
- realmKey := smbcc .Key (sp .Realm ())
113
+ if pl .SecurityMode () == ADMode {
114
+ realmKey := smbcc .Key (pl .Realm ())
115
115
cfg .Globals = append (cfg .Globals , realmKey )
116
116
}
117
- if sp .IsClustered () {
117
+ if pl .IsClustered () {
118
118
cfg .InstanceFeatures = []smbcc.FeatureFlag {smbcc .CTDB }
119
119
}
120
- sp .ConfigState .Configs [cfgKey ] = cfg
120
+ pl .ConfigState .Configs [cfgKey ] = cfg
121
121
changed = true
122
122
}
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 ()
125
125
changed = true
126
126
}
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 ]
130
130
if ! found {
131
- opts := sp .idmapOptions ()
131
+ opts := pl .idmapOptions ()
132
132
// security mode
133
133
opts ["security" ] = "ads"
134
134
// 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 {
138
138
Options : opts ,
139
139
}
140
140
changed = true
0 commit comments