From b65a6816b75219baf8c8e916910d812595529923 Mon Sep 17 00:00:00 2001 From: pantafive <56078241+pantafive@users.noreply.github.com> Date: Mon, 29 Dec 2025 15:46:54 +0100 Subject: [PATCH] Make --imageName optional when --templateId is specified When creating a pod with --templateId, the image name is already defined in the template on RunPod UI. This removes --imageName as a required flag and adds runtime validation to require it only when --templateId is not set. Fixes #162 --- cmd/pod/createPod.go | 6 ++++-- cmd/pods/createPods.go | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/pod/createPod.go b/cmd/pod/createPod.go index 249e8c1..1950e43 100644 --- a/cmd/pod/createPod.go +++ b/cmd/pod/createPod.go @@ -37,6 +37,9 @@ var CreatePodCmd = &cobra.Command{ Short: "start a pod", Long: "start a pod from runpod.io", Run: func(cmd *cobra.Command, args []string) { + if templateId == "" && imageName == "" { + cobra.CheckErr(fmt.Errorf("--imageName is required when --templateId is not specified")) + } input := &api.CreatePodInput{ ContainerDiskInGb: containerDiskInGb, DeployCost: deployCost, @@ -103,6 +106,5 @@ func init() { CreatePodCmd.Flags().StringVar(&dataCenterId, "dataCenterId", "", "datacenter id to create in") CreatePodCmd.Flags().BoolVar(&startSSH, "startSSH", false, "enable SSH login") - CreatePodCmd.MarkFlagRequired("gpuType") //nolint - CreatePodCmd.MarkFlagRequired("imageName") //nolint + CreatePodCmd.MarkFlagRequired("gpuType") //nolint } diff --git a/cmd/pods/createPods.go b/cmd/pods/createPods.go index 1826c37..15c03e3 100644 --- a/cmd/pods/createPods.go +++ b/cmd/pods/createPods.go @@ -35,6 +35,9 @@ var CreatePodsCmd = &cobra.Command{ Short: "create a group of pods", Long: "create a group of pods on runpod.io", Run: func(cmd *cobra.Command, args []string) { + if templateId == "" && imageName == "" { + cobra.CheckErr(fmt.Errorf("--imageName is required when --templateId is not specified")) + } gpus := strings.Split(gpuTypeId, ",") gpusIndex := 0 input := &api.CreatePodInput{ @@ -106,7 +109,6 @@ func init() { CreatePodsCmd.Flags().StringVar(&templateId, "templateId", "", "templateId to use with the pods") CreatePodsCmd.Flags().StringVar(&volumeMountPath, "volumePath", "/runpod", "container volume path") - CreatePodsCmd.MarkFlagRequired("gpuType") //nolint - CreatePodsCmd.MarkFlagRequired("imageName") //nolint - CreatePodsCmd.MarkFlagRequired("name") //nolint + CreatePodsCmd.MarkFlagRequired("gpuType") //nolint + CreatePodsCmd.MarkFlagRequired("name") //nolint }