mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-23 21:40:20 +00:00
cleanup: fix golint warnings in util, e2e
util: golint warns about exported methods to have a comment or to unexport them. e2e: golint warns about package comment to be of the form "Package e2e ..." Reported-by: https://goreportcard.com/report/github.com/ceph/ceph-csi Updates: #975 Signed-off-by: Yug Gupta <ygupta@redhat.com>
This commit is contained in:
parent
979f2b36ed
commit
753f6b7fec
@ -10,6 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
|
@ -33,6 +33,7 @@ const (
|
||||
tmpKeyFileNamePrefix = "keyfile-"
|
||||
)
|
||||
|
||||
// Credentials struct represents credentials to access the ceph cluster.
|
||||
type Credentials struct {
|
||||
ID string
|
||||
KeyFile string
|
||||
@ -93,19 +94,23 @@ func newCredentialsFromSecret(idField, keyField string, secrets map[string]strin
|
||||
return c, err
|
||||
}
|
||||
|
||||
// DeleteCredentials removes the KeyFile.
|
||||
func (cr *Credentials) DeleteCredentials() {
|
||||
// don't complain about unhandled error
|
||||
_ = os.Remove(cr.KeyFile)
|
||||
}
|
||||
|
||||
// NewUserCredentials creates new user credentials from secret.
|
||||
func NewUserCredentials(secrets map[string]string) (*Credentials, error) {
|
||||
return newCredentialsFromSecret(credUserID, credUserKey, secrets)
|
||||
}
|
||||
|
||||
// NewAdminCredentials creates new admin credentials from secret.
|
||||
func NewAdminCredentials(secrets map[string]string) (*Credentials, error) {
|
||||
return newCredentialsFromSecret(credAdminID, credAdminKey, secrets)
|
||||
}
|
||||
|
||||
// NewCredentials generates new credentials when id and key are provided.
|
||||
func NewCredentials(id, key string) (*Credentials, error) {
|
||||
var c = &Credentials{}
|
||||
|
||||
@ -118,6 +123,7 @@ func NewCredentials(id, key string) (*Credentials, error) {
|
||||
return c, err
|
||||
}
|
||||
|
||||
// GetMonValFromSecret returns monitors from secret.
|
||||
func GetMonValFromSecret(secrets map[string]string) (string, error) {
|
||||
if mons, ok := secrets[credMonitors]; ok {
|
||||
return mons, nil
|
||||
|
@ -57,6 +57,7 @@ func (e ErrSnapNameConflict) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// NewErrSnapNameConflict returns a ErrSnapNameConflict error when CSI snap name already exists.
|
||||
func NewErrSnapNameConflict(name string, err error) ErrSnapNameConflict {
|
||||
return ErrSnapNameConflict{name, err}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ type VolumeLocks struct {
|
||||
mux sync.Mutex
|
||||
}
|
||||
|
||||
// NewVolumeLocks returns new VolumeLocks
|
||||
// NewVolumeLocks returns new VolumeLocks.
|
||||
func NewVolumeLocks() *VolumeLocks {
|
||||
return &VolumeLocks{
|
||||
locks: sets.NewString(),
|
||||
@ -53,6 +53,7 @@ func (vl *VolumeLocks) TryAcquire(volumeID string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Release deletes the lock on volumeID.
|
||||
func (vl *VolumeLocks) Release(volumeID string) {
|
||||
vl.mux.Lock()
|
||||
defer vl.mux.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user