github.com/cyverse/go-irodsclient@v0.13.2/examples/create_ticket/create_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/types" 10 11 log "github.com/sirupsen/logrus" 12 ) 13 14 func main() { 15 logger := log.WithFields(log.Fields{ 16 "package": "main", 17 "function": "main", 18 }) 19 20 // Parse cli parameters 21 flag.Parse() 22 args := flag.Args() 23 24 if len(args) < 2 { 25 fmt.Fprintf(os.Stderr, "Give a ticket type and an iRODS path!\n") 26 os.Exit(1) 27 } 28 29 ticketType := args[0] 30 irodsPath := args[1] 31 ticketName := "" 32 if len(args) >= 3 { 33 ticketName = args[2] 34 } 35 36 // Read account configuration from YAML file 37 yaml, err := os.ReadFile("account.yml") 38 if err != nil { 39 logger.Error(err) 40 panic(err) 41 } 42 43 account, err := types.CreateIRODSAccountFromYAML(yaml) 44 if err != nil { 45 logger.Error(err) 46 panic(err) 47 } 48 49 logger.Debugf("Account : %v", account.MaskSensitiveData()) 50 51 // Create a file system 52 appName := "create_ticket" 53 filesystem, err := fs.NewFileSystemWithDefault(account, appName) 54 if err != nil { 55 logger.Error(err) 56 panic(err) 57 } 58 59 defer filesystem.Release() 60 61 err = filesystem.CreateTicket(ticketName, types.TicketType(ticketType), irodsPath) 62 if err != nil { 63 logger.Error(err) 64 panic(err) 65 } 66 }