github.com/cyverse/go-irodsclient@v0.13.2/examples/get_ticket/get_ticket.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"os"
     7  
     8  	"github.com/cyverse/go-irodsclient/fs"
     9  	"github.com/cyverse/go-irodsclient/irods/session"
    10  	"github.com/cyverse/go-irodsclient/irods/types"
    11  
    12  	log "github.com/sirupsen/logrus"
    13  )
    14  
    15  func main() {
    16  	logger := log.WithFields(log.Fields{
    17  		"package":  "main",
    18  		"function": "main",
    19  	})
    20  
    21  	// Parse cli parameters
    22  	flag.Parse()
    23  	args := flag.Args()
    24  
    25  	if len(args) != 1 {
    26  		fmt.Fprintf(os.Stderr, "Give an iRODS ticket!\n")
    27  		os.Exit(1)
    28  	}
    29  
    30  	ticketName := args[0]
    31  
    32  	// Read account configuration from YAML file
    33  	yaml, err := os.ReadFile("account.yml")
    34  	if err != nil {
    35  		logger.Error(err)
    36  		panic(err)
    37  	}
    38  
    39  	account, err := types.CreateIRODSAccountFromYAML(yaml)
    40  	if err != nil {
    41  		logger.Error(err)
    42  		panic(err)
    43  	}
    44  
    45  	logger.Debugf("Account : %v", account.MaskSensitiveData())
    46  
    47  	// Create a file system
    48  	appName := "get_ticket"
    49  	config := fs.NewFileSystemConfigWithDefault(appName)
    50  	sessConfig := session.NewIRODSSessionConfig(config.ApplicationName, config.ConnectionErrorTimeout, config.ConnectionInitNumber, config.ConnectionLifespan, config.OperationTimeout, config.ConnectionIdleTimeout, config.ConnectionMax, config.TCPBufferSize, config.StartNewTransaction)
    51  	sess, err := session.NewIRODSSession(account, sessConfig)
    52  	if err != nil {
    53  		logger.Error(err)
    54  		panic(err)
    55  	}
    56  
    57  	defer sess.Release()
    58  
    59  	/*
    60  		conn, err := sess.AcquireConnection()
    61  		if err != nil {
    62  			logger.Error(err)
    63  			panic(err)
    64  		}
    65  
    66  		ticket, err := irods_fs.GetTicket(conn, ticketName)
    67  		if err != nil {
    68  			logger.Error(err)
    69  			panic(err)
    70  		}
    71  	*/
    72  	fmt.Printf("> Ticket: %s\n", ticketName)
    73  	/*
    74  		fmt.Printf("%s\n", ticket.ToString())
    75  	*/
    76  }