forked from LaconicNetwork/kompose
Adding support for --profile cmd option
This commit is contained in:
parent
708b222ed5
commit
a7c63a650c
@ -46,6 +46,7 @@ var (
|
|||||||
ConvertDeploymentConfig bool
|
ConvertDeploymentConfig bool
|
||||||
ConvertReplicas int
|
ConvertReplicas int
|
||||||
ConvertController string
|
ConvertController string
|
||||||
|
ConvertProfiles []string
|
||||||
ConvertPushImage bool
|
ConvertPushImage bool
|
||||||
ConvertNamespace string
|
ConvertNamespace string
|
||||||
ConvertPushImageRegistry string
|
ConvertPushImageRegistry string
|
||||||
@ -115,6 +116,7 @@ var convertCmd = &cobra.Command{
|
|||||||
IsReplicaSetFlag: cmd.Flags().Lookup("replicas").Changed,
|
IsReplicaSetFlag: cmd.Flags().Lookup("replicas").Changed,
|
||||||
IsDeploymentConfigFlag: cmd.Flags().Lookup("deployment-config").Changed,
|
IsDeploymentConfigFlag: cmd.Flags().Lookup("deployment-config").Changed,
|
||||||
YAMLIndent: ConvertYAMLIndent,
|
YAMLIndent: ConvertYAMLIndent,
|
||||||
|
Profiles: ConvertProfiles,
|
||||||
WithKomposeAnnotation: WithKomposeAnnotation,
|
WithKomposeAnnotation: WithKomposeAnnotation,
|
||||||
MultipleContainerMode: MultipleContainerMode,
|
MultipleContainerMode: MultipleContainerMode,
|
||||||
ServiceGroupMode: ServiceGroupMode,
|
ServiceGroupMode: ServiceGroupMode,
|
||||||
@ -199,6 +201,8 @@ func init() {
|
|||||||
|
|
||||||
convertCmd.Flags().IntVar(&ConvertYAMLIndent, "indent", 2, "Spaces length to indent generated yaml files")
|
convertCmd.Flags().IntVar(&ConvertYAMLIndent, "indent", 2, "Spaces length to indent generated yaml files")
|
||||||
|
|
||||||
|
convertCmd.Flags().StringArrayVar(&ConvertProfiles, "profile", []string{}, `Specify the profile to use, can use multiple.`)
|
||||||
|
|
||||||
// In order to 'separate' both OpenShift and Kubernetes only flags. A custom help page is created
|
// In order to 'separate' both OpenShift and Kubernetes only flags. A custom help page is created
|
||||||
customHelp := `Usage:{{if .Runnable}}
|
customHelp := `Usage:{{if .Runnable}}
|
||||||
{{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[flags]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
|
{{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[flags]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
|
||||||
|
|||||||
0
output.yaml
Normal file
0
output.yaml
Normal file
@ -217,7 +217,7 @@ func Convert(opt kobject.ConvertOptions) ([]runtime.Object, error) {
|
|||||||
komposeObject := kobject.KomposeObject{
|
komposeObject := kobject.KomposeObject{
|
||||||
ServiceConfigs: make(map[string]kobject.ServiceConfig),
|
ServiceConfigs: make(map[string]kobject.ServiceConfig),
|
||||||
}
|
}
|
||||||
komposeObject, err = l.LoadFile(opt.InputFiles)
|
komposeObject, err = l.LoadFile(opt.InputFiles, opt.Profiles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ type ConvertOptions struct {
|
|||||||
BuildRepo string
|
BuildRepo string
|
||||||
BuildBranch string
|
BuildBranch string
|
||||||
Build string
|
Build string
|
||||||
|
Profiles []string
|
||||||
PushImage bool
|
PushImage bool
|
||||||
PushImageRegistry string
|
PushImageRegistry string
|
||||||
CreateChart bool
|
CreateChart bool
|
||||||
@ -117,6 +118,7 @@ type ServiceConfig struct {
|
|||||||
Args []string `compose:"args"`
|
Args []string `compose:"args"`
|
||||||
VolList []string `compose:"volumes"`
|
VolList []string `compose:"volumes"`
|
||||||
Network []string `compose:"network"`
|
Network []string `compose:"network"`
|
||||||
|
Profiles []string `compose:"profiles"`
|
||||||
Labels map[string]string `compose:"labels"`
|
Labels map[string]string `compose:"labels"`
|
||||||
Annotations map[string]string `compose:""`
|
Annotations map[string]string `compose:""`
|
||||||
CPUSet string `compose:"cpuset"`
|
CPUSet string `compose:"cpuset"`
|
||||||
|
|||||||
@ -149,14 +149,19 @@ func checkUnsupportedKey(composeProject *types.Project) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoadFile loads a compose file into KomposeObject
|
// LoadFile loads a compose file into KomposeObject
|
||||||
func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) {
|
func (c *Compose) LoadFile(files []string, profiles []string) (kobject.KomposeObject, error) {
|
||||||
// Gather the working directory
|
// Gather the working directory
|
||||||
workingDir, err := getComposeFileDir(files)
|
workingDir, err := getComposeFileDir(files)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kobject.KomposeObject{}, err
|
return kobject.KomposeObject{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
projectOptions, err := cli.NewProjectOptions(files, cli.WithOsEnv, cli.WithWorkingDirectory(workingDir), cli.WithInterpolation(true))
|
projectOptions, err := cli.NewProjectOptions(
|
||||||
|
files, cli.WithOsEnv,
|
||||||
|
cli.WithWorkingDirectory(workingDir),
|
||||||
|
cli.WithInterpolation(true),
|
||||||
|
cli.WithProfiles(profiles),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kobject.KomposeObject{}, errors.Wrap(err, "Unable to create compose options")
|
return kobject.KomposeObject{}, errors.Wrap(err, "Unable to create compose options")
|
||||||
}
|
}
|
||||||
@ -462,6 +467,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Project) (kobject.Kompos
|
|||||||
serviceConfig.Privileged = composeServiceConfig.Privileged
|
serviceConfig.Privileged = composeServiceConfig.Privileged
|
||||||
serviceConfig.User = composeServiceConfig.User
|
serviceConfig.User = composeServiceConfig.User
|
||||||
serviceConfig.ReadOnly = composeServiceConfig.ReadOnly
|
serviceConfig.ReadOnly = composeServiceConfig.ReadOnly
|
||||||
|
serviceConfig.Profiles = []string{"frontend-dev"}
|
||||||
serviceConfig.Stdin = composeServiceConfig.StdinOpen
|
serviceConfig.Stdin = composeServiceConfig.StdinOpen
|
||||||
serviceConfig.Tty = composeServiceConfig.Tty
|
serviceConfig.Tty = composeServiceConfig.Tty
|
||||||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
|
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
// Loader interface defines loader that loads files and converts it to kobject representation
|
// Loader interface defines loader that loads files and converts it to kobject representation
|
||||||
type Loader interface {
|
type Loader interface {
|
||||||
LoadFile(files []string) (kobject.KomposeObject, error)
|
LoadFile(files []string, profiles []string) (kobject.KomposeObject, error)
|
||||||
///Name() string
|
///Name() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user