Skip to content

feature(veinmind-runner): add harbor webhook - #113

Closed
huzai9527 wants to merge 2 commits into
chaitin:masterfrom
huzai9527:webhook
Closed

feature(veinmind-runner): add harbor webhook#113
huzai9527 wants to merge 2 commits into
chaitin:masterfrom
huzai9527:webhook

Conversation

@huzai9527

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread veinmind-runner/pkg/authz/authz_config.go
Comment thread veinmind-runner/pkg/authz/authz_config.go
Comment thread veinmind-runner/pkg/authz/authz_config.go
Comment thread veinmind-runner/pkg/authz/authz_report.go
engine := s.registerRouter()

go func() {
err := engine.Run(":" + s.option.port)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以直接 engine.RunListener(s.option.listener)

log.Error(err)
return
}
postData, err := route.ParseHarborwebhookPostdata(c)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑下方法的入参,尽量做到通用,这里可能[]byte比较合适

}
val, ok := s.option.policies.Load(postData.Type)
if !ok {
log.Error(err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要打印err

}

func (s *harborWebhookServer) registerRouter() *gin.Engine {
engine := gin.Default()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整个函数体需要合理的代码块换行

Comment thread veinmind-runner/pkg/authz/harbor_webhook.go

func (s *harborWebhookServer) registerRouter() *gin.Engine {
engine := gin.Default()
engine.POST("/api", func(c *gin.Context) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

路由层里不要加业务逻辑代码,拆分直接传给业务层处理

@d1nfinite

Copy link
Copy Markdown
Collaborator

duplicate #116

@d1nfinite d1nfinite closed this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants