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: extension.go
    path of file: ./repos/moby/vendor/github.com/moby/swarmkit/v2/manager/controlapi
    
    the code of the file until where you have to start completion: package controlapi

import (
	"context"
	"strings"

	"github.com/moby/swarmkit/v2/api"
	"github.com/moby/swarmkit/v2/identity"
	"github.com/moby/swarmkit/v2/log"
	"github.com/moby/swarmkit/v2/manager/state/store"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

// CreateExtension creates an `Extension` based on the provided `CreateExtensionRequest.Extension`
// and returns a `CreateExtensionResponse`.
//   - Returns `InvalidArgument` if the `CreateExtensionRequest.Extension` is malformed,
//     or fails validation.
//   - Returns an error if the creation fails.
func (s *Server) CreateExtension(ctx context.Context, request *api.CreateExtensionRequest
    
func (s *Server) CreateExtension(ctx context.Context, request *api.CreateExtensionRequest) (*api.CreateExtensionResponse, error) {
	if request.Annotations == nil || request.Annotations.Name == "" {
		return nil, status.Errorf(codes.InvalidArgument, "extension name must be provided")
	}

	extension := &api.Extension{
		ID:          identity.NewID(),
		Annotations: *request.Annotations,
		Description: request.Description,
	}

	err := s.store.Update(func(tx store.Tx) error {
		return store.CreateExtension(tx, extension)
	})

	switch err {
	case store.ErrNameConflict:
		return nil, status.Errorf(codes.AlreadyExists, "extension %s already exists", request.Annotations.Name)
	case nil:
		log.G(ctx).WithFields(log.Fields{
			"extension.Name": request.Annotations.Name,
			"method":         "CreateExtension",
		}).Debugf("extension created")

		return &api.CreateExtensionResponse{Extension: extension}, nil
	default:
		return nil, status.Errorf(codes.Internal, "could not create extension: %v", err.Error())
	}
}