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

gonic fix #351

Closed
wants to merge 9 commits into from
Closed
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
2 changes: 1 addition & 1 deletion agent/container/pkg/application/githubmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *GithubApiClient) FetchVersions(packageName string) ([]Version, error) {
var versions []Version
err = json.Unmarshal(body, &versions)
if err != nil {
return nil, fmt.Errorf("error occured while unmarshalling the version %w", err)
return nil, fmt.Errorf("error occurred while unmarshalling the version %w", err)
}

return versions, nil
Expand Down
4 changes: 2 additions & 2 deletions agent/container/pkg/application/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"go.opentelemetry.io/otel/attribute"
)

//githubHandler handles the github webhooks post requests.
// githubHandler handles the github webhooks post requests.
func (app *Application) localRegistryHandler(w http.ResponseWriter, r *http.Request) {

ctx:=context.Background()
ctx := context.Background()
tracer := otel.Tracer("container-gitlab")
_, span := tracer.Start(opentelemetry.BuildContext(ctx), "localRegistryHandler")
span.SetAttributes(attribute.String("http.method", "POST"))
Expand Down
4 changes: 2 additions & 2 deletions agent/container/pkg/handler/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (ah *APIHandler) BindRequest(r *gin.Engine) {

apiGroup := r.Group("/")
{
apiGroup.GET("/api-docs", ah.GetApiDocs)
apiGroup.GET("/api-docs", ah.GetAPIDocs)
apiGroup.GET("/status", ah.GetStatus)
apiGroup.POST("/event/docker/hub", ah.PostEventDockerHub)
apiGroup.POST("/event/azure/container", ah.PostEventAzureContainer)
Expand All @@ -54,7 +54,7 @@ func (ah *APIHandler) BindRequest(r *gin.Engine) {
// GetApiDocs serves the Swagger API documentation generated from the OpenAPI YAML file.
// It responds with a JSON representation of the API's endpoints, parameters, responses, and other details.
// This endpoint can be used by tools like Swagger UI to provide interactive documentation for the API.
func (ah *APIHandler) GetApiDocs(c *gin.Context) {
func (ah *APIHandler) GetAPIDocs(c *gin.Context) {
swagger, err := api.GetSwagger()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/events/event_metrics_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func publishK8sMetrics(id string, mtype string, mdata *v1.Event, js nats.JetStre
ClusterName: ClusterName,
ImageName: imageName,
}
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject, metricsJSON)
if err != nil {
return true, err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/ketall/ketall.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var ClusterName string = os.Getenv("CLUSTER_NAME")
func PublishAllResources(result model.Resource, js nats.JetStreamContext) error {
metrics := result
metrics.ClusterName = ClusterName
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject_getall_resource, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject_getall_resource, metricsJSON)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions agent/kubviz/plugins/kubepreupgrade/kubePreUpgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ type PreferredResource map[string]ResourceStruct

var (
k8sVersion = "master"
deletedApiReplacements = map[string]groupResourceKind{
deletedAPIReplacements = map[string]groupResourceKind{
"extensions/v1beta1/Ingress": {"networking.k8s.io/v1", "ingresses", "Ingress"},
}
)
var result *model.Result

func publishK8sDepricated_Deleted_Api(result *model.Result, js nats.JetStreamContext) error {
func publishK8sDepricatedDeletedAPI(result *model.Result, js nats.JetStreamContext) error {
for _, deprecatedAPI := range result.DeprecatedAPIs {
deprecatedAPI.ClusterName = ClusterName
deprecatedAPIJson, _ := json.Marshal(deprecatedAPI)
Expand Down Expand Up @@ -109,7 +109,7 @@ func KubePreUpgradeDetector(config *rest.Config, js nats.JetStreamContext) error
return err
}
result = getResults(config, kubernetesAPIs)
err = publishK8sDepricated_Deleted_Api(result, js)
err = publishK8sDepricatedDeletedAPI(result, js)
return err
}

Expand Down Expand Up @@ -371,7 +371,7 @@ func getResults(configRest *rest.Config, kubeAPIs model.KubernetesAPIs) *model.R

gvr, list := getResources(client, groupResourceKind{resourceGroupVersion.GroupVersion, resource.Name, resource.Kind})

if newApi, ok := deletedApiReplacements[keyAPI]; ok {
if newApi, ok := deletedAPIReplacements[keyAPI]; ok {
list.Items = fixDeletedItemsList(client, list.Items, newApi)
}

Expand Down
7 changes: 2 additions & 5 deletions agent/kubviz/plugins/kubescore/kube_score.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ func publish(ns string, js nats.JetStreamContext) error {

publishKubescoreMetrics(report, js)
//err = publishKubescoreMetrics(uuid.New().String(), ns, out, js)
if err != nil {
return err
}
return nil
}

Expand All @@ -75,8 +72,8 @@ func publishKubescoreMetrics(report []json_v2.ScoredObject, js nats.JetStreamCon
ClusterName: ClusterName,
Report: report,
}
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.KUBESCORE_SUBJECT, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.KUBESCORE_SUBJECT, metricsJSON)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/outdated/outdated.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func PublishOutdatedImages(out model.CheckResultfinal, js nats.JetStreamContext)

metrics := out
metrics.ClusterName = ClusterName
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject_outdated_images, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.EventSubject_outdated_images, metricsJSON)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/rakkess/rakees_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func RakeesOutput(config *rest.Config, js nats.JetStreamContext) error {
List: HumanreadableAccessCode(listOutcome),
Update: HumanreadableAccessCode(updateOutcome),
}
metricsJson, _ := json.Marshal(metrics)
_, err = js.Publish(constants.EventSubject_rakees, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err = js.Publish(constants.EventSubject_rakees, metricsJSON)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/trivy/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func PublishTrivyK8sReport(report report.ConsolidatedReport, js nats.JetStreamCo
ClusterName: ClusterName,
Report: report,
}
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.TRIVY_K8S_SUBJECT, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.TRIVY_K8S_SUBJECT, metricsJSON)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions agent/kubviz/plugins/trivy/trivy_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RunTrivyImageScans(config *rest.Config, js nats.JetStreamContext) error {

images, err := ListImages(config)
if err != nil {
log.Println("error occured while trying to list images, error :", err.Error())
log.Println("error occurred while trying to list images, error :", err.Error())
return err
}

Expand Down Expand Up @@ -90,8 +90,8 @@ func PublishImageScanReports(report types.Report, js nats.JetStreamContext) erro
ClusterName: ClusterName,
Report: report,
}
metricsJson, _ := json.Marshal(metrics)
_, err := js.Publish(constants.TRIVY_IMAGE_SUBJECT, metricsJson)
metricsJSON, _ := json.Marshal(metrics)
_, err := js.Publish(constants.TRIVY_IMAGE_SUBJECT, metricsJSON)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions agent/kubviz/plugins/trivy/trivy_sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func PublishTrivySbomReport(report map[string]interface{}, js nats.JetStreamCont
ClusterName: ClusterName,
Report: report,
}
metricsJson, err := json.Marshal(metrics)
metricsJSON, err := json.Marshal(metrics)
if err != nil {
log.Println("error occurred while marshalling sbom metrics in agent", err.Error())
return err
}
_, err = js.Publish(constants.TRIVY_SBOM_SUBJECT, metricsJson)
_, err = js.Publish(constants.TRIVY_SBOM_SUBJECT, metricsJSON)
if err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions client/pkg/clickhouse/db_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewDBClient(conf *config.Config) (DBInterface, *sql.DB, error) {
if conf.ClickHouseUsername != "" && conf.ClickHousePassword != "" {
fmt.Println("Using provided username and password")
connOptions = clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)},
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DBPort)},
Debug: true,
Auth: clickhouse.Auth{
Username: conf.ClickHouseUsername,
Expand All @@ -77,7 +77,7 @@ func NewDBClient(conf *config.Config) (DBInterface, *sql.DB, error) {
} else {
fmt.Println("Using connection without username and password")
connOptions = clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)},
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DBPort)},
Debug: true,
Debugf: func(format string, v ...interface{}) {
fmt.Printf(format, v...)
Expand Down Expand Up @@ -109,7 +109,7 @@ func NewDBClient(conf *config.Config) (DBInterface, *sql.DB, error) {
if conf.ClickHouseUsername != "" && conf.ClickHousePassword != "" {
fmt.Println("Using provided username and password")
connOption = clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)},
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DBPort)},
Debug: true,
Auth: clickhouse.Auth{
Username: conf.ClickHouseUsername,
Expand All @@ -119,7 +119,7 @@ func NewDBClient(conf *config.Config) (DBInterface, *sql.DB, error) {
} else {
fmt.Println("Using connection without username and password")
connOption = clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)},
Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DBPort)},
}
}

Expand Down Expand Up @@ -583,7 +583,7 @@ func (c *DBClient) InsertKubvizEvent(metrics model.Metrics) {
}

defer stmt.Close()
eventJson, _ := json.Marshal(metrics.Event)
eventJSON, _ := json.Marshal(metrics.Event)
formattedFirstTimestamp := metrics.Event.FirstTimestamp.Time.UTC().Format("2006-01-02 15:04:05")
formattedLastTimestamp := metrics.Event.LastTimestamp.Time.UTC().Format("2006-01-02 15:04:05")

Expand All @@ -598,7 +598,7 @@ func (c *DBClient) InsertKubvizEvent(metrics model.Metrics) {
metrics.Event.Message,
metrics.Event.Reason,
metrics.Event.Source.Host,
string(eventJson),
string(eventJSON),
metrics.ImageName,
formattedFirstTimestamp,
formattedLastTimestamp,
Expand Down Expand Up @@ -936,7 +936,7 @@ func (c *DBClient) Close() {
}

func DbUrl(conf *config.Config) string {
return fmt.Sprintf("tcp://%s:%d?debug=true", conf.DBAddress, conf.DbPort)
return fmt.Sprintf("tcp://%s:%d?debug=true", conf.DBAddress, conf.DBPort)
}
func (c *DBClient) RetriveKetallEvent() ([]model.Resource, error) {
rows, err := c.conn.Query("SELECT ClusterName, Namespace, Kind, Resource, Age FROM getall_resources")
Expand Down Expand Up @@ -1018,8 +1018,8 @@ func (c *DBClient) RetrieveKubvizEvent() ([]model.DbEvent, error) {
log.Printf("Error: %s", err)
return nil, err
}
eventJson, _ := json.Marshal(dbEvent)
log.Printf("DB Event: %s", string(eventJson))
eventJSON, _ := json.Marshal(dbEvent)
log.Printf("DB Event: %s", string(eventJSON))
events = append(events, dbEvent)
}

Expand Down
Loading
Loading