Skip to content

Commit

Permalink
fix: create hook with first revision failed if no revision name provided
Browse files Browse the repository at this point in the history
  • Loading branch information
fireyun committed Feb 28, 2024
1 parent fcd1d2b commit 40c95bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bcs-services/bcs-bscp/cmd/data-service/service/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
pbbase "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/core/base"
pbhook "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/core/hook"
pbds "github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/protocol/data-service"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/tools"
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/types"
)

Expand Down Expand Up @@ -68,6 +69,10 @@ func (s *Service) CreateHook(ctx context.Context, req *pbds.CreateHookReq) (*pbd
}

// 2. create hook revision
// it must be the first hook revision, so no need to check the revision name uniqueness
if req.Spec.RevisionName == "" {
req.Spec.RevisionName = tools.GenerateRevisionName()
}
revision := &table.HookRevision{
Spec: &table.HookRevisionSpec{
Name: req.Spec.RevisionName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *Service) CreateHookRevision(ctx context.Context,

if _, err := s.dao.HookRevision().GetByName(kt, req.Attachment.BizId, req.Attachment.HookId,
req.Spec.Name); err == nil {
return nil, fmt.Errorf("hook name %s already exists", req.Spec.Name)
return nil, fmt.Errorf("hook revision name %s already exists", req.Spec.Name)
}

spec, err := req.Spec.HookRevisionSpec()
Expand Down

0 comments on commit 40c95bc

Please sign in to comment.