format
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Quentin 2023-09-26 08:40:41 +02:00
parent d8633d7fb8
commit 706ff58a6f
Signed by: quentin
GPG Key ID: E9602264D639FF68
8 changed files with 139 additions and 147 deletions

2
api.go
View File

@ -1,8 +1,8 @@
package main
import (
"errors"
"encoding/json"
"errors"
"fmt"
"github.com/gorilla/mux"
"net/http"

2
cli.go
View File

@ -3,9 +3,9 @@ package main
import (
"flag"
"fmt"
"golang.org/x/term"
"os"
"syscall"
"golang.org/x/term"
)
var fsCli = flag.NewFlagSet("cli", flag.ContinueOnError)

View File

@ -10,7 +10,6 @@ import (
"strings"
)
func gadmin() (*garage.APIClient, context.Context) {
// Set Host and other parameters
configuration := garage.NewConfiguration()
@ -47,8 +46,6 @@ func grgGetKey(accessKey string) (*garage.KeyInfo, error) {
return resp, nil
}
func grgCreateBucket(bucket string) (*garage.BucketInfo, error) {
client, ctx := gadmin()

View File

@ -112,6 +112,7 @@ type Capabilities struct {
CanAdmin bool
CanInvite bool
}
func NewCapabilities(login *LoginStatus, entry *ldap.Entry) *Capabilities {
// Initialize
canAdmin := false
@ -148,6 +149,7 @@ type LoggedUser struct {
Quota *UserQuota
s3key *garage.KeyInfo
}
func NewLoggedUser(login *LoginStatus) (*LoggedUser, error) {
requestKind := "(objectClass=organizationalPerson)"
if strings.EqualFold(login.Info.DN(), config.AdminAccount) {
@ -251,7 +253,6 @@ func RequireUser(r *http.Request) (*LoggedUser, error) {
return nil, ErrNotAuthenticated
}
loginStatus, err := NewLoginStatus(r, login_info)
if err != nil {
return nil, err

View File

@ -192,7 +192,6 @@ func logRequest(handler http.Handler) http.Handler {
// Page handlers ----
// --- Home Controller
type HomePageData struct {
User *LoggedUser

View File

@ -5,8 +5,8 @@ import (
"fmt"
"strconv"
"github.com/go-ldap/ldap/v3"
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
"github.com/go-ldap/ldap/v3"
)
const (
@ -107,6 +107,7 @@ type QuotaStat struct {
Ratio float64 `json:"ratio"`
Burstable bool `json:"burstable"`
}
func NewQuotaStat(current, max int64, burstable bool) QuotaStat {
return QuotaStat{
Current: current,

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
"sort"
"strings"
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
)
var (
@ -19,16 +19,14 @@ var (
ErrBucketDeleteUnfinishedUpload = fmt.Errorf("You must remove all the unfinished multipart uploads before deleting a bucket")
)
type WebsiteId struct {
Pretty string `json:"name"`
Internal string `json:"-"`
Alt []string `json:"alt_name"`
Expanded bool `json:"expanded"`
Url string `json:"domain"`
}
func NewWebsiteId(id string, aliases []string) *WebsiteId {
pretty := id
var alt []string
@ -65,7 +63,7 @@ func NewWebsiteController(user *LoggedUser) (*WebsiteController, error) {
return nil, err
}
for _, bckt := range(keyInfo.Buckets) {
for _, bckt := range keyInfo.Buckets {
if len(bckt.GlobalAliases) > 0 {
wid := NewWebsiteId(*bckt.Id, bckt.GlobalAliases)
idx[wid.Pretty] = wid
@ -183,7 +181,6 @@ func (w *WebsiteController) Create(pretty string) (*WebsiteView, error) {
ur.SetWebsiteAccess(*wr)
ur.SetQuotas(*qr)
binfo, err = grgUpdateBucket(*binfo.Id, ur)
if err != nil {
return nil, ErrCantConfigureBucket
@ -219,9 +216,6 @@ func (w *WebsiteController) Delete(pretty string) error {
return err
}
type WebsiteView struct {
Name *WebsiteId `json:"identified_as"`
Size QuotaStat `json:"quota_size"`