github.com/Axway/agent-sdk@v1.1.101/pkg/cmd/agentsync/cmdprops.go (about)

     1  package agentsync
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Axway/agent-sdk/pkg/cmd/properties"
     7  )
     8  
     9  const syncFlag = "synchronize"
    10  
    11  var syncMode = false
    12  
    13  // IsSyncMode - returns true when synchronize flag passed in
    14  func IsSyncMode() bool {
    15  	return syncMode
    16  }
    17  
    18  // SetSyncMode - checks for the syncFlag, if present sets IsSyncMode to true
    19  func SetSyncMode(props properties.Properties) {
    20  	if val := props.BoolFlagValue(syncFlag); val {
    21  		syncMode = val
    22  	}
    23  }
    24  
    25  // CheckSyncFlag - checks to see if the sync flag was used and runs the ProcessSynchronization.
    26  //   If return is 0 or greater exit should happen, with return as exitcode
    27  func CheckSyncFlag() int {
    28  	if syncMode {
    29  		// Call sync commands
    30  		err := agentSync.ProcessSynchronization()
    31  		if err != nil {
    32  			fmt.Printf("ERROR: %s\n", err.Error())
    33  			return 1
    34  		}
    35  		return 0
    36  	}
    37  	return -1
    38  }
    39  
    40  // AddSyncConfigProperties - Adds the flag needed for Sync Process Config
    41  func AddSyncConfigProperties(props properties.Properties) {
    42  	props.AddBoolFlag(syncFlag, "Run the sync process for the discovery agent")
    43  }