aboutsummaryrefslogtreecommitdiff
path: root/website.go
diff options
context:
space:
mode:
Diffstat (limited to 'website.go')
-rw-r--r--website.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/website.go b/website.go
index 2cad12c..74daf89 100644
--- a/website.go
+++ b/website.go
@@ -17,6 +17,8 @@ var (
ErrCantConfigureBucket = fmt.Errorf("Unable to configure the bucket (activating website, adding quotas, etc.)")
ErrBucketDeleteNotEmpty = fmt.Errorf("You must remove all the files before deleting a bucket")
ErrBucketDeleteUnfinishedUpload = fmt.Errorf("You must remove all the unfinished multipart uploads before deleting a bucket")
+ ErrCantChangeVhost = fmt.Errorf("Can't change the vhost to the desired value. Maybe it's already used by someone else or an internal error occured")
+ ErrCantRemoveOldVhost = fmt.Errorf("The new vhost is bound to the bucket but the old one can't be removed, this is an internal error")
)
type WebsiteId struct {
@@ -141,12 +143,24 @@ func (w *WebsiteController) Patch(pretty string, patch *WebsitePatch) (*WebsiteV
ur := garage.NewUpdateBucketRequest()
ur.SetQuotas(*urQuota)
- // Call garage
+ // Call garage "update bucket" function
binfo, err = grgUpdateBucket(website.Internal, ur)
if err != nil {
return nil, ErrCantConfigureBucket
}
+ // Update the alias if the vhost field is set and different
+ if patch.Vhost != nil && *patch.Vhost != "" && *patch.Vhost != pretty {
+ binfo, err = grgAddGlobalAlias(website.Internal, *patch.Vhost)
+ if err != nil {
+ return nil, ErrCantChangeVhost
+ }
+ binfo, err = grgDelGlobalAlias(website.Internal, pretty)
+ if err != nil {
+ return nil, ErrCantRemoveOldVhost
+ }
+ }
+
return NewWebsiteView(binfo), nil
}
@@ -233,4 +247,5 @@ func NewWebsiteView(binfo *garage.BucketInfo) *WebsiteView {
type WebsitePatch struct {
Size *int64 `json:"quota_size"`
+ Vhost *string `json:"vhost"`
}