Skip to content

Commit 84efc40

Browse files
committed
Use explicit octal prefix for file permissions
Convert legacy octal notation (0600, 0644) to modern Go style with explicit 0o prefix (0o600, 0o644) for improved code clarity.
1 parent ffc379c commit 84efc40

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/crc/machine/start.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ func createHost(machineConfig config.MachineConfig, preset crcPreset.Preset) err
694694
if err := cluster.GenerateUserPassword(constants.GetKubeAdminPasswordPath(), "kubeadmin"); err != nil {
695695
return errors.Wrap(err, "Error generating new kubeadmin password")
696696
}
697-
if err = os.WriteFile(constants.GetDeveloperPasswordPath(), []byte(constants.DefaultDeveloperPassword), 0600); err != nil {
697+
if err = os.WriteFile(constants.GetDeveloperPasswordPath(), []byte(constants.DefaultDeveloperPassword), 0o600); err != nil {
698698
return errors.Wrap(err, "Error writing developer password")
699699
}
700700
}
@@ -748,7 +748,7 @@ func enableEmergencyLogin(sshRunner *crcssh.Runner) error {
748748
for i := range b {
749749
b[i] = charset[rand.Intn(len(charset))] //nolint:gosec
750750
}
751-
if err := os.WriteFile(constants.PasswdFilePath, b, 0600); err != nil {
751+
if err := os.WriteFile(constants.PasswdFilePath, b, 0o600); err != nil {
752752
return err
753753
}
754754
logging.Infof("Emergency login password for core user is stored to %s", constants.PasswdFilePath)
@@ -775,7 +775,7 @@ func updateSSHKeyPair(sshRunner *crcssh.Runner) error {
775775
}
776776

777777
logging.Info("Updating authorized keys...")
778-
err = sshRunner.CopyData(publicKey, "/home/core/.ssh/authorized_keys", 0644)
778+
err = sshRunner.CopyData(publicKey, "/home/core/.ssh/authorized_keys", 0o644)
779779
if err != nil {
780780
return err
781781
}
@@ -874,10 +874,10 @@ func startMicroshift(ctx context.Context, sshRunner *crcssh.Runner, ocConfig oc.
874874
if _, _, err := sshRunner.RunPrivileged("Starting microshift service", "systemctl", "start", "microshift"); err != nil {
875875
return err
876876
}
877-
if err := sshRunner.CopyFileFromVM(fmt.Sprintf("/var/lib/microshift/resources/kubeadmin/api%s/kubeconfig", constants.ClusterDomain), constants.KubeconfigFilePath, 0600); err != nil {
877+
if err := sshRunner.CopyFileFromVM(fmt.Sprintf("/var/lib/microshift/resources/kubeadmin/api%s/kubeconfig", constants.ClusterDomain), constants.KubeconfigFilePath, 0o600); err != nil {
878878
return err
879879
}
880-
if err := sshRunner.CopyFile(constants.KubeconfigFilePath, "/opt/kubeconfig", 0644); err != nil {
880+
if err := sshRunner.CopyFile(constants.KubeconfigFilePath, "/opt/kubeconfig", 0o644); err != nil {
881881
return err
882882
}
883883

@@ -895,5 +895,5 @@ func ensurePullSecretPresentInVM(sshRunner *crcssh.Runner, pullSec cluster.PullS
895895
if err != nil {
896896
return err
897897
}
898-
return sshRunner.CopyDataPrivileged([]byte(content), "/etc/crio/openshift-pull-secret", 0600)
898+
return sshRunner.CopyDataPrivileged([]byte(content), "/etc/crio/openshift-pull-secret", 0o600)
899899
}

0 commit comments

Comments
 (0)