func (s *platformService) Update(opts appTypes.PlatformOptions) error {
	if opts.Name == "" {
		return appTypes.ErrPlatformNameMissing
	}
	conn, err := db.Conn()
	if err != nil {
		return err
	}
	defer conn.Close()
	_, err = s.FindByName(opts.Name)
	if err != nil {
		return err
	}
	if opts.Input != nil {
		data, err := ioutil.ReadAll(opts.Input)
		if err != nil {
			return err
		}
		if len(data) == 0 {
			return appTypes.ErrMissingFileContent
		}
		opts.Data = data
		opts.ImageName, err = servicemanager.PlatformImage.NewImage(opts.Name)
		if err != nil {
			return err
		}
		err = builder.PlatformUpdate(opts)
		if err != nil {
			return err
		}
		err = servicemanager.PlatformImage.AppendImage(opts.Name, opts.ImageName)
		if err != nil {
			return err
		}
		var apps []App
		err = conn.Apps().Find(bson.M{"framework": opts.Name}).All(&apps)
		if err != nil {
			return err
		}
		for _, app := range apps {
			app.SetUpdatePlatform(true)
		}
	}
	if opts.Args["disabled"] != "" {
		disableBool, err := strconv.ParseBool(opts.Args["disabled"])
		if err != nil {
			return err
		}
		return s.storage.Update(appTypes.Platform{Name: opts.Name, Disabled: disableBool})
	}
	return nil
}
func (s *platformService) Update(opts appTypes.PlatformOptions) error {
	if opts.Name == "" {
		return appTypes.ErrPlatformNameMissing
	}
	conn, err := db.Conn()
	if err != nil {
		return err
	}
	defer conn.Close()
	_, err = s.FindByName(opts.Name)
	if err != nil {
		return err
	}
	if opts.Input != nil {
		data, err := ioutil.ReadAll(opts.Input)
		if err != nil {
			return err
		}
		if len(data) == 0 {
			return appTypes.ErrMissingFileContent
		}
		opts.Data = data
		opts.ImageName, err = servicemanager.PlatformImage.NewImage(opts.Name)
		if err != nil {
			return err
		}
		err = builder.PlatformUpdate(opts)
		if err != nil {
			return err
		}
		err = servicemanager.PlatformImage.AppendImage(opts.Name, opts.ImageName)
		if err != nil {
			return err
		}
		var apps []App
		err = conn.Apps().Find(bson.M{"framework": opts.Name}).All(&apps)
		if err != nil {
			return err
		}
		for _, app := range apps {
			app.SetUpdatePlatform(true)
		}
	}
	if opts.Args["disabled"] != "" {
		disableBool, err := strconv.ParseBool(opts.Args["disabled"])
		if err != nil {
			return err
		}
		return s.storage.Update(appTypes.Platform{Name: opts.Name, Disabled: disableBool})
	}
	return nil
}
func ( s * platformService ) Update ( opts appTypes . PlatformOptions ) error { if opts . Name == " " { return appTypes . ErrPlatformNameMissing } conn , err := db . Conn ( ) if err != nil { return err } defer conn . Close ( ) _ , err = s . FindByName ( opts . Name ) if err != nil { return err } if opts . Input != nil { data , err := ioutil . ReadAll ( opts . Input ) if err != nil { return err } if len ( data ) == 0 { return appTypes . ErrMissingFileContent } opts . Data = data opts . ImageName , err = servicemanager . PlatformImage . NewImage ( opts . Name ) if err != nil { return err } err = builder . PlatformUpdate ( opts ) if err != nil { return err } err = servicemanager . PlatformImage . AppendImage ( opts . Name , opts . ImageName ) if err != nil { return err } var apps [ ] App err = conn . Apps ( ) . Find ( bson . M { " " : opts . Name } ) . All ( & apps ) if err != nil { return err } for _ , app := range apps { app . SetUpdatePlatform ( true ) } } if opts . Args [ " " ] != " " { disableBool , err := strconv . ParseBool ( opts . Args [ " " ] ) if err != nil { return err } return s . storage . Update ( appTypes . Platform { Name : opts . Name , Disabled : disableBool } ) } return nil }
// Update implements Update method of PlatformService interface
Update implements Update method of PlatformService interface