-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: core-api add publish event report api (#88)
* feat: core-api add publish event report api
- Loading branch information
1 parent
d86fd2c
commit f67a3b3
Showing
81 changed files
with
1,290 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
run: | ||
# default concurrency is a available CPU number | ||
concurrency: 4 | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 2m | ||
# exit code when at least one issue was found, default is 1 | ||
issues-exit-code: 1 | ||
# include test files or not, default is true | ||
tests: false | ||
# default is true. Enables skipping of directories: | ||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | ||
skip-dirs-use-default: true | ||
|
||
skip-files: | ||
- ".*/mock/.*.go" | ||
- ".*testing.go" | ||
|
||
linters: | ||
# enable-all: true | ||
# disable-all: true | ||
disable: | ||
- errcheck | ||
enable: | ||
- nilerr | ||
- nakedret | ||
- lll | ||
- gofmt | ||
- gocritic | ||
- gocyclo | ||
- whitespace | ||
- stylecheck | ||
- misspell | ||
- goimports | ||
# - bodyclose | ||
# - nestif | ||
# - gofumpt | ||
# - godox | ||
# - wsl | ||
# - funlen | ||
# - golint | ||
# - cyclop | ||
fast: false | ||
|
||
linters-settings: | ||
stylecheck: | ||
checks: ["-ST1000", "-ST1016", "-ST1020", "-ST1021", "-ST1022"] | ||
goimports: | ||
# A comma-separated list of prefixes, which, if set, checks import paths | ||
# with the given prefixes are grouped after 3rd-party packages. | ||
# Default: "" | ||
local-prefixes: "core" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making | ||
* 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. | ||
* Licensed under the MIT License (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* We undertake not to change the open source license (MIT license) applicable | ||
* to the current version of the project delivered to anyone in the future. | ||
*/ | ||
|
||
package microgateway | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/spf13/cast" | ||
|
||
"core/pkg/service" | ||
"core/pkg/util" | ||
) | ||
|
||
type reportPublishEventSerializer struct { | ||
BkGatewayName string `json:"bk_gateway_name" binding:"required" example:"benchmark"` | ||
BkStageName string `json:"bk_stage_name" binding:"required" example:"dev"` | ||
Name string `json:"name" binding:"required" example:"generate_release_task"` | ||
Status string `json:"status" binding:"required" example:"success" ` | ||
Detail map[string]interface{} `json:"detail"` | ||
} | ||
|
||
// ReportPublishEvent report publish event | ||
func ReportPublishEvent(c *gin.Context) { | ||
var query reportPublishEventSerializer | ||
if err := c.ShouldBindJSON(&query); err != nil { | ||
util.BadRequestErrorJSONResponse(c, util.ValidationErrorMessage(err)) | ||
return | ||
} | ||
svc := service.NewPublishEventService() | ||
publishID := cast.ToInt64(c.Param("publish_id")) | ||
event := service.Event{ | ||
Gateway: query.BkGatewayName, | ||
Stage: query.BkGatewayName, | ||
Name: query.Name, | ||
Status: query.Status, | ||
PublishID: publishID, | ||
DetailMap: query.Detail, | ||
} | ||
err := svc.Report(c.Request.Context(), event) | ||
if err != nil { | ||
util.SystemErrorJSONResponse(c, err) | ||
return | ||
} | ||
util.SuccessJSONResponse(c, gin.H{ | ||
"result": "report success", | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.