github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/domain/query.go (about) 1 package domain 2 3 import ( 4 "fmt" 5 6 "github.com/pterm/pterm" 7 structureSpec "github.com/taubyte/go-specs/structure" 8 resources "github.com/taubyte/tau-cli/cli/commands/resources/common" 9 "github.com/taubyte/tau-cli/cli/common" 10 domainI18n "github.com/taubyte/tau-cli/i18n/domain" 11 domainLib "github.com/taubyte/tau-cli/lib/domain" 12 domainPrompts "github.com/taubyte/tau-cli/prompts/domain" 13 domainTable "github.com/taubyte/tau-cli/table/domain" 14 ) 15 16 func (link) Query() common.Command { 17 return (&resources.Query[*structureSpec.Domain]{ 18 LibListResources: domainLib.ListResources, 19 TableList: domainTable.List, 20 PromptsGetOrSelect: domainPrompts.GetOrSelect, 21 22 // Wrapping TableQuery to display registration information 23 TableQuery: func(domain *structureSpec.Domain) { 24 domainTable.Query(domain) 25 26 validator, err := domainLib.NewValidator(domain.Name) 27 if err != nil { 28 pterm.Warning.Println(domainI18n.NewDomainValidatorFailed(domain.Name, err).Error()) 29 return 30 } 31 32 isGeneratedFqdn, err := domainLib.IsAGeneratedFQDN(domain.Fqdn) 33 if err != nil { 34 pterm.Error.Printfln(domainI18n.IsGeneratedFQDNFailed(domain.Fqdn, err).Error()) 35 return 36 } 37 if isGeneratedFqdn { 38 return 39 } 40 41 clientResponse, err := validator.ValidateFQDN(domain.Fqdn) 42 if err != nil { 43 pterm.Warning.Println(domainI18n.ValidateFQDNFailed(domain.Fqdn, err).Error()) 44 return 45 } 46 // Display the register table without showing the `add to dns entry help` 47 fmt.Println(domainTable.GetRegisterTable(clientResponse)) 48 }, 49 }).Default() 50 } 51 52 func (link) List() common.Command { 53 return (&resources.List[*structureSpec.Domain]{ 54 LibListResources: domainLib.ListResources, 55 TableList: domainTable.List, 56 }).Default() 57 }