github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/prompts/domain/new.go (about) 1 package domainPrompts 2 3 import ( 4 structureSpec "github.com/taubyte/go-specs/structure" 5 domainLib "github.com/taubyte/tau-cli/lib/domain" 6 "github.com/taubyte/tau-cli/prompts" 7 "github.com/urfave/cli/v2" 8 ) 9 10 func New(ctx *cli.Context) (*structureSpec.Domain, error) { 11 domain := &structureSpec.Domain{} 12 13 taken, err := domainLib.List() 14 if err != nil { 15 return nil, err 16 } 17 18 domain.Name = prompts.GetOrRequireAUniqueName(ctx, NamePrompt, taken) 19 domain.Description = prompts.GetOrAskForADescription(ctx) 20 domain.Tags = prompts.GetOrAskForTags(ctx) 21 22 if GetGeneratedFQDN(ctx) { 23 generatedPrefix := GetGeneratedFQDNPrefix(ctx) 24 25 domain.Fqdn, err = domainLib.NewGeneratedFQDN(generatedPrefix) 26 if err != nil { 27 return nil, err 28 } 29 } else { 30 domain.Fqdn = GetOrRequireAnFQDN(ctx) 31 } 32 33 err = certificate(ctx, domain, true) 34 if err != nil { 35 return nil, err 36 } 37 38 return domain, nil 39 }