Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extract functionality for building CMD and ENTRYPOINT
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
You can’t perform that action at this time.