-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): impl bucket creation api
- Loading branch information
Showing
5 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Module } from '@nestjs/common' | ||
import { BucketsService } from './buckets.service' | ||
import { BucketsController } from './buckets.controller' | ||
import { ApplicationsService } from 'src/applications/applications.service' | ||
|
||
@Module({ | ||
controllers: [BucketsController], | ||
providers: [BucketsService], | ||
providers: [BucketsService, ApplicationsService], | ||
}) | ||
export class BucketsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
export class CreateBucketDto {} | ||
import { BucketPolicy } from '../entities/bucket.entity' | ||
|
||
export class CreateBucketDto { | ||
shortName: string | ||
appid: string | ||
policy: BucketPolicy | ||
storage: string | ||
|
||
get name() { | ||
return `${this.appid}-${this.shortName}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,61 @@ | ||
export class Bucket {} | ||
import { KubernetesObject, V1ObjectMeta } from '@kubernetes/client-node' | ||
import { Condition } from '../../core/kubernetes.interface' | ||
|
||
export class Bucket { | ||
static readonly Group = 'oss.laf.dev' | ||
static readonly Version = 'v1' | ||
static readonly PluralName = 'buckets' | ||
static readonly Kind = 'Bucket' | ||
static get GroupVersion() { | ||
return `${Bucket.Group}/${Bucket.Version}` | ||
} | ||
|
||
static create(name: string, namespace: string, spec?: IBucketSpec) { | ||
const data: IBucket = { | ||
apiVersion: Bucket.GroupVersion, | ||
kind: Bucket.Kind, | ||
metadata: new V1ObjectMeta(), | ||
spec: spec, | ||
} | ||
data.metadata.name = name | ||
data.metadata.namespace = namespace | ||
return data | ||
} | ||
} | ||
export enum BucketPolicy { | ||
Private = 'private', | ||
ReadOnly = 'readonly', | ||
Public = 'readwrite', | ||
} | ||
|
||
export interface IBucket extends KubernetesObject { | ||
spec: IBucketSpec | ||
status?: IBucketStatus | ||
} | ||
|
||
export interface IBucketSpec { | ||
policy: BucketPolicy | ||
storage: string | ||
} | ||
|
||
export interface IBucketStatus { | ||
// username of bucket in oss | ||
user: string | ||
policy: BucketPolicy | ||
versioning: boolean | ||
capacity: IBucketCapacity | ||
// type: Ready | ||
conditions: Condition[] | ||
} | ||
|
||
export interface IBucketCapacity { | ||
maxStorage: string | ||
// used storage | ||
storage: string | ||
objectCount: number | ||
} | ||
|
||
export interface IBucketList { | ||
apiVersion: string | ||
items: IBucket[] | ||
} |