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: enableha.go
    path of file: ./repos/juju/state
    
    the code of the file until where you have to start completion: // Copyright 2018 Canonical Ltd.
// Licensed under the AGPLv3, see LICENC
    
func (c *controllerNode) SetAgentVersion(v version.Binary) (err error) {
	defer errors.DeferredAnnotatef(&err, "cannot set agent version for controller %s", c.Id())
	if err := checkVersionValidity(v); err != nil {
		return err
	}
	binaryVersion := &tools.Tools{Version: v}
	ops := []txn.Op{{
		C:      controllerNodesC,
		Id:     c.doc.DocID,
		Assert: notDeadDoc,
		Update: bson.D{{"$set", bson.D{{"agent-version", binaryVersion}}}},
	}}
	// A "raw" transaction is needed here because this function gets
	// called before database migrations have run so we don't
	// necessarily want the model UUID added to the id.
	if err := c.st.runRawTransaction(ops); err != nil {
		return errors.Trace(err)
	}
	c.doc.AgentVersion = binaryVersion
	return nil
}