Created
December 27, 2013 21:30
-
-
Save cpuguy83/8152875 to your computer and use it in GitHub Desktop.
extract functionality for building CMD and ENTRYPOINT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (b *buildFile) BuildCmdFromJson(args string) []string { | |
var cmd []string | |
if err := json.Unmarshal([]byte(args), &cmd); err != nil { | |
utils.Debugf("Error unmarhsalling: %s, setting %s to /bin/sh -c", err) | |
cmd = []string{"/bin/sh", "-c", args} | |
} | |
return cmd | |
} | |
func (b *buildFile) CmdCmd(args string) error { | |
cmd := b.BuildCmdFromJson(args) | |
if err := b.commit("", cmd, fmt.Sprintf("CMD %v", cmd)); err != nil { | |
return err | |
} | |
b.config.Cmd = cmd | |
return nil | |
} | |
func (b *buildFile) CmdEntrypoint(args string) error { | |
entrypoint := b.BuildCmdFromJson(args) | |
if err := b.commit("", entrypoint, fmt.Sprintf("ENTRYPOINT %v", entrypoint)); err != nil { | |
return err | |
} | |
b.config.Entrypoint = entrypoint | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment