Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
feat: #164 initial models for collections
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Feb 12, 2022
1 parent 4a558a9 commit 02ffceb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 29 deletions.
34 changes: 34 additions & 0 deletions server-go/collection/entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package collection

import (
"github.com/riotkit-org/backup-repository/config"
"github.com/riotkit-org/backup-repository/security"
)

type StrategySpec struct {
KeepLastOlderNotMoreThan string `json:"keepLastOlderNotMoreThan"`
MaxOlderCopies int `json:"maxOlderCopies"`
}

type BackupWindow struct {
From string `json:"from"`
Duration string `json:"duration"`
}

type BackupWindows []BackupWindow

type Spec struct {
Description string `json:"description"`
FilenameTemplate string `json:"filenameTemplate"`
MaxBackupsCount int `json:"maxBackupsCount"`
MaxOneVersionSize string `json:"maxOneVersionSize"`
MaxCollectionSize string `json:"maxCollectionSize"`
Windows BackupWindows `json:"windows"`
StrategyName string `json:"strategyName"`
StrategySpec StrategySpec `json:"strategySpec"`
AccessControl security.AccessControlList `json:"accessControl"`
}

type Collection struct {
Metadata config.ObjectMetadata `json:"metadata"`
}
6 changes: 3 additions & 3 deletions server-go/docs/examples/collection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: iwa-ait
spec:
description: IWA-AIT website files
filename: iwa-ait.tar.gz
filenameTemplate: iwa-ait-${version}.tar.gz
maxBackupsCount: 5
maxOneVersionSize: 10G
maxCollectionSize: 55G
Expand All @@ -16,12 +16,12 @@ spec:
duration: 1h

# fifo, fifo-plus-older
strategy: fifo-plus-older
strategyName: fifo-plus-older
strategySpec:
keepLastOlderNotMoreThan: 5d
maxOlderCopies: 2

accessControl:
- name: admin
- userName: admin
roles:
- collectionManager
19 changes: 7 additions & 12 deletions server-go/docs/examples/dynamic/access.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
apiVersion: backups.riotkit.org/v1alpha1
kind: GrantedAccess
metadata:
# hash of the JWT
name: 39671096ba800ca9b238c7c01b053fa0d5d09ca3151e050d148ddfffaefa9466ceba75d47c2098a0f72110aea4deeb24f6cd1b31f27e27aa6fe7b82dad956049
spec:
user: admin
expiresAt: "2022-01-01 08:00"
active: true
description: "Temporary token for single file upload"
requesterIP: "1.2.3.4"
# hash of the JWT
id: 39671096ba800ca9b238c7c01b053fa0d5d09ca3151e050d148ddfffaefa9466ceba75d47c2098a0f72110aea4deeb24f6cd1b31f27e27aa6fe7b82dad956049
user: admin
expiresAt: "2022-01-01 08:00"
active: true
description: "Temporary token for single file upload"
requesterIP: "1.2.3.4"
20 changes: 6 additions & 14 deletions server-go/docs/examples/dynamic/version.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
---
apiVersion: backups.riotkit.org/v1alpha1
kind: BackupVersion
metadata:
name: iwa-ait-1
labels:
backups.riotkit.org/collection: iwa-ait
spec:
selector:
name: iwa-ait
version: 1
filename: iwa-ait-v1.tar.gz
uploadDate: "2022-01-01 06:30"
uploadedBy: admin
name: 7a9ecd01-8dec-4be2-8ece-e2a6047e4ffd
collectionId: iwa-ait
version: 1
filename: iwa-ait-v1.tar.gz
uploadDate: "2022-01-01 06:30"
uploadedBy: admin
15 changes: 15 additions & 0 deletions server-go/security/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"time"
)

//
// User permissions
//

type Permissions []string

func (p Permissions) HasRole(name string) bool {
Expand All @@ -22,6 +26,17 @@ func (p Permissions) has(name string) bool {
return false
}

//
// Permissions for objects
//

type AccessControlObject struct {
UserName string `json:"userName"`
Roles []Permissions `json:"roles"`
}

type AccessControlList []AccessControlObject

//
// GrantedAccess stores information about generated JWT tokens (successful logins to the system)
//
Expand Down

0 comments on commit 02ffceb

Please sign in to comment.