Skip to content

Commit 6be2025

Browse files
committed
Fix lint error
1 parent 1e872f5 commit 6be2025

17 files changed

+129
-108
lines changed

config/config.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type Config struct {
6666
GSIServerDN string `json:"irods_gsi_server_dn,omitempty" yaml:"irods_gsi_server_dn,omitempty" envconfig:"IRODS_GSI_SERVER_DN"`
6767
}
6868

69+
// GetDefaultConfig returns default config
6970
func GetDefaultConfig() *Config {
7071
return &Config{
7172
AuthenticationScheme: AuthenticationSchemeDefault,
@@ -103,8 +104,8 @@ func NewConfigFromYamlFile(yamlPath string) (*Config, error) {
103104
return config, nil
104105
}
105106

106-
// NewConfigFromJsonFile creates Config from JSON
107-
func NewConfigFromJsonFile(jsonPath string) (*Config, error) {
107+
// NewConfigFromJSONFile creates Config from JSON
108+
func NewConfigFromJSONFile(jsonPath string) (*Config, error) {
108109
config := GetDefaultConfig()
109110

110111
jsonBytes, err := os.ReadFile(jsonPath)
@@ -120,8 +121,8 @@ func NewConfigFromJsonFile(jsonPath string) (*Config, error) {
120121
return config, nil
121122
}
122123

123-
// NewConfigFromJson creates Config from JSON
124-
func NewConfigFromJson(jsonBytes []byte) (*Config, error) {
124+
// NewConfigFromJSON creates Config from JSON
125+
func NewConfigFromJSON(jsonBytes []byte) (*Config, error) {
125126
config := GetDefaultConfig()
126127

127128
err := json.Unmarshal(jsonBytes, config)

config/icommands.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func NewICommandsEnvironmentManager() (*ICommandsEnvironmentManager, error) {
7979
}, nil
8080
}
8181

82+
// SetPPID sets ppid of environment, used to obfuscate password
8283
func (manager *ICommandsEnvironmentManager) SetPPID(ppid int) {
8384
manager.PPID = ppid
8485

@@ -139,6 +140,7 @@ func (manager *ICommandsEnvironmentManager) FromIRODSAccount(account *types.IROD
139140
}
140141
}
141142

143+
// SetEnvironmentFilePath sets environment file path
142144
func (manager *ICommandsEnvironmentManager) SetEnvironmentFilePath(envFilePath string) error {
143145
envFilePath, err := util.ExpandHomeDir(envFilePath)
144146
if err != nil {
@@ -156,6 +158,7 @@ func (manager *ICommandsEnvironmentManager) SetEnvironmentFilePath(envFilePath s
156158
return nil
157159
}
158160

161+
// SetEnvironmentDirPath sets environment dir path
159162
func (manager *ICommandsEnvironmentManager) SetEnvironmentDirPath(envDirPath string) error {
160163
envDirPath, err := util.ExpandHomeDir(envDirPath)
161164
if err != nil {
@@ -185,7 +188,7 @@ func (manager *ICommandsEnvironmentManager) Load() error {
185188
if util.ExistFile(manager.EnvironmentFilePath) {
186189
logger.Debugf("reading icommands configuration file %q", manager.EnvironmentFilePath)
187190

188-
cfg, err := NewConfigFromJsonFile(manager.EnvironmentFilePath)
191+
cfg, err := NewConfigFromJSONFile(manager.EnvironmentFilePath)
189192
if err != nil {
190193
return xerrors.Errorf("failed to create icommands configuration from file %q: %w", manager.EnvironmentFilePath, err)
191194
}
@@ -203,7 +206,7 @@ func (manager *ICommandsEnvironmentManager) Load() error {
203206
if util.ExistFile(manager.SessionFilePath) {
204207
logger.Debugf("reading icommands session file %q", manager.SessionFilePath)
205208

206-
cfg, err := NewConfigFromJsonFile(manager.SessionFilePath)
209+
cfg, err := NewConfigFromJSONFile(manager.SessionFilePath)
207210
if err != nil {
208211
return xerrors.Errorf("failed to create icommands session from file %q: %w", manager.SessionFilePath, err)
209212
}
@@ -239,29 +242,30 @@ func (manager *ICommandsEnvironmentManager) Load() error {
239242
return nil
240243
}
241244

245+
// GetSessionConfig returns session config that is merged with environment
242246
func (manager *ICommandsEnvironmentManager) GetSessionConfig() (*Config, error) {
243247
if manager.Environment == nil && manager.Session == nil {
244248
return nil, xerrors.Errorf("environment is not set")
245249
}
246250

247-
envJsonBytes, err := manager.Environment.ToJSON()
251+
envJSONBytes, err := manager.Environment.ToJSON()
248252
if err != nil {
249253
return nil, xerrors.Errorf("failed to get json from environment")
250254
}
251255

252256
envMap := map[string]interface{}{}
253-
err = json.Unmarshal(envJsonBytes, &envMap)
257+
err = json.Unmarshal(envJSONBytes, &envMap)
254258
if err != nil {
255259
return nil, xerrors.Errorf("failed to unmarshal JSON to map: %w", err)
256260
}
257261

258-
sessionJsonBytes, err := manager.Session.ToJSON()
262+
sessionJSONBytes, err := manager.Session.ToJSON()
259263
if err != nil {
260264
return nil, xerrors.Errorf("failed to get json from session")
261265
}
262266

263267
sessionMap := map[string]interface{}{}
264-
err = json.Unmarshal(sessionJsonBytes, &sessionMap)
268+
err = json.Unmarshal(sessionJSONBytes, &sessionMap)
265269
if err != nil {
266270
return nil, xerrors.Errorf("failed to unmarshal JSON to map: %w", err)
267271
}
@@ -277,9 +281,10 @@ func (manager *ICommandsEnvironmentManager) GetSessionConfig() (*Config, error)
277281
return nil, xerrors.Errorf("failed to marshal map to JSON: %w", err)
278282
}
279283

280-
return NewConfigFromJson(newEnvBytes)
284+
return NewConfigFromJSON(newEnvBytes)
281285
}
282286

287+
// ToIRODSAccount exports to IRODSAccount
283288
func (manager *ICommandsEnvironmentManager) ToIRODSAccount() (*types.IRODSAccount, error) {
284289
if manager.Environment == nil {
285290
return nil, xerrors.Errorf("environment is not set")

config/password_obfuscation.go

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func NewPasswordObfuscator() *PasswordObfuscator {
4949
}
5050
}
5151

52+
// SetUID sets UID for seeding
5253
func (obf *PasswordObfuscator) SetUID(uid int) {
5354
obf.UID = uid
5455
}

fs/file_handle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (handle *FileHandle) Close() error {
9797
handle.irodsFileLockHandle = nil
9898
}
9999

100-
defer handle.filesystem.ioSession.ReturnConnection(handle.connection)
100+
defer handle.filesystem.ioSession.ReturnConnection(handle.connection) //nolint
101101

102102
err := irods_fs.CloseDataObject(handle.connection, handle.irodsFileHandle)
103103
handle.filesystem.fileHandleMap.Remove(handle.id)

fs/fs.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (fs *FileSystem) GetIOConnection() (*connection.IRODSConnection, error) {
104104
}
105105

106106
// ReturnIOConnection returns irods connection for IO back to session
107-
func (fs *FileSystem) ReturnIOConnection(conn *connection.IRODSConnection) {
108-
fs.ioSession.ReturnConnection(conn)
107+
func (fs *FileSystem) ReturnIOConnection(conn *connection.IRODSConnection) error {
108+
return fs.ioSession.ReturnConnection(conn)
109109
}
110110

111111
// GetMetadataConnection returns irods connection for metadata operations
@@ -114,8 +114,8 @@ func (fs *FileSystem) GetMetadataConnection() (*connection.IRODSConnection, erro
114114
}
115115

116116
// ReturnMetadataConnection returns irods connection for metadata operations back to session
117-
func (fs *FileSystem) ReturnMetadataConnection(conn *connection.IRODSConnection) {
118-
fs.metadataSession.ReturnConnection(conn)
117+
func (fs *FileSystem) ReturnMetadataConnection(conn *connection.IRODSConnection) error {
118+
return fs.metadataSession.ReturnConnection(conn)
119119
}
120120

121121
// ConnectionTotal counts current established connections
@@ -129,7 +129,7 @@ func (fs *FileSystem) GetServerVersion() (*types.IRODSVersion, error) {
129129
if err != nil {
130130
return nil, err
131131
}
132-
defer fs.metadataSession.ReturnConnection(conn)
132+
defer fs.metadataSession.ReturnConnection(conn) //nolint
133133

134134
return conn.GetVersion(), nil
135135
}
@@ -274,7 +274,7 @@ func (fs *FileSystem) RemoveDir(path string, recurse bool, force bool) error {
274274
if err != nil {
275275
return err
276276
}
277-
defer fs.metadataSession.ReturnConnection(conn)
277+
defer fs.metadataSession.ReturnConnection(conn) //nolint
278278

279279
err = irods_fs.DeleteCollection(conn, irodsPath, recurse, force)
280280
if err != nil {
@@ -294,7 +294,7 @@ func (fs *FileSystem) RemoveFile(path string, force bool) error {
294294
if err != nil {
295295
return err
296296
}
297-
defer fs.metadataSession.ReturnConnection(conn)
297+
defer fs.metadataSession.ReturnConnection(conn) //nolint
298298

299299
// if file handle is opened, wg
300300
wg := sync.WaitGroup{}
@@ -348,7 +348,7 @@ func (fs *FileSystem) RenameDirToDir(srcPath string, destPath string) error {
348348
if err != nil {
349349
return err
350350
}
351-
defer fs.metadataSession.ReturnConnection(conn)
351+
defer fs.metadataSession.ReturnConnection(conn) //nolint
352352

353353
// preprocess
354354
handles, err := fs.preprocessRenameFileHandleForDir(irodsSrcPath)
@@ -398,7 +398,7 @@ func (fs *FileSystem) RenameFileToFile(srcPath string, destPath string) error {
398398
if err != nil {
399399
return err
400400
}
401-
defer fs.metadataSession.ReturnConnection(conn)
401+
defer fs.metadataSession.ReturnConnection(conn) //nolint
402402

403403
// preprocess
404404
handles, err := fs.preprocessRenameFileHandle(irodsSrcPath)
@@ -550,7 +550,7 @@ func (fs *FileSystem) MakeDir(path string, recurse bool) error {
550550
if err != nil {
551551
return err
552552
}
553-
defer fs.metadataSession.ReturnConnection(conn)
553+
defer fs.metadataSession.ReturnConnection(conn) //nolint
554554

555555
dirEntry, err := fs.StatDir(path)
556556
if err == nil {
@@ -598,7 +598,7 @@ func (fs *FileSystem) CopyFileToFile(srcPath string, destPath string, force bool
598598
if err != nil {
599599
return err
600600
}
601-
defer fs.metadataSession.ReturnConnection(conn)
601+
defer fs.metadataSession.ReturnConnection(conn) //nolint
602602

603603
err = irods_fs.CopyDataObject(conn, irodsSrcPath, irodsDestPath, force)
604604
if err != nil {
@@ -622,7 +622,7 @@ func (fs *FileSystem) TruncateFile(path string, size int64) error {
622622
if err != nil {
623623
return err
624624
}
625-
defer fs.metadataSession.ReturnConnection(conn)
625+
defer fs.metadataSession.ReturnConnection(conn) //nolint
626626

627627
err = irods_fs.TruncateDataObject(conn, irodsPath, size)
628628
if err != nil {
@@ -642,7 +642,7 @@ func (fs *FileSystem) ReplicateFile(path string, resource string, update bool) e
642642
if err != nil {
643643
return err
644644
}
645-
defer fs.metadataSession.ReturnConnection(conn)
645+
defer fs.metadataSession.ReturnConnection(conn) //nolint
646646

647647
err = irods_fs.ReplicateDataObject(conn, irodsPath, resource, update, false)
648648
if err != nil {
@@ -666,7 +666,7 @@ func (fs *FileSystem) OpenFile(path string, resource string, mode string) (*File
666666
keywords := map[common.KeyWord]string{}
667667
handle, offset, err := irods_fs.OpenDataObject(conn, irodsPath, resource, mode, keywords)
668668
if err != nil {
669-
fs.ioSession.ReturnConnection(conn)
669+
fs.ioSession.ReturnConnection(conn) //nolint
670670
return nil, err
671671
}
672672

@@ -724,27 +724,27 @@ func (fs *FileSystem) CreateFile(path string, resource string, mode string) (*Fi
724724
keywords := map[common.KeyWord]string{}
725725
handle, err := irods_fs.CreateDataObject(conn, irodsPath, resource, mode, true, keywords)
726726
if err != nil {
727-
fs.ioSession.ReturnConnection(conn)
727+
fs.ioSession.ReturnConnection(conn) //nolint
728728
return nil, err
729729
}
730730

731731
// close - this is required to let other processes see the file existence
732732
err = irods_fs.CloseDataObject(conn, handle)
733733
if err != nil {
734-
fs.ioSession.ReturnConnection(conn)
734+
fs.ioSession.ReturnConnection(conn) //nolint
735735
return nil, err
736736
}
737737

738738
entry, err := fs.getDataObjectWithConnectionNoCache(conn, irodsPath)
739739
if err != nil {
740-
fs.ioSession.ReturnConnection(conn)
740+
fs.ioSession.ReturnConnection(conn) //nolint
741741
return nil, err
742742
}
743743

744744
// re-open
745745
handle, offset, err := irods_fs.OpenDataObject(conn, irodsPath, resource, mode, keywords)
746746
if err != nil {
747-
fs.ioSession.ReturnConnection(conn)
747+
fs.ioSession.ReturnConnection(conn) //nolint
748748
return nil, err
749749
}
750750

@@ -773,7 +773,7 @@ func (fs *FileSystem) getCollectionNoCache(path string) (*Entry, error) {
773773
if err != nil {
774774
return nil, err
775775
}
776-
defer fs.metadataSession.ReturnConnection(conn)
776+
defer fs.metadataSession.ReturnConnection(conn) //nolint
777777

778778
collection, err := irods_fs.GetCollection(conn, path)
779779
if err != nil {
@@ -894,7 +894,7 @@ func (fs *FileSystem) listEntries(collection *types.IRODSCollection) ([]*Entry,
894894
if err != nil {
895895
return nil, err
896896
}
897-
defer fs.metadataSession.ReturnConnection(conn)
897+
defer fs.metadataSession.ReturnConnection(conn) //nolint
898898

899899
collections, err := irods_fs.ListSubCollections(conn, collection.Path)
900900
if err != nil {
@@ -990,7 +990,7 @@ func (fs *FileSystem) getDataObjectNoCache(path string) (*Entry, error) {
990990
if err != nil {
991991
return nil, err
992992
}
993-
defer fs.metadataSession.ReturnConnection(conn)
993+
defer fs.metadataSession.ReturnConnection(conn) //nolint
994994

995995
dataobject, err := irods_fs.GetDataObjectMasterReplicaWithoutCollection(conn, path)
996996
if err != nil {

fs/fs_acl.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (fs *FileSystem) GetDirACLInheritance(path string) (*types.IRODSAccessInher
7777
if err != nil {
7878
return nil, err
7979
}
80-
defer fs.metadataSession.ReturnConnection(conn)
80+
defer fs.metadataSession.ReturnConnection(conn) //nolint
8181

8282
inheritance, err := irods_fs.GetCollectionAccessInheritance(conn, irodsPath)
8383
if err != nil {
@@ -102,7 +102,7 @@ func (fs *FileSystem) ListDirACLs(path string) ([]*types.IRODSAccess, error) {
102102
if err != nil {
103103
return nil, err
104104
}
105-
defer fs.metadataSession.ReturnConnection(conn)
105+
defer fs.metadataSession.ReturnConnection(conn) //nolint
106106

107107
accesses, err := irods_fs.ListCollectionAccesses(conn, irodsPath)
108108
if err != nil {
@@ -174,7 +174,7 @@ func (fs *FileSystem) ListFileACLs(path string) ([]*types.IRODSAccess, error) {
174174
if err != nil {
175175
return nil, err
176176
}
177-
defer fs.metadataSession.ReturnConnection(conn)
177+
defer fs.metadataSession.ReturnConnection(conn) //nolint
178178

179179
collectionEntry, err := fs.getCollection(util.GetIRODSPathDirname(irodsPath))
180180
if err != nil {
@@ -266,7 +266,7 @@ func (fs *FileSystem) listACLsForEntries(collection *types.IRODSCollection) ([]*
266266
if err != nil {
267267
return nil, err
268268
}
269-
defer fs.metadataSession.ReturnConnection(conn)
269+
defer fs.metadataSession.ReturnConnection(conn) //nolint
270270

271271
// ListAccessesForSubCollections does not return Accesses for some files/dirs
272272
// For these files/dirs, we compare accesses we obtained to the list of files/dirs in a dir

0 commit comments

Comments
 (0)