Adds both build and push support
This adds support for building and pushing docker containers when you perform either `kompose convert` or `kompose up`. Docker Compose files who have build parameters with their respective image and build keys will automatically be both built and pushed.
This commit is contained in:
+17
-5
@@ -19,6 +19,7 @@ package cmd
|
||||
import (
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/kubernetes-incubator/kompose/pkg/app"
|
||||
"github.com/kubernetes-incubator/kompose/pkg/kobject"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -30,6 +31,7 @@ var (
|
||||
ConvertOut string
|
||||
ConvertBuildRepo string
|
||||
ConvertBuildBranch string
|
||||
ConvertBuild string
|
||||
ConvertChart bool
|
||||
ConvertDeployment bool
|
||||
ConvertDaemonSet bool
|
||||
@@ -52,6 +54,12 @@ var convertCmd = &cobra.Command{
|
||||
Short: "Convert a Docker Compose file",
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// Check that build-config wasn't passed in with --provider=kubernetes
|
||||
provider := strings.ToLower(GlobalProvider)
|
||||
if provider == "kubernetes" && UpBuild == "build-config" {
|
||||
log.Fatalf("build-config is not a valid --build parameter with provider Kubernetes")
|
||||
}
|
||||
|
||||
// Create the Convert Options.
|
||||
ConvertOpt = kobject.ConvertOptions{
|
||||
ToStdout: ConvertStdout,
|
||||
@@ -65,6 +73,7 @@ var convertCmd = &cobra.Command{
|
||||
CreateD: ConvertDeployment,
|
||||
CreateDS: ConvertDaemonSet,
|
||||
CreateRC: ConvertReplicationController,
|
||||
Build: ConvertBuild,
|
||||
BuildRepo: ConvertBuildRepo,
|
||||
BuildBranch: ConvertBuildBranch,
|
||||
CreateDeploymentConfig: ConvertDeploymentConfig,
|
||||
@@ -112,6 +121,7 @@ func init() {
|
||||
convertCmd.Flags().MarkHidden("build-branch")
|
||||
|
||||
// Standard between the two
|
||||
convertCmd.Flags().StringVar(&ConvertBuild, "build", "none", `Set the type of build ("local"|"build-config" (OpenShift only)|"none")`)
|
||||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into YAML format")
|
||||
convertCmd.Flags().MarkDeprecated("yaml", "YAML is the default format now.")
|
||||
convertCmd.Flags().MarkShorthandDeprecated("y", "YAML is the default format now.")
|
||||
@@ -135,15 +145,17 @@ Examples:
|
||||
Available Commands:{{range .Commands}}{{if .IsAvailableCommand}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableLocalFlags}}
|
||||
|
||||
Resource Flags:
|
||||
--build-branch Specify repository branch to use for buildconfig (default is current branch name)
|
||||
--build-repo Specify source repository for buildconfig (default is current branch's remote url
|
||||
-c, --chart Create a Helm chart for converted objects
|
||||
Kubernetes Flags:
|
||||
--daemon-set Generate a Kubernetes daemonset object
|
||||
-d, --deployment Generate a Kubernetes deployment object
|
||||
-c, --chart Create a Helm chart for converted objects
|
||||
--replication-controller Generate a Kubernetes replication controller object
|
||||
|
||||
OpenShift Flags:
|
||||
--build-branch Specify repository branch to use for buildconfig (default is current branch name)
|
||||
--build-repo Specify source repository for buildconfig (default is current branch's remote url
|
||||
--deployment-config Generate an OpenShift deployment config object
|
||||
--insecure-repository Specify to use insecure docker repository while generating Openshift image stream object
|
||||
--replication-controller Generate a Kubernetes replication controller object
|
||||
|
||||
Flags:
|
||||
{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{ if .HasAvailableInheritedFlags}}
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"strings"
|
||||
|
||||
"github.com/kubernetes-incubator/kompose/pkg/app"
|
||||
@@ -31,6 +32,7 @@ var (
|
||||
UpInsecureRepo bool
|
||||
UpNamespace string
|
||||
UpOpt kobject.ConvertOptions
|
||||
UpBuild string
|
||||
)
|
||||
|
||||
var upCmd = &cobra.Command{
|
||||
@@ -39,8 +41,15 @@ var upCmd = &cobra.Command{
|
||||
Long: `Deploy your Dockerized application to a container orchestrator. (default "kubernetes")`,
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// Check that build-config wasn't passed in with --provider=kubernetes
|
||||
provider := strings.ToLower(GlobalProvider)
|
||||
if provider == "kubernetes" && UpBuild == "build-config" {
|
||||
log.Fatalf("build-config is not a valid --build parameter with provider Kubernetes")
|
||||
}
|
||||
|
||||
// Create the Convert options.
|
||||
UpOpt = kobject.ConvertOptions{
|
||||
Build: UpBuild,
|
||||
Replicas: UpReplicas,
|
||||
InputFiles: GlobalFiles,
|
||||
Provider: strings.ToLower(GlobalProvider),
|
||||
@@ -63,5 +72,6 @@ func init() {
|
||||
upCmd.Flags().IntVar(&UpReplicas, "replicas", 1, "Specify the number of replicas generated")
|
||||
upCmd.Flags().BoolVar(&UpInsecureRepo, "insecure-repository", false, "Use an insecure Docker repository for OpenShift ImageStream")
|
||||
upCmd.Flags().StringVar(&UpNamespace, "namespace", "default", "Specify Namespace to deploy your application")
|
||||
upCmd.Flags().StringVar(&UpBuild, "build", "local", `Set the type of build ("local"|"build-config" (OpenShift only)|"none")`)
|
||||
RootCmd.AddCommand(upCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user