Skip to content

Commit

Permalink
Stacks add support for camel case (#1427)
Browse files Browse the repository at this point in the history
* Stacks add support for camel case

Signed-off-by: Javier López Barba <javier@okteto.com>

* Rename camel case vars

Signed-off-by: Javier López Barba <javier@okteto.com>
  • Loading branch information
jLopezbarb committed Apr 21, 2021
1 parent 1562497 commit b20d6a9
Showing 1 changed file with 42 additions and 18 deletions.
60 changes: 42 additions & 18 deletions pkg/model/stack_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,29 @@ type StackRaw struct {

//Service represents an okteto stack service
type ServiceRaw struct {
Deploy *DeployInfoRaw `yaml:"deploy,omitempty"`
Build *BuildInfo `yaml:"build,omitempty"`
CapAdd []apiv1.Capability `yaml:"cap_add,omitempty"`
CapDrop []apiv1.Capability `yaml:"cap_drop,omitempty"`
Command Args `yaml:"command,omitempty"`
Entrypoint Command `yaml:"entrypoint,omitempty"`
Args Args `yaml:"args,omitempty"`
EnvFiles []string `yaml:"env_file,omitempty"`
Environment *RawMessage `yaml:"environment,omitempty"`
Expose *RawMessage `yaml:"expose,omitempty"`
Image string `yaml:"image,omitempty"`
Labels *RawMessage `json:"labels,omitempty" yaml:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
Ports []PortRaw `yaml:"ports,omitempty"`
Scale int32 `yaml:"scale"`
StopGracePeriod *RawMessage `yaml:"stop_grace_period,omitempty"`
Volumes []StackVolume `yaml:"volumes,omitempty"`
WorkingDir string `yaml:"working_dir,omitempty"`
Deploy *DeployInfoRaw `yaml:"deploy,omitempty"`
Build *BuildInfo `yaml:"build,omitempty"`
CapAddSneakCase []apiv1.Capability `yaml:"cap_add,omitempty"`
CapAdd []apiv1.Capability `yaml:"capAdd,omitempty"`
CapDropSneakCase []apiv1.Capability `yaml:"cap_drop,omitempty"`
CapDrop []apiv1.Capability `yaml:"capDrop,omitempty"`
Command Args `yaml:"command,omitempty"`
Entrypoint Command `yaml:"entrypoint,omitempty"`
Args Args `yaml:"args,omitempty"`
EnvFilesSneakCase []string `yaml:"env_file,omitempty"`
EnvFiles []string `yaml:"envFile,omitempty"`
Environment *RawMessage `yaml:"environment,omitempty"`
Expose *RawMessage `yaml:"expose,omitempty"`
Image string `yaml:"image,omitempty"`
Labels *RawMessage `json:"labels,omitempty" yaml:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
Ports []PortRaw `yaml:"ports,omitempty"`
Scale int32 `yaml:"scale"`
StopGracePeriodSneakCase *RawMessage `yaml:"stop_grace_period,omitempty"`
StopGracePeriod *RawMessage `yaml:"stopGracePeriod,omitempty"`
Volumes []StackVolume `yaml:"volumes,omitempty"`
WorkingDirSneakCase string `yaml:"working_dir,omitempty"`
WorkingDir string `yaml:"workingDir,omitempty"`

Public bool `yaml:"public,omitempty"`
Replicas int32 `yaml:"replicas"`
Expand Down Expand Up @@ -210,7 +215,13 @@ func (serviceRaw *ServiceRaw) ToService(svcName string, isCompose bool) (*Servic
s.Build = serviceRaw.Build

s.CapAdd = serviceRaw.CapAdd
if len(serviceRaw.CapAddSneakCase) > 0 {
s.CapAdd = serviceRaw.CapAddSneakCase
}
s.CapDrop = serviceRaw.CapDrop
if len(serviceRaw.CapDropSneakCase) > 0 {
s.CapDrop = serviceRaw.CapDropSneakCase
}

if isCompose {
if len(serviceRaw.Args.Values) > 0 {
Expand All @@ -232,6 +243,9 @@ func (serviceRaw *ServiceRaw) ToService(svcName string, isCompose bool) (*Servic
}

s.EnvFiles = serviceRaw.EnvFiles
if len(serviceRaw.EnvFilesSneakCase) > 0 {
s.EnvFiles = serviceRaw.EnvFilesSneakCase
}

s.Environment, err = unmarshalEnvs(serviceRaw.Environment)
if err != nil {
Expand Down Expand Up @@ -268,8 +282,18 @@ func (serviceRaw *ServiceRaw) ToService(svcName string, isCompose bool) (*Servic
if err != nil {
return nil, err
}
if serviceRaw.StopGracePeriodSneakCase != nil {
s.StopGracePeriod, err = unmarshalDuration(serviceRaw.StopGracePeriodSneakCase)
if err != nil {
return nil, err
}
}

s.Volumes = serviceRaw.Volumes
s.WorkingDir = serviceRaw.WorkingDir
if serviceRaw.WorkingDirSneakCase != "" {
s.WorkingDir = serviceRaw.WorkingDirSneakCase
}

return s, nil
}
Expand Down

0 comments on commit b20d6a9

Please sign in to comment.