Add flag to support store manifest when kompose up (#1208)

This commit is contained in:
Hang Yan 2019-12-26 19:30:03 +08:00 committed by GitHub
parent bc28ffc675
commit e0c8f6d23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import (
var (
UpReplicas int
UpEmptyVols bool
StoreManifest bool
UpVolumes string
UpInsecureRepo bool
UpNamespace string
@ -56,6 +57,7 @@ var upCmd = &cobra.Command{
UpOpt = kobject.ConvertOptions{
Build: UpBuild,
PushImage: UpPushImage,
StoreManifest: StoreManifest,
Replicas: UpReplicas,
InputFiles: GlobalFiles,
Provider: GlobalProvider,
@ -86,6 +88,7 @@ func init() {
upCmd.Flags().StringVar(&UpBuildRepo, "build-repo", "", "Specify source repository for buildconfig (default remote origin)")
upCmd.Flags().StringVar(&UpBuildBranch, "build-branch", "", "Specify repository branch to use for buildconfig (default master)")
upCmd.Flags().BoolVar(&UpPushImage, "push-image", true, "If we should push the docker image we built")
upCmd.Flags().BoolVar(&StoreManifest, "store-manifest", false, "Store the generated manifest (default false)")
upCmd.Flags().StringVar(&UpController, "controller", "", `Set the output controller ("deployment"|"daemonSet"|"replicationController")`)
upCmd.Flags().MarkHidden("insecure-repository")
upCmd.Flags().MarkHidden("build-repo")

View File

@ -47,6 +47,7 @@ type ConvertOptions struct {
CreateChart bool
GenerateYaml bool
GenerateJSON bool
StoreManifest bool
EmptyVols bool
Volumes string
InsecureRepository bool

View File

@ -1210,6 +1210,13 @@ func (k *Kubernetes) Deploy(komposeObject kobject.KomposeObject, opt kobject.Con
return errors.Wrap(err, "k.Transform failed")
}
if opt.StoreManifest {
log.Info("Store manifest to disk")
if err := PrintList(objects, opt); err != nil {
return errors.Wrap(err, "Store manifest failed")
}
}
pvcStr := " "
if !opt.EmptyVols || opt.Volumes != "emptyDir" {
pvcStr = " and PersistentVolumeClaims "