vsphere/tags_helper.go
func tagsClientIfDefined(d *schema.ResourceData, meta interface{}) (*tags.RestClient, error) {
	old, new := d.GetChange(vSphereTagAttributeKey)
	if len(old.(*schema.Set).List()) > 0 || len(new.(*schema.Set).List()) > 0 {
		log.Printf("[DEBUG] tagsClientIfDefined: Loading tagging client")
		client, err := meta.(*VSphereClient).TagsClient()
		if err != nil {
			return nil, err
		}
		return client, nil
	}
	log.Printf("[DEBUG] tagsClientIfDefined: No tags configured, skipping loading of tagging client")
	return nil, nil
}
func tagsClientIfDefined(d *schema.ResourceData, meta interface{}) (*tags.RestClient, error) {
	old, new := d.GetChange(vSphereTagAttributeKey)
	if len(old.(*schema.Set).List()) > 0 || len(new.(*schema.Set).List()) > 0 {
		log.Printf("[DEBUG] tagsClientIfDefined: Loading tagging client")
		client, err := meta.(*VSphereClient).TagsClient()
		if err != nil {
			return nil, err
		}
		return client, nil
	}
	log.Printf("[DEBUG] tagsClientIfDefined: No tags configured, skipping loading of tagging client")
	return nil, nil
}
func tagsClientIfDefined ( d * schema . ResourceData , meta interface { } ) ( * tags . RestClient , error ) { old , new := d . GetChange ( vSphereTagAttributeKey ) if len ( old . ( * schema . Set ) . List ( ) ) > 0 || len ( new . ( * schema . Set ) . List ( ) ) > 0 { log . Printf ( " " ) client , err := meta . ( * VSphereClient ) . TagsClient ( ) if err != nil { return nil , err } return client , nil } log . Printf ( " " ) return nil , nil }
// tagsClientIfDefined goes through the client validation process and returns
// the tags client only if there are tags defined in the supplied ResourceData.
//
// This should be used to fetch the tagging REST client on resources that
// support tags, usually closer to the beginning of a CRUD function to check to
// make sure it's worth proceeding with most of the operation. The returned
// client should be checked for nil before passing it to processTagDiff.
tagsClientIfDefined goes through the client validation process and returns the tags client only if there are tags defined in the supplied ResourceData . This should be used to fetch the tagging REST client on resources that support tags usually closer to the beginning of a CRUD function to check to make sure it s worth proceeding with most of the operation . The returned client should be checked for nil before passing it to processTagDiff .