diff --git a/src/channel/channel.service.ts b/src/channel/channel.service.ts index 55f234a..77ddc90 100644 --- a/src/channel/channel.service.ts +++ b/src/channel/channel.service.ts @@ -55,9 +55,10 @@ export class ChannelService { ): Promise { const { name, description, initiator, organizations, peers, policy } = channel; - const members = (organizations || []) - .concat(initiator) - .map((d) => ({ name: d, initiator: d === initiator })); + const members = uniq((organizations || []).concat(initiator)).map((d) => ({ + name: d, + initiator: d === initiator, + })); const k8s = await this.k8sService.getClient(auth); const { body } = await k8s.channel.create({ metadata: { diff --git a/src/channel/models/channel.model.ts b/src/channel/models/channel.model.ts index f24b0d8..9daba4e 100644 --- a/src/channel/models/channel.model.ts +++ b/src/channel/models/channel.model.ts @@ -1,7 +1,7 @@ import { Field, ID, ObjectType } from '@nestjs/graphql'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; import { SpecMember } from 'src/common/models/spec-member.model'; import { Epolicy } from 'src/epolicy/models/epolicy.model'; -import { ChannelStatus } from './channel-status.enum'; import { SpecPeer } from './spec-peer.model'; @ObjectType() @@ -25,7 +25,7 @@ export class Channel { creationTimestamp?: string; /** 状态 */ - @Field(() => ChannelStatus, { description: '状态' }) + @Field(() => CrdStatusType, { description: '状态' }) status?: string; /** 我创建的 */ diff --git a/src/organization/models/status-type.enum.ts b/src/common/models/crd-statue-type.enum.ts similarity index 77% rename from src/organization/models/status-type.enum.ts rename to src/common/models/crd-statue-type.enum.ts index b9dddd6..a91e9b1 100644 --- a/src/organization/models/status-type.enum.ts +++ b/src/common/models/crd-statue-type.enum.ts @@ -1,6 +1,6 @@ import { registerEnumType } from '@nestjs/graphql'; -export enum StatusType { +export enum CrdStatusType { Deploying = 'Deploying', Deployed = 'Deployed', Precreated = 'Precreated', @@ -14,10 +14,12 @@ export enum StatusType { FederationDissolved = 'FederationDissolved', NetworkCreated = 'NetworkCreated', NetworkDissolved = 'NetworkDissolved', + ChannelCreated = 'ChannelCreated', + ChannelArchived = 'ChannelArchived', } -registerEnumType(StatusType, { - name: 'StatusType', +registerEnumType(CrdStatusType, { + name: 'CrdStatusType', description: 'IBPCR 状态', valuesMap: { Deploying: { @@ -46,16 +48,16 @@ registerEnumType(StatusType, { description: '正常', }, FederationPending: { - description: 'FederationPending means `Proposal-Vote` not passed yet', + description: '组建中', }, FederationActivated: { - description: 'FederationActivated means `Proposal-Vote` passed', + description: '已激活', }, FederationFailed: { - description: 'FederationFailed means `Proposal-Vote` failed', + description: '组建失败', }, FederationDissolved: { - description: 'FederationDissolved means `Federation` no longer active', + description: '已解散', }, NetworkCreated: { description: '正常', @@ -63,5 +65,11 @@ registerEnumType(StatusType, { NetworkDissolved: { description: '已解散', }, + ChannelCreated: { + description: 'ChannelCreated', + }, + ChannelArchived: { + description: 'ChannelArchived', + }, }, }); diff --git a/src/federation/federation.service.ts b/src/federation/federation.service.ts index 922f278..cb8d204 100644 --- a/src/federation/federation.service.ts +++ b/src/federation/federation.service.ts @@ -10,10 +10,10 @@ import { CRD } from 'src/kubernetes/lib'; import { NewFederationInput } from './dto/new-federation.input'; import { ProposalService } from 'src/proposal/proposal.service'; import { ProposalType } from 'src/proposal/models/proposal-type.enum'; -import { FederationStatus } from './models/federation-status.enum'; import { K8sV1Status } from 'src/common/models/k8s-v1-status.model'; import { OrganizationService } from 'src/organization/organization.service'; import { uniq } from 'lodash'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; @Injectable() export class FederationService { @@ -200,7 +200,7 @@ export class FederationService { async deleteFederation(auth: JwtAuth, name: string): Promise { const detail = await this.federation(auth, name); - if (detail?.status !== FederationStatus.FederationDissolved) { + if (detail?.status !== CrdStatusType.FederationDissolved) { throw new InternalServerErrorException( 'Only dissolved federation can be deleted.', ); diff --git a/src/federation/models/federation-status.enum.ts b/src/federation/models/federation-status.enum.ts deleted file mode 100644 index 5100921..0000000 --- a/src/federation/models/federation-status.enum.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum FederationStatus { - FederationPending = 'FederationPending', - FederationActivated = 'FederationActivated', - FederationFailed = 'FederationFailed', - FederationDissolved = 'FederationDissolved', - Error = 'Error', -} - -registerEnumType(FederationStatus, { - name: 'FederationStatus', - description: '「联盟」状态', - valuesMap: { - FederationPending: { - description: '组建中', - }, - FederationActivated: { - description: '已激活', - }, - FederationFailed: { - description: '组建失败', - }, - FederationDissolved: { - description: '已解散', - }, - Error: { - description: '失败', - }, - }, -}); diff --git a/src/federation/models/federation.model.ts b/src/federation/models/federation.model.ts index 58bfd6c..6960ebe 100644 --- a/src/federation/models/federation.model.ts +++ b/src/federation/models/federation.model.ts @@ -1,9 +1,9 @@ import { ObjectType, Field, ID, HideField } from '@nestjs/graphql'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; import { SpecMember } from 'src/common/models/spec-member.model'; import { Network } from 'src/network/models/network.model'; import { Organization } from 'src/organization/models/organization.model'; import { ProposalPolicy } from 'src/proposal/models/proposal-policy.enum'; -import { FederationStatus } from './federation-status.enum'; @ObjectType({ description: '联盟' }) export class Federation { @@ -42,6 +42,6 @@ export class Federation { policy?: string; /** 状态 */ - @Field(() => FederationStatus, { description: '状态' }) + @Field(() => CrdStatusType, { description: '状态' }) status?: string; } diff --git a/src/ibppeer/models/ibppeer-status.enum.ts b/src/ibppeer/models/ibppeer-status.enum.ts deleted file mode 100644 index 2027897..0000000 --- a/src/ibppeer/models/ibppeer-status.enum.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum IbppeerStatus { - Deploying = 'Deploying', - Deployed = 'Deployed', - Error = 'Error', -} - -registerEnumType(IbppeerStatus, { - name: 'IbppeerStatus', - description: '「Peer节点」状态', - valuesMap: { - Deploying: { - description: 'Deploying', - }, - Deployed: { - description: 'Deployed', - }, - Error: { - description: '失败', - }, - }, -}); diff --git a/src/ibppeer/models/ibppeer.model.ts b/src/ibppeer/models/ibppeer.model.ts index c432f68..906356e 100644 --- a/src/ibppeer/models/ibppeer.model.ts +++ b/src/ibppeer/models/ibppeer.model.ts @@ -1,7 +1,7 @@ import { Field, HideField, ID, ObjectType } from '@nestjs/graphql'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; import { SpecResource } from 'src/common/models/spec-resource.model'; import { AnyObj } from 'src/types'; -import { IbppeerStatus } from './ibppeer-status.enum'; @ObjectType() export class Ibppeer { @@ -25,7 +25,7 @@ export class Ibppeer { limits?: AnyObj; /** 运行状态 */ - @Field(() => IbppeerStatus, { description: '运行状态' }) + @Field(() => CrdStatusType, { description: '运行状态' }) status?: string; @HideField() diff --git a/src/network/models/network.model.ts b/src/network/models/network.model.ts index cbbcdcc..ef3d033 100644 --- a/src/network/models/network.model.ts +++ b/src/network/models/network.model.ts @@ -1,9 +1,9 @@ import { Field, HideField, ID, ObjectType } from '@nestjs/graphql'; import { Channel } from 'src/channel/models/channel.model'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; import { SpecResource } from 'src/common/models/spec-resource.model'; import { Ibppeer } from 'src/ibppeer/models/ibppeer.model'; import { Organization } from 'src/organization/models/organization.model'; -import { StatusType } from 'src/organization/models/status-type.enum'; import { AnyObj } from 'src/types'; import { OrderVersion } from '../dto/order-version.enum'; @@ -25,7 +25,7 @@ export class Network { expiredTime?: string; /** 状态 */ - @Field(() => StatusType, { description: '状态' }) + @Field(() => CrdStatusType, { description: '状态' }) status?: string; /** 引擎类型 */ diff --git a/src/organization/models/organization.model.ts b/src/organization/models/organization.model.ts index 910dc82..9781304 100644 --- a/src/organization/models/organization.model.ts +++ b/src/organization/models/organization.model.ts @@ -1,8 +1,8 @@ import { Field, HideField, ID, ObjectType } from '@nestjs/graphql'; +import { CrdStatusType } from 'src/common/models/crd-statue-type.enum'; import { Ibppeer } from 'src/ibppeer/models/ibppeer.model'; import { Network } from 'src/network/models/network.model'; import { User } from 'src/users/models/user.model'; -import { StatusType } from './status-type.enum'; @ObjectType({ description: '组织' }) export class Organization { @@ -32,7 +32,7 @@ export class Organization { clients?: string[]; /** 状态 */ - @Field(() => StatusType) + @Field(() => CrdStatusType) status?: string; /** 原因 */ diff --git a/src/schema.gql b/src/schema.gql index 7c7342f..62dd470 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -28,7 +28,7 @@ type Channel { peers: [SpecPeer!] """状态""" - status: ChannelStatus + status: CrdStatusType } input ChannelPeer { @@ -39,16 +39,58 @@ input ChannelPeer { namespace: String! } -"""「通道」状态""" -enum ChannelStatus { - """Deployed""" +"""IBPCR 状态""" +enum CrdStatusType { + """ChannelArchived""" + ChannelArchived + + """ChannelCreated""" + ChannelCreated + + """正常""" + Created + + """ + Deployed is the status when the component's deployment is done successfully + """ Deployed - """Deploying""" + """Deploying is the status when component is being deployed""" Deploying - """失败""" + """异常""" Error + + """已激活""" + FederationActivated + + """已解散""" + FederationDissolved + + """组建失败""" + FederationFailed + + """组建中""" + FederationPending + + """Initializing is the status when a component is initializing""" + Initializing + + """正常""" + NetworkCreated + + """已解散""" + NetworkDissolved + + """ + Precreated is the status of the orderers when they are waiting for config block + """ + Precreated + + """ + Warning is the status when a component is running, but will fail in future + """ + Warning } """背书策略""" @@ -99,25 +141,7 @@ type Federation { policy: ProposalPolicy """状态""" - status: FederationStatus -} - -"""「联盟」状态""" -enum FederationStatus { - """失败""" - Error - - """已激活""" - FederationActivated - - """已解散""" - FederationDissolved - - """组建失败""" - FederationFailed - - """组建中""" - FederationPending + status: CrdStatusType } type Ibppeer { @@ -140,19 +164,7 @@ type Ibppeer { networks: [String!] """运行状态""" - status: IbppeerStatus -} - -"""「Peer节点」状态""" -enum IbppeerStatus { - """Deployed""" - Deployed - - """Deploying""" - Deploying - - """失败""" - Error + status: CrdStatusType } """ @@ -302,7 +314,7 @@ type Network { peers: [Ibppeer!] """状态""" - status: StatusType + status: CrdStatusType """节点存储""" storage: String @@ -466,7 +478,7 @@ type Organization { reason: String """状态""" - status: StatusType + status: CrdStatusType """成员""" users: [User!] @@ -638,54 +650,6 @@ type SpecResource { memory: String! } -"""IBPCR 状态""" -enum StatusType { - """正常""" - Created - - """ - Deployed is the status when the component's deployment is done successfully - """ - Deployed - - """Deploying is the status when component is being deployed""" - Deploying - - """异常""" - Error - - """FederationActivated means `Proposal-Vote` passed""" - FederationActivated - - """FederationDissolved means `Federation` no longer active""" - FederationDissolved - - """FederationFailed means `Proposal-Vote` failed""" - FederationFailed - - """FederationPending means `Proposal-Vote` not passed yet""" - FederationPending - - """Initializing is the status when a component is initializing""" - Initializing - - """正常""" - NetworkCreated - - """已解散""" - NetworkDissolved - - """ - Precreated is the status of the orderers when they are waiting for config block - """ - Precreated - - """ - Warning is the status when a component is running, but will fail in future - """ - Warning -} - input UpdateChannel { """操作类型""" operate: Operator!