fix(big fix upgrade): upgrade multiple areas of the core functionalities
This commit is contained in:
@ -4,6 +4,7 @@ import { Cloudly } from '../classes.cloudly.js';
|
||||
import { logger } from '../logger.js';
|
||||
|
||||
import { Cluster } from './classes.cluster.js';
|
||||
import { data } from '@serve.zone/interfaces';
|
||||
|
||||
export class ClusterManager {
|
||||
public ready = plugins.smartpromise.defer();
|
||||
@ -26,10 +27,8 @@ export class ClusterManager {
|
||||
const cluster = await this.createCluster({
|
||||
id: plugins.smartunique.uniSimple('cluster'),
|
||||
data: {
|
||||
userId: null,
|
||||
userId: null, // this is created by the createCluster method
|
||||
name: dataArg.clusterName,
|
||||
initialJumpToken: plugins.smartunique.uniSimple('initialJumpToken'),
|
||||
initialJumpTokenUsedAt: null,
|
||||
acmeInfo: null,
|
||||
cloudlyUrl: `https://${this.cloudlyRef.config.data.publicUrl}:${this.cloudlyRef.config.data.publicPort}/`,
|
||||
servers: [],
|
||||
@ -82,19 +81,17 @@ export class ClusterManager {
|
||||
// TODO: implement getclusterConfigByServerIp
|
||||
}
|
||||
|
||||
public async getClusterBy_JumpCode(initialJumpTokenArg: string) {
|
||||
public async getClusterBy_UserId(userIdArg: string) {
|
||||
await this.ready.promise;
|
||||
|
||||
return await Cluster.getInstance({
|
||||
data: {
|
||||
initialJumpToken: initialJumpTokenArg,
|
||||
userId: userIdArg,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public async getClusterBy_Identity(
|
||||
clusterIdentity: plugins.servezoneInterfaces.data.IIdentity
|
||||
) {
|
||||
public async getClusterBy_Identity(clusterIdentity: plugins.servezoneInterfaces.data.IIdentity) {
|
||||
await this.ready.promise;
|
||||
|
||||
return await Cluster.getInstance({
|
||||
@ -125,19 +122,27 @@ export class ClusterManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* allows storage of a config
|
||||
* creates a cluster (and a new user for it) and saves it
|
||||
* @param configName
|
||||
* @param configObjectArg
|
||||
*/
|
||||
public async createCluster(configObjectArg: plugins.servezoneInterfaces.data.ICluster) {
|
||||
// TODO: guards
|
||||
// lets create the cluster user
|
||||
const clusterUser = new this.cloudlyRef.authManager.CUser();
|
||||
clusterUser.id = await this.cloudlyRef.authManager.CUser.getNewId();
|
||||
clusterUser.data = {
|
||||
role: 'cluster',
|
||||
type: 'machine',
|
||||
}
|
||||
const clusterUser = new this.cloudlyRef.authManager.CUser({
|
||||
id: await this.cloudlyRef.authManager.CUser.getNewId(),
|
||||
data: {
|
||||
role: 'cluster',
|
||||
type: 'machine',
|
||||
tokens: [
|
||||
{
|
||||
expiresAt: Date.now() + 3600 * 1000 * 24 * 365,
|
||||
assignedRoles: ['cluster'],
|
||||
token: await this.cloudlyRef.authManager.createNewSecureToken(),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
await clusterUser.save();
|
||||
Object.assign(configObjectArg, {
|
||||
userId: clusterUser.id,
|
||||
|
Reference in New Issue
Block a user