make use of short declaration of variables and cleanup code

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2022-04-12 22:48:26 +05:30
parent d45bacb34b
commit f30b14f8fd
16 changed files with 66 additions and 61 deletions

View File

@@ -28,8 +28,10 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var (
scheme = runtime.NewScheme()
codecs = serializer.NewCodecFactory(scheme)
)
func init() {
addToScheme(scheme)

View File

@@ -246,9 +246,9 @@ func main(cmd *cobra.Command, args []string) {
factory := informers.NewSharedInformerFactory(snapClient, 0)
lister := factory.Snapshot().V1().VolumeSnapshotClasses().Lister()
//Start the informers
// Start the informers
factory.Start(ctx.Done())
//wait for the caches to sync
// wait for the caches to sync
factory.WaitForCacheSync(ctx.Done())
if err := startServer(ctx, tlsConfig, cw, lister); err != nil {

View File

@@ -22,7 +22,7 @@ func TestWebhookCertReload(t *testing.T) {
certFile = tmpDir + "/tls.crt"
keyFile = tmpDir + "/tls.key"
port = 30443
err := os.Mkdir(tmpDir, 0777)
err := os.Mkdir(tmpDir, 0o777)
if err != nil && err != os.ErrExist {
t.Errorf("unexpected error occurred while creating tmp dir: %v", err)
}
@@ -149,7 +149,7 @@ func generateTestCertKeyPair(t *testing.T, certPath, keyPath string) error {
}
fmt.Printf("wrote new cert: %s\n", certPath)
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
return fmt.Errorf("Failed to open tls.key for writing: %v", err)
}