forked from LaconicNetwork/kompose
Adding support for --profile cmd option
This commit is contained in:
+1
-1
@@ -217,7 +217,7 @@ func Convert(opt kobject.ConvertOptions) ([]runtime.Object, error) {
|
||||
komposeObject := kobject.KomposeObject{
|
||||
ServiceConfigs: make(map[string]kobject.ServiceConfig),
|
||||
}
|
||||
komposeObject, err = l.LoadFile(opt.InputFiles)
|
||||
komposeObject, err = l.LoadFile(opt.InputFiles, opt.Profiles)
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ type ConvertOptions struct {
|
||||
BuildRepo string
|
||||
BuildBranch string
|
||||
Build string
|
||||
Profiles []string
|
||||
PushImage bool
|
||||
PushImageRegistry string
|
||||
CreateChart bool
|
||||
@@ -117,6 +118,7 @@ type ServiceConfig struct {
|
||||
Args []string `compose:"args"`
|
||||
VolList []string `compose:"volumes"`
|
||||
Network []string `compose:"network"`
|
||||
Profiles []string `compose:"profiles"`
|
||||
Labels map[string]string `compose:"labels"`
|
||||
Annotations map[string]string `compose:""`
|
||||
CPUSet string `compose:"cpuset"`
|
||||
|
||||
@@ -149,14 +149,19 @@ func checkUnsupportedKey(composeProject *types.Project) []string {
|
||||
}
|
||||
|
||||
// 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
|
||||
workingDir, err := getComposeFileDir(files)
|
||||
if err != nil {
|
||||
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 {
|
||||
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.User = composeServiceConfig.User
|
||||
serviceConfig.ReadOnly = composeServiceConfig.ReadOnly
|
||||
serviceConfig.Profiles = []string{"frontend-dev"}
|
||||
serviceConfig.Stdin = composeServiceConfig.StdinOpen
|
||||
serviceConfig.Tty = composeServiceConfig.Tty
|
||||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
// Loader interface defines loader that loads files and converts it to kobject representation
|
||||
type Loader interface {
|
||||
LoadFile(files []string) (kobject.KomposeObject, error)
|
||||
LoadFile(files []string, profiles []string) (kobject.KomposeObject, error)
|
||||
///Name() string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user