applyexec.go 355 B

1234567891011121314151617181920
  1. package applyexec
  2. import (
  3. "fmt"
  4. "os/exec"
  5. "strings"
  6. )
  7. type Service struct{}
  8. func New() *Service { return &Service{} }
  9. func (s *Service) Apply() error {
  10. cmd := exec.Command("netplan", "apply")
  11. output, err := cmd.CombinedOutput()
  12. if err != nil {
  13. return fmt.Errorf("netplan apply failed: %s", strings.TrimSpace(string(output)))
  14. }
  15. return nil
  16. }