vsphere/tags_helper.go
func (p *tagDiffProcessor) processAttachOperations() error {
	tagIDs := p.diffNewOld()
	if len(tagIDs) < 1 {
		// Nothing to do
		return nil
	}
	for _, tagID := range tagIDs {
		objID := p.subject.Reference().Value
		objType, err := tagTypeForObject(p.subject)
		if err != nil {
			return err
		}
		ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
		defer cancel()
		log.Printf("[DEBUG] Attaching tag %q for object %q", tagID, objID)
		if err := p.client.AttachTagToObject(ctx, tagID, objID, objType); err != nil {
			return err
		}
	}
	return nil
}
func (p *tagDiffProcessor) processAttachOperations() error {
	tagIDs := p.diffNewOld()
	if len(tagIDs) < 1 {
		// Nothing to do
		return nil
	}
	for _, tagID := range tagIDs {
		objID := p.subject.Reference().Value
		objType, err := tagTypeForObject(p.subject)
		if err != nil {
			return err
		}
		ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
		defer cancel()
		log.Printf("[DEBUG] Attaching tag %q for object %q", tagID, objID)
		if err := p.client.AttachTagToObject(ctx, tagID, objID, objType); err != nil {
			return err
		}
	}
	return nil
}
func ( p * tagDiffProcessor ) processAttachOperations ( ) error { tagIDs := p . diffNewOld ( ) if len ( tagIDs ) < 1 { // Nothing to do return nil } for _ , tagID := range tagIDs { objID := p . subject . Reference ( ) . Value objType , err := tagTypeForObject ( p . subject ) if err != nil { return err } ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultAPITimeout ) defer cancel ( ) log . Printf ( " " , tagID , objID ) if err := p . client . AttachTagToObject ( ctx , tagID , objID , objType ) ; err != nil { return err } } return nil }
// processAttachOperations processes all pending attach operations by diffing old
// and new and adding any IDs that were not found in old.
processAttachOperations processes all pending attach operations by diffing old and new and adding any IDs that were not found in old .