Skip to content

Commit

Permalink
Fix initial app deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Jun 16, 2021
1 parent dca79e5 commit e2b4936
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ var deployCmd = &cobra.Command{
domain, err = config.GetDomain(*server, domainName)
if err != nil {
fmt.Printf("Creating the domain %s...\n", domainName)
err = actions.DomainAdd(*server, domainName, types.ServerIPAddresses{
err = actions.DomainAdd(server, domainName, types.ServerIPAddresses{
IPv4: []string{defaultIp},
})
if err != nil {
return err
}
fmt.Println("Domain has been created.")
domain, err = config.GetDomain(*server, domainName)
if err != nil {
return err
}
} else {
fmt.Printf("Domain %s has been found.\n", domainName)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/domains/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var createCmd = &cobra.Command{
}

cmd.SilenceUsage = true
err = actions.DomainAdd(*server, args[1], ips)
err = actions.DomainAdd(server, args[1], ips)

if err == nil {
utils.Log.PrintL("domain.create.success", args[1])
Expand Down
4 changes: 2 additions & 2 deletions internal/actions/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func DatabaseAdd(host types.Server, domain types.Domain, dbs types.DatabaseServe
DatabaseServerID: newdb.DatabaseServerID,
})

config.SetDomain(host, domain)
config.SetDomain(&host, domain)
return nil
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func DatabaseDeploy(host types.Server, domain types.Domain, db types.Database, f
}

domain.DatabaseUsers = append(domain.DatabaseUsers, *dbu)
config.SetDomain(host, domain)
config.SetDomain(&host, domain)
}

var s *string
Expand Down
4 changes: 2 additions & 2 deletions internal/actions/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func validateIps(val types.ServerIPAddresses, comp types.ServerIPAddresses) (boo
return v4Valid, v6Valid
}

func DomainAdd(host types.Server, domain string, ipa types.ServerIPAddresses) error {
_, err := config.GetDomain(host, domain)
func DomainAdd(host *types.Server, domain string, ipa types.ServerIPAddresses) error {
_, err := config.GetDomain(*host, domain)
if err == nil {
return errors.New(locales.L.Get("errors.domain.already.exists", domain))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/actions/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func FtpUserCreate(host types.Server, domain types.Domain, user *types.FtpUser)
}

domain.FTPUsers = append(domain.FTPUsers, *user)
config.SetDomain(host, domain)
config.SetDomain(&host, domain)

return user, nil
}
6 changes: 3 additions & 3 deletions internal/config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func DeleteDatabase(host types.Server, dbn string) {
}

if domain != nil {
SetDomain(host, *domain)
SetDomain(&host, *domain)
}
}

Expand All @@ -162,7 +162,7 @@ func SetDomains(host *types.Server, newData []types.Domain) {
SetServers(append([]types.Server{*host}, servers...))
}

func SetDomain(host types.Server, domain types.Domain) {
func SetDomain(host *types.Server, domain types.Domain) {
domains, _ := utils.FilterDomains(host.Domains, domain.Name)
SetDomains(&host, append(domains, domain))
SetDomains(host, append(domains, domain))
}

0 comments on commit e2b4936

Please sign in to comment.