in src/go/cmd/cachewarmer/cachewarmer-worker/main.go [29:89]
func initializeApplicationVariables(ctx context.Context) *cachewarmer.Worker {
var enableDebugging = flag.Bool("enableDebugging", false, "enable debug logging")
var storageAccountResourceGroup = flag.String("storageAccountResourceGroup", "", "the storage account resource group")
var storageAccount = flag.String("storageAccountName", "", "the storage account name to host the queue")
var storageKey = flag.String("storageKey", "", "the storage key to access the queue")
var queueNamePrefix = flag.String("queueNamePrefix", "", "the queue name to be used for organizing the work. The queues will be created automatically")
flag.Parse()
if *enableDebugging {
log.EnableDebugging()
}
if len(*storageAccount) == 0 {
fmt.Fprintf(os.Stderr, "ERROR: storageAccount is not specified\n")
usage()
os.Exit(1)
}
if len(*storageAccountResourceGroup) == 0 && len(*storageKey) == 0 {
fmt.Fprintf(os.Stderr, "ERROR: storageAccountResourceGroup or storageKey must be specified\n")
usage()
os.Exit(1)
}
if len(*queueNamePrefix) == 0 {
fmt.Fprintf(os.Stderr, "ERROR: queueNamePrefix is not specified\n")
usage()
os.Exit(1)
}
if isValid, errorMessage := azure.ValidateQueueName(*queueNamePrefix); isValid == false {
fmt.Fprintf(os.Stderr, "ERROR: queueNamePrefix is not valid: %s\n", errorMessage)
usage()
os.Exit(1)
}
storageAccountKey := ""
if len(*storageKey) != 0 {
storageAccountKey = *storageKey
} else {
primaryKey, err := cachewarmer.GetPrimaryStorageKey(ctx, *storageAccountResourceGroup, *storageAccount)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: unable to get storage account key: %s", err)
os.Exit(1)
}
storageAccountKey = primaryKey
}
cacheWarmerQueues, err := cachewarmer.InitializeCacheWarmerQueues(
ctx,
*storageAccount,
storageAccountKey,
*queueNamePrefix)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: error initializing queue %v\n", err)
os.Exit(1)
}
return cachewarmer.InitializeWorker(cacheWarmerQueues)
}