Installed checks if any file at `s.path()` matches the output of `lima sudoers`.
()
| 43 | |
| 44 | // Installed checks if any file at `s.path()` matches the output of `lima sudoers`. |
| 45 | func (s *sudoersFile) Installed() bool { |
| 46 | b, err := afero.ReadFile(s.fs, s.path()) |
| 47 | if err != nil { |
| 48 | if errors.Is(err, fs.ErrNotExist) { |
| 49 | s.l.Infof("sudoers file not found: %v", err) |
| 50 | } else { |
| 51 | s.l.Errorf("failed to read sudoers file: %v", err) |
| 52 | } |
| 53 | return false |
| 54 | } |
| 55 | cmd := s.limaCmdCreator.CreateWithoutStdio("sudoers") |
| 56 | out, err := cmd.Output() |
| 57 | if err != nil { |
| 58 | s.l.Errorf("failed to run lima sudoers command: %v", err) |
| 59 | return false |
| 60 | } |
| 61 | return bytes.Equal(b, out) |
| 62 | } |
| 63 | |
| 64 | // Install creates the sudoers file at `s.path()` with the contents of `lima sudoers`. |
| 65 | func (s *sudoersFile) Install() error { |
nothing calls this directly
no test coverage detected