Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix image name when creating chaincodeBuild #50

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/chaincodebuild/chaincodebuild.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ export class ChaincodebuildService {
}
}

const metadataName = genNanoid('chaincodebuild');
const k8s = await this.k8sService.getClient(auth);
const { body } = await k8s.chaincodeBuild.create({
metadata: {
name: genNanoid('chaincodebuild'),
name: metadataName,
},
spec: {
license: {
Expand All @@ -164,7 +165,7 @@ export class ChaincodebuildService {
object: objectName,
},
dockerBuild: {
appImage: `${this.imgConfig.namespace}/${displayName}:${version}`,
appImage: `${this.imgConfig.namespace}/${metadataName}:${version}`,
context: `${MINIO_BUCKET_NAME}/${objectName}`,
dockerfile: `${MINIO_BUCKET_NAME}/${objectName}/Dockerfile`,
pushSecret: 'dockerhub-secret',
Expand Down
9 changes: 3 additions & 6 deletions src/epolicy/dto/new-epolicy.input.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Field, InputType } from '@nestjs/graphql';
import { Length } from 'class-validator';

@InputType()
export class NewEpolicyInput {
/** 策略名称(metadata.name) */
/** 策略名称 */
@Field(() => String, {
description:
'策略名称,规则:小写字母、数字、“-”,开头和结尾只能是字母或数字([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)',
description: '策略名称',
})
@Length(3, 63)
name: string;
displayName: string;

/** 策略描述 */
description?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/epolicy/epolicy.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
query getEpolicies($network: String) {
epolicies(network: $network) {
name
displayName
description
channel
value
Expand All @@ -14,6 +15,7 @@ query getEpolicies($network: String) {
mutation createEpolicy($epolicy: NewEpolicyInput!) {
epolicyCreate(epolicy: $epolicy) {
name
displayName
value
description
channel
Expand Down
7 changes: 5 additions & 2 deletions src/epolicy/epolicy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ForbiddenException, Injectable } from '@nestjs/common';
import { ChannelService } from 'src/channel/channel.service';
import { Channel } from 'src/channel/models/channel.model';
import { K8sV1Status } from 'src/common/models/k8s-v1-status.model';
import { genNanoid } from 'src/common/utils';
import { KubernetesService } from 'src/kubernetes/kubernetes.service';
import { CRD } from 'src/kubernetes/lib';
import { NetworkService } from 'src/network/network.service';
Expand All @@ -28,6 +29,7 @@ export class EpolicyService {
: creationTimestamp;
return {
name: epolicy.metadata?.name,
displayName: epolicy.spec?.displayName,
creationTimestamp,
lastHeartbeatTime,
channel: epolicy.spec?.channel,
Expand Down Expand Up @@ -60,13 +62,14 @@ export class EpolicyService {
auth: JwtAuth,
epolicy: NewEpolicyInput,
): Promise<Epolicy> {
const { name, description, channel, value } = epolicy;
const { displayName, description, channel, value } = epolicy;
const k8s = await this.k8sService.getClient(auth);
const { body } = await k8s.endorsePolicy.create({
metadata: {
name,
name: genNanoid('epolicy'),
},
spec: {
displayName,
description,
channel,
value,
Expand Down
3 changes: 3 additions & 0 deletions src/epolicy/models/epolicy.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export class Epolicy {
@Field(() => ID, { description: 'name' })
name: string;

/** 策略名称 */
displayName?: string;

/** 所在通道 */
channel: string;

Expand Down
1 change: 1 addition & 0 deletions src/kubernetes/lib/interfaces/crd/endorse-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface EndorsePolicy {
spec?: {
channel: string;
description?: string;
displayName: string;
value: string;
[k: string]: any;
};
Expand Down
9 changes: 5 additions & 4 deletions src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ type Epolicy {
"""描述"""
description: String

"""策略名称"""
displayName: String

"""更新时间"""
lastHeartbeatTime: String

Expand Down Expand Up @@ -443,10 +446,8 @@ input NewEpolicyInput {
"""策略描述"""
description: String

"""
策略名称,规则:小写字母、数字、“-”,开头和结尾只能是字母或数字([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)
"""
name: String!
"""策略名称"""
displayName: String!

"""
策略内容:可选组织为已选通道内的成员,语法参考(https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax)
Expand Down