mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -33,6 +33,7 @@ const (
|
|||||||
tmpKeyFileNamePrefix = "keyfile-"
|
tmpKeyFileNamePrefix = "keyfile-"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Credentials struct represents credentials to access the ceph cluster.
|
||||||
type Credentials struct {
|
type Credentials struct {
|
||||||
ID string
|
ID string
|
||||||
KeyFile string
|
KeyFile string
|
||||||
@ -93,19 +94,23 @@ func newCredentialsFromSecret(idField, keyField string, secrets map[string]strin
|
|||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteCredentials removes the KeyFile.
|
||||||
func (cr *Credentials) DeleteCredentials() {
|
func (cr *Credentials) DeleteCredentials() {
|
||||||
// don't complain about unhandled error
|
// don't complain about unhandled error
|
||||||
_ = os.Remove(cr.KeyFile)
|
_ = os.Remove(cr.KeyFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewUserCredentials creates new user credentials from secret.
|
||||||
func NewUserCredentials(secrets map[string]string) (*Credentials, error) {
|
func NewUserCredentials(secrets map[string]string) (*Credentials, error) {
|
||||||
return newCredentialsFromSecret(credUserID, credUserKey, secrets)
|
return newCredentialsFromSecret(credUserID, credUserKey, secrets)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewAdminCredentials creates new admin credentials from secret.
|
||||||
func NewAdminCredentials(secrets map[string]string) (*Credentials, error) {
|
func NewAdminCredentials(secrets map[string]string) (*Credentials, error) {
|
||||||
return newCredentialsFromSecret(credAdminID, credAdminKey, secrets)
|
return newCredentialsFromSecret(credAdminID, credAdminKey, secrets)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCredentials generates new credentials when id and key are provided.
|
||||||
func NewCredentials(id, key string) (*Credentials, error) {
|
func NewCredentials(id, key string) (*Credentials, error) {
|
||||||
var c = &Credentials{}
|
var c = &Credentials{}
|
||||||
|
|
||||||
@ -118,6 +123,7 @@ func NewCredentials(id, key string) (*Credentials, error) {
|
|||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMonValFromSecret returns monitors from secret.
|
||||||
func GetMonValFromSecret(secrets map[string]string) (string, error) {
|
func GetMonValFromSecret(secrets map[string]string) (string, error) {
|
||||||
if mons, ok := secrets[credMonitors]; ok {
|
if mons, ok := secrets[credMonitors]; ok {
|
||||||
return mons, nil
|
return mons, nil
|
||||||
|
@ -57,6 +57,7 @@ func (e ErrSnapNameConflict) Error() string {
|
|||||||
return e.err.Error()
|
return e.err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewErrSnapNameConflict returns a ErrSnapNameConflict error when CSI snap name already exists.
|
||||||
func NewErrSnapNameConflict(name string, err error) ErrSnapNameConflict {
|
func NewErrSnapNameConflict(name string, err error) ErrSnapNameConflict {
|
||||||
return ErrSnapNameConflict{name, err}
|
return ErrSnapNameConflict{name, err}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ type VolumeLocks struct {
|
|||||||
mux sync.Mutex
|
mux sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVolumeLocks returns new VolumeLocks
|
// NewVolumeLocks returns new VolumeLocks.
|
||||||
func NewVolumeLocks() *VolumeLocks {
|
func NewVolumeLocks() *VolumeLocks {
|
||||||
return &VolumeLocks{
|
return &VolumeLocks{
|
||||||
locks: sets.NewString(),
|
locks: sets.NewString(),
|
||||||
@ -53,6 +53,7 @@ func (vl *VolumeLocks) TryAcquire(volumeID string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release deletes the lock on volumeID.
|
||||||
func (vl *VolumeLocks) Release(volumeID string) {
|
func (vl *VolumeLocks) Release(volumeID string) {
|
||||||
vl.mux.Lock()
|
vl.mux.Lock()
|
||||||
defer vl.mux.Unlock()
|
defer vl.mux.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user