github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/generic/deleteprops.go (about)

     1  package generic
     2  
     3  import (
     4  	"github.com/jfrog/jfrog-client-go/utils/errorutils"
     5  )
     6  
     7  type DeletePropsCommand struct {
     8  	PropsCommand
     9  }
    10  
    11  func NewDeletePropsCommand() *DeletePropsCommand {
    12  	return &DeletePropsCommand{}
    13  }
    14  
    15  func (deleteProps *DeletePropsCommand) DeletePropsCommand(command PropsCommand) *DeletePropsCommand {
    16  	deleteProps.PropsCommand = command
    17  	return deleteProps
    18  }
    19  
    20  func (deleteProps *DeletePropsCommand) CommandName() string {
    21  	return "rt_delete_properties"
    22  }
    23  
    24  func (deleteProps *DeletePropsCommand) Run() error {
    25  	rtDetails, err := deleteProps.RtDetails()
    26  	if errorutils.CheckError(err) != nil {
    27  		return err
    28  	}
    29  	servicesManager, err := createPropsServiceManager(deleteProps.threads, rtDetails)
    30  	if err != nil {
    31  		return err
    32  	}
    33  
    34  	resultItems, searchErr := searchItems(deleteProps.Spec(), servicesManager)
    35  
    36  	propsParams := GetPropsParams(resultItems, deleteProps.props)
    37  	success, err := servicesManager.DeleteProps(propsParams)
    38  	result := deleteProps.Result()
    39  	result.SetSuccessCount(success)
    40  	result.SetFailCount(len(resultItems) - success)
    41  	if err == nil {
    42  		return searchErr
    43  	}
    44  	return err
    45  }