You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: plugin.go
    path of file: ./repos/cds/engine/api/plugin
    
    the code of the file until where you have to start completion: package plugin

import (
	"context"
	"io"

	"github.com/go-gorp/gorp"
	"github.com/rockbears/log"

	"github.com/ovh/cds/engine/api/objectstore"
	"github.com/ovh/cds/sdk"
)

// AddBinary add binary to the plugin, uploading it to objectsore and updates databases
func AddBinary(ctx context.Context, db gorp.SqlExecutor, storage objectstore.Driver, p *sdk.GRPCPlugin, b *sdk.GRPCPluginBinary, 
    
func UpdateBinary(ctx context.Context, db gorp.SqlExecutor, storageDriver objectstore.Driver, p *sdk.GRPCPlugin, b *sdk.GRPCPluginBinary, r io.ReadCloser) error {
	var oldBinary *sdk.GRPCPluginBinary
	var index int
	for i := range p.Binaries {
		if p.Binaries[i].OS == b.OS && p.Binaries[i].Arch == b.Arch {
			oldBinary = &p.Binaries[i]
			index = i
			break
		}
	}
	if oldBinary == nil {
		return sdk.WithStack(sdk.ErrUnsupportedOSArchPlugin)
	}

	if err := storageDriver.Delete(ctx, oldBinary); err != nil {
		log.Error(ctx, "UpdateBinary> unable to delete %+v", oldBinary)
	}

	objectPath, err := storageDriver.Store(b, r)
	if err != nil {
		return err
	}

	b.ObjectPath = objectPath
	p.Binaries[index] = *b

	return Update(db, p)
}