From 1f2643ab4d9dcd109bac9116651adfd37e7c217a Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Wed, 24 Jan 2024 21:35:16 +0100 Subject: [PATCH] Nit tips Signed-off-by: Carlos Eduardo Arango Gutierrez --- README.md | 15 +++++++++------ cmd/dryrun/dryrun.go | 6 +----- examples/v1alpha1_environment.yaml | 6 ++---- pkg/provisioner/dryrun.go | 20 ++++++++++---------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 1a4b1c0e..a53bb9d0 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ metadata: name: holodeck description: "Devel infra environment" spec: - provider: aws # or ssh for now + provider: aws # or ssh currently supported auth: keyName: user privateKey: "/Users/user/.ssh/user.pem" @@ -75,7 +75,7 @@ spec: version: 1.6.24 kubernetes: install: true - installer: kubeadm # supported installers: kubeadm, kind + installer: kubeadm # supported installers: kubeadm, kind, microk8s version: v1.28.5 ``` @@ -83,20 +83,23 @@ spec: ```bash $ holodeck create -f ./examples/v1alpha1_environment.yaml +... ``` ### Delete an environment ```bash $ holodeck delete -f ./examples/v1alpha1_environment.yaml +... ``` ### Dry Run ```bash $ holodeck dryrun -f ./examples/v1alpha1_environment.yaml -Checking if instance type g4dn.xlarge is supported in region xx-xxxx-1 -Checking if image ami-xxxxxxxxx is supported in region xx-xxxx-1 -Resolving dependencies... -Dryrun succeeded +Dryrun environment holodeck 🔍 +✔ Checking if instance type g4dn.xlarge is supported in region eu-north-1 +✔ Checking if image ami-0fe8bec493a81c7da is supported in region eu-north-1 +✔ Resolving dependencies 📦 +Dryrun succeeded 🎉 ``` \ No newline at end of file diff --git a/cmd/dryrun/dryrun.go b/cmd/dryrun/dryrun.go index cce1d883..783af9d6 100644 --- a/cmd/dryrun/dryrun.go +++ b/cmd/dryrun/dryrun.go @@ -72,10 +72,6 @@ func (m command) build() *cli.Command { return fmt.Errorf("failed to read config file %s: %v", opts.envFile, err) } - if opts.cfg.Spec.ContainerRuntime.Name == "" && opts.cfg.Spec.Kubernetes.Install { - m.log.Warning("No container runtime specified, will default defaulting to containerd") - } - return nil }, Action: func(c *cli.Context) error { @@ -109,7 +105,7 @@ func (m command) run(c *cli.Context, opts *options) error { return err } - m.log.Check("Dryrun succeeded\n") + m.log.Info("Dryrun succeeded \U0001F389") return nil } diff --git a/examples/v1alpha1_environment.yaml b/examples/v1alpha1_environment.yaml index b230c28b..642835f1 100644 --- a/examples/v1alpha1_environment.yaml +++ b/examples/v1alpha1_environment.yaml @@ -16,9 +16,7 @@ spec: image: architecture: amd64 imageId: ami-0fe8bec493a81c7da - containerRuntime: - install: true kubernetes: install: true - installer: kind - version: 1.29 + installer: kubeadm + version: v1.28.5 diff --git a/pkg/provisioner/dryrun.go b/pkg/provisioner/dryrun.go index 7a7a5267..3ab54436 100644 --- a/pkg/provisioner/dryrun.go +++ b/pkg/provisioner/dryrun.go @@ -28,13 +28,9 @@ func Dryrun(log *logger.FunLogger, env v1alpha1.Environment) error { // Resolve dependencies from top to bottom log.Wg.Add(1) - go log.Loading("Resolving dependencies \U0001F4E6 ...") + go log.Loading("Resolving dependencies \U0001F4E6") // Kubernetes -> Container Toolkit -> Container Runtime -> NVDriver if env.Spec.Kubernetes.Install { - if !env.Spec.ContainerRuntime.Install { - log.Fail <- struct{}{} - return fmt.Errorf("cannot install Kubernetes without a container runtime") - } // check if env.Spec.Kubernetes.KubernetesVersion is in the format of vX.Y.Z if env.Spec.Kubernetes.KubernetesInstaller == "kubeadm" && !strings.HasPrefix(env.Spec.Kubernetes.KubernetesVersion, "v") { log.Fail <- struct{}{} @@ -42,11 +38,15 @@ func Dryrun(log *logger.FunLogger, env v1alpha1.Environment) error { } } - if env.Spec.ContainerRuntime.Install && (env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeContainerd && - env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeCrio && - env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeDocker) { - log.Fail <- struct{}{} - return fmt.Errorf("container runtime %s not supported", env.Spec.ContainerRuntime.Name) + if env.Spec.ContainerRuntime.Install { + if env.Spec.ContainerRuntime.Name == "" { + log.Warning("No container runtime specified, will default to containerd") + } else if env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeContainerd && + env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeCrio && + env.Spec.ContainerRuntime.Name != v1alpha1.ContainerRuntimeDocker { + log.Fail <- struct{}{} + return fmt.Errorf("container runtime %s not supported", env.Spec.ContainerRuntime.Name) + } } log.Done <- struct{}{}