Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding apache test package #111

Merged
merged 17 commits into from
Oct 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Alternative parsing
  • Loading branch information
ycombinator committed Oct 1, 2020
commit 21e1f9008b4a949aa9c7d50d4f231b282cf65a7e
25 changes: 22 additions & 3 deletions internal/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type service struct {

type portMapping struct {
ExternalIP string
ExternalPort int `yaml:"published"`
InternalPort int `yaml:"target"`
ExternalPort int
InternalPort int
Protocol string
}

Expand All @@ -47,7 +47,26 @@ func (p *portMapping) UnmarshalYAML(node *yaml.Node) error {
// configuration file, sometimes a map is returned and other times a
// string is returned. Here we first check if a map was returned.
if node.Kind == yaml.MappingNode {
return yaml.Unmarshal([]byte(node.Value), p)
b, err := yaml.Marshal(node)
if err != nil {
return errors.Wrap(err, "could not re-encode YAML map node to YAML")
}

var s struct {
Target int
Published int
Protocol string
}

if err := yaml.Unmarshal(b, &s); err != nil {
return errors.Wrap(err, "could not unmarshal YAML map node")
}

p.InternalPort = s.Target
p.ExternalPort = s.Published
p.Protocol = s.Protocol

return nil
}

var str string
Expand Down