From 79617b3cf8dd9089b1c55674f6baea6d4a4aaeea Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Mon, 10 Feb 2025 14:14:48 -0500 Subject: [PATCH] virtctl - add function to check that it is installed Signed-off-by: Ygal Blum --- virtctl/virtctl.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 virtctl/virtctl.go diff --git a/virtctl/virtctl.go b/virtctl/virtctl.go new file mode 100644 index 0000000..c670873 --- /dev/null +++ b/virtctl/virtctl.go @@ -0,0 +1,22 @@ +// Copyright 2025 The go-commons Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package virtctl + +import "os/exec" + +func IsInstalled() bool { + err := exec.Command("virtctl", "version").Run() + return err == nil +}