func (c *MarathonClient) parseApplicationFromFile(filename string, opts *CreateOptions) (*Application, *CreateOptions, error) { log.Info("Creating Application from file: %s", filename) options := initCreateOptions(opts) file, err := os.Open(filename) if err != nil { return nil, nil, fmt.Errorf("Error opening filename %s, %s", filename, err.Error()) } var encoder encoding.Encoder encoder, err = encoding.NewEncoderFromFileExt(filename) if err != nil { return nil, nil, err } parsed, missing := envsubst.SubstFileTokens(file, filename, options.EnvParams) if options.ErrorOnMissingParams && missing { return nil, nil, ErrorAppParamsMissing } app := new(Application) err = encoder.UnMarshalStr(parsed, &app) if err != nil { return nil, nil, err } return app, options, nil }
func (c *MarathonClient) CreateGroupFromFile(filename string, opts *CreateOptions) (*Group, error) { log.Info("Creating Group from file: %s", filename) options := initCreateOptions(opts) file, err := os.Open(filename) if err != nil { return nil, fmt.Errorf("Error opening filename %s, %s", filename, err.Error()) } var encoder encoding.Encoder encoder, err = encoding.NewEncoderFromFileExt(filename) if err != nil { return nil, err } parsed, missing := envsubst.SubstFileTokens(file, filename, options.EnvParams) if options.ErrorOnMissingParams && missing { return nil, ErrorAppParamsMissing } group := new(Group) err = encoder.UnMarshalStr(parsed, &group) if err != nil { return nil, err } return c.CreateGroup(group, options.Wait, options.Force) }