Infer storage type using label (#1456)

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
This commit is contained in:
Shivam Sandbhor
2021-11-13 20:33:10 +08:00
committed by GitHub
parent 6836599adc
commit 1c4ff96626
12 changed files with 1099 additions and 4 deletions
+7 -2
View File
@@ -17,6 +17,7 @@ limitations under the License.
package app
import (
"fmt"
"strings"
log "github.com/sirupsen/logrus"
@@ -132,8 +133,12 @@ func ValidateFlags(args []string, cmd *cobra.Command, opt *kobject.ConvertOption
log.Fatalf("YAML and JSON format cannot be provided at the same time")
}
if opt.Volumes != "persistentVolumeClaim" && opt.Volumes != "emptyDir" && opt.Volumes != "hostPath" && opt.Volumes != "configMap" {
log.Fatal("Unknown Volume type: ", opt.Volumes, ", possible values are: persistentVolumeClaim, hostPath, configMap and emptyDir")
if _, ok := kubernetes.ValidVolumeSet[opt.Volumes]; !ok {
validVolumesTypes := make([]string, 0)
for validVolumeType := range kubernetes.ValidVolumeSet {
validVolumesTypes = append(validVolumesTypes, fmt.Sprintf("'%s'", validVolumeType))
}
log.Fatal("Unknown Volume type: ", opt.Volumes, ", possible values are: ", strings.Join(validVolumesTypes, " "))
}
}