home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit efed9b71b4df09a46dc96393ae9d247b81539158
parent a7444361e15c1ac4454d9743d771ac7b2a4ca3f8
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Fri,  9 Sep 2022 11:56:00 +0200

nix/packages: add operator-tooling.

As it is a nix package with a flake, I could expose an overlay there
and use it directly here. To be done later, as it would reduce the
need to duplicate the build information.

Also remove crc, not using it.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Dnix/packages/crc/default.nix | 107-------------------------------------------------------------------------------
Dnix/packages/crc/patches/1_10.patch | 193-------------------------------------------------------------------------------
Dnix/packages/crc/patches/1_11.patch | 193-------------------------------------------------------------------------------
Dnix/packages/crc/patches/1_9.patch | 193-------------------------------------------------------------------------------
Mnix/packages/default.nix | 9+--------
Anix/packages/operator-tooling/default.nix | 21+++++++++++++++++++++
Mshells/osp.nix | 1+
Mshells/tekton.nix | 1+
Musers/vincent/containers/openshift.nix | 1+
9 files changed, 25 insertions(+), 694 deletions(-)

diff --git a/nix/packages/crc/default.nix b/nix/packages/crc/default.nix @@ -1,107 +0,0 @@ -{ stdenv, lib, buildGoPackage, buildGoModule, fetchFromGitHub, pkg-config, libvirt, podman, oc_4_4, oc_4_3 }: - -with lib; -rec { - crcGen = - { version - , sha256 - , bundle - , oc - , crc_driver_libvirt - , patches - }: buildGoPackage rec { - inherit patches; - - pname = "crc"; - name = "${pname}-${version}"; - - src = fetchFromGitHub { - inherit sha256; - owner = "code-ready"; - repo = "crc"; - rev = "${version}"; - }; - - goPackagePath = "github.com/code-ready/crc"; - subPackages = [ "cmd/crc" ]; - ldflags = - let - t = "${goPackagePath}/pkg/crc"; - in - [ - "-X ${t}/version.crcVersion=${version}" - "-X ${t}/version.bundleVersion=${bundle}" - "-X ${t}/constants.OcBinaryName=${oc}/bin/oc" - "-X ${t}/constants.PodmanBinaryName=${podman}/bin/podman" - "-X ${t}/machine/libvirt.MachineDriverCommand=${crc_driver_libvirt}/bin/machine-driver-libvirt" - ]; - - meta = with lib; { - homepage = https://github.com/code-ready/crc; - description = "OpenShift 4.x cluster for testing and development purposes"; - license = licenses.asl20; - maintainers = with maintainers; [ vdemeester ]; - }; - }; - - crc_driver_libvirtGen = - { version - , sha256 - , vendorSha256 - , - }: buildGoModule rec { - inherit vendorSha256; - pname = "crc_driver_libvirt"; - name = "${pname}-${version}"; - - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ libvirt ]; - - subPackages = [ "cmd/machine-driver-libvirt" ]; - src = fetchFromGitHub { - inherit sha256; - owner = "code-ready"; - repo = "machine-driver-libvirt"; - rev = "${version}"; - }; - modSha256 = "${vendorSha256}"; - - }; - - - # bundle is https://storage.googleapis.com/crc-bundle-github-ci/crc_libvirt_4.4.3.zip - crc_1_9 = makeOverridable crcGen { - version = "1.9.0"; - sha256 = "1q2jdm847snjj7wqchsik7qpczvx4awgi5rgvw930mm2b635r3aq"; - bundle = "4.3.10"; - oc = oc_4_3; - patches = [ ./patches/1_9.patch ]; - crc_driver_libvirt = crc_driver_libvirt_0_12_7; - }; - crc_1_10 = makeOverridable crcGen { - version = "1.10.0"; - sha256 = "11vy42zb2xzhwsgnz17894gfn03knvp2yr094k3zhly6wkxbwbk3"; - bundle = "4.4.3"; - oc = oc_4_4; - patches = [ ./patches/1_10.patch ]; - crc_driver_libvirt = crc_driver_libvirt_0_12_7; - }; - crc_1_11 = makeOverridable crcGen { - version = "1.11.0"; - sha256 = "1r302qwpmh3wj9lb46fza3swksylm4zrq9jijz56qk9392yxj1v4"; - bundle = "4.4.5"; - oc = oc_4_4; - patches = [ ./patches/1_11.patch ]; - crc_driver_libvirt = crc_driver_libvirt_0_12_8; - }; - crc_driver_libvirt_0_12_7 = makeOverridable crc_driver_libvirtGen { - version = "0.12.7"; - sha256 = "1mv6wqyzsc24y2gnw0nxmiy52sf3lgfnqkq98v8jdvq3fn6lgacm"; - vendorSha256 = "069rac4m7y7m0lsk04ipsfvq8p51hwlkib2wrsnf7r9sla3dl6fx"; - }; - crc_driver_libvirt_0_12_8 = makeOverridable crc_driver_libvirtGen { - version = "0.12.8"; - sha256 = "1ks6vb7276xn4mr2f6d6cg4dhp3mrqgxwr36v0md0fbl6bai6ppk"; - vendorSha256 = "069rac4m7y7m0lsk04ipsfvq8p51hwlkib2wrsnf7r9sla3dl6fx"; - }; -} diff --git a/nix/packages/crc/patches/1_10.patch b/nix/packages/crc/patches/1_10.patch @@ -1,193 +0,0 @@ -From d9d8c0666fd8feb3a606bf960c16b212eb7a1db7 Mon Sep 17 00:00:00 2001 -From: Vincent Demeester <vincent@sbr.pm> -Date: Wed, 13 May 2020 13:06:13 +0200 -Subject: [PATCH] checkLibvirtEnabled: support linked too - -Signed-off-by: Vincent Demeester <vincent@sbr.pm> ---- - pkg/crc/constants/constants_linux.go | 2 +- - pkg/crc/machine/libvirt/constants.go | 2 +- - pkg/crc/oc/oc.go | 6 +- - pkg/crc/oc/oc_cache.go | 3 + - pkg/crc/preflight/preflight_checks_linux.go | 84 ++++++++++++--------- - 5 files changed, 57 insertions(+), 40 deletions(-) - -diff --git a/pkg/crc/constants/constants_linux.go b/pkg/crc/constants/constants_linux.go -index 2598e34..26cf87a 100644 ---- a/pkg/crc/constants/constants_linux.go -+++ b/pkg/crc/constants/constants_linux.go -@@ -1,6 +1,6 @@ - package constants - --const ( -+var ( - OcBinaryName = "oc" - PodmanBinaryName = "podman" - ) -diff --git a/pkg/crc/machine/libvirt/constants.go b/pkg/crc/machine/libvirt/constants.go -index 13b557a..dc3b3f3 100644 ---- a/pkg/crc/machine/libvirt/constants.go -+++ b/pkg/crc/machine/libvirt/constants.go -@@ -16,10 +16,10 @@ const ( - ) - - const ( -- MachineDriverCommand = "crc-driver-libvirt" - MachineDriverVersion = "0.12.7" - ) - - var ( -+ MachineDriverCommand = "crc-driver-libvirt" - MachineDriverDownloadUrl = fmt.Sprintf("https://github.com/code-ready/machine-driver-libvirt/releases/download/%s/crc-driver-libvirt", MachineDriverVersion) - ) -diff --git a/pkg/crc/oc/oc.go b/pkg/crc/oc/oc.go -index 5b7a552..cdfaf6f 100644 ---- a/pkg/crc/oc/oc.go -+++ b/pkg/crc/oc/oc.go -@@ -43,8 +43,12 @@ func (oc OcLocalRunner) GetKubeconfigPath() string { - - // UseOcWithConfig return the oc binary along with valid kubeconfig - func UseOCWithConfig(machineName string) OcConfig { -+ ocBinaryPath := filepath.Join(constants.CrcBinDir, constants.OcBinaryName) -+ if filepath.IsAbs(constants.OcBinaryName) { -+ ocBinaryPath = constants.OcBinaryName -+ } - localRunner := OcLocalRunner{ -- OcBinaryPath: filepath.Join(constants.CrcBinDir, constants.OcBinaryName), -+ OcBinaryPath: ocBinaryPath, - KubeconfigPath: filepath.Join(constants.MachineInstanceDir, machineName, "kubeconfig"), - } - return NewOcConfig(localRunner, constants.DefaultContext, constants.DefaultName) -diff --git a/pkg/crc/oc/oc_cache.go b/pkg/crc/oc/oc_cache.go -index ecf6f63..4d0e6c9 100644 ---- a/pkg/crc/oc/oc_cache.go -+++ b/pkg/crc/oc/oc_cache.go -@@ -29,6 +29,9 @@ func (oc *OcCached) EnsureIsCached() error { - } - - func (oc *OcCached) IsCached() bool { -+ if filepath.IsAbs(constants.OcBinaryName) { -+ return true -+ } - if _, err := os.Stat(filepath.Join(constants.CrcBinDir, constants.OcBinaryName)); os.IsNotExist(err) { - return false - } -diff --git a/pkg/crc/preflight/preflight_checks_linux.go b/pkg/crc/preflight/preflight_checks_linux.go -index ecb699a..2f119d1 100644 ---- a/pkg/crc/preflight/preflight_checks_linux.go -+++ b/pkg/crc/preflight/preflight_checks_linux.go -@@ -116,18 +116,18 @@ func fixLibvirtInstalled() error { - func checkLibvirtEnabled() error { - logging.Debug("Checking if libvirtd.service is enabled") - // check if libvirt service is enabled -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return fmt.Errorf("systemctl not found on path: %s", err.Error()) -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -- if err != nil { -- return fmt.Errorf("Error checking if libvirtd service is enabled") -- } -- if strings.TrimSpace(stdOut) != "enabled" { -- return fmt.Errorf("libvirtd.service is not enabled") -- } -- logging.Debug("libvirtd.service is already enabled") -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return fmt.Errorf("systemctl not found on path: %s", err.Error()) -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Error checking if libvirtd service is enabled: %s", err) -+ // } -+ // if strings.TrimSpace(stdOut) != "enabled" && strings.TrimSpace(stdOut) != "linked" { -+ // return fmt.Errorf("libvirtd.service is not enabled") -+ // } -+ // logging.Debug("libvirtd.service is already enabled") - return nil - } - -@@ -212,17 +212,17 @@ func fixUserPartOfLibvirtGroup() error { - - func checkLibvirtServiceRunning() error { - logging.Debug("Checking if libvirtd.service is running") -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return err -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -- if err != nil { -- return fmt.Errorf("Failed to check if libvirtd service is active") -- } -- if strings.TrimSpace(stdOut) != "active" { -- return fmt.Errorf("libvirtd.service is not running") -- } -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return err -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Failed to check if libvirtd service is active") -+ // } -+ // if strings.TrimSpace(stdOut) != "active" { -+ // return fmt.Errorf("libvirtd.service is not running") -+ // } - logging.Debug("libvirtd.service is already running") - return nil - } -@@ -246,6 +246,16 @@ func checkMachineDriverLibvirtInstalled() error { - - // Check if crc-driver-libvirt is available - libvirtDriverPath := filepath.Join(constants.CrcBinDir, libvirt.MachineDriverCommand) -+ if filepath.IsAbs(libvirt.MachineDriverCommand) { -+ libvirtDriverPath = filepath.Join(constants.CrcBinDir, "crc-driver-libvirt") -+ -+ err := unix.Access(libvirtDriverPath, unix.X_OK) -+ if err != nil { -+ if _, _, err := crcos.RunWithDefaultLocale("ln", "-s", libvirt.MachineDriverCommand, libvirtDriverPath); err != nil { -+ return fmt.Errorf("%s symbolic link to %s failed", libvirt.MachineDriverCommand, libvirtDriverPath) -+ } -+ } -+ } - err := unix.Access(libvirtDriverPath, unix.X_OK) - if err != nil { - return fmt.Errorf("%s is not executable", libvirtDriverPath) -@@ -550,20 +560,20 @@ func removeCrcDnsmasqConfigFile() error { - } - - func checkCrcNetworkManagerConfig() error { -- logging.Debug("Checking NetworkManager configuration") -- c := []byte(crcNetworkManagerConfig) -- _, err := os.Stat(crcNetworkManagerConfigPath) -- if err != nil { -- return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -- if err != nil { -- return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- if !bytes.Equal(config, c) { -- return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -- } -- logging.Debug("NetworkManager configuration is good") -+ // logging.Debug("Checking NetworkManager configuration") -+ // c := []byte(crcNetworkManagerConfig) -+ // _, err := os.Stat(crcNetworkManagerConfigPath) -+ // if err != nil { -+ // return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -+ // if err != nil { -+ // return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // if !bytes.Equal(config, c) { -+ // return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -+ // } -+ // logging.Debug("NetworkManager configuration is good") - return nil - } - --- -2.26.2 - diff --git a/nix/packages/crc/patches/1_11.patch b/nix/packages/crc/patches/1_11.patch @@ -1,193 +0,0 @@ -From 8250d730f31f2ff995b06b7c404d2682dea62402 Mon Sep 17 00:00:00 2001 -From: Vincent Demeester <vincent@sbr.pm> -Date: Fri, 5 Jun 2020 12:09:52 +0200 -Subject: [PATCH] crc: adapt for nixos - -Signed-off-by: Vincent Demeester <vincent@sbr.pm> ---- - pkg/crc/cache/cache.go | 3 + - pkg/crc/constants/constants_linux.go | 2 +- - pkg/crc/machine/libvirt/constants.go | 2 +- - pkg/crc/oc/oc.go | 6 +- - pkg/crc/preflight/preflight_checks_linux.go | 84 ++++++++++++--------- - 5 files changed, 57 insertions(+), 40 deletions(-) - -diff --git a/pkg/crc/cache/cache.go b/pkg/crc/cache/cache.go -index 72a5bab..e60aa05 100644 ---- a/pkg/crc/cache/cache.go -+++ b/pkg/crc/cache/cache.go -@@ -37,6 +37,9 @@ func NewGoodhostsCache(destDir string) *Cache { - } - - func (c *Cache) IsCached() bool { -+ if filepath.IsAbs(c.binaryName) { -+ return true -+ } - if _, err := os.Stat(filepath.Join(c.destDir, c.binaryName)); os.IsNotExist(err) { - return false - } -diff --git a/pkg/crc/constants/constants_linux.go b/pkg/crc/constants/constants_linux.go -index 0323d5e..0184239 100644 ---- a/pkg/crc/constants/constants_linux.go -+++ b/pkg/crc/constants/constants_linux.go -@@ -1,6 +1,6 @@ - package constants - --const ( -+var ( - OcBinaryName = "oc" - PodmanBinaryName = "podman" - GoodhostsBinaryName = "goodhosts" -diff --git a/pkg/crc/machine/libvirt/constants.go b/pkg/crc/machine/libvirt/constants.go -index a3b5807..a95a020 100644 ---- a/pkg/crc/machine/libvirt/constants.go -+++ b/pkg/crc/machine/libvirt/constants.go -@@ -16,10 +16,10 @@ const ( - ) - - const ( -- MachineDriverCommand = "crc-driver-libvirt" - MachineDriverVersion = "0.12.8" - ) - - var ( -+ MachineDriverCommand = "crc-driver-libvirt" - MachineDriverDownloadUrl = fmt.Sprintf("https://github.com/code-ready/machine-driver-libvirt/releases/download/%s/crc-driver-libvirt", MachineDriverVersion) - ) -diff --git a/pkg/crc/oc/oc.go b/pkg/crc/oc/oc.go -index 9b688e9..cdfaf6f 100644 ---- a/pkg/crc/oc/oc.go -+++ b/pkg/crc/oc/oc.go -@@ -43,8 +43,12 @@ func (oc OcLocalRunner) GetKubeconfigPath() string { - - // UseOcWithConfig return the oc binary along with valid kubeconfig - func UseOCWithConfig(machineName string) OcConfig { -+ ocBinaryPath := filepath.Join(constants.CrcBinDir, constants.OcBinaryName) -+ if filepath.IsAbs(constants.OcBinaryName) { -+ ocBinaryPath = constants.OcBinaryName -+ } - localRunner := OcLocalRunner{ -- OcBinaryPath: filepath.Join(constants.CrcOcBinDir, constants.OcBinaryName), -+ OcBinaryPath: ocBinaryPath, - KubeconfigPath: filepath.Join(constants.MachineInstanceDir, machineName, "kubeconfig"), - } - return NewOcConfig(localRunner, constants.DefaultContext, constants.DefaultName) -diff --git a/pkg/crc/preflight/preflight_checks_linux.go b/pkg/crc/preflight/preflight_checks_linux.go -index 14c987b..93bf418 100644 ---- a/pkg/crc/preflight/preflight_checks_linux.go -+++ b/pkg/crc/preflight/preflight_checks_linux.go -@@ -116,18 +116,18 @@ func fixLibvirtInstalled() error { - func checkLibvirtEnabled() error { - logging.Debug("Checking if libvirtd.service is enabled") - // check if libvirt service is enabled -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return fmt.Errorf("systemctl not found on path: %s", err.Error()) -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -- if err != nil { -- return fmt.Errorf("Error checking if libvirtd service is enabled") -- } -- if strings.TrimSpace(stdOut) != "enabled" { -- return fmt.Errorf("libvirtd.service is not enabled") -- } -- logging.Debug("libvirtd.service is already enabled") -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return fmt.Errorf("systemctl not found on path: %s", err.Error()) -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Error checking if libvirtd service is enabled: %s", err) -+ // } -+ // if strings.TrimSpace(stdOut) != "enabled" && strings.TrimSpace(stdOut) != "linked" { -+ // return fmt.Errorf("libvirtd.service is not enabled") -+ // } -+ // logging.Debug("libvirtd.service is already enabled") - return nil - } - -@@ -212,17 +212,17 @@ func fixUserPartOfLibvirtGroup() error { - - func checkLibvirtServiceRunning() error { - logging.Debug("Checking if libvirtd.service is running") -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return err -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -- if err != nil { -- return fmt.Errorf("Failed to check if libvirtd service is active") -- } -- if strings.TrimSpace(stdOut) != "active" { -- return fmt.Errorf("libvirtd.service is not running") -- } -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return err -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Failed to check if libvirtd service is active") -+ // } -+ // if strings.TrimSpace(stdOut) != "active" { -+ // return fmt.Errorf("libvirtd.service is not running") -+ // } - logging.Debug("libvirtd.service is already running") - return nil - } -@@ -246,6 +246,16 @@ func checkMachineDriverLibvirtInstalled() error { - - // Check if crc-driver-libvirt is available - libvirtDriverPath := filepath.Join(constants.CrcBinDir, libvirt.MachineDriverCommand) -+ if filepath.IsAbs(libvirt.MachineDriverCommand) { -+ libvirtDriverPath = filepath.Join(constants.CrcBinDir, "crc-driver-libvirt") -+ -+ err := unix.Access(libvirtDriverPath, unix.X_OK) -+ if err != nil { -+ if _, _, err := crcos.RunWithDefaultLocale("ln", "-s", libvirt.MachineDriverCommand, libvirtDriverPath); err != nil { -+ return fmt.Errorf("%s symbolic link to %s failed", libvirt.MachineDriverCommand, libvirtDriverPath) -+ } -+ } -+ } - err := unix.Access(libvirtDriverPath, unix.X_OK) - if err != nil { - return fmt.Errorf("%s is not executable", libvirtDriverPath) -@@ -552,20 +562,20 @@ func removeCrcDnsmasqConfigFile() error { - } - - func checkCrcNetworkManagerConfig() error { -- logging.Debug("Checking NetworkManager configuration") -- c := []byte(crcNetworkManagerConfig) -- _, err := os.Stat(crcNetworkManagerConfigPath) -- if err != nil { -- return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -- if err != nil { -- return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- if !bytes.Equal(config, c) { -- return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -- } -- logging.Debug("NetworkManager configuration is good") -+ // logging.Debug("Checking NetworkManager configuration") -+ // c := []byte(crcNetworkManagerConfig) -+ // _, err := os.Stat(crcNetworkManagerConfigPath) -+ // if err != nil { -+ // return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -+ // if err != nil { -+ // return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // if !bytes.Equal(config, c) { -+ // return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -+ // } -+ // logging.Debug("NetworkManager configuration is good") - return nil - } - --- -2.26.2 - diff --git a/nix/packages/crc/patches/1_9.patch b/nix/packages/crc/patches/1_9.patch @@ -1,193 +0,0 @@ -From d9d8c0666fd8feb3a606bf960c16b212eb7a1db7 Mon Sep 17 00:00:00 2001 -From: Vincent Demeester <vincent@sbr.pm> -Date: Wed, 13 May 2020 13:06:13 +0200 -Subject: [PATCH] checkLibvirtEnabled: support linked too - -Signed-off-by: Vincent Demeester <vincent@sbr.pm> ---- - pkg/crc/constants/constants_linux.go | 2 +- - pkg/crc/machine/libvirt/constants.go | 2 +- - pkg/crc/oc/oc.go | 6 +- - pkg/crc/oc/oc_cache.go | 3 + - pkg/crc/preflight/preflight_checks_linux.go | 84 ++++++++++++--------- - 5 files changed, 57 insertions(+), 40 deletions(-) - -diff --git a/pkg/crc/constants/constants_linux.go b/pkg/crc/constants/constants_linux.go -index 2598e34..26cf87a 100644 ---- a/pkg/crc/constants/constants_linux.go -+++ b/pkg/crc/constants/constants_linux.go -@@ -1,6 +1,6 @@ - package constants - --const ( -+var ( - OcBinaryName = "oc" - PodmanBinaryName = "podman" - ) -diff --git a/pkg/crc/machine/libvirt/constants.go b/pkg/crc/machine/libvirt/constants.go -index 13b557a..dc3b3f3 100644 ---- a/pkg/crc/machine/libvirt/constants.go -+++ b/pkg/crc/machine/libvirt/constants.go -@@ -16,10 +16,10 @@ const ( - ) - - const ( -- MachineDriverCommand = "crc-driver-libvirt" - MachineDriverVersion = "0.12.7" - ) - - var ( -+ MachineDriverCommand = "crc-driver-libvirt" - MachineDriverDownloadUrl = fmt.Sprintf("https://github.com/code-ready/machine-driver-libvirt/releases/download/%s/crc-driver-libvirt", MachineDriverVersion) - ) -diff --git a/pkg/crc/oc/oc.go b/pkg/crc/oc/oc.go -index 5b7a552..cdfaf6f 100644 ---- a/pkg/crc/oc/oc.go -+++ b/pkg/crc/oc/oc.go -@@ -43,8 +43,12 @@ func (oc OcLocalRunner) GetKubeconfigPath() string { - - // UseOcWithConfig return the oc binary along with valid kubeconfig - func UseOCWithConfig(machineName string) OcConfig { -+ ocBinaryPath := filepath.Join(constants.CrcBinDir, constants.OcBinaryName) -+ if filepath.IsAbs(constants.OcBinaryName) { -+ ocBinaryPath = constants.OcBinaryName -+ } - localRunner := OcLocalRunner{ -- OcBinaryPath: filepath.Join(constants.CrcBinDir, constants.OcBinaryName), -+ OcBinaryPath: ocBinaryPath, - KubeconfigPath: filepath.Join(constants.MachineInstanceDir, machineName, "kubeconfig"), - } - return NewOcConfig(localRunner, constants.DefaultContext, constants.DefaultName) -diff --git a/pkg/crc/oc/oc_cache.go b/pkg/crc/oc/oc_cache.go -index ecf6f63..4d0e6c9 100644 ---- a/pkg/crc/oc/oc_cache.go -+++ b/pkg/crc/oc/oc_cache.go -@@ -29,6 +29,9 @@ func (oc *OcCached) EnsureIsCached() error { - } - - func (oc *OcCached) IsCached() bool { -+ if filepath.IsAbs(constants.OcBinaryName) { -+ return true -+ } - if _, err := os.Stat(filepath.Join(constants.CrcBinDir, constants.OcBinaryName)); os.IsNotExist(err) { - return false - } -diff --git a/pkg/crc/preflight/preflight_checks_linux.go b/pkg/crc/preflight/preflight_checks_linux.go -index ecb699a..2f119d1 100644 ---- a/pkg/crc/preflight/preflight_checks_linux.go -+++ b/pkg/crc/preflight/preflight_checks_linux.go -@@ -116,18 +116,18 @@ func fixLibvirtInstalled() error { - func checkLibvirtEnabled() error { - logging.Debug("Checking if libvirtd.service is enabled") - // check if libvirt service is enabled -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return fmt.Errorf("systemctl not found on path: %s", err.Error()) -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -- if err != nil { -- return fmt.Errorf("Error checking if libvirtd service is enabled") -- } -- if strings.TrimSpace(stdOut) != "enabled" { -- return fmt.Errorf("libvirtd.service is not enabled") -- } -- logging.Debug("libvirtd.service is already enabled") -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return fmt.Errorf("systemctl not found on path: %s", err.Error()) -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-enabled", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Error checking if libvirtd service is enabled: %s", err) -+ // } -+ // if strings.TrimSpace(stdOut) != "enabled" && strings.TrimSpace(stdOut) != "linked" { -+ // return fmt.Errorf("libvirtd.service is not enabled") -+ // } -+ // logging.Debug("libvirtd.service is already enabled") - return nil - } - -@@ -212,17 +212,17 @@ func fixUserPartOfLibvirtGroup() error { - - func checkLibvirtServiceRunning() error { - logging.Debug("Checking if libvirtd.service is running") -- path, err := exec.LookPath("systemctl") -- if err != nil { -- return err -- } -- stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -- if err != nil { -- return fmt.Errorf("Failed to check if libvirtd service is active") -- } -- if strings.TrimSpace(stdOut) != "active" { -- return fmt.Errorf("libvirtd.service is not running") -- } -+ // path, err := exec.LookPath("systemctl") -+ // if err != nil { -+ // return err -+ // } -+ // stdOut, _, err := crcos.RunWithDefaultLocale(path, "is-active", "libvirtd") -+ // if err != nil { -+ // return fmt.Errorf("Failed to check if libvirtd service is active") -+ // } -+ // if strings.TrimSpace(stdOut) != "active" { -+ // return fmt.Errorf("libvirtd.service is not running") -+ // } - logging.Debug("libvirtd.service is already running") - return nil - } -@@ -246,6 +246,16 @@ func checkMachineDriverLibvirtInstalled() error { - - // Check if crc-driver-libvirt is available - libvirtDriverPath := filepath.Join(constants.CrcBinDir, libvirt.MachineDriverCommand) -+ if filepath.IsAbs(libvirt.MachineDriverCommand) { -+ libvirtDriverPath = filepath.Join(constants.CrcBinDir, "crc-driver-libvirt") -+ -+ err := unix.Access(libvirtDriverPath, unix.X_OK) -+ if err != nil { -+ if _, _, err := crcos.RunWithDefaultLocale("ln", "-s", libvirt.MachineDriverCommand, libvirtDriverPath); err != nil { -+ return fmt.Errorf("%s symbolic link to %s failed", libvirt.MachineDriverCommand, libvirtDriverPath) -+ } -+ } -+ } - err := unix.Access(libvirtDriverPath, unix.X_OK) - if err != nil { - return fmt.Errorf("%s is not executable", libvirtDriverPath) -@@ -550,20 +560,20 @@ func removeCrcDnsmasqConfigFile() error { - } - - func checkCrcNetworkManagerConfig() error { -- logging.Debug("Checking NetworkManager configuration") -- c := []byte(crcNetworkManagerConfig) -- _, err := os.Stat(crcNetworkManagerConfigPath) -- if err != nil { -- return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -- if err != nil { -- return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -- } -- if !bytes.Equal(config, c) { -- return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -- } -- logging.Debug("NetworkManager configuration is good") -+ // logging.Debug("Checking NetworkManager configuration") -+ // c := []byte(crcNetworkManagerConfig) -+ // _, err := os.Stat(crcNetworkManagerConfigPath) -+ // if err != nil { -+ // return fmt.Errorf("File not found: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // config, err := ioutil.ReadFile(filepath.Clean(crcNetworkManagerConfigPath)) -+ // if err != nil { -+ // return fmt.Errorf("Error opening file: %s: %s", crcNetworkManagerConfigPath, err.Error()) -+ // } -+ // if !bytes.Equal(config, c) { -+ // return fmt.Errorf("Config file contains changes: %s", crcNetworkManagerConfigPath) -+ // } -+ // logging.Debug("NetworkManager configuration is good") - return nil - } - --- -2.26.2 - diff --git a/nix/packages/default.nix b/nix/packages/default.nix @@ -83,14 +83,7 @@ rec { kam ; - inherit (pkgs.callPackage ./crc { oc_4_4 = oc_4_4; oc_4_3 = oc_4_3; }) - crc_1_9 - crc_1_10 - crc_1_11 - crc_driver_libvirt_0_12_7 - crc_driver_libvirt_0_12_8 - ; - crc = crc_1_10; + operator-tool = pkgs.callPackage ./operator-tooling { }; # Operator SDK inherit (pkgs.callPackage ./operator-sdk { }) diff --git a/nix/packages/operator-tooling/default.nix b/nix/packages/operator-tooling/default.nix @@ -0,0 +1,21 @@ +{ stdenv, lib, buildGo117Module, git, fetchFromGitHub }: + +buildGo117Module rec { + name = "operator-tool-${version}"; + version = "0.0.1"; + rev = "v${version}"; + + src = fetchFromGitHub { + inherit rev; + owner = "openshift-pipelines"; + repo = "operator-tooling"; + sha256 = "sha256-QCtX1fgJ5HVafn3FmiEjah+AF+po3ZQh7kODrjc2On4="; + }; + vendorSha256 = null; + + meta = { + description = "Tooling for managing operator remote payload"; + homepage = https://github.com/openshift-pipelines/operator-tooling; + license = lib.licenses.asl20; + }; +} diff --git a/shells/osp.nix b/shells/osp.nix @@ -15,6 +15,7 @@ pkgs.mkShell { kustomize my.oc my.operator-sdk + my.operator-tool my.tkn my.opm python39Packages.pyaml diff --git a/shells/tekton.nix b/shells/tekton.nix @@ -9,6 +9,7 @@ pkgs.mkShell { ko my.oc my.tkn + my.operator-tool google-cloud-sdk gron ]; diff --git a/users/vincent/containers/openshift.nix b/users/vincent/containers/openshift.nix @@ -8,5 +8,6 @@ my.openshift-install my.operator-sdk my.opm + my.operator-tool ]; }