From 0f407ee6aecdcc66a4b719ef7e3dfcfdcda5fa8e Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Thu, 18 Jan 2024 09:52:01 -0800 Subject: [PATCH 01/10] Go 1.20. Signed-off-by: Jeff Ortel --- addon/adapter.go | 14 ++------- addon/error.go | 1 - addon/task.go | 21 ------------- api/addon.go | 5 ---- api/adoptionplan.go | 13 --------- api/analysis.go | 47 +++--------------------------- api/application.go | 26 ++++------------- api/archetype.go | 7 ----- api/assessment.go | 6 ---- api/auth.go | 5 ---- api/base.go | 47 ++---------------------------- api/batch.go | 3 -- api/bucket.go | 21 ++++--------- api/businessservice.go | 6 ---- api/cache.go | 5 ---- api/context.go | 7 ----- api/dependency.go | 6 ---- api/error.go | 5 ---- api/file.go | 5 ---- api/filter/error.go | 2 -- api/filter/filter.go | 24 --------------- api/filter/lexer.go | 12 -------- api/filter/parser.go | 9 ------ api/group.go | 6 ---- api/identity.go | 7 ----- api/import.go | 26 ++++------------- api/jobfunction.go | 6 ---- api/migrationwave.go | 6 ---- api/pkg.go | 7 ----- api/proxy.go | 5 ---- api/reflect/fields.go | 2 -- api/review.go | 6 ---- api/ruleset.go | 12 -------- api/schema.go | 2 -- api/setting.go | 4 --- api/sort/error.go | 1 - api/sort/sort.go | 5 ---- api/stakeholder.go | 6 ---- api/tag.go | 6 ---- api/tagcategory.go | 6 ---- api/target.go | 5 ---- api/task.go | 14 --------- api/taskgroup.go | 6 ---- api/tracker.go | 4 --- assessment/application.go | 11 ------- assessment/archetype.go | 10 ------- assessment/assessment.go | 20 ------------- assessment/membership.go | 4 --- assessment/pkg.go | 9 ------ assessment/questionnaire.go | 4 --- assessment/set.go | 9 ------ assessment/tag.go | 4 --- auth/builtin.go | 16 ---------- auth/keycloak.go | 8 ----- auth/provider.go | 8 ----- auth/reconcile.go | 14 --------- auth/request.go | 2 -- auth/role.go | 6 ---- cmd/main.go | 4 --- controller/addon.go | 7 ----- database/pkg.go | 2 -- encryption/aes.go | 7 ----- go.mod | 4 +-- importer/manager.go | 7 ----- k8s/api/tackle/v1alpha1/addon.go | 4 --- k8s/api/tackle/v1alpha1/tackle.go | 2 -- k8s/client.go | 1 - metrics/manager.go | 1 - migration/migrate.go | 4 --- migration/pkg.go | 5 ---- migration/v10/model/analysis.go | 10 ------- migration/v10/model/application.go | 6 ---- migration/v10/model/assessment.go | 1 - migration/v10/model/core.go | 10 ------- migration/v10/model/pkg.go | 2 -- migration/v11/model/analysis.go | 10 ------- migration/v11/model/application.go | 6 ---- migration/v11/model/assessment.go | 1 - migration/v11/model/core.go | 10 ------- migration/v11/model/pkg.go | 2 -- migration/v12/model/analysis.go | 10 ------- migration/v12/model/application.go | 6 ---- migration/v12/model/assessment.go | 1 - migration/v12/model/core.go | 10 ------- migration/v12/model/pkg.go | 2 -- migration/v2/model/application.go | 4 --- migration/v2/model/core.go | 7 ----- migration/v2/model/pkg.go | 2 -- migration/v2/model/seed.go | 1 - migration/v3/migrate.go | 5 ---- migration/v3/model/analysis.go | 2 -- migration/v3/model/application.go | 6 ---- migration/v3/model/core.go | 7 ----- migration/v3/model/pkg.go | 2 -- migration/v3/seed/bundle.go | 4 --- migration/v4/model/analysis.go | 2 -- migration/v4/model/application.go | 6 ---- migration/v4/model/core.go | 7 ----- migration/v4/model/pkg.go | 2 -- migration/v5/migrate.go | 2 -- migration/v5/model/analysis.go | 7 ----- migration/v5/model/application.go | 6 ---- migration/v5/model/core.go | 6 ---- migration/v5/model/pkg.go | 2 -- migration/v6/model/analysis.go | 8 ----- migration/v6/model/application.go | 6 ---- migration/v6/model/core.go | 8 ----- migration/v6/model/pkg.go | 2 -- migration/v7/model/analysis.go | 8 ----- migration/v7/model/application.go | 6 ---- migration/v7/model/core.go | 8 ----- migration/v7/model/pkg.go | 2 -- migration/v8/model/analysis.go | 9 ------ migration/v8/model/application.go | 6 ---- migration/v8/model/core.go | 8 ----- migration/v8/model/pkg.go | 2 -- migration/v9/model/analysis.go | 9 ------ migration/v9/model/application.go | 6 ---- migration/v9/model/core.go | 8 ----- migration/v9/model/pkg.go | 2 -- model/pkg.go | 5 ---- model/query.go | 1 - settings/addon.go | 1 - settings/all.go | 1 - settings/auth.go | 1 - settings/hub.go | 1 - settings/metrics.go | 4 --- task/auth.go | 8 ++--- task/manager.go | 23 --------------- task/rule.go | 6 ---- tracker/jira.go | 15 ---------- tracker/pkg.go | 4 --- 132 files changed, 33 insertions(+), 914 deletions(-) diff --git a/addon/adapter.go b/addon/adapter.go index dacd3926e..5a75e1cdc 100644 --- a/addon/adapter.go +++ b/addon/adapter.go @@ -19,7 +19,6 @@ var ( Log = logr.WithName("addon") ) -// // Addon An addon adapter configured for a task execution. var Addon *Adapter @@ -33,20 +32,17 @@ func init() { Addon = newAdapter() } -// // Client type Client = binding.Client type Params = binding.Params type Param = binding.Param type Path = binding.Path -// // Error type ResetError = binding.RestError type Conflict = binding.Conflict type NotFound = binding.NotFound -// // Handler type Application = binding.Application type Bucket = binding.Bucket @@ -59,11 +55,9 @@ type Setting = binding.Setting type Tag = binding.Tag type TagCategory = binding.TagCategory -// // Filter type Filter = binding.Filter -// // The Adapter provides hub/addon integration. type Adapter struct { // Task API. @@ -90,12 +84,11 @@ type Adapter struct { client *Client } -// // Run addon. // Reports: -// - Started -// - Succeeded -// - Failed (when addon returns error). +// - Started +// - Succeeded +// - Failed (when addon returns error). func (h *Adapter) Run(addon func() error) { var err error // @@ -134,7 +127,6 @@ func (h *Adapter) Run(addon func() error) { } } -// // newAdapter builds a new Addon Adapter object. func newAdapter() (adapter *Adapter) { richClient := binding.New(Settings.Addon.Hub.URL) diff --git a/addon/error.go b/addon/error.go index 541d019b6..96ee19747 100644 --- a/addon/error.go +++ b/addon/error.go @@ -1,6 +1,5 @@ package addon -// // SoftError A "soft" anticipated error. // Deprecated: type SoftError struct { diff --git a/addon/task.go b/addon/task.go index c71f09c51..b1b9cd7bd 100644 --- a/addon/task.go +++ b/addon/task.go @@ -9,7 +9,6 @@ import ( "strings" ) -// // Task API. type Task struct { richClient *binding.RichClient @@ -19,7 +18,6 @@ type Task struct { report api.TaskReport } -// // Load a task by ID. func (h *Task) Load() { var err error @@ -32,7 +30,6 @@ func (h *Task) Load() { return } -// // Application returns the application associated with the task. func (h *Task) Application() (r *api.Application, err error) { appRef := h.task.Application @@ -44,14 +41,12 @@ func (h *Task) Application() (r *api.Application, err error) { return } -// // Data returns the addon data. func (h *Task) Data() (d map[string]interface{}) { d = h.task.Data.(map[string]interface{}) return } -// // DataWith populates the addon data object. func (h *Task) DataWith(object interface{}) (err error) { b, _ := json.Marshal(h.task.Data) @@ -59,13 +54,11 @@ func (h *Task) DataWith(object interface{}) (err error) { return } -// // Variant returns the task variant. func (h *Task) Variant() string { return h.task.Variant } -// // Started report addon started. func (h *Task) Started() { h.deleteReport() @@ -75,7 +68,6 @@ func (h *Task) Started() { return } -// // Succeeded report addon succeeded. func (h *Task) Succeeded() { h.report.Status = task.Succeeded @@ -85,7 +77,6 @@ func (h *Task) Succeeded() { return } -// // Failed report addon failed. // The reason can be a printf style format. func (h *Task) Failed(reason string, v ...interface{}) { @@ -101,7 +92,6 @@ func (h *Task) Failed(reason string, v ...interface{}) { return } -// // Errorf report addon error. func (h *Task) Errorf(severity, description string, v ...interface{}) { h.Error(api.TaskError{ @@ -110,7 +100,6 @@ func (h *Task) Errorf(severity, description string, v ...interface{}) { }) } -// // Error report addon error. func (h *Task) Error(error ...api.TaskError) { h.report.Status = task.Failed @@ -127,7 +116,6 @@ func (h *Task) Error(error ...api.TaskError) { return } -// // Activity report addon activity. // The description can be a printf style format. func (h *Task) Activity(entry string, v ...interface{}) { @@ -151,7 +139,6 @@ func (h *Task) Activity(entry string, v ...interface{}) { return } -// // Attach ensures the file is attached to the report // associated with the last entry in the activity. func (h *Task) Attach(f *api.File) { @@ -160,7 +147,6 @@ func (h *Task) Attach(f *api.File) { return } -// // AttachAt ensures the file is attached to // the report indexed to the activity. // The activity is a 1-based index. Zero(0) means NOT associated. @@ -191,7 +177,6 @@ func (h *Task) AttachAt(f *api.File, activity int) { return } -// // Total report addon total items. func (h *Task) Total(n int) { h.report.Total = n @@ -203,7 +188,6 @@ func (h *Task) Total(n int) { return } -// // Increment report addon completed (+1) items. func (h *Task) Increment() { h.report.Completed++ @@ -215,7 +199,6 @@ func (h *Task) Increment() { return } -// // Completed report addon completed (N) items. func (h *Task) Completed(n int) { h.report.Completed = n @@ -224,14 +207,12 @@ func (h *Task) Completed(n int) { return } -// // Bucket returns the bucket API. func (h *Task) Bucket() (b *binding.BucketContent) { b = h.richClient.Task.Bucket(h.task.ID) return } -// // Result report addon result. func (h *Task) Result(object interface{}) { h.report.Result = object @@ -240,7 +221,6 @@ func (h *Task) Result(object interface{}) { return } -// // deleteReport deletes the task report. func (h *Task) deleteReport() { params := Params{ @@ -253,7 +233,6 @@ func (h *Task) deleteReport() { } } -// // pushReport create/update the task report. func (h *Task) pushReport() { var err error diff --git a/api/addon.go b/api/addon.go index 19d51f9d5..a1788ed58 100644 --- a/api/addon.go +++ b/api/addon.go @@ -9,20 +9,17 @@ import ( k8s "sigs.k8s.io/controller-runtime/pkg/client" ) -// // Routes const ( AddonsRoot = "/addons" AddonRoot = AddonsRoot + "/:" + Name ) -// // AddonHandler handles addon routes. type AddonHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h AddonHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -94,14 +91,12 @@ func (h AddonHandler) List(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, content) } -// // Addon REST resource. type Addon struct { Name string `json:"name"` Image string `json:"image"` } -// // With model. func (r *Addon) With(m *crd.Addon) { r.Name = m.Name diff --git a/api/adoptionplan.go b/api/adoptionplan.go index c36e7d730..0dd4cd9df 100644 --- a/api/adoptionplan.go +++ b/api/adoptionplan.go @@ -8,7 +8,6 @@ import ( "strings" ) -// // Effort estimates const ( EffortS = "small" @@ -17,19 +16,15 @@ const ( EffortXL = "extra_large" ) -// // Routes const ( AdoptionPlansRoot = "/reports/adoptionplan" ) -// -// type AdoptionPlanHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h AdoptionPlanHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -110,7 +105,6 @@ func (h AdoptionPlanHandler) Graph(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, sorted) } -// // Vertex represents a vertex in the dependency graph. type Vertex struct { ID uint `json:"applicationId" yaml:"applicationId"` @@ -122,7 +116,6 @@ type Vertex struct { PositionX int `json:"positionX" yaml:"positionX"` } -// // NewDependencyGraph creates an empty dependency graph. func NewDependencyGraph() (graph DependencyGraph) { graph.vertices = make(map[uint]*Vertex) @@ -132,7 +125,6 @@ func NewDependencyGraph() (graph DependencyGraph) { return } -// // DependencyGraph is an application dependency graph. type DependencyGraph struct { // all applications @@ -145,27 +137,23 @@ type DependencyGraph struct { costs map[uint]int } -// // AddVertex adds a vertex to the graph. func (r *DependencyGraph) AddVertex(v *Vertex) { r.vertices[v.ID] = v } -// // HasVertex checks for the presence of a vertex in the graph. func (r *DependencyGraph) HasVertex(v uint) (ok bool) { _, ok = r.vertices[v] return } -// // AddEdge adds an edge between two vertices. func (r *DependencyGraph) AddEdge(v, w uint) { r.edges[v] = append(r.edges[v], w) r.incoming[w] = append(r.incoming[w], v) } -// // CalculateCost calculates the total cost to reach a given vertex. // Costs are memoized. func (r *DependencyGraph) CalculateCost(v uint) (cumulativeCost int) { @@ -189,7 +177,6 @@ func (r *DependencyGraph) CalculateCost(v uint) (cumulativeCost int) { return } -// // TopologicalSort sorts the graph such that the vertices // with fewer dependencies are first, and detects cycles. func (r *DependencyGraph) TopologicalSort() (sorted []*Vertex, ok bool) { diff --git a/api/analysis.go b/api/analysis.go index 92efeabb1..9bea1c1d8 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -21,7 +21,6 @@ import ( "strings" ) -// // Routes const ( AnalysesRoot = "/analyses" @@ -54,13 +53,11 @@ const ( DepField = "dependencies" ) -// // AnalysisHandler handles analysis resource routes. type AnalysisHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h AnalysisHandler) AddRoutes(e *gin.Engine) { // Primary @@ -1628,7 +1625,6 @@ func (h AnalysisHandler) DepAppReports(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, resources) } -// // appIDs provides application IDs. // filter: // - application.(id|name) @@ -1673,7 +1669,6 @@ func (h *AnalysisHandler) appIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { return } -// // analysisIDs provides analysis IDs. func (h *AnalysisHandler) analysisIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { q = h.DB(ctx) @@ -1684,10 +1679,10 @@ func (h *AnalysisHandler) analysisIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB return } -// // issueIDs returns issue filtered issue IDs. // Filter: -// issue.* +// +// issue.* func (h *AnalysisHandler) issueIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { q = h.DB(ctx) q = q.Model(&model.Issue{}) @@ -1720,10 +1715,10 @@ func (h *AnalysisHandler) issueIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { return } -// // depIDs returns issue filtered issue IDs. // Filter: -// techDeps.* +// +// techDeps.* func (h *AnalysisHandler) depIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { q = h.DB(ctx) q = q.Model(&model.TechDependency{}) @@ -1756,7 +1751,6 @@ func (h *AnalysisHandler) depIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) { return } -// // archive // - Set the 'archived' flag. // - Set the 'summary' field with archived issues. @@ -1818,7 +1812,6 @@ func (h *AnalysisHandler) archive(ctx *gin.Context) (err error) { return } -// // Analysis REST resource. type Analysis struct { Resource `yaml:",inline"` @@ -1829,7 +1822,6 @@ type Analysis struct { Summary []ArchivedIssue `json:"summary,omitempty" yaml:",omitempty" swaggertype:"object"` } -// // With updates the resource with the model. func (r *Analysis) With(m *model.Analysis) { r.Resource.With(&m.Model) @@ -1856,7 +1848,6 @@ func (r *Analysis) With(m *model.Analysis) { } } -// // Model builds a model. func (r *Analysis) Model() (m *model.Analysis) { m = &model.Analysis{} @@ -1878,7 +1869,6 @@ func (r *Analysis) Model() (m *model.Analysis) { return } -// // Issue REST resource. type Issue struct { Resource `yaml:",inline"` @@ -1894,7 +1884,6 @@ type Issue struct { Labels []string `json:"labels"` } -// // With updates the resource with the model. func (r *Issue) With(m *model.Issue) { r.Resource.With(&m.Model) @@ -1923,7 +1912,6 @@ func (r *Issue) With(m *model.Issue) { r.Effort = m.Effort } -// // Model builds a model. func (r *Issue) Model() (m *model.Issue) { m = &model.Issue{} @@ -1946,7 +1934,6 @@ func (r *Issue) Model() (m *model.Issue) { return } -// // TechDependency REST resource. type TechDependency struct { Resource `yaml:",inline"` @@ -1958,7 +1945,6 @@ type TechDependency struct { SHA string `json:"sha,omitempty" yaml:",omitempty"` } -// // With updates the resource with the model. func (r *TechDependency) With(m *model.TechDependency) { r.Resource.With(&m.Model) @@ -1972,7 +1958,6 @@ func (r *TechDependency) With(m *model.TechDependency) { } } -// // Model builds a model. func (r *TechDependency) Model() (m *model.TechDependency) { sort.Strings(r.Labels) @@ -1986,7 +1971,6 @@ func (r *TechDependency) Model() (m *model.TechDependency) { return } -// // Incident REST resource. type Incident struct { Resource `yaml:",inline"` @@ -1997,7 +1981,6 @@ type Incident struct { Facts FactMap `json:"facts"` } -// // With updates the resource with the model. func (r *Incident) With(m *model.Incident) { r.Resource.With(&m.Model) @@ -2010,7 +1993,6 @@ func (r *Incident) With(m *model.Incident) { } } -// // Model builds a model. func (r *Incident) Model() (m *model.Incident) { m = &model.Incident{} @@ -2022,18 +2004,15 @@ func (r *Incident) Model() (m *model.Incident) { return } -// // Link analysis report link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty" yaml:",omitempty"` } -// // ArchivedIssue created when issues are archived. type ArchivedIssue model.ArchivedIssue -// // RuleReport REST resource. type RuleReport struct { RuleSet string `json:"ruleset"` @@ -2047,7 +2026,6 @@ type RuleReport struct { Applications int `json:"applications"` } -// // IssueReport REST resource. type IssueReport struct { ID uint `json:"id"` @@ -2062,7 +2040,6 @@ type IssueReport struct { Files int `json:"files"` } -// // IssueAppReport REST resource. type IssueAppReport struct { ID uint `json:"id"` @@ -2081,7 +2058,6 @@ type IssueAppReport struct { } `json:"issue"` } -// // FileReport REST resource. type FileReport struct { IssueID uint `json:"issueId" yaml:"issueId"` @@ -2090,7 +2066,6 @@ type FileReport struct { Effort int `json:"effort"` } -// // DepReport REST resource. type DepReport struct { Provider string `json:"provider"` @@ -2099,7 +2074,6 @@ type DepReport struct { Applications int `json:"applications"` } -// // DepAppReport REST resource. type DepAppReport struct { ID uint `json:"id"` @@ -2117,18 +2091,15 @@ type DepAppReport struct { } `json:"dependency"` } -// // FactMap map. type FactMap map[string]interface{} -// // AnalysisWriter used to create a file containing an analysis. type AnalysisWriter struct { encoder ctx *gin.Context } -// // db returns a db client. func (r *AnalysisWriter) db() (db *gorm.DB) { rtx := WithContext(r.ctx) @@ -2136,7 +2107,6 @@ func (r *AnalysisWriter) db() (db *gorm.DB) { return } -// // Create an analysis file and returns the path. func (r *AnalysisWriter) Create(id uint) (path string, err error) { ext := ".json" @@ -2162,7 +2132,6 @@ func (r *AnalysisWriter) Create(id uint) (path string, err error) { return } -// // Write the analysis file. func (r *AnalysisWriter) Write(id uint, output io.Writer) (err error) { m := &model.Analysis{} @@ -2191,7 +2160,6 @@ func (r *AnalysisWriter) Write(id uint, output io.Writer) (err error) { return } -// // newEncoder returns an encoder. func (r *AnalysisWriter) newEncoder(output io.Writer) (encoder encoder, err error) { accepted := r.ctx.NegotiateFormat(BindMIMEs...) @@ -2209,7 +2177,6 @@ func (r *AnalysisWriter) newEncoder(output io.Writer) (encoder encoder, err erro return } -// // addIssues writes issues. func (r *AnalysisWriter) addIssues(m *model.Analysis) (err error) { r.field("issues") @@ -2238,7 +2205,6 @@ func (r *AnalysisWriter) addIssues(m *model.Analysis) (err error) { return } -// // addDeps writes dependencies. func (r *AnalysisWriter) addDeps(m *model.Analysis) (err error) { r.field("dependencies") @@ -2266,14 +2232,12 @@ func (r *AnalysisWriter) addDeps(m *model.Analysis) (err error) { return } -// // ReportWriter analysis report writer. type ReportWriter struct { encoder ctx *gin.Context } -// // db returns a db client. func (r *ReportWriter) db() (db *gorm.DB) { rtx := WithContext(r.ctx) @@ -2281,7 +2245,6 @@ func (r *ReportWriter) db() (db *gorm.DB) { return } -// // Write builds and streams the analysis report. func (r *ReportWriter) Write(id uint) { reportDir := Settings.Analysis.ReportPath @@ -2316,7 +2279,6 @@ func (r *ReportWriter) Write(id uint) { return } -// // buildOutput creates the report output.js file. func (r *ReportWriter) buildOutput(id uint) (path string, err error) { m := &model.Analysis{} @@ -2361,7 +2323,6 @@ func (r *ReportWriter) buildOutput(id uint) (path string, err error) { return } -// // addTags writes tags. func (r *ReportWriter) addTags(m *model.Analysis) (err error) { r.field("tags") diff --git a/api/application.go b/api/application.go index c8a1bb653..1e3df78e3 100644 --- a/api/application.go +++ b/api/application.go @@ -13,7 +13,6 @@ import ( "gorm.io/gorm/clause" ) -// // Routes const ( ApplicationsRoot = "/applications" @@ -29,26 +28,22 @@ const ( AppAssessmentRoot = AppAssessmentsRoot + "/:" + ID2 ) -// // Params const ( Source = "source" ) -// // Tag Sources const ( SourceAssessment = "assessment" SourceArchetype = "archetype" ) -// // ApplicationHandler handles application resource routes. type ApplicationHandler struct { BucketOwner } -// // AddRoutes adds routes. func (h ApplicationHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -1066,7 +1061,6 @@ func (h ApplicationHandler) AssessmentCreate(ctx *gin.Context) { h.Respond(ctx, http.StatusCreated, r) } -// // Application REST resource. type Application struct { Resource `yaml:",inline"` @@ -1091,7 +1085,6 @@ type Application struct { Effort int `json:"effort"` } -// // With updates the resource using the model. func (r *Application) With(m *model.Application, tags []model.ApplicationTag) { r.Resource.With(&m.Model) @@ -1146,7 +1139,6 @@ func (r *Application) With(m *model.Application, tags []model.ApplicationTag) { r.Risk = assessment.RiskUnknown } -// // WithVirtualTags updates the resource with tags derived from assessments. func (r *Application) WithVirtualTags(tags []model.Tag, source string) { for _, t := range tags { @@ -1156,7 +1148,6 @@ func (r *Application) WithVirtualTags(tags []model.Tag, source string) { } } -// // WithResolver uses an ApplicationResolver to update the resource with // values derived from the application's assessments and archetypes. func (r *Application) WithResolver(resolver *assessment.ApplicationResolver) (err error) { @@ -1192,7 +1183,6 @@ func (r *Application) WithResolver(resolver *assessment.ApplicationResolver) (er return } -// // Model builds a model. func (r *Application) Model() (m *model.Application) { m = &model.Application{ @@ -1245,7 +1235,6 @@ func (r *Application) Model() (m *model.Application) { return } -// // Repository REST nested resource. type Repository struct { Kind string `json:"kind"` @@ -1255,7 +1244,6 @@ type Repository struct { Path string `json:"path"` } -// // Fact REST nested resource. type Fact struct { Key string `json:"key"` @@ -1277,20 +1265,21 @@ func (r *Fact) Model() (m *model.Fact) { return } -// // FactKey is a fact source and fact name separated by a colon. -// Example: 'analysis:languages' +// +// Example: 'analysis:languages' // // A FactKey can be used to identify an anonymous fact. -// Example: 'languages' or ':languages' +// +// Example: 'languages' or ':languages' // // A FactKey can also be used to identify just a source. This use must include the trailing // colon to distinguish it from an anonymous fact. This is used when listing or replacing // all facts that belong to a source. -// Example: 'analysis:" +// +// Example: 'analysis:" type FactKey string -// // Qualify qualifies the name with the source. func (r *FactKey) Qualify(source string) { *r = FactKey( @@ -1299,7 +1288,6 @@ func (r *FactKey) Qualify(source string) { ":")) } -// // Source returns the source portion of a fact key. func (r FactKey) Source() (source string) { s, _, found := strings.Cut(string(r), ":") @@ -1309,7 +1297,6 @@ func (r FactKey) Source() (source string) { return } -// // Name returns the name portion of a fact key. func (r FactKey) Name() (name string) { _, n, found := strings.Cut(string(r), ":") @@ -1321,7 +1308,6 @@ func (r FactKey) Name() (name string) { return } -// // Stakeholders REST subresource. type Stakeholders struct { Owner *Ref `json:"owner"` diff --git a/api/archetype.go b/api/archetype.go index f647395ec..e2efd0670 100644 --- a/api/archetype.go +++ b/api/archetype.go @@ -10,7 +10,6 @@ import ( "gorm.io/gorm/clause" ) -// // Routes const ( ArchetypesRoot = "/archetypes" @@ -18,13 +17,11 @@ const ( ArchetypeAssessmentsRoot = ArchetypeRoot + "/assessments" ) -// // ArchetypeHandler handles Archetype resource routes. type ArchetypeHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h ArchetypeHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -335,7 +332,6 @@ func (h ArchetypeHandler) AssessmentCreate(ctx *gin.Context) { h.Respond(ctx, http.StatusCreated, r) } -// // Archetype REST resource. type Archetype struct { Resource `yaml:",inline"` @@ -354,7 +350,6 @@ type Archetype struct { Review *Ref `json:"review"` } -// // With updates the resource with the model. func (r *Archetype) With(m *model.Archetype) { r.Resource.With(&m.Model) @@ -393,7 +388,6 @@ func (r *Archetype) With(m *model.Archetype) { r.Risk = assessment.RiskUnknown } -// // WithResolver uses an ArchetypeResolver to update the resource with // values derived from the archetype's assessments. func (r *Archetype) WithResolver(resolver *assessment.ArchetypeResolver) (err error) { @@ -416,7 +410,6 @@ func (r *Archetype) WithResolver(resolver *assessment.ArchetypeResolver) (err er return } -// // Model builds a model from the resource. func (r *Archetype) Model() (m *model.Archetype) { m = &model.Archetype{ diff --git a/api/assessment.go b/api/assessment.go index ee1d73631..d024637eb 100644 --- a/api/assessment.go +++ b/api/assessment.go @@ -10,20 +10,17 @@ import ( "gorm.io/gorm/clause" ) -// // Routes const ( AssessmentsRoot = "/assessments" AssessmentRoot = AssessmentsRoot + "/:" + ID ) -// // AssessmentHandler handles Assessment resource routes. type AssessmentHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h AssessmentHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -148,7 +145,6 @@ func (h AssessmentHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Assessment REST resource. type Assessment struct { Resource `yaml:",inline"` @@ -167,7 +163,6 @@ type Assessment struct { Required bool `json:"required"` } -// // With updates the resource with the model. func (r *Assessment) With(m *model.Assessment) { r.Resource.With(&m.Model) @@ -197,7 +192,6 @@ func (r *Assessment) With(m *model.Assessment) { r.Status = a.Status() } -// // Model builds a model. func (r *Assessment) Model() (m *model.Assessment) { m = &model.Assessment{} diff --git a/api/auth.go b/api/auth.go index 8956813a5..e247dae1b 100644 --- a/api/auth.go +++ b/api/auth.go @@ -6,7 +6,6 @@ import ( "net/http" ) -// // Routes const ( AuthRoot = "/auth" @@ -14,13 +13,11 @@ const ( AuthRefreshRoot = AuthRoot + "/refresh" ) -// // AuthHandler handles auth routes. type AuthHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h AuthHandler) AddRoutes(e *gin.Engine) { e.POST(AuthLoginRoot, h.Login) @@ -87,7 +84,6 @@ func (h AuthHandler) Refresh(ctx *gin.Context) { h.Respond(ctx, http.StatusCreated, r) } -// // Login REST resource. type Login struct { User string `json:"user"` @@ -97,7 +93,6 @@ type Login struct { Expiry int `json:"expiry"` } -// // Required enforces that the user (identified by a token) has // been granted the necessary scope to access a resource. func Required(scope string) func(*gin.Context) { diff --git a/api/base.go b/api/base.go index d40512cb3..40a6fb53a 100644 --- a/api/base.go +++ b/api/base.go @@ -30,11 +30,9 @@ const ( MaxCount = 50000 ) -// // BaseHandler base handler. type BaseHandler struct{} -// // DB return db client associated with the context. func (h *BaseHandler) DB(ctx *gin.Context) (db *gorm.DB) { rtx := WithContext(ctx) @@ -42,7 +40,6 @@ func (h *BaseHandler) DB(ctx *gin.Context) (db *gorm.DB) { return } -// // Client returns k8s client from the context. func (h *BaseHandler) Client(ctx *gin.Context) (client client.Client) { rtx := WithContext(ctx) @@ -50,7 +47,6 @@ func (h *BaseHandler) Client(ctx *gin.Context) (client client.Client) { return } -// // WithCount report count. // Sets the X-Total header for pagination. // Returns an error when count exceeds the limited and @@ -78,7 +74,6 @@ func (h *BaseHandler) WithCount(ctx *gin.Context, count int64) (err error) { return } -// // preLoad update DB to pre-load fields. func (h *BaseHandler) preLoad(db *gorm.DB, fields ...string) (tx *gorm.DB) { tx = db @@ -89,14 +84,12 @@ func (h *BaseHandler) preLoad(db *gorm.DB, fields ...string) (tx *gorm.DB) { return } -// // fields builds a map of fields. func (h *BaseHandler) fields(m interface{}) (mp map[string]interface{}) { mp = reflect.Fields(m) return } -// // pk returns the PK (ID) parameter. func (h *BaseHandler) pk(ctx *gin.Context) (id uint) { s := ctx.Param(ID) @@ -105,11 +98,10 @@ func (h *BaseHandler) pk(ctx *gin.Context) (id uint) { return } -// // modBody updates the body using the `mod` function. -// 1. read the body. -// 2. mod() -// 3. write body. +// 1. read the body. +// 2. mod() +// 3. write body. func (h *BaseHandler) modBody( ctx *gin.Context, r interface{}, @@ -133,7 +125,6 @@ func (h *BaseHandler) modBody( return } -// // CurrentUser gets username from Keycloak auth token. func (h *BaseHandler) CurrentUser(ctx *gin.Context) (user string) { rtx := WithContext(ctx) @@ -145,7 +136,6 @@ func (h *BaseHandler) CurrentUser(ctx *gin.Context) (user string) { return } -// // HasScope determines if the token has the specified scope. func (h *BaseHandler) HasScope(ctx *gin.Context, scope string) (b bool) { in := auth.BaseScope{} @@ -160,7 +150,6 @@ func (h *BaseHandler) HasScope(ctx *gin.Context, scope string) (b bool) { return } -// // Bind based on Content-Type header. // Opinionated towards json. func (h *BaseHandler) Bind(ctx *gin.Context, r interface{}) (err error) { @@ -180,7 +169,6 @@ func (h *BaseHandler) Bind(ctx *gin.Context, r interface{}) (err error) { return } -// // BindJSON attempts to bind a request body to a struct, assuming that the body is JSON. // Binding is strict: unknown fields in the input will cause binding to fail. func (h *BaseHandler) BindJSON(ctx *gin.Context, r interface{}) (err error) { @@ -199,7 +187,6 @@ func (h *BaseHandler) BindJSON(ctx *gin.Context, r interface{}) (err error) { return } -// // BindYAML attempts to bind a request body to a struct, assuming that the body is YAML. // Binding is strict: unknown fields in the input will cause binding to fail. func (h *BaseHandler) BindYAML(ctx *gin.Context, r interface{}) (err error) { @@ -218,7 +205,6 @@ func (h *BaseHandler) BindYAML(ctx *gin.Context, r interface{}) (err error) { return } -// // Validate that the struct field values obey the binding field tags. func (h *BaseHandler) Validate(r interface{}) (err error) { if binding.Validator == nil { @@ -231,7 +217,6 @@ func (h *BaseHandler) Validate(r interface{}) (err error) { return } -// // Decoder returns a decoder based on encoding. // Opinionated towards json. func (h *BaseHandler) Decoder(ctx *gin.Context, encoding string, r io.Reader) (d Decoder, err error) { @@ -255,21 +240,18 @@ func (h *BaseHandler) Decoder(ctx *gin.Context, encoding string, r io.Reader) (d return } -// // Status sets the status code. func (h *BaseHandler) Status(ctx *gin.Context, code int) { rtx := WithContext(ctx) rtx.Status(code) } -// // Respond sets the response. func (h *BaseHandler) Respond(ctx *gin.Context, code int, r interface{}) { rtx := WithContext(ctx) rtx.Respond(code, r) } -// // Accepted determines if the mime is accepted. // Wildcards ignored. func (h *BaseHandler) Accepted(ctx *gin.Context, mimes ...string) (b bool) { @@ -287,7 +269,6 @@ func (h *BaseHandler) Accepted(ctx *gin.Context, mimes ...string) (b bool) { return } -// // Attachment sets the Content-Disposition header. func (h *BaseHandler) Attachment(ctx *gin.Context, name string) { attachment := fmt.Sprintf("attachment; filename=\"%s\"", name) @@ -296,7 +277,6 @@ func (h *BaseHandler) Attachment(ctx *gin.Context, name string) { attachment) } -// // REST resource. type Resource struct { ID uint `json:"id,omitempty" yaml:"id,omitempty"` @@ -305,7 +285,6 @@ type Resource struct { CreateTime time.Time `json:"createTime" yaml:"createTime,omitempty"` } -// // With updates the resource with the model. func (r *Resource) With(m *model.Model) { r.ID = m.ID @@ -314,7 +293,6 @@ func (r *Resource) With(m *model.Model) { r.CreateTime = m.CreateTime } -// // ref with id and named model. func (r *Resource) ref(id uint, m interface{}) (ref Ref) { ref.ID = id @@ -322,7 +300,6 @@ func (r *Resource) ref(id uint, m interface{}) (ref Ref) { return } -// // refPtr with id and named model. func (r *Resource) refPtr(id *uint, m interface{}) (ref *Ref) { if id == nil { @@ -334,7 +311,6 @@ func (r *Resource) refPtr(id *uint, m interface{}) (ref *Ref) { return } -// // idPtr extracts ref ID. func (r *Resource) idPtr(ref *Ref) (id *uint) { if ref != nil { @@ -343,14 +319,12 @@ func (r *Resource) idPtr(ref *Ref) (id *uint) { return } -// // nameOf model. func (r *Resource) nameOf(m interface{}) (name string) { name = reflect.NameOf(m) return } -// // Ref represents a FK. // Contains the PK and (name) natural key. // The name is optional and read-only. @@ -359,14 +333,12 @@ type Ref struct { Name string `json:"name,omitempty"` } -// // With id and named model. func (r *Ref) With(id uint, name string) { r.ID = id r.Name = name } -// // TagRef represents a reference to a Tag. // Contains the tag ID, name, tag source. type TagRef struct { @@ -376,7 +348,6 @@ type TagRef struct { Virtual bool `json:"virtual,omitempty" yaml:"virtual,omitempty"` } -// // With id and named model. func (r *TagRef) With(id uint, name string, source string, virtual bool) { r.ID = id @@ -385,14 +356,12 @@ func (r *TagRef) With(id uint, name string, source string, virtual bool) { r.Virtual = virtual } -// // Page provides pagination. type Page struct { Offset int Limit int } -// // With context. func (p *Page) With(ctx *gin.Context) { s := ctx.Query("offset") @@ -406,7 +375,6 @@ func (p *Page) With(ctx *gin.Context) { return } -// // Paginated returns a paginated DB. func (p *Page) Paginated(in *gorm.DB) (out *gorm.DB) { out = in @@ -419,17 +387,14 @@ func (p *Page) Paginated(in *gorm.DB) (out *gorm.DB) { return } -// // Sort provides sorting. type Sort = sort.Sort -// // Decoder binding decoder. type Decoder interface { Decode(r interface{}) (err error) } -// // Cursor Paginated rows iterator. type Cursor struct { Page @@ -439,7 +404,6 @@ type Cursor struct { Error error } -// // Next returns true when has next row. func (r *Cursor) Next(m interface{}) (next bool) { if r.Error != nil { @@ -467,7 +431,6 @@ func (r *Cursor) Next(m interface{}) (next bool) { return } -// // With configures the cursor. func (r *Cursor) With(db *gorm.DB, p Page) { r.DB = db.Offset(p.Offset) @@ -476,14 +439,12 @@ func (r *Cursor) With(db *gorm.DB, p Page) { r.Page = p } -// // Count returns the count adjusted for offset. func (r *Cursor) Count() (n int64) { n = int64(r.Offset) + r.Index return n } -// // Close the cursor. func (r *Cursor) Close() { if r.Rows != nil { @@ -491,7 +452,6 @@ func (r *Cursor) Close() { } } -// // pageLimited returns true when page Limit defined and exceeded. func (r *Cursor) pageLimited() (b bool) { if r.Limit < 1 { @@ -501,7 +461,6 @@ func (r *Cursor) pageLimited() (b bool) { return } -// // StrMap returns a map[string]any. // The YAML decoder can produce map[any]any which is not valid for json. // Converts map[any]any to map[string]any as needed. diff --git a/api/batch.go b/api/batch.go index ccdc1098e..e71a4cb8b 100644 --- a/api/batch.go +++ b/api/batch.go @@ -8,7 +8,6 @@ import ( "net/http" ) -// // Routes const ( BatchRoot = "/batch" @@ -16,13 +15,11 @@ const ( BatchTagsRoot = BatchRoot + TagsRoot ) -// // BatchHandler handles batch resource creation routes. type BatchHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h BatchHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") diff --git a/api/bucket.go b/api/bucket.go index bb3c36456..7775cd26c 100644 --- a/api/bucket.go +++ b/api/bucket.go @@ -13,7 +13,6 @@ import ( "time" ) -// // Routes const ( BucketsRoot = "/buckets" @@ -21,13 +20,11 @@ const ( BucketContentRoot = BucketRoot + "/*" + Wildcard ) -// // BucketHandler handles bucket routes. type BucketHandler struct { BucketOwner } -// // AddRoutes adds routes. func (h BucketHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -192,7 +189,6 @@ func (h BucketHandler) BucketDelete(ctx *gin.Context) { h.bucketDelete(ctx, h.pk(ctx)) } -// // Bucket REST resource. type Bucket struct { Resource `yaml:",inline"` @@ -200,7 +196,6 @@ type Bucket struct { Expiration *time.Time `json:"expiration,omitempty"` } -// // With updates the resource with the model. func (r *Bucket) With(m *model.Bucket) { r.Resource.With(&m.Model) @@ -212,13 +207,15 @@ type BucketOwner struct { BaseHandler } -// // bucketGet reads bucket content. // When path is DIRECTORY: -// Accept=text/html return body is index.html. -// Else streams tarball. +// +// Accept=text/html return body is index.html. +// Else streams tarball. +// // When path is FILE: -// Streams FILE content. +// +// Streams FILE content. func (h *BucketOwner) bucketGet(ctx *gin.Context, id uint) { var err error m := &model.Bucket{} @@ -246,7 +243,6 @@ func (h *BucketOwner) bucketGet(ctx *gin.Context, id uint) { } } -// // bucketPut write a file to the bucket. // The `Directory` header determines how the uploaded file is to be handled. // When `Directory`=Expand, the file (TARBALL) is extracted into the bucket. @@ -271,7 +267,6 @@ func (h *BucketOwner) bucketPut(ctx *gin.Context, id uint) { h.Status(ctx, http.StatusNoContent) } -// // bucketDelete content from the bucket. func (h *BucketOwner) bucketDelete(ctx *gin.Context, id uint) { m := &model.Bucket{} @@ -290,7 +285,6 @@ func (h *BucketOwner) bucketDelete(ctx *gin.Context, id uint) { h.Status(ctx, http.StatusNoContent) } -// // putDir write a directory into bucket. func (h *BucketOwner) putDir(ctx *gin.Context, output string) (err error) { file, err := ctx.FormFile(FileField) @@ -316,7 +310,6 @@ func (h *BucketOwner) putDir(ctx *gin.Context, output string) (err error) { return } -// // getDir reads a directory from the bucket. func (h *BucketOwner) getDir(ctx *gin.Context, input string, filter tar.Filter) { tarWriter := tar.NewWriter(ctx.Writer) @@ -336,7 +329,6 @@ func (h *BucketOwner) getDir(ctx *gin.Context, input string, filter tar.Filter) return } -// // getFile reads a file from the bucket. func (h *BucketOwner) getFile(ctx *gin.Context, m *model.Bucket) { rPath := ctx.Param(Wildcard) @@ -344,7 +336,6 @@ func (h *BucketOwner) getFile(ctx *gin.Context, m *model.Bucket) { ctx.File(path) } -// // putFile writes a file to the bucket. func (h *BucketOwner) putFile(ctx *gin.Context, m *model.Bucket) (err error) { path := pathlib.Join(m.Path, ctx.Param(Wildcard)) diff --git a/api/businessservice.go b/api/businessservice.go index b715dd40e..940b6f966 100644 --- a/api/businessservice.go +++ b/api/businessservice.go @@ -7,20 +7,17 @@ import ( "net/http" ) -// // Routes const ( BusinessServicesRoot = "/businessservices" BusinessServiceRoot = BusinessServicesRoot + "/:" + ID ) -// // BusinessServiceHandler handles business-service routes. type BusinessServiceHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h BusinessServiceHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -164,7 +161,6 @@ func (h BusinessServiceHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // BusinessService REST resource. type BusinessService struct { Resource `yaml:",inline"` @@ -173,7 +169,6 @@ type BusinessService struct { Stakeholder *Ref `json:"owner"` } -// // With updates the resource with the model. func (r *BusinessService) With(m *model.BusinessService) { r.Resource.With(&m.Model) @@ -182,7 +177,6 @@ func (r *BusinessService) With(m *model.BusinessService) { r.Stakeholder = r.refPtr(m.StakeholderID, m.Stakeholder) } -// // Model builds a model. func (r *BusinessService) Model() (m *model.BusinessService) { m = &model.BusinessService{ diff --git a/api/cache.go b/api/cache.go index 3ade7b329..d7ad30586 100644 --- a/api/cache.go +++ b/api/cache.go @@ -11,20 +11,17 @@ import ( "strings" ) -// // Routes const ( CacheRoot = "/cache" CacheDirRoot = CacheRoot + "/*" + Wildcard ) -// // CacheHandler handles cache routes. type CacheHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h CacheHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -91,7 +88,6 @@ func (h CacheHandler) Delete(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // cache builds the resource. func (h *CacheHandler) cache(dir string) (cache *Cache, err error) { cache = &Cache{} @@ -143,7 +139,6 @@ func (h *CacheHandler) cache(dir string) (cache *Cache, err error) { return } -// // Cache REST resource. type Cache struct { Path string `json:"path"` diff --git a/api/context.go b/api/context.go index 1f0a7a595..f9670ccac 100644 --- a/api/context.go +++ b/api/context.go @@ -8,7 +8,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// // Context custom settings. type Context struct { *gin.Context @@ -24,14 +23,12 @@ type Context struct { Response Response } -// // Response values. type Response struct { Status int Body interface{} } -// // Status sets the values to respond to the request with. func (r *Context) Status(status int) { r.Response = Response{ @@ -40,7 +37,6 @@ func (r *Context) Status(status int) { } } -// // Respond sets the values to respond to the request with. func (r *Context) Respond(status int, body interface{}) { r.Response = Response{ @@ -49,7 +45,6 @@ func (r *Context) Respond(status int, body interface{}) { } } -// // WithContext is a rich context. func WithContext(ctx *gin.Context) (n *Context) { key := "RichContext" @@ -64,7 +59,6 @@ func WithContext(ctx *gin.Context) (n *Context) { return } -// // Transaction handler. func Transaction(ctx *gin.Context) { switch ctx.Request.Method { @@ -90,7 +84,6 @@ func Transaction(ctx *gin.Context) { } } -// // Render renders the response based on the Accept: header. // Opinionated towards json. func Render() gin.HandlerFunc { diff --git a/api/dependency.go b/api/dependency.go index 220e9157e..ec53269e9 100644 --- a/api/dependency.go +++ b/api/dependency.go @@ -8,20 +8,17 @@ import ( "gorm.io/gorm/clause" ) -// // Routes const ( DependenciesRoot = "/dependencies" DependencyRoot = DependenciesRoot + "/:" + ID ) -// // DependencyHandler handles application dependency routes. type DependencyHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h DependencyHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -56,7 +53,6 @@ func (h DependencyHandler) Get(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, r) } -// // List godoc // @summary List all dependencies. // @description List all dependencies. @@ -145,7 +141,6 @@ func (h DependencyHandler) Delete(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Dependency REST resource. type Dependency struct { Resource `yaml:",inline"` @@ -153,7 +148,6 @@ type Dependency struct { From Ref `json:"from"` } -// // With updates the resource using the model. func (r *Dependency) With(m *model.Dependency) { r.Resource.With(&m.Model) diff --git a/api/error.go b/api/error.go index f6e7c6024..1c2b797fd 100644 --- a/api/error.go +++ b/api/error.go @@ -13,7 +13,6 @@ import ( "os" ) -// // BadRequestError reports bad request errors. type BadRequestError struct { Reason string @@ -28,7 +27,6 @@ func (r *BadRequestError) Is(err error) (matched bool) { return } -// // BatchError reports errors stemming from batch operations. type BatchError struct { Message string @@ -49,7 +47,6 @@ func (r BatchError) Is(err error) (matched bool) { return } -// // TrackerError reports an error stemming from the Hub being unable // to communicate with an external issue tracker. type TrackerError struct { @@ -65,7 +62,6 @@ func (r *TrackerError) Is(err error) (matched bool) { return } -// // Forbidden reports auth errors. type Forbidden struct { Reason string @@ -80,7 +76,6 @@ func (r *Forbidden) Is(err error) (matched bool) { return } -// // ErrorHandler handles error conditions from lower handlers. func ErrorHandler() gin.HandlerFunc { return func(ctx *gin.Context) { diff --git a/api/file.go b/api/file.go index 6f907f793..b633753ec 100644 --- a/api/file.go +++ b/api/file.go @@ -11,20 +11,17 @@ import ( "time" ) -// // Routes const ( FilesRoot = "/files" FileRoot = FilesRoot + "/:" + ID ) -// // FileHandler handles file routes. type FileHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h FileHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -242,7 +239,6 @@ func (h FileHandler) Delete(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // File REST resource. type File struct { Resource `yaml:",inline"` @@ -251,7 +247,6 @@ type File struct { Expiration *time.Time `json:"expiration,omitempty"` } -// // With updates the resource with the model. func (r *File) With(m *model.File) { r.Resource.With(&m.Model) diff --git a/api/filter/error.go b/api/filter/error.go index 69887e227..105a2756b 100644 --- a/api/filter/error.go +++ b/api/filter/error.go @@ -2,7 +2,6 @@ package filter import "fmt" -// // Error reports bad request errors. type Error struct { Reason string @@ -17,7 +16,6 @@ func (r *Error) Is(err error) (matched bool) { return } -// // Errorf build error. func Errorf(s string, v ...interface{}) (err error) { err = &Error{fmt.Sprintf(s, v...)} diff --git a/api/filter/filter.go b/api/filter/filter.go index 181df8c6a..e86a0ec2f 100644 --- a/api/filter/filter.go +++ b/api/filter/filter.go @@ -11,7 +11,6 @@ const ( QueryParam = "filter" ) -// // New filter. func New(ctx *gin.Context, assertions []Assert) (f Filter, err error) { p := Parser{} @@ -26,13 +25,11 @@ func New(ctx *gin.Context, assertions []Assert) (f Filter, err error) { return } -// // Filter is a collection of predicates. type Filter struct { predicates []Predicate } -// // Validate - func (f *Filter) Validate(assertions []Assert) (err error) { if len(assertions) == 0 { @@ -65,7 +62,6 @@ func (f *Filter) Validate(assertions []Assert) (err error) { return } -// // Field returns a field. func (f *Filter) Field(name string) (field Field, found bool) { fields := f.Fields(name) @@ -76,7 +72,6 @@ func (f *Filter) Field(name string) (field Field, found bool) { return } -// // Fields returns fields. func (f *Filter) Fields(name string) (fields []Field) { name = strings.ToLower(name) @@ -89,7 +84,6 @@ func (f *Filter) Fields(name string) (fields []Field) { return } -// // Resource returns a filter scoped to resource. func (f *Filter) Resource(r string) (filter Filter) { r = strings.ToLower(r) @@ -107,7 +101,6 @@ func (f *Filter) Resource(r string) (filter Filter) { return } -// // Where applies (root) fields to the where clause. func (f *Filter) Where(in *gorm.DB, selector ...string) (out *gorm.DB) { out = in @@ -121,7 +114,6 @@ func (f *Filter) Where(in *gorm.DB, selector ...string) (out *gorm.DB) { return } -// // With return filter with selected predicates. func (f *Filter) With(selector ...string) (out Filter) { fs := FieldSelector(selector) @@ -134,7 +126,6 @@ func (f *Filter) With(selector ...string) (out Filter) { return } -// // Delete specified fields. func (f *Filter) Delete(name string) (found bool) { var wanted []Predicate @@ -149,13 +140,11 @@ func (f *Filter) Delete(name string) (found bool) { return } -// // Empty returns true when the filter has no predicates. func (f *Filter) Empty() bool { return len(f.predicates) == 0 } -// // FieldSelector fields. // fields with '+' prefix are included. // fields with '-' prefix are excluded. @@ -163,7 +152,6 @@ func (f *Filter) Empty() bool { // An empty selector includes ALL. type FieldSelector []string -// // Match fields by qualified name. func (r FieldSelector) Match(f *Field) (m bool) { if f.Resource() != "" { @@ -200,20 +188,17 @@ func (r FieldSelector) Match(f *Field) (m bool) { return } -// // Field predicate. type Field struct { Predicate } -// // Name returns the field name. func (f *Field) Name() (s string) { _, s = f.split() return } -// // As returns the renamed field. func (f *Field) As(s string) (named Field) { named = Field{f.Predicate} @@ -221,14 +206,12 @@ func (f *Field) As(s string) (named Field) { return } -// // Resource returns the field resource. func (f *Field) Resource() (s string) { s, _ = f.split() return } -// // Where updates the where clause. func (f *Field) Where(in *gorm.DB) (out *gorm.DB) { sql, values := f.SQL() @@ -236,7 +219,6 @@ func (f *Field) Where(in *gorm.DB) (out *gorm.DB) { return } -// // SQL builds SQL. // Returns statement and values (for ?). func (f *Field) SQL() (s string, vList []interface{}) { @@ -301,7 +283,6 @@ func (f *Field) SQL() (s string, vList []interface{}) { return } -// // Expand flattens a multi-value field and returns a Field for each value. func (f *Field) Expand() (expanded []Field) { for _, v := range f.Value.ByKind(LITERAL, STRING) { @@ -317,7 +298,6 @@ func (f *Field) Expand() (expanded []Field) { return } -// // split field name. // format: resource.name // The resource may be "" (anonymous). @@ -333,7 +313,6 @@ func (f *Field) split() (relation string, name string) { return } -// // operator returns SQL operator. func (f *Field) operator() (s string) { switch len(f.Value) { @@ -352,7 +331,6 @@ func (f *Field) operator() (s string) { return } -// // Assert - type Assert struct { Field string @@ -360,7 +338,6 @@ type Assert struct { And bool } -// // assert validation. func (r *Assert) assert(p *Predicate) (err error) { name := p.Field.Value @@ -381,7 +358,6 @@ func (r *Assert) assert(p *Predicate) (err error) { return } -// // AsValue returns the real value. func AsValue(t Token) (object interface{}) { v := t.Value diff --git a/api/filter/lexer.go b/api/filter/lexer.go index 5091c7e54..8aafef5f0 100644 --- a/api/filter/lexer.go +++ b/api/filter/lexer.go @@ -25,14 +25,12 @@ const ( OPERATOR = 0x03 ) -// // Lexer token reader. type Lexer struct { tokens []Token index int } -// // With builds with the specified filter. func (r *Lexer) With(filter string) (err error) { reader := Reader{input: filter} @@ -100,7 +98,6 @@ func (r *Lexer) With(filter string) (err error) { return } -// // next returns the next token. func (r *Lexer) next() (token Token, next bool) { if r.index < len(r.tokens) { @@ -111,7 +108,6 @@ func (r *Lexer) next() (token Token, next bool) { return } -// // Put rewinds the lexer by 1 token. func (r *Lexer) put() { if r.index > 0 { @@ -119,21 +115,18 @@ func (r *Lexer) put() { } } -// // Token scanned token. type Token struct { Kind byte Value string } -// // Reader scan the input. type Reader struct { input string index int } -// // Next character. // Returns 0 at EOF. func (r *Reader) next() (ch byte) { @@ -144,7 +137,6 @@ func (r *Reader) next() (ch byte) { return } -// // Put rewinds one character. func (r *Reader) put() { if r.index > 0 { @@ -152,13 +144,11 @@ func (r *Reader) put() { } } -// // Quoted string token reader. type Quoted struct { *Reader } -// // Read token. func (q *Quoted) Read() (token Token, err error) { lastCh := byte(0) @@ -185,13 +175,11 @@ func (q *Quoted) Read() (token Token, err error) { return } -// // Operator token reader. type Operator struct { *Reader } -// // Read token. func (q *Operator) Read() (token Token, err error) { var bfr []byte diff --git a/api/filter/parser.go b/api/filter/parser.go index 9f2fb5def..5bde583ef 100644 --- a/api/filter/parser.go +++ b/api/filter/parser.go @@ -2,12 +2,10 @@ package filter import "math" -// // Parser used to parse the filter. type Parser struct { } -// // Filter parses the filter and builds a Filter. func (r *Parser) Filter(filter string) (f Filter, err error) { if filter == "" { @@ -67,7 +65,6 @@ func (r *Parser) Filter(filter string) (f Filter, err error) { return } -// // Predicate filter predicate. type Predicate struct { Unused Token @@ -76,11 +73,9 @@ type Predicate struct { Value Value } -// // Value term value. type Value []Token -// // ByKind returns values by kind. func (r Value) ByKind(kind ...byte) (matched []Token) { for _, t := range r { @@ -93,7 +88,6 @@ func (r Value) ByKind(kind ...byte) (matched []Token) { return } -// // Operator returns true when contains the specified operator. func (r *Value) Operator(operator byte) (matched bool) { operators := r.ByKind(OPERATOR) @@ -103,14 +97,12 @@ func (r *Value) Operator(operator byte) (matched bool) { return } -// // List construct. // Example: (red|blue|green) type List struct { *Lexer } -// // Build the value. func (r *List) Build() (v Value, err error) { for { @@ -145,7 +137,6 @@ func (r *List) Build() (v Value, err error) { return } -// // validate the result. func (r *List) validate(v Value) (err error) { lastOp := byte(0) diff --git a/api/group.go b/api/group.go index 5d0438ed0..c9f26bd41 100644 --- a/api/group.go +++ b/api/group.go @@ -7,20 +7,17 @@ import ( "net/http" ) -// // Routes const ( StakeholderGroupsRoot = "/stakeholdergroups" StakeholderGroupRoot = StakeholderGroupsRoot + "/:" + ID ) -// // StakeholderGroupHandler handles stakeholder group routes. type StakeholderGroupHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h StakeholderGroupHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -176,7 +173,6 @@ func (h StakeholderGroupHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // StakeholderGroup REST resource. type StakeholderGroup struct { Resource `yaml:",inline"` @@ -186,7 +182,6 @@ type StakeholderGroup struct { MigrationWaves []Ref `json:"migrationWaves" yaml:"migrationWaves"` } -// // With updates the resource with the model. func (r *StakeholderGroup) With(m *model.StakeholderGroup) { r.Resource.With(&m.Model) @@ -206,7 +201,6 @@ func (r *StakeholderGroup) With(m *model.StakeholderGroup) { } } -// // Model builds a model. func (r *StakeholderGroup) Model() (m *model.StakeholderGroup) { m = &model.StakeholderGroup{ diff --git a/api/identity.go b/api/identity.go index f429f484b..5a6185325 100644 --- a/api/identity.go +++ b/api/identity.go @@ -7,21 +7,18 @@ import ( "strconv" ) -// // Routes const ( IdentitiesRoot = "/identities" IdentityRoot = IdentitiesRoot + "/:" + ID ) -// // Params. const ( Decrypted = "decrypted" AppId = "application" ) -// // IdentityHandler handles identity resource routes. type IdentityHandler struct { BaseHandler @@ -211,7 +208,6 @@ func (h IdentityHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Set `decrypted` in the context. // Results in 403 when the token does not have the required scope. func (h *IdentityHandler) setDecrypted(ctx *gin.Context) { @@ -228,7 +224,6 @@ func (h *IdentityHandler) setDecrypted(ctx *gin.Context) { return } -// // Identity REST resource. type Identity struct { Resource `yaml:",inline"` @@ -241,7 +236,6 @@ type Identity struct { Settings string `json:"settings"` } -// // With updates the resource with the model. func (r *Identity) With(m *model.Identity) { r.Resource.With(&m.Model) @@ -254,7 +248,6 @@ func (r *Identity) With(m *model.Identity) { r.Settings = m.Settings } -// // Model builds a model. func (r *Identity) Model() (m *model.Identity) { m = &model.Identity{ diff --git a/api/import.go b/api/import.go index 3b8fe19a0..bf91ebd81 100644 --- a/api/import.go +++ b/api/import.go @@ -11,7 +11,6 @@ import ( "time" ) -// // Record types const ( RecordTypeApplication = "1" @@ -22,14 +21,12 @@ const ( ExpectedFieldCount = 17 ) -// // Import Statuses const ( InProgress = "In Progress" Completed = "Completed" ) -// // Routes const ( SummariesRoot = "/importsummaries" @@ -40,13 +37,11 @@ const ( ImportRoot = ImportsRoot + "/:" + ID ) -// // ImportHandler handles import routes. type ImportHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h ImportHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -63,7 +58,6 @@ func (h ImportHandler) AddRoutes(e *gin.Engine) { routeGroup.POST(UploadRoot, h.UploadCSV) } -// // GetImport godoc // @summary Get an import by ID. // @description Get an import by ID. @@ -84,7 +78,6 @@ func (h ImportHandler) GetImport(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, m.AsMap()) } -// // ListImports godoc // @summary List imports. // @description List imports. @@ -119,7 +112,6 @@ func (h ImportHandler) ListImports(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, resources) } -// // DeleteImport godoc // @summary Delete an import. // @description Delete an import. This leaves any created application or dependency. @@ -138,7 +130,6 @@ func (h ImportHandler) DeleteImport(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // GetSummary godoc // @summary Get an import summary by ID. // @description Get an import by ID. @@ -159,7 +150,6 @@ func (h ImportHandler) GetSummary(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, m) } -// // ListSummaries godoc // @summary List import summaries. // @description List import summaries. @@ -185,7 +175,6 @@ func (h ImportHandler) ListSummaries(ctx *gin.Context) { h.Respond(ctx, http.StatusOK, resources) } -// // DeleteSummary godoc // @summary Delete an import summary and associated import records. // @description Delete an import summary and associated import records. @@ -204,7 +193,6 @@ func (h ImportHandler) DeleteSummary(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // UploadCSV godoc // @summary Upload a CSV containing applications and dependencies to import. // @description Upload a CSV containing applications and dependencies to import. @@ -301,7 +289,6 @@ func (h ImportHandler) UploadCSV(ctx *gin.Context) { h.Respond(ctx, http.StatusCreated, summary) } -// // DownloadCSV godoc // @summary Export the source CSV for a particular import summary. // @description Export the source CSV for a particular import summary. @@ -322,13 +309,14 @@ func (h ImportHandler) DownloadCSV(ctx *gin.Context) { ctx.Data(http.StatusOK, "text/csv", m.Content) } -// // CSV upload supports two types of records in the same file: application imports, and dependencies. // A dependency row must consist of the following columns: // // Col 1: Record Type 1 -- This will always contain a "2" for a dependency // Col 2: Application Name -- The name of the application that has the dependency relationship. -// This application must exist. +// +// This application must exist. +// // Col 6: Dependency -- The name of the application on the other side of the dependency relationship. // Col 7: Dependency Direction -- Whether this is a "northbound" or "southbound" dependency. // @@ -350,7 +338,6 @@ func (h ImportHandler) dependencyFromRow(fileName string, row []string) (app mod return } -// // CSV upload supports two types of records in the same file: application imports, and dependencies. // An application row must consist of the following columns: // @@ -359,7 +346,9 @@ func (h ImportHandler) dependencyFromRow(fileName string, row []string) (app mod // Col 3: Description -- A short description of the application. // Col 4: Comments -- Additional comments on the application. // Col 5: Business Service -- The name of the business service this Application should belong to. -// This business service must already exist. +// +// This business service must already exist. +// // Col 6: Dependency -- Optional dependency to another Application (by name) // Col 7: Dependency direction -- Either northbound or southbound // @@ -418,11 +407,9 @@ func (h ImportHandler) applicationFromRow(fileName string, row []string) (app mo return } -// // Import REST resource. type Import map[string]interface{} -// // ImportSummary REST resource. type ImportSummary struct { Resource `yaml:",inline"` @@ -434,7 +421,6 @@ type ImportSummary struct { CreateEntities bool `json:"createEntities" yaml:"createEntities"` } -// // With updates the resource with the model. func (r *ImportSummary) With(m *model.ImportSummary) { r.Resource.With(&m.Model) diff --git a/api/jobfunction.go b/api/jobfunction.go index 6458b75ab..4af8b3f9f 100644 --- a/api/jobfunction.go +++ b/api/jobfunction.go @@ -7,20 +7,17 @@ import ( "net/http" ) -// // Routes const ( JobFunctionsRoot = "/jobfunctions" JobFunctionRoot = JobFunctionsRoot + "/:" + ID ) -// // JobFunctionHandler handles job-function routes. type JobFunctionHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h JobFunctionHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -164,7 +161,6 @@ func (h JobFunctionHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // JobFunction REST resource. type JobFunction struct { Resource `yaml:",inline"` @@ -172,7 +168,6 @@ type JobFunction struct { Stakeholders []Ref `json:"stakeholders"` } -// // With updates the resource with the model. func (r *JobFunction) With(m *model.JobFunction) { r.Resource.With(&m.Model) @@ -184,7 +179,6 @@ func (r *JobFunction) With(m *model.JobFunction) { } } -// // Model builds a model. func (r *JobFunction) Model() (m *model.JobFunction) { m = &model.JobFunction{ diff --git a/api/migrationwave.go b/api/migrationwave.go index a2290d8bc..c819012a5 100644 --- a/api/migrationwave.go +++ b/api/migrationwave.go @@ -8,20 +8,17 @@ import ( "time" ) -// // Routes const ( MigrationWavesRoot = "/migrationwaves" MigrationWaveRoot = MigrationWavesRoot + "/:" + ID ) -// // MigrationWaveHandler handles Migration Wave resource routes. type MigrationWaveHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h MigrationWaveHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -180,7 +177,6 @@ func (h MigrationWaveHandler) Delete(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // MigrationWave REST Resource type MigrationWave struct { Resource `yaml:",inline"` @@ -192,7 +188,6 @@ type MigrationWave struct { StakeholderGroups []Ref `json:"stakeholderGroups" yaml:"stakeholderGroups"` } -// // With updates the resource using the model. func (r *MigrationWave) With(m *model.MigrationWave) { r.Resource.With(&m.Model) @@ -219,7 +214,6 @@ func (r *MigrationWave) With(m *model.MigrationWave) { } } -// // Model builds a model. func (r *MigrationWave) Model() (m *model.MigrationWave) { m = &model.MigrationWave{ diff --git a/api/pkg.go b/api/pkg.go index f1a0a0cb8..36f78c052 100644 --- a/api/pkg.go +++ b/api/pkg.go @@ -23,7 +23,6 @@ var ( log = logr.WithName("api") ) -// // Params const ( ID = "id" @@ -35,7 +34,6 @@ const ( FileField = "file" ) -// // Headers const ( Accept = "Accept" @@ -46,25 +44,21 @@ const ( Total = "X-Total" ) -// // MIME Types. const ( MIMEOCTETSTREAM = "application/octet-stream" TAR = "application/x-tar" ) -// // BindMIMEs supported binding MIME types. var BindMIMEs = []string{binding.MIMEJSON, binding.MIMEYAML} -// // Header Values const ( DirectoryArchive = "archive" DirectoryExpand = "expand" ) -// // All builds all handlers. func All() []Handler { return []Handler{ @@ -103,7 +97,6 @@ func All() []Handler { } } -// // Handler API. type Handler interface { AddRoutes(e *gin.Engine) diff --git a/api/proxy.go b/api/proxy.go index 4c5ffdd57..6308fc0f6 100644 --- a/api/proxy.go +++ b/api/proxy.go @@ -8,7 +8,6 @@ import ( "net/http" ) -// // Routes const ( ProxiesRoot = "/proxies" @@ -19,7 +18,6 @@ const ( Kind = "kind" ) -// // ProxyHandler handles proxy resource routes. type ProxyHandler struct { BaseHandler @@ -171,7 +169,6 @@ func (h ProxyHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Proxy REST resource. type Proxy struct { Resource `yaml:",inline"` @@ -183,7 +180,6 @@ type Proxy struct { Identity *Ref `json:"identity"` } -// // With updates the resource with the model. func (r *Proxy) With(m *model.Proxy) { r.Resource.With(&m.Model) @@ -198,7 +194,6 @@ func (r *Proxy) With(m *model.Proxy) { } } -// // Model builds a model. func (r *Proxy) Model() (m *model.Proxy) { m = &model.Proxy{ diff --git a/api/reflect/fields.go b/api/reflect/fields.go index 2d3de7877..f89c21764 100644 --- a/api/reflect/fields.go +++ b/api/reflect/fields.go @@ -5,7 +5,6 @@ import ( "time" ) -// // Fields returns a map of fields. func Fields(m interface{}) (mp map[string]interface{}) { var inspect func(r interface{}) @@ -61,7 +60,6 @@ func Fields(m interface{}) (mp map[string]interface{}) { return } -// // NameOf returns the name of a model. func NameOf(m interface{}) (name string) { mt := reflect.TypeOf(m) diff --git a/api/review.go b/api/review.go index 80cc3a1f8..172b3aaa6 100644 --- a/api/review.go +++ b/api/review.go @@ -7,7 +7,6 @@ import ( "net/http" ) -// // Routes const ( ReviewsRoot = "/reviews" @@ -15,13 +14,11 @@ const ( CopyRoot = ReviewsRoot + "/copy" ) -// // ReviewHandler handles review routes. type ReviewHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h ReviewHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -221,7 +218,6 @@ func (h ReviewHandler) CopyReview(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Review REST resource. type Review struct { Resource `yaml:",inline"` @@ -246,7 +242,6 @@ func (r *Review) With(m *model.Review) { r.Archetype = r.refPtr(m.ArchetypeID, m.Archetype) } -// // Model builds a model. func (r *Review) Model() (m *model.Review) { m = &model.Review{ @@ -265,7 +260,6 @@ func (r *Review) Model() (m *model.Review) { return } -// // CopyRequest REST resource. type CopyRequest struct { SourceReview uint `json:"sourceReview" binding:"required"` diff --git a/api/ruleset.go b/api/ruleset.go index 051b843a0..843e3b1b7 100644 --- a/api/ruleset.go +++ b/api/ruleset.go @@ -10,14 +10,12 @@ import ( "net/http" ) -// // Routes const ( RuleSetsRoot = "/rulesets" RuleSetRoot = RuleSetsRoot + "/:" + ID ) -// // RuleSetHandler handles ruleset resource routes. type RuleSetHandler struct { BaseHandler @@ -202,7 +200,6 @@ func (h *RuleSetHandler) ruleSetIDs(ctx *gin.Context, f qf.Filter) (q *gorm.DB) return } -// // create the ruleset. func (h *RuleSetHandler) create(ctx *gin.Context, r *RuleSet) (err error) { m := r.Model() @@ -222,7 +219,6 @@ func (h *RuleSetHandler) create(ctx *gin.Context, r *RuleSet) (err error) { return } -// // update the ruleset. func (h *RuleSetHandler) update(ctx *gin.Context, r *RuleSet) (err error) { m := &model.RuleSet{} @@ -279,7 +275,6 @@ func (h *RuleSetHandler) update(ctx *gin.Context, r *RuleSet) (err error) { return } -// // delete the ruleset. func (h *RuleSetHandler) delete(ctx *gin.Context, id uint) (err error) { ruleset := &model.RuleSet{} @@ -298,7 +293,6 @@ func (h *RuleSetHandler) delete(ctx *gin.Context, id uint) (err error) { return } -// // RuleSet REST resource. type RuleSet struct { Resource `yaml:",inline"` @@ -311,7 +305,6 @@ type RuleSet struct { DependsOn []Ref `json:"dependsOn" yaml:"dependsOn"` } -// // With updates the resource with the model. func (r *RuleSet) With(m *model.RuleSet) { r.Resource.With(&m.Model) @@ -336,7 +329,6 @@ func (r *RuleSet) With(m *model.RuleSet) { } } -// // Model builds a model. func (r *RuleSet) Model() (m *model.RuleSet) { m = &model.RuleSet{ @@ -365,7 +357,6 @@ func (r *RuleSet) Model() (m *model.RuleSet) { return } -// // HasRule - determine if the ruleset is referenced. func (r *RuleSet) HasRule(id uint) (b bool) { for _, ruleset := range r.Rules { @@ -377,7 +368,6 @@ func (r *RuleSet) HasRule(id uint) (b bool) { return } -// // Rule - REST Resource. type Rule struct { Resource `yaml:",inline"` @@ -387,7 +377,6 @@ type Rule struct { File *Ref `json:"file,omitempty"` } -// // With updates the resource with the model. func (r *Rule) With(m *model.Rule) { r.Resource.With(&m.Model) @@ -396,7 +385,6 @@ func (r *Rule) With(m *model.Rule) { r.File = r.refPtr(m.FileID, m.File) } -// // Model builds a model. func (r *Rule) Model() (m *model.Rule) { m = &model.Rule{} diff --git a/api/schema.go b/api/schema.go index 6ce04048a..d3270b8d3 100644 --- a/api/schema.go +++ b/api/schema.go @@ -5,7 +5,6 @@ import ( "net/http" ) -// // SchemaHandler providers schema (route) handler. type SchemaHandler struct { BaseHandler @@ -15,7 +14,6 @@ type SchemaHandler struct { Version string } -// // AddRoutes Adds routes. func (h *SchemaHandler) AddRoutes(r *gin.Engine) { h.router = r diff --git a/api/setting.go b/api/setting.go index f21f5bb82..d043f5a30 100644 --- a/api/setting.go +++ b/api/setting.go @@ -9,20 +9,17 @@ import ( "strings" ) -// // Routes const ( SettingsRoot = "/settings" SettingRoot = SettingsRoot + "/:" + Key ) -// // SettingHandler handles setting routes. type SettingHandler struct { BaseHandler } -// // AddRoutes add routes. func (h SettingHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -229,7 +226,6 @@ func (h SettingHandler) Delete(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Setting REST Resource type Setting struct { Key string `json:"key"` diff --git a/api/sort/error.go b/api/sort/error.go index 8288edeac..15fd4c724 100644 --- a/api/sort/error.go +++ b/api/sort/error.go @@ -2,7 +2,6 @@ package sort import "fmt" -// // SortError reports sorting error. type SortError struct { field string diff --git a/api/sort/sort.go b/api/sort/sort.go index a76fe76de..483ea26e0 100644 --- a/api/sort/sort.go +++ b/api/sort/sort.go @@ -7,21 +7,18 @@ import ( "strings" ) -// // Clause sort clause. type Clause struct { direction string name string } -// // Sort provides sorting. type Sort struct { fields map[string]interface{} clauses []Clause } -// // With context. func (r *Sort) With(ctx *gin.Context, m interface{}) (err error) { param := ctx.Query("sort") @@ -66,7 +63,6 @@ func (r *Sort) With(ctx *gin.Context, m interface{}) (err error) { return } -// // Sorted returns sorted DB. func (r *Sort) Sorted(in *gorm.DB) (out *gorm.DB) { out = in @@ -81,7 +77,6 @@ func (r *Sort) Sorted(in *gorm.DB) (out *gorm.DB) { return } -// // inspect object and return fields. func (r *Sort) inspect(m interface{}) (fields map[string]interface{}) { fields = reflect.Fields(m) diff --git a/api/stakeholder.go b/api/stakeholder.go index 12b707c5c..f459f1552 100644 --- a/api/stakeholder.go +++ b/api/stakeholder.go @@ -7,20 +7,17 @@ import ( "net/http" ) -// // Routes const ( StakeholdersRoot = "/stakeholders" StakeholderRoot = StakeholdersRoot + "/:" + ID ) -// // StakeholderHandler handles stakeholder routes. type StakeholderHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h StakeholderHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -187,7 +184,6 @@ func (h StakeholderHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Stakeholder REST resource. type Stakeholder struct { Resource `yaml:",inline"` @@ -201,7 +197,6 @@ type Stakeholder struct { MigrationWaves []Ref `json:"migrationWaves" yaml:"migrationWaves"` } -// // With updates the resource with the model. func (r *Stakeholder) With(m *model.Stakeholder) { r.Resource.With(&m.Model) @@ -240,7 +235,6 @@ func (r *Stakeholder) With(m *model.Stakeholder) { } } -// // Model builds a model. func (r *Stakeholder) Model() (m *model.Stakeholder) { m = &model.Stakeholder{ diff --git a/api/tag.go b/api/tag.go index fff043fde..56702f9ea 100644 --- a/api/tag.go +++ b/api/tag.go @@ -7,20 +7,17 @@ import ( "net/http" ) -// // Routes const ( TagsRoot = "/tags" TagRoot = TagsRoot + "/:" + ID ) -// // TagHandler handles tag routes. type TagHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h TagHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -164,7 +161,6 @@ func (h TagHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Tag REST resource. type Tag struct { Resource `yaml:",inline"` @@ -172,7 +168,6 @@ type Tag struct { Category Ref `json:"category" binding:"required"` } -// // With updates the resource with the model. func (r *Tag) With(m *model.Tag) { r.Resource.With(&m.Model) @@ -180,7 +175,6 @@ func (r *Tag) With(m *model.Tag) { r.Category = r.ref(m.CategoryID, &m.Category) } -// // Model builds a model. func (r *Tag) Model() (m *model.Tag) { m = &model.Tag{ diff --git a/api/tagcategory.go b/api/tagcategory.go index 03bd7be08..b28f210bd 100644 --- a/api/tagcategory.go +++ b/api/tagcategory.go @@ -7,7 +7,6 @@ import ( "net/http" ) -// // Routes const ( TagCategoriesRoot = "/tagcategories" @@ -15,13 +14,11 @@ const ( TagCategoryTagsRoot = TagCategoryRoot + "/tags" ) -// // TagCategoryHandler handles the tag-type route. type TagCategoryHandler struct { BaseHandler } -// // AddRoutes adds routes. func (h TagCategoryHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -209,7 +206,6 @@ func (h TagCategoryHandler) TagList(ctx *gin.Context) { ctx.JSON(http.StatusOK, resources) } -// // TagCategory REST resource. type TagCategory struct { Resource `yaml:",inline"` @@ -220,7 +216,6 @@ type TagCategory struct { Tags []Ref `json:"tags"` } -// // With updates the resource with the model. func (r *TagCategory) With(m *model.TagCategory) { r.Resource.With(&m.Model) @@ -236,7 +231,6 @@ func (r *TagCategory) With(m *model.TagCategory) { } } -// // Model builds a model. func (r *TagCategory) Model() (m *model.TagCategory) { m = &model.TagCategory{ diff --git a/api/target.go b/api/target.go index c99ea4ab0..190f00877 100644 --- a/api/target.go +++ b/api/target.go @@ -12,14 +12,12 @@ import ( "net/http" ) -// // Routes const ( TargetsRoot = "/targets" TargetRoot = TargetsRoot + "/:" + ID ) -// // TargetHandler handles Target resource routes. type TargetHandler struct { BaseHandler @@ -235,7 +233,6 @@ func (h TargetHandler) Update(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Target REST resource. type Target struct { Resource `yaml:",inline"` @@ -254,7 +251,6 @@ type Label struct { Label string `json:"label"` } -// // With updates the resource with the model. func (r *Target) With(m *model.Target) { r.Resource.With(&m.Model) @@ -275,7 +271,6 @@ func (r *Target) With(m *model.Target) { _ = json.Unmarshal(m.Labels, &r.Labels) } -// // Model builds a model. func (r *Target) Model() (m *model.Target) { m = &model.Target{ diff --git a/api/task.go b/api/task.go index ea986f556..a8b815a3f 100644 --- a/api/task.go +++ b/api/task.go @@ -17,7 +17,6 @@ import ( "time" ) -// // Routes const ( TasksRoot = "/tasks" @@ -33,13 +32,11 @@ const ( LocatorParam = "locator" ) -// // TaskHandler handles task routes. type TaskHandler struct { BucketOwner } -// // AddRoutes adds routes. func (h TaskHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -482,7 +479,6 @@ func (h TaskHandler) DeleteReport(ctx *gin.Context) { h.Status(ctx, http.StatusNoContent) } -// // Fields omitted by: // - Create // - Update. @@ -501,7 +497,6 @@ func (h *TaskHandler) omitted(db *gorm.DB) (out *gorm.DB) { return } -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -512,14 +507,12 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` Description string `json:"description"` } -// // Task REST resource. type Task struct { Resource `yaml:",inline"` @@ -546,7 +539,6 @@ type Task struct { Attached []Attachment `json:"attached" yaml:",omitempty"` } -// // With updates the resource with the model. func (r *Task) With(m *model.Task) { r.Resource.With(&m.Model) @@ -588,7 +580,6 @@ func (r *Task) With(m *model.Task) { } } -// // Model builds a model. func (r *Task) Model() (m *model.Task) { m = &model.Task{ @@ -609,7 +600,6 @@ func (r *Task) Model() (m *model.Task) { return } -// // injectFiles inject attached files into the activity. func (r *Task) injectFiles(db *gorm.DB) (err error) { sort.Slice( @@ -649,7 +639,6 @@ func (r *Task) injectFiles(db *gorm.DB) (err error) { return } -// // TaskReport REST resource. type TaskReport struct { Resource `yaml:",inline"` @@ -663,7 +652,6 @@ type TaskReport struct { TaskID uint `json:"task"` } -// // With updates the resource with the model. func (r *TaskReport) With(m *model.TaskReport) { r.Resource.With(&m.Model) @@ -685,7 +673,6 @@ func (r *TaskReport) With(m *model.TaskReport) { } } -// // Model builds a model. func (r *TaskReport) Model() (m *model.TaskReport) { if r.Activity == nil { @@ -714,7 +701,6 @@ func (r *TaskReport) Model() (m *model.TaskReport) { return } -// // Attachment associates Files with a TaskReport. type Attachment struct { // Ref references an attached File. diff --git a/api/taskgroup.go b/api/taskgroup.go index c494743bd..d3d442723 100644 --- a/api/taskgroup.go +++ b/api/taskgroup.go @@ -10,7 +10,6 @@ import ( "net/http" ) -// // Routes const ( TaskGroupsRoot = "/taskgroups" @@ -20,13 +19,11 @@ const ( TaskGroupSubmitRoot = TaskGroupRoot + "/submit" ) -// // TaskGroupHandler handles task group routes. type TaskGroupHandler struct { BucketOwner } -// // AddRoutes adds routes. func (h TaskGroupHandler) AddRoutes(e *gin.Engine) { routeGroup := e.Group("/") @@ -354,7 +351,6 @@ func (h TaskGroupHandler) BucketDelete(ctx *gin.Context) { h.bucketDelete(ctx, *m.BucketID) } -// // TaskGroup REST resource. type TaskGroup struct { Resource `yaml:",inline"` @@ -366,7 +362,6 @@ type TaskGroup struct { Tasks []Task `json:"tasks"` } -// // With updates the resource with the model. func (r *TaskGroup) With(m *model.TaskGroup) { r.Resource.With(&m.Model) @@ -390,7 +385,6 @@ func (r *TaskGroup) With(m *model.TaskGroup) { } } -// // Model builds a model. func (r *TaskGroup) Model() (m *model.TaskGroup) { m = &model.TaskGroup{ diff --git a/api/tracker.go b/api/tracker.go index fa62013c4..18d6918c2 100644 --- a/api/tracker.go +++ b/api/tracker.go @@ -350,28 +350,24 @@ func (r *Tracker) Model() (m *model.Tracker) { return } -// // Project API Resource type Project struct { ID string `json:"id"` Name string `json:"name"` } -// // With updates the resource with the model. func (r *Project) With(i *tracker.Project) { r.ID = i.ID r.Name = i.Name } -// // IssueType API Resource type IssueType struct { ID string `json:"id"` Name string `json:"name"` } -// // With updates the resource with the model. func (r *IssueType) With(i *tracker.IssueType) { r.ID = i.ID diff --git a/assessment/application.go b/assessment/application.go index 3600ea475..2335222e9 100644 --- a/assessment/application.go +++ b/assessment/application.go @@ -4,14 +4,12 @@ import ( "github.com/konveyor/tackle2-hub/model" ) -// // Application represents an Application with its assessments. type Application struct { *model.Application Assessments []Assessment } -// // With updates the Application with the db model and deserializes its assessments. func (r *Application) With(m *model.Application) { r.Application = m @@ -23,7 +21,6 @@ func (r *Application) With(m *model.Application) { } } -// // NewApplicationResolver creates a new ApplicationResolver from an application and other shared resolvers. func NewApplicationResolver(m *model.Application, tags *TagResolver, membership *MembershipResolver, questionnaire *QuestionnaireResolver) (a *ApplicationResolver) { a = &ApplicationResolver{ @@ -38,7 +35,6 @@ func NewApplicationResolver(m *model.Application, tags *TagResolver, membership return } -// // ApplicationResolver wraps an Application model // with archetype and assessment resolution behavior. type ApplicationResolver struct { @@ -49,7 +45,6 @@ type ApplicationResolver struct { questionnaireResolver *QuestionnaireResolver } -// // Archetypes returns the list of archetypes the application is a member of. func (r *ApplicationResolver) Archetypes() (archetypes []Archetype, err error) { if len(r.archetypes) > 0 { @@ -61,7 +56,6 @@ func (r *ApplicationResolver) Archetypes() (archetypes []Archetype, err error) { return } -// // ArchetypeTags returns the list of tags that the application should inherit from the archetypes it is a member of, // including any tags that would be inherited due to answers given to the archetypes' assessments. func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error) { @@ -95,7 +89,6 @@ func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error) { return } -// // RequiredAssessments returns the slice of assessments that are for required questionnaires. func (r *ApplicationResolver) RequiredAssessments() (required []Assessment) { for _, a := range r.application.Assessments { @@ -106,7 +99,6 @@ func (r *ApplicationResolver) RequiredAssessments() (required []Assessment) { return } -// // AssessmentTags returns the list of tags that the application should inherit from the answers given // to its assessments. func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag) { @@ -123,7 +115,6 @@ func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag) { return } -// // Risk returns the overall risk level for the application based on its or its archetypes' assessments. func (r *ApplicationResolver) Risk() (risk string, err error) { var assessments []Assessment @@ -148,7 +139,6 @@ func (r *ApplicationResolver) Risk() (risk string, err error) { return } -// // Confidence returns the application's overall assessment confidence score. func (r *ApplicationResolver) Confidence() (confidence int, err error) { var assessments []Assessment @@ -173,7 +163,6 @@ func (r *ApplicationResolver) Confidence() (confidence int, err error) { return } -// // Assessed returns whether the application has been fully assessed. func (r *ApplicationResolver) Assessed() (assessed bool, err error) { // if the application has any of its own assessments, only consider them for diff --git a/assessment/archetype.go b/assessment/archetype.go index 6ad51f245..cc905f1c7 100644 --- a/assessment/archetype.go +++ b/assessment/archetype.go @@ -2,14 +2,12 @@ package assessment import "github.com/konveyor/tackle2-hub/model" -// // Archetype represents an Archetype with its assessments. type Archetype struct { *model.Archetype Assessments []Assessment } -// // With updates the Archetype with the db model and deserializes its assessments. func (r *Archetype) With(m *model.Archetype) { r.Archetype = m @@ -21,7 +19,6 @@ func (r *Archetype) With(m *model.Archetype) { } } -// // NewArchetypeResolver creates a new ArchetypeResolver. func NewArchetypeResolver(m *model.Archetype, tags *TagResolver, membership *MembershipResolver, questionnaire *QuestionnaireResolver) (a *ArchetypeResolver) { a = &ArchetypeResolver{ @@ -35,7 +32,6 @@ func NewArchetypeResolver(m *model.Archetype, tags *TagResolver, membership *Mem return } -// // ArchetypeResolver wraps an Archetype model // with assessment-related functionality. type ArchetypeResolver struct { @@ -45,7 +41,6 @@ type ArchetypeResolver struct { questionnaire *QuestionnaireResolver } -// // AssessmentTags returns the list of tags that the archetype should // inherit from the answers given to its assessments. func (r *ArchetypeResolver) AssessmentTags() (tags []model.Tag) { @@ -65,7 +60,6 @@ func (r *ArchetypeResolver) AssessmentTags() (tags []model.Tag) { return } -// // RequiredAssessments returns the slice of assessments that are for required questionnaires. func (r *ArchetypeResolver) RequiredAssessments() (required []Assessment) { for _, a := range r.archetype.Assessments { @@ -76,21 +70,18 @@ func (r *ArchetypeResolver) RequiredAssessments() (required []Assessment) { return } -// // Risk returns the overall risk level for the archetypes' assessments. func (r *ArchetypeResolver) Risk() (risk string) { risk = Risk(r.RequiredAssessments()) return } -// // Confidence returns the archetype's overall assessment confidence score. func (r *ArchetypeResolver) Confidence() (confidence int) { confidence = Confidence(r.RequiredAssessments()) return } -// // Assessed returns whether the archetype has been fully assessed. func (r *ArchetypeResolver) Assessed() (assessed bool) { if r.questionnaire == nil { @@ -100,7 +91,6 @@ func (r *ArchetypeResolver) Assessed() (assessed bool) { return } -// // Applications returns the archetype's member applications. func (r *ArchetypeResolver) Applications() (applications []Application, err error) { if r.membership == nil { diff --git a/assessment/assessment.go b/assessment/assessment.go index 43fdef1d6..ceb37a8ec 100644 --- a/assessment/assessment.go +++ b/assessment/assessment.go @@ -7,7 +7,6 @@ import ( "github.com/konveyor/tackle2-hub/model" ) -// // Assessment represents a deserialized Assessment. type Assessment struct { *model.Assessment @@ -16,7 +15,6 @@ type Assessment struct { RiskMessages RiskMessages `json:"riskMessages"` } -// // With updates the Assessment with the db model and deserializes its fields. func (r *Assessment) With(m *model.Assessment) { r.Assessment = m @@ -25,7 +23,6 @@ func (r *Assessment) With(m *model.Assessment) { _ = json.Unmarshal(m.RiskMessages, &r.RiskMessages) } -// // Status returns the started status of the assessment. func (r *Assessment) Status() string { if r.Complete() { @@ -37,7 +34,6 @@ func (r *Assessment) Status() string { } } -// // Complete returns whether all sections have been completed. func (r *Assessment) Complete() bool { for _, s := range r.Sections { @@ -48,7 +44,6 @@ func (r *Assessment) Complete() bool { return true } -// // Started returns whether any sections have been started. func (r *Assessment) Started() bool { for _, s := range r.Sections { @@ -59,7 +54,6 @@ func (r *Assessment) Started() bool { return false } -// // Risk calculates the risk level (red, yellow, green, unknown) for the application. func (r *Assessment) Risk() string { var total uint @@ -85,7 +79,6 @@ func (r *Assessment) Risk() string { return RiskGreen } -// // Confidence calculates a confidence score based on the answers to an assessment's questions. // The algorithm is a reimplementation of the calculation done by Pathfinder. func (r *Assessment) Confidence() (score int) { @@ -125,7 +118,6 @@ func (r *Assessment) Confidence() (score int) { return } -// // Section represents a group of questions in a questionnaire. type Section struct { Order *uint `json:"order" yaml:"order" binding:"required"` @@ -134,7 +126,6 @@ type Section struct { Comment string `json:"comment,omitempty" yaml:"comment,omitempty"` } -// // Complete returns whether all questions in the section have been answered. func (r *Section) Complete() bool { for _, q := range r.Questions { @@ -145,7 +136,6 @@ func (r *Section) Complete() bool { return true } -// // Started returns whether any questions in the section have been answered. func (r *Section) Started() bool { for _, q := range r.Questions { @@ -156,7 +146,6 @@ func (r *Section) Started() bool { return false } -// // Risks returns a slice of the risks of each of its questions. func (r *Section) Risks() []string { risks := []string{} @@ -166,7 +155,6 @@ func (r *Section) Risks() []string { return risks } -// // Tags returns all the tags that should be applied based on how // the questions in the section have been answered. func (r *Section) Tags() (tags []CategorizedTag) { @@ -176,7 +164,6 @@ func (r *Section) Tags() (tags []CategorizedTag) { return } -// // Question represents a question in a questionnaire. type Question struct { Order *uint `json:"order" yaml:"order" binding:"required"` @@ -187,7 +174,6 @@ type Question struct { Answers []Answer `json:"answers" yaml:"answers" binding:"min=1,dive"` } -// // Risk returns the risk level for the question based on how it has been answered. func (r *Question) Risk() string { for _, a := range r.Answers { @@ -198,7 +184,6 @@ func (r *Question) Risk() string { return RiskUnknown } -// // Answered returns whether the question has had an answer selected. func (r *Question) Answered() bool { for _, a := range r.Answers { @@ -209,7 +194,6 @@ func (r *Question) Answered() bool { return false } -// // Tags returns any tags to be applied based on how the question is answered. func (r *Question) Tags() (tags []CategorizedTag) { for _, answer := range r.Answers { @@ -221,7 +205,6 @@ func (r *Question) Tags() (tags []CategorizedTag) { return } -// // Answer represents an answer to a question in a questionnaire. type Answer struct { Order *uint `json:"order" yaml:"order" binding:"required"` @@ -235,14 +218,12 @@ type Answer struct { AutoAnswered bool `json:"autoAnswered,omitempty" yaml:"autoAnswered,omitempty"` } -// // CategorizedTag represents a human-readable pair of category and tag. type CategorizedTag struct { Category string `json:"category" yaml:"category"` Tag string `json:"tag" yaml:"tag"` } -// // RiskMessages contains messages to display for each risk level. type RiskMessages struct { Red string `json:"red" yaml:"red"` @@ -251,7 +232,6 @@ type RiskMessages struct { Unknown string `json:"unknown" yaml:"unknown"` } -// // Thresholds contains the threshold values for determining risk for the questionnaire. type Thresholds struct { Red uint `json:"red" yaml:"red"` diff --git a/assessment/membership.go b/assessment/membership.go index 88a37131d..b6180c5f3 100644 --- a/assessment/membership.go +++ b/assessment/membership.go @@ -7,7 +7,6 @@ import ( "gorm.io/gorm/clause" ) -// // NewMembershipResolver builds a MembershipResolver. func NewMembershipResolver(db *gorm.DB) (m *MembershipResolver) { m = &MembershipResolver{db: db} @@ -16,7 +15,6 @@ func NewMembershipResolver(db *gorm.DB) (m *MembershipResolver) { return } -// // MembershipResolver resolves archetype membership. type MembershipResolver struct { db *gorm.DB @@ -26,7 +24,6 @@ type MembershipResolver struct { membersCached bool } -// // Applications returns the list of applications that are members of the given archetype. func (r *MembershipResolver) Applications(m Archetype) (applications []Application, err error) { err = r.cacheArchetypeMembers() @@ -39,7 +36,6 @@ func (r *MembershipResolver) Applications(m Archetype) (applications []Applicati return } -// // Archetypes returns the list of archetypes that the application is a member of. func (r *MembershipResolver) Archetypes(app Application) (archetypes []Archetype, err error) { err = r.cacheArchetypes() diff --git a/assessment/pkg.go b/assessment/pkg.go index 0f9951780..9d9367a00 100644 --- a/assessment/pkg.go +++ b/assessment/pkg.go @@ -5,7 +5,6 @@ import ( "github.com/konveyor/tackle2-hub/model" ) -// // Assessment risk const ( RiskUnknown = "unknown" @@ -14,7 +13,6 @@ const ( RiskGreen = "green" ) -// // Assessment status const ( StatusEmpty = "empty" @@ -22,21 +20,18 @@ const ( StatusComplete = "complete" ) -// // Confidence adjustment const ( AdjusterRed = 0.5 AdjusterYellow = 0.98 ) -// // Confidence multiplier. const ( MultiplierRed = 0.6 MultiplierYellow = 0.95 ) -// // Risk weights const ( WeightRed = 1 @@ -45,7 +40,6 @@ const ( WeightUnknown = 70 ) -// // Risk returns the single highest risk score for a group of assessments. func Risk(assessments []Assessment) (risk string) { risk = RiskUnknown @@ -85,7 +79,6 @@ func Risk(assessments []Assessment) (risk string) { return } -// // Confidence returns a total confidence score for a group of assessments. func Confidence(assessments []Assessment) (confidence int) { if len(assessments) == 0 { @@ -98,7 +91,6 @@ func Confidence(assessments []Assessment) (confidence int) { return } -// // PrepareForApplication prepares the sections of an assessment by including, excluding, // or auto-answering questions based on a set of tags. func PrepareForApplication(tagResolver *TagResolver, application *model.Application, assessment *model.Assessment) { @@ -115,7 +107,6 @@ func PrepareForApplication(tagResolver *TagResolver, application *model.Applicat return } -// // PrepareForArchetype prepares the sections of an assessment by including, excluding, // or auto-answering questions based on a set of tags. func PrepareForArchetype(tagResolver *TagResolver, archetype *model.Archetype, assessment *model.Assessment) { diff --git a/assessment/questionnaire.go b/assessment/questionnaire.go index d615d0262..905520c9e 100644 --- a/assessment/questionnaire.go +++ b/assessment/questionnaire.go @@ -6,7 +6,6 @@ import ( "gorm.io/gorm" ) -// // NewQuestionnaireResolver builds a QuestionnaireResolver. func NewQuestionnaireResolver(db *gorm.DB) (a *QuestionnaireResolver, err error) { a = &QuestionnaireResolver{db: db} @@ -15,7 +14,6 @@ func NewQuestionnaireResolver(db *gorm.DB) (a *QuestionnaireResolver, err error) return } -// // QuestionnaireResolver resolves questionnaire logic. type QuestionnaireResolver struct { db *gorm.DB @@ -41,13 +39,11 @@ func (r *QuestionnaireResolver) cacheQuestionnaires() (err error) { return } -// // Required returns whether a questionnaire is required. func (r *QuestionnaireResolver) Required(id uint) (required bool) { return r.requiredQuestionnaires.Contains(id) } -// // Assessed returns whether a slice contains a completed assessment for each of the required // questionnaires. func (r *QuestionnaireResolver) Assessed(assessments []Assessment) (assessed bool) { diff --git a/assessment/set.go b/assessment/set.go index 5a49ee930..0de4f357a 100644 --- a/assessment/set.go +++ b/assessment/set.go @@ -1,6 +1,5 @@ package assessment -// // NewSet builds a new Set. func NewSet() (s Set) { s = Set{} @@ -8,20 +7,17 @@ func NewSet() (s Set) { return } -// // Set is an unordered collection of uints // with no duplicate elements. type Set struct { members map[uint]bool } -// // Size returns the number of members in the set. func (r Set) Size() int { return len(r.members) } -// // Add a member to the set. func (r Set) Add(members ...uint) { for _, member := range members { @@ -29,13 +25,11 @@ func (r Set) Add(members ...uint) { } } -// // Contains returns whether an element is a member of the set. func (r Set) Contains(element uint) bool { return r.members[element] } -// // Superset tests whether every element of other is in the set. func (r Set) Superset(other Set, strict bool) bool { if strict && r.Size() <= other.Size() { @@ -49,13 +43,11 @@ func (r Set) Superset(other Set, strict bool) bool { return true } -// // Subset tests whether every element of this set is in the other. func (r Set) Subset(other Set, strict bool) bool { return other.Superset(r, strict) } -// // Intersects tests whether this set and the other have at least one element in common. func (r Set) Intersects(other Set) bool { for m := range r.members { @@ -66,7 +58,6 @@ func (r Set) Intersects(other Set) bool { return false } -// // Members returns the members of the set as a slice. func (r Set) Members() []uint { members := []uint{} diff --git a/assessment/tag.go b/assessment/tag.go index 798178fad..930ed9b31 100644 --- a/assessment/tag.go +++ b/assessment/tag.go @@ -7,7 +7,6 @@ import ( "gorm.io/gorm/clause" ) -// // NewTagResolver builds a TagResolver. func NewTagResolver(db *gorm.DB) (t *TagResolver, err error) { t = &TagResolver{ @@ -17,21 +16,18 @@ func NewTagResolver(db *gorm.DB) (t *TagResolver, err error) { return } -// // TagResolver resolves CategorizedTags to Tag models. type TagResolver struct { cache map[string]map[string]*model.Tag db *gorm.DB } -// // Resolve a category and tag name to a Tag model. func (r *TagResolver) Resolve(category string, tag string) (t *model.Tag, found bool) { t, found = r.cache[category][tag] return } -// // Assessment returns all the Tag models that should be applied from the assessment. func (r *TagResolver) Assessment(assessment Assessment) (tags []model.Tag) { for _, s := range assessment.Sections { diff --git a/auth/builtin.go b/auth/builtin.go index fb4fca5c7..76aabfb3e 100644 --- a/auth/builtin.go +++ b/auth/builtin.go @@ -7,11 +7,9 @@ import ( "strings" ) -// // Validators provide token validation based on claims. var Validators []Validator -// // Validator provides token validation. type Validator interface { // Valid determines if the token is valid. @@ -21,24 +19,20 @@ type Validator interface { Valid(token *jwt.Token, db *gorm.DB) (err error) } -// // NoAuth provider always permits access. type NoAuth struct { } -// // NewToken creates a new signed token. func (r NoAuth) NewToken(user string, scopes []string, claims jwt.MapClaims) (signed string, err error) { return } -// // Authenticate the token func (r *NoAuth) Authenticate(_ *Request) (jwToken *jwt.Token, err error) { return } -// // Scopes decodes a list of scopes from the token. // For the NoAuth provider, this just returns a single // wildcard scope matching everything. @@ -47,31 +41,26 @@ func (r *NoAuth) Scopes(jwToken *jwt.Token) (scopes []Scope) { return } -// // User mocks username for NoAuth func (r *NoAuth) User(jwToken *jwt.Token) (name string) { name = "admin.noauth" return } -// // Login and obtain a token. func (r *NoAuth) Login(user, password string) (token Token, err error) { return } -// // Refresh token. func (r *NoAuth) Refresh(refresh string) (token Token, err error) { return } -// // Builtin auth provider. type Builtin struct { } -// // Authenticate the token func (r *Builtin) Authenticate(request *Request) (jwToken *jwt.Token, err error) { token := strings.Replace(request.Token, "Bearer", "", 1) @@ -154,7 +143,6 @@ func (r *Builtin) Authenticate(request *Request) (jwToken *jwt.Token, err error) return } -// // Scopes returns a list of scopes. func (r *Builtin) Scopes(jwToken *jwt.Token) (scopes []Scope) { claims := jwToken.Claims.(jwt.MapClaims) @@ -168,7 +156,6 @@ func (r *Builtin) Scopes(jwToken *jwt.Token) (scopes []Scope) { return } -// // User returns the user associated with the token. func (r *Builtin) User(jwToken *jwt.Token) (user string) { claims := jwToken.Claims.(jwt.MapClaims) @@ -176,19 +163,16 @@ func (r *Builtin) User(jwToken *jwt.Token) (user string) { return } -// // Login and obtain a token. func (r *Builtin) Login(user, password string) (token Token, err error) { return } -// // Refresh token. func (r *Builtin) Refresh(refresh string) (token Token, err error) { return } -// // NewToken creates a new signed token. func (r *Builtin) NewToken(user string, scopes []string, claims jwt.MapClaims) (signed string, err error) { token := jwt.New(jwt.SigningMethodHS512) diff --git a/auth/keycloak.go b/auth/keycloak.go index 29720fca9..3bcc8ef6f 100644 --- a/auth/keycloak.go +++ b/auth/keycloak.go @@ -10,7 +10,6 @@ import ( "time" ) -// // NewKeycloak builds a new Keycloak auth provider. func NewKeycloak(host, realm string) (p Provider) { client := gocloak.NewClient(host) @@ -23,7 +22,6 @@ func NewKeycloak(host, realm string) (p Provider) { return } -// // Keycloak auth provider type Keycloak struct { client gocloak.GoCloak @@ -31,13 +29,11 @@ type Keycloak struct { realm string } -// // NewToken creates a new signed token. func (r Keycloak) NewToken(user string, scopes []string, claims jwt.MapClaims) (signed string, err error) { return } -// // Login and obtain a token. func (r *Keycloak) Login(user, password string) (token Token, err error) { jwt, err := r.client.Login( @@ -56,7 +52,6 @@ func (r *Keycloak) Login(user, password string) (token Token, err error) { return } -// // Refresh token. func (r *Keycloak) Refresh(refresh string) (token Token, err error) { jwt, err := r.client.RefreshToken( @@ -74,7 +69,6 @@ func (r *Keycloak) Refresh(refresh string) (token Token, err error) { return } -// // Authenticate the token func (r *Keycloak) Authenticate(request *Request) (jwToken *jwt.Token, err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) @@ -113,7 +107,6 @@ func (r *Keycloak) Authenticate(request *Request) (jwToken *jwt.Token, err error return } -// // Scopes decodes a list of scopes from the token. func (r *Keycloak) Scopes(jwToken *jwt.Token) (scopes []Scope) { claims := jwToken.Claims.(*jwt.MapClaims) @@ -125,7 +118,6 @@ func (r *Keycloak) Scopes(jwToken *jwt.Token) (scopes []Scope) { return } -// // User resolves token to Keycloak username. func (r *Keycloak) User(jwToken *jwt.Token) (user string) { claims, _ := jwToken.Claims.(*jwt.MapClaims) diff --git a/auth/provider.go b/auth/provider.go index 3b83d6c1b..7a74bc235 100644 --- a/auth/provider.go +++ b/auth/provider.go @@ -22,7 +22,6 @@ func init() { Remote = &NoAuth{} } -// // Provider provides RBAC. type Provider interface { // NewToken creates a signed token. @@ -45,7 +44,6 @@ type Token struct { Expiry int } -// // NotAuthenticated is returned when a token cannot be authenticated. type NotAuthenticated struct { Token string @@ -61,7 +59,6 @@ func (e *NotAuthenticated) Is(err error) (matched bool) { return } -// // NotValid is returned when a token is not valid. type NotValid struct { Reason string @@ -78,7 +75,6 @@ func (e *NotValid) Is(err error) (matched bool) { return } -// // Scope represents an authorization scope. type Scope interface { // Match returns whether the scope is a match. @@ -87,14 +83,12 @@ type Scope interface { String() (s string) } -// // BaseScope provides base behavior. type BaseScope struct { Resource string Method string } -// // With parses a scope and populate fields. // Format: : func (r *BaseScope) With(s string) { @@ -109,7 +103,6 @@ func (r *BaseScope) With(s string) { return } -// // Match returns whether the scope is a match. func (r *BaseScope) Match(resource string, method string) (b bool) { b = (r.Resource == "*" || strings.EqualFold(r.Resource, resource)) && @@ -117,7 +110,6 @@ func (r *BaseScope) Match(resource string, method string) (b bool) { return } -// // String representations of the scope. func (r *BaseScope) String() (s string) { s = strings.Join([]string{r.Resource, r.Method}, ":") diff --git a/auth/reconcile.go b/auth/reconcile.go index 089566609..5a87ecb7f 100644 --- a/auth/reconcile.go +++ b/auth/reconcile.go @@ -10,7 +10,6 @@ import ( "time" ) -// // NewReconciler builds a new Keycloak realm reconciler. func NewReconciler(host, realm, id, secret, admin, pass, adminRealm string) (r Reconciler) { client := gocloak.NewClient(host) @@ -27,7 +26,6 @@ func NewReconciler(host, realm, id, secret, admin, pass, adminRealm string) (r R return } -// // Keycloak realm reconciler type Reconciler struct { client gocloak.GoCloak @@ -40,7 +38,6 @@ type Reconciler struct { token *gocloak.JWT } -// // Realm is a container for the users, // scopes, and roles that exist in the // hub's keycloak realm. @@ -50,7 +47,6 @@ type Realm struct { Roles map[string]gocloak.Role } -// // Reconcile ensures that the Hub realm // exists and the expected clients, roles, scopes, // and users are present in it. @@ -90,7 +86,6 @@ func (r *Reconciler) Reconcile() (err error) { return } -// // loadRealm loads all the scopes, roles, and users from // the hub keycloak realm and populates a Realm struct. func (r *Reconciler) loadRealm() (realm *Realm, err error) { @@ -111,7 +106,6 @@ func (r *Reconciler) loadRealm() (realm *Realm, err error) { return } -// // ensureRealm ensures that the hub realm exists. func (r *Reconciler) ensureRealm() (err error) { _, err = r.client.GetRealm(context.Background(), r.token.AccessToken, r.realm) @@ -138,7 +132,6 @@ func (r *Reconciler) ensureRealm() (err error) { return } -// // ensureClient ensures that the hub client exists. func (r *Reconciler) ensureClient() (err error) { var found bool @@ -168,7 +161,6 @@ func (r *Reconciler) ensureClient() (err error) { return } -// // ensureUsers ensures that the hub users exist and have the necessary roles. func (r *Reconciler) ensureUsers(realm *Realm) (err error) { users, err := LoadUsers(Settings.Auth.UserPath) @@ -243,7 +235,6 @@ func (r *Reconciler) ensureUsers(realm *Realm) (err error) { return } -// // ensureRoles ensures that hub roles and scopes are present in keycloak by // creating them if they are missing and assigning scope mappings. func (r *Reconciler) ensureRoles(realm *Realm) (err error) { @@ -351,7 +342,6 @@ func (r *Reconciler) ensureRoles(realm *Realm) (err error) { return } -// // getClient returns a keycloak realm client. func (r *Reconciler) getClient(clientId string) (client *gocloak.Client, found bool, err error) { max := 1 @@ -372,7 +362,6 @@ func (r *Reconciler) getClient(clientId string) (client *gocloak.Client, found b return } -// // userMap generates a mapping of usernames to user objects func (r *Reconciler) userMap() (userMap map[string]gocloak.User, err error) { userMap = make(map[string]gocloak.User) @@ -389,7 +378,6 @@ func (r *Reconciler) userMap() (userMap map[string]gocloak.User, err error) { return } -// // realmRoleMap generates a mapping of realm role names to role objects func (r *Reconciler) realmRoleMap() (roleMap map[string]gocloak.Role, err error) { roleMap = make(map[string]gocloak.Role) @@ -408,7 +396,6 @@ func (r *Reconciler) realmRoleMap() (roleMap map[string]gocloak.Role, err error) return } -// // scopeMap generates a mapping of client scope names to scope objects func (r *Reconciler) scopeMap() (scopeMap map[string]gocloak.ClientScope, err error) { scopeMap = make(map[string]gocloak.ClientScope) @@ -427,7 +414,6 @@ func (r *Reconciler) scopeMap() (scopeMap map[string]gocloak.ClientScope, err er return } -// // login logs into the keycloak admin-cli client as the administrator. func (r *Reconciler) login() (err error) { for { diff --git a/auth/request.go b/auth/request.go index a28e9681a..e4bea3654 100644 --- a/auth/request.go +++ b/auth/request.go @@ -6,7 +6,6 @@ import ( "gorm.io/gorm" ) -// // Request auth request. type Request struct { Token string @@ -15,7 +14,6 @@ type Request struct { DB *gorm.DB } -// // Permit the specified request. func (r *Request) Permit() (result Result, err error) { var ( diff --git a/auth/role.go b/auth/role.go index 96e2c45e7..e4b803d5a 100644 --- a/auth/role.go +++ b/auth/role.go @@ -11,7 +11,6 @@ import ( var Settings = &settings.Settings -// // AddonRole defines the addon scopes. var AddonRole = []string{ "applications:get", @@ -33,7 +32,6 @@ var AddonRole = []string{ "rulesets:get", } -// // Role represents a RBAC role which grants // access to particular resources in the hub. type Role struct { @@ -41,14 +39,12 @@ type Role struct { Resources []Resource `yaml:"resources" validate:"required"` } -// // Resource is a set of permissions for a hub resource that a role may have. type Resource struct { Name string `yaml:"name" validate:"required"` Verbs []string `yaml:"verbs" validate:"required,dive,oneof=get post put patch delete"` } -// // User is a hub user which may have Roles. type User struct { // Username @@ -59,7 +55,6 @@ type User struct { Roles []string `yaml:"roles"` } -// // LoadRoles loads a list of Role structs from a yaml file // that is located at the given path. func LoadRoles(path string) (roles []Role, err error) { @@ -84,7 +79,6 @@ func LoadRoles(path string) (roles []Role, err error) { return } -// // LoadUsers loads a list of User structs from a yaml // file that is located at the given path. func LoadUsers(path string) (users []User, err error) { diff --git a/cmd/main.go b/cmd/main.go index 2c5791c93..56d0e3cfe 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -35,7 +35,6 @@ func init() { _ = Settings.Load() } -// // Setup the DB and models. func Setup() (db *gorm.DB, err error) { err = migration.Migrate(migration.All()) @@ -53,14 +52,12 @@ func Setup() (db *gorm.DB, err error) { return } -// // buildScheme adds CRDs to the k8s scheme. func buildScheme() (err error) { err = crd.AddToScheme(scheme.Scheme) return } -// // addonManager func addonManager(db *gorm.DB) (mgr manager.Manager, err error) { cfg, err := config.GetConfig() @@ -86,7 +83,6 @@ func addonManager(db *gorm.DB) (mgr manager.Manager, err error) { return } -// // main. func main() { log.Info("Started", "settings", Settings) diff --git a/controller/addon.go b/controller/addon.go index e225ceb90..9823d5046 100644 --- a/controller/addon.go +++ b/controller/addon.go @@ -22,15 +22,12 @@ const ( Name = "addon" ) -// // Package logger. var log = logr2.WithName(Name) -// // Settings defines applcation settings. var Settings = &settings.Settings -// // Add the controller. func Add(mgr manager.Manager, db *gorm.DB) error { reconciler := &Reconciler{ @@ -60,7 +57,6 @@ func Add(mgr manager.Manager, db *gorm.DB) error { return nil } -// // Reconciler reconciles addon CRs. type Reconciler struct { record.EventRecorder @@ -69,7 +65,6 @@ type Reconciler struct { Log logr.Logger } -// // Reconcile a Addon CR. // Note: Must not a pointer receiver to ensure that the // logger and other state is not shared. @@ -108,13 +103,11 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r return } -// // addonChanged an addon has been created/updated. func (r *Reconciler) addonChanged(addon *api.Addon) (err error) { return } -// // addonDeleted an addon has been deleted. func (r *Reconciler) addonDeleted(name string) (err error) { return diff --git a/database/pkg.go b/database/pkg.go index f392feafb..3f215a9d4 100644 --- a/database/pkg.go +++ b/database/pkg.go @@ -22,7 +22,6 @@ const ( FKsOff = "&_foreign_keys=no" ) -// // Open and automigrate the DB. func Open(enforceFKs bool) (db *gorm.DB, err error) { connStr := fmt.Sprintf(ConnectionString, Settings.DB.Path) @@ -59,7 +58,6 @@ func Open(enforceFKs bool) (db *gorm.DB, err error) { return } -// // Close the DB. func Close(db *gorm.DB) (err error) { var sqlDB *sql.DB diff --git a/encryption/aes.go b/encryption/aes.go index d6f2c73e3..8b21dffaf 100644 --- a/encryption/aes.go +++ b/encryption/aes.go @@ -8,14 +8,12 @@ import ( "io" ) -// // AES encryption. type AES struct { // Key Length must be (12|24|32). Key []byte } -// // Encrypt plain string. // Returns an AES encrypted; base64 encoded string. func (r *AES) Encrypt(plain string) (encrypted string, err error) { @@ -39,7 +37,6 @@ func (r *AES) Encrypt(plain string) (encrypted string, err error) { return } -// // Decrypt and AES encrypted string. // The `encrypted` string is an AES encrypted; base64 encoded string. // Returns the decoded string. @@ -67,7 +64,6 @@ func (r *AES) Decrypt(encrypted string) (plain string, err error) { return } -// // With Sets the key using the passphrase. // Only the first 32 bytes of the passphrase are used. func (r *AES) With(passphrase string) { @@ -83,21 +79,18 @@ func (r *AES) With(passphrase string) { } } -// // encode string. func (r *AES) encode(in []byte) (out string) { out = base64.StdEncoding.EncodeToString(in) return } -// // decode bytes. func (r *AES) decode(in string) (out []byte, err error) { out, err = base64.StdEncoding.DecodeString(in) return } -// // New AES encryptor for passphrase. func New(passphrase string) (n *AES) { n = &AES{} diff --git a/go.mod b/go.mod index 2c6b55e11..ea271b33d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/konveyor/tackle2-hub -go 1.18 +go 1.20 require ( github.com/Nerzal/gocloak/v10 v10.0.1 @@ -25,6 +25,7 @@ require ( k8s.io/apimachinery v0.25.0 k8s.io/apiserver v0.25.0 k8s.io/client-go v0.25.0 + k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed sigs.k8s.io/controller-runtime v0.13.1 ) @@ -100,7 +101,6 @@ require ( k8s.io/component-base v0.25.0 // indirect k8s.io/klog/v2 v2.70.1 // indirect k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect - k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/importer/manager.go b/importer/manager.go index 575e71528..e18384c94 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -14,14 +14,12 @@ import ( "time" ) -// // Manager for processing application imports. type Manager struct { // DB DB *gorm.DB } -// // Run the manager. func (m *Manager) Run(ctx context.Context) { go func() { @@ -37,7 +35,6 @@ func (m *Manager) Run(ctx context.Context) { }() } -// // processImports creates applications and dependencies from // unprocessed imports. func (m *Manager) processImports() (err error) { @@ -75,7 +72,6 @@ func (m *Manager) processImports() (err error) { return } -// // createDependency creates an application dependency from // a dependency import record. func (m *Manager) createDependency(imp *model.Import) (ok bool) { @@ -115,7 +111,6 @@ func (m *Manager) createDependency(imp *model.Import) (ok bool) { return } -// // createApplication creates an application from an // application import record. func (m *Manager) createApplication(imp *model.Import) (ok bool) { @@ -362,7 +357,6 @@ func (m *Manager) findStakeholder(email string) (stakeholder model.Stakeholder, return } -// // normalizedName transforms given name to be comparable as same with similar names // Example: normalizedName(" F oo-123 bar! ") returns "foo123bar!" func normalizedName(name string) (normName string) { @@ -372,7 +366,6 @@ func normalizedName(name string) (normName string) { return } -// // parseStakeholder attempts to parse a stakeholder's name and an email address // out of a string like `John Smith `. The pattern is very // simple and treats anything before the first bracket as the name, diff --git a/k8s/api/tackle/v1alpha1/addon.go b/k8s/api/tackle/v1alpha1/addon.go index fb22b7b92..b01f370ef 100644 --- a/k8s/api/tackle/v1alpha1/addon.go +++ b/k8s/api/tackle/v1alpha1/addon.go @@ -21,7 +21,6 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// // AddonSpec defines the desired state of Addon type AddonSpec struct { // Addon fqin. @@ -34,7 +33,6 @@ type AddonSpec struct { Resources core.ResourceRequirements `json:"resources,omitempty"` } -// // AddonStatus defines the observed state of Addon type AddonStatus struct { // The most recent generation observed by the controller. @@ -42,7 +40,6 @@ type AddonStatus struct { ObservedGeneration int64 `json:"observedGeneration,omitempty"` } -// // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true @@ -56,7 +53,6 @@ type Addon struct { Status AddonStatus `json:"status,omitempty"` } -// // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type AddonList struct { meta.TypeMeta `json:",inline"` diff --git a/k8s/api/tackle/v1alpha1/tackle.go b/k8s/api/tackle/v1alpha1/tackle.go index 766e01b49..fbbe22c90 100644 --- a/k8s/api/tackle/v1alpha1/tackle.go +++ b/k8s/api/tackle/v1alpha1/tackle.go @@ -20,7 +20,6 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true @@ -33,7 +32,6 @@ type Tackle struct { meta.ObjectMeta `json:"metadata,omitempty"` } -// // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type TackleList struct { meta.TypeMeta `json:",inline"` diff --git a/k8s/client.go b/k8s/client.go index e688cbe8d..a756a98b2 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -13,7 +13,6 @@ import ( var Settings = &settings.Settings -// // NewClient builds new k8s client. func NewClient() (newClient client.Client, err error) { if Settings.Disconnected { diff --git a/metrics/manager.go b/metrics/manager.go index 292a1db3a..ee60684be 100644 --- a/metrics/manager.go +++ b/metrics/manager.go @@ -35,7 +35,6 @@ func (m *Manager) Run(ctx context.Context) { }() } -// // gaugeApplications reports the number of applications in inventory func (m *Manager) gaugeApplications() { count := int64(0) diff --git a/migration/migrate.go b/migration/migrate.go index 7f0e38258..06a152a27 100644 --- a/migration/migrate.go +++ b/migration/migrate.go @@ -15,7 +15,6 @@ import ( "strings" ) -// // Migrate the hub by applying all necessary Migrations. func Migrate(migrations []Migration) (err error) { var db *gorm.DB @@ -109,7 +108,6 @@ func Migrate(migrations []Migration) (err error) { return } -// // Set the version record. func setVersion(db *gorm.DB, version int) (err error) { setting := &model.Setting{Key: VersionKey} @@ -124,7 +122,6 @@ func setVersion(db *gorm.DB, version int) (err error) { return } -// // AutoMigrate the database. func autoMigrate(db *gorm.DB, models []interface{}) (err error) { db, err = database.Open(false) @@ -145,7 +142,6 @@ func autoMigrate(db *gorm.DB, models []interface{}) (err error) { return } -// // writeSchema - writes the migrated schema to a file. func writeSchema(db *gorm.DB, version int) (err error) { var list []struct { diff --git a/migration/pkg.go b/migration/pkg.go index 61a0c99d9..0def8250b 100644 --- a/migration/pkg.go +++ b/migration/pkg.go @@ -20,29 +20,24 @@ import ( var log = logr.WithName("migration") var Settings = &settings.Settings -// // VersionKey is the setting containing the migration version. const VersionKey = ".migration.version" -// // MinimumVersion is the index of the // earliest version that we can migrate from. var MinimumVersion = 1 -// // Version represents the value of the .migration.version setting. type Version struct { Version int `json:"version"` } -// // Migration encapsulates the functionality necessary to perform a migration. type Migration interface { Apply(*gorm.DB) error Models() []interface{} } -// // All migrations in order. func All() []Migration { return []Migration{ diff --git a/migration/v10/model/analysis.go b/migration/v10/model/analysis.go index 34efb6de2..d3b425d8f 100644 --- a/migration/v10/model/analysis.go +++ b/migration/v10/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -15,7 +14,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -29,7 +27,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -47,7 +44,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -60,14 +56,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // ArchivedIssue resource created when issues are archived. type ArchivedIssue struct { RuleSet string `json:"ruleSet"` @@ -79,7 +73,6 @@ type ArchivedIssue struct { Incidents int `json:"incidents"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -98,7 +91,6 @@ func (r *RuleSet) Builtin() bool { return r.UUID != nil } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -132,7 +124,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model @@ -145,7 +136,6 @@ type Rule struct { File *File } -// // Target - analysis rule selector. type Target struct { Model diff --git a/migration/v10/model/application.go b/migration/v10/model/application.go index 64e1e52a2..76ea4900b 100644 --- a/migration/v10/model/application.go +++ b/migration/v10/model/application.go @@ -40,7 +40,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -51,14 +50,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -70,7 +67,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -79,7 +75,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -100,7 +95,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v10/model/assessment.go b/migration/v10/model/assessment.go index a8cc0b6fe..3a734e86e 100644 --- a/migration/v10/model/assessment.go +++ b/migration/v10/model/assessment.go @@ -12,7 +12,6 @@ type Questionnaire struct { Assessments []Assessment `gorm:"constraint:OnDelete:CASCADE"` } -// // Builtin returns true if this is a Konveyor-provided questionnaire. func (r *Questionnaire) Builtin() bool { return r.UUID != nil diff --git a/migration/v10/model/core.go b/migration/v10/model/core.go index fca0b85ab..17016a248 100644 --- a/migration/v10/model/core.go +++ b/migration/v10/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -27,7 +26,6 @@ type Setting struct { Value JSON `gorm:"type:json"` } -// // With updates the value of the Setting with the json representation // of the `value` parameter. func (r *Setting) With(value interface{}) (err error) { @@ -38,7 +36,6 @@ func (r *Setting) With(value interface{}) (err error) { return } -// // As unmarshalls the value of the Setting into the `ptr` parameter. func (r *Setting) As(ptr interface{}) (err error) { err = json.Unmarshal(r.Value, ptr) @@ -156,7 +153,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -167,11 +163,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -182,7 +176,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -212,7 +205,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -249,7 +241,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -286,7 +277,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v10/model/pkg.go b/migration/v10/model/pkg.go index 46c071c59..2ba843598 100644 --- a/migration/v10/model/pkg.go +++ b/migration/v10/model/pkg.go @@ -6,11 +6,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v11/model/analysis.go b/migration/v11/model/analysis.go index e7e297af6..6869a5bc4 100644 --- a/migration/v11/model/analysis.go +++ b/migration/v11/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -15,7 +14,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -29,7 +27,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -47,7 +44,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -60,14 +56,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // ArchivedIssue resource created when issues are archived. type ArchivedIssue struct { RuleSet string `json:"ruleSet"` @@ -79,7 +73,6 @@ type ArchivedIssue struct { Incidents int `json:"incidents"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -98,7 +91,6 @@ func (r *RuleSet) Builtin() bool { return r.UUID != nil } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -132,7 +124,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model @@ -145,7 +136,6 @@ type Rule struct { File *File } -// // Target - analysis rule selector. type Target struct { Model diff --git a/migration/v11/model/application.go b/migration/v11/model/application.go index f6c1586c2..285eff3b3 100644 --- a/migration/v11/model/application.go +++ b/migration/v11/model/application.go @@ -40,7 +40,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -51,14 +50,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -70,7 +67,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -79,7 +75,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -100,7 +95,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v11/model/assessment.go b/migration/v11/model/assessment.go index a8cc0b6fe..3a734e86e 100644 --- a/migration/v11/model/assessment.go +++ b/migration/v11/model/assessment.go @@ -12,7 +12,6 @@ type Questionnaire struct { Assessments []Assessment `gorm:"constraint:OnDelete:CASCADE"` } -// // Builtin returns true if this is a Konveyor-provided questionnaire. func (r *Questionnaire) Builtin() bool { return r.UUID != nil diff --git a/migration/v11/model/core.go b/migration/v11/model/core.go index fca0b85ab..17016a248 100644 --- a/migration/v11/model/core.go +++ b/migration/v11/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -27,7 +26,6 @@ type Setting struct { Value JSON `gorm:"type:json"` } -// // With updates the value of the Setting with the json representation // of the `value` parameter. func (r *Setting) With(value interface{}) (err error) { @@ -38,7 +36,6 @@ func (r *Setting) With(value interface{}) (err error) { return } -// // As unmarshalls the value of the Setting into the `ptr` parameter. func (r *Setting) As(ptr interface{}) (err error) { err = json.Unmarshal(r.Value, ptr) @@ -156,7 +153,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -167,11 +163,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -182,7 +176,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -212,7 +205,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -249,7 +241,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -286,7 +277,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v11/model/pkg.go b/migration/v11/model/pkg.go index 46c071c59..2ba843598 100644 --- a/migration/v11/model/pkg.go +++ b/migration/v11/model/pkg.go @@ -6,11 +6,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v12/model/analysis.go b/migration/v12/model/analysis.go index e7e297af6..6869a5bc4 100644 --- a/migration/v12/model/analysis.go +++ b/migration/v12/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -15,7 +14,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -29,7 +27,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -47,7 +44,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -60,14 +56,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // ArchivedIssue resource created when issues are archived. type ArchivedIssue struct { RuleSet string `json:"ruleSet"` @@ -79,7 +73,6 @@ type ArchivedIssue struct { Incidents int `json:"incidents"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -98,7 +91,6 @@ func (r *RuleSet) Builtin() bool { return r.UUID != nil } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -132,7 +124,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model @@ -145,7 +136,6 @@ type Rule struct { File *File } -// // Target - analysis rule selector. type Target struct { Model diff --git a/migration/v12/model/application.go b/migration/v12/model/application.go index f6c1586c2..285eff3b3 100644 --- a/migration/v12/model/application.go +++ b/migration/v12/model/application.go @@ -40,7 +40,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -51,14 +50,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -70,7 +67,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -79,7 +75,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -100,7 +95,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v12/model/assessment.go b/migration/v12/model/assessment.go index a8cc0b6fe..3a734e86e 100644 --- a/migration/v12/model/assessment.go +++ b/migration/v12/model/assessment.go @@ -12,7 +12,6 @@ type Questionnaire struct { Assessments []Assessment `gorm:"constraint:OnDelete:CASCADE"` } -// // Builtin returns true if this is a Konveyor-provided questionnaire. func (r *Questionnaire) Builtin() bool { return r.UUID != nil diff --git a/migration/v12/model/core.go b/migration/v12/model/core.go index 6fb8ce100..becf51693 100644 --- a/migration/v12/model/core.go +++ b/migration/v12/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -27,7 +26,6 @@ type Setting struct { Value JSON `gorm:"type:json"` } -// // With updates the value of the Setting with the json representation // of the `value` parameter. func (r *Setting) With(value interface{}) (err error) { @@ -38,7 +36,6 @@ func (r *Setting) With(value interface{}) (err error) { return } -// // As unmarshalls the value of the Setting into the `ptr` parameter. func (r *Setting) As(ptr interface{}) (err error) { err = json.Unmarshal(r.Value, ptr) @@ -156,7 +153,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -167,11 +163,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -182,7 +176,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -213,7 +206,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -250,7 +242,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -287,7 +278,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v12/model/pkg.go b/migration/v12/model/pkg.go index 46c071c59..2ba843598 100644 --- a/migration/v12/model/pkg.go +++ b/migration/v12/model/pkg.go @@ -6,11 +6,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v2/model/application.go b/migration/v2/model/application.go index 1c17a8c8a..dead21df1 100644 --- a/migration/v2/model/application.go +++ b/migration/v2/model/application.go @@ -23,7 +23,6 @@ type Application struct { BusinessService *BusinessService } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -35,7 +34,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -44,7 +42,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -65,7 +62,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v2/model/core.go b/migration/v2/model/core.go index 32ab4fb82..6d568fbb1 100644 --- a/migration/v2/model/core.go +++ b/migration/v2/model/core.go @@ -10,7 +10,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -84,11 +83,9 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -110,7 +107,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -147,7 +143,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -196,7 +191,6 @@ type TaskReport struct { Task *Task } -// // Proxy configuration. // kind = (http|https) type Proxy struct { @@ -210,7 +204,6 @@ type Proxy struct { Identity *Identity } -// // Identity represents and identity with a set of credentials. type Identity struct { Model diff --git a/migration/v2/model/pkg.go b/migration/v2/model/pkg.go index c895d46c4..b3f6211e7 100644 --- a/migration/v2/model/pkg.go +++ b/migration/v2/model/pkg.go @@ -8,11 +8,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v2/model/seed.go b/migration/v2/model/seed.go index 7ae95ec53..8f7197dce 100644 --- a/migration/v2/model/seed.go +++ b/migration/v2/model/seed.go @@ -4,7 +4,6 @@ import ( "gorm.io/gorm" ) -// // Seed the database with models. func Seed(db *gorm.DB) { settings := []Setting{ diff --git a/migration/v3/migrate.go b/migration/v3/migrate.go index deed54cb4..d258418b5 100644 --- a/migration/v3/migrate.go +++ b/migration/v3/migrate.go @@ -85,7 +85,6 @@ func (r Migration) Models() []interface{} { return model.All() } -// // factMigration migrates Application.Facts. // This involves changing the Facts type from JSON which maps to // a column in the DB to an ORM virtual field. This, and the data @@ -126,7 +125,6 @@ func (r Migration) factMigration(db *gorm.DB) (err error) { return } -// // bucketMigration migrates buckets. func (r Migration) bucketMigration(db *gorm.DB) (err error) { migrator := db.Migrator() @@ -150,7 +148,6 @@ func (r Migration) bucketMigration(db *gorm.DB) (err error) { return } -// // appBucketMigration migrates application buckets. // The (v2) Application.Bucket (string) contains the bucket storage path. Migration needs to // build a `Bucket` object using this path for each and set v3 BucketID. @@ -195,7 +192,6 @@ func (r Migration) appBucketMigration(db *gorm.DB) (err error) { return } -// // taskBucketMigration migrates task buckets. // The (v2) Task.Bucket (string) contains the bucket storage path. Migration needs to // build a `Bucket` object using this path for each and set v3 BucketID. @@ -240,7 +236,6 @@ func (r Migration) taskBucketMigration(db *gorm.DB) (err error) { return } -// // taskGroupBucketMigration migrates task group buckets. // The (v2) TaskGroup.Bucket (string) contains the bucket storage path. Migration needs to // build a `Bucket` object using this path for each and set v3 BucketID. diff --git a/migration/v3/model/analysis.go b/migration/v3/model/analysis.go index 48e8dafdb..71d16cb3a 100644 --- a/migration/v3/model/analysis.go +++ b/migration/v3/model/analysis.go @@ -1,6 +1,5 @@ package model -// // RuleBundle - Analysis rules. type RuleBundle struct { Model @@ -16,7 +15,6 @@ type RuleBundle struct { RuleSets []RuleSet `gorm:"constraint:OnDelete:CASCADE"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model diff --git a/migration/v3/model/application.go b/migration/v3/model/application.go index 9c5db0f16..dd1e6a201 100644 --- a/migration/v3/model/application.go +++ b/migration/v3/model/application.go @@ -31,7 +31,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -42,14 +41,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -61,7 +58,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -70,7 +66,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -91,7 +86,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v3/model/core.go b/migration/v3/model/core.go index bd253bb69..72418ef9f 100644 --- a/migration/v3/model/core.go +++ b/migration/v3/model/core.go @@ -10,7 +10,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -132,11 +131,9 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -158,7 +155,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -195,7 +191,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -244,7 +239,6 @@ type TaskReport struct { Task *Task } -// // Proxy configuration. // kind = (http|https) type Proxy struct { @@ -258,7 +252,6 @@ type Proxy struct { Identity *Identity } -// // Identity represents and identity with a set of credentials. type Identity struct { Model diff --git a/migration/v3/model/pkg.go b/migration/v3/model/pkg.go index 8a631093e..72de00566 100644 --- a/migration/v3/model/pkg.go +++ b/migration/v3/model/pkg.go @@ -8,11 +8,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v3/seed/bundle.go b/migration/v3/seed/bundle.go index 05209fe03..3f34eb5b9 100644 --- a/migration/v3/seed/bundle.go +++ b/migration/v3/seed/bundle.go @@ -7,7 +7,6 @@ import ( "os" ) -// // RuleBundle seed object. type RuleBundle struct { model.RuleBundle @@ -15,7 +14,6 @@ type RuleBundle struct { excluded bool } -// // Create resources and files. func (r *RuleBundle) Create(db *gorm.DB) { r.Image = &model.File{Name: "file.svg"} @@ -37,7 +35,6 @@ func (r *RuleBundle) Create(db *gorm.DB) { _ = db.Create(&r.RuleBundle) } -// // Metadata builds windup metadata. func Metadata(source, target string) (b []byte) { type MD struct { @@ -51,7 +48,6 @@ func Metadata(source, target string) (b []byte) { return } -// // Target builds metadata. func Target(t string) (b []byte) { return Metadata("", t) diff --git a/migration/v4/model/analysis.go b/migration/v4/model/analysis.go index 48e8dafdb..71d16cb3a 100644 --- a/migration/v4/model/analysis.go +++ b/migration/v4/model/analysis.go @@ -1,6 +1,5 @@ package model -// // RuleBundle - Analysis rules. type RuleBundle struct { Model @@ -16,7 +15,6 @@ type RuleBundle struct { RuleSets []RuleSet `gorm:"constraint:OnDelete:CASCADE"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model diff --git a/migration/v4/model/application.go b/migration/v4/model/application.go index 071a68440..3cf8509d1 100644 --- a/migration/v4/model/application.go +++ b/migration/v4/model/application.go @@ -36,7 +36,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -47,14 +46,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -66,7 +63,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -75,7 +71,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -96,7 +91,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v4/model/core.go b/migration/v4/model/core.go index bd253bb69..72418ef9f 100644 --- a/migration/v4/model/core.go +++ b/migration/v4/model/core.go @@ -10,7 +10,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -132,11 +131,9 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -158,7 +155,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -195,7 +191,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -244,7 +239,6 @@ type TaskReport struct { Task *Task } -// // Proxy configuration. // kind = (http|https) type Proxy struct { @@ -258,7 +252,6 @@ type Proxy struct { Identity *Identity } -// // Identity represents and identity with a set of credentials. type Identity struct { Model diff --git a/migration/v4/model/pkg.go b/migration/v4/model/pkg.go index f333361bb..2f09a63c7 100644 --- a/migration/v4/model/pkg.go +++ b/migration/v4/model/pkg.go @@ -8,11 +8,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v5/migrate.go b/migration/v5/migrate.go index 14cc284ce..7f221f67a 100644 --- a/migration/v5/migrate.go +++ b/migration/v5/migrate.go @@ -130,7 +130,6 @@ func (r Migration) migrateRuleBundles(db *gorm.DB) (err error) { return } -// // updateBundleSeed updates the description for Open Liberty. func (r Migration) updateBundleSeed(db *gorm.DB) (err error) { db = db.Model(&model.RuleSet{}) @@ -142,7 +141,6 @@ func (r Migration) updateBundleSeed(db *gorm.DB) (err error) { return } -// // migrateIdentitiesUniqName de-duplicates identity names. func (r Migration) migrateIdentitiesUniqName(db *gorm.DB) (err error) { var identities []v3.Identity diff --git a/migration/v5/model/analysis.go b/migration/v5/model/analysis.go index 3624852ea..134799a95 100644 --- a/migration/v5/model/analysis.go +++ b/migration/v5/model/analysis.go @@ -1,6 +1,5 @@ package model -// // Analysis report. type Analysis struct { Model @@ -11,7 +10,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -24,7 +22,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -42,7 +39,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -55,14 +51,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -78,7 +72,6 @@ type RuleSet struct { Rules []Rule `gorm:"constraint:OnDelete:CASCADE"` } -// // Rule - Analysis rule. type Rule struct { Model diff --git a/migration/v5/model/application.go b/migration/v5/model/application.go index aae434219..865eb643f 100644 --- a/migration/v5/model/application.go +++ b/migration/v5/model/application.go @@ -39,7 +39,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -50,14 +49,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -69,7 +66,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -78,7 +74,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -99,7 +94,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v5/model/core.go b/migration/v5/model/core.go index a64b1e5b7..4a34f2771 100644 --- a/migration/v5/model/core.go +++ b/migration/v5/model/core.go @@ -11,7 +11,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -133,11 +132,9 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -159,7 +156,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -196,7 +192,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -245,7 +240,6 @@ type TaskReport struct { Task *Task } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v5/model/pkg.go b/migration/v5/model/pkg.go index 4ce2479de..17b80b721 100644 --- a/migration/v5/model/pkg.go +++ b/migration/v5/model/pkg.go @@ -8,11 +8,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v6/model/analysis.go b/migration/v6/model/analysis.go index 43f3e8e1a..790451a4d 100644 --- a/migration/v6/model/analysis.go +++ b/migration/v6/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -13,7 +12,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -27,7 +25,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -45,7 +42,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -58,14 +54,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -82,7 +76,6 @@ type RuleSet struct { DependsOn []RuleSet `gorm:"many2many:RuleSetDependencies;constraint:OnDelete:CASCADE"` } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -116,7 +109,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model diff --git a/migration/v6/model/application.go b/migration/v6/model/application.go index aae434219..865eb643f 100644 --- a/migration/v6/model/application.go +++ b/migration/v6/model/application.go @@ -39,7 +39,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -50,14 +49,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -69,7 +66,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -78,7 +74,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -99,7 +94,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v6/model/core.go b/migration/v6/model/core.go index 6d6557ae6..89db28c8c 100644 --- a/migration/v6/model/core.go +++ b/migration/v6/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -134,7 +133,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -145,11 +143,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -160,7 +156,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -190,7 +185,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -227,7 +221,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -264,7 +257,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v6/model/pkg.go b/migration/v6/model/pkg.go index 33c97725e..9e842a5b5 100644 --- a/migration/v6/model/pkg.go +++ b/migration/v6/model/pkg.go @@ -6,11 +6,9 @@ var ( Settings = &settings.Settings ) -// // JSON field (data) type. type JSON = []byte -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v7/model/analysis.go b/migration/v7/model/analysis.go index a3f1ea1f2..096a4f36d 100644 --- a/migration/v7/model/analysis.go +++ b/migration/v7/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -13,7 +12,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -27,7 +25,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -45,7 +42,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -58,14 +54,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -83,7 +77,6 @@ type RuleSet struct { DependsOn []RuleSet `gorm:"many2many:RuleSetDependencies;constraint:OnDelete:CASCADE"` } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -117,7 +110,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model diff --git a/migration/v7/model/application.go b/migration/v7/model/application.go index f604ccfe0..8625ae812 100644 --- a/migration/v7/model/application.go +++ b/migration/v7/model/application.go @@ -39,7 +39,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -50,14 +49,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -69,7 +66,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -78,7 +74,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -99,7 +94,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v7/model/core.go b/migration/v7/model/core.go index c18e5663e..f1b742361 100644 --- a/migration/v7/model/core.go +++ b/migration/v7/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -135,7 +134,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -146,11 +144,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -161,7 +157,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -191,7 +186,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -228,7 +222,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -265,7 +258,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v7/model/pkg.go b/migration/v7/model/pkg.go index 111324a64..50bfb9d62 100644 --- a/migration/v7/model/pkg.go +++ b/migration/v7/model/pkg.go @@ -2,7 +2,6 @@ package model import "github.com/konveyor/tackle2-hub/settings" -// // JSON field (data) type. type JSON = []byte @@ -10,7 +9,6 @@ var ( Settings = &settings.Settings ) -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v8/model/analysis.go b/migration/v8/model/analysis.go index 3c9e2e52e..abe025661 100644 --- a/migration/v8/model/analysis.go +++ b/migration/v8/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -13,7 +12,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -27,7 +25,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -45,7 +42,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -58,14 +54,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -84,7 +78,6 @@ func (r *RuleSet) Builtin() bool { return r.UUID != nil } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -118,7 +111,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model @@ -131,7 +123,6 @@ type Rule struct { File *File } -// // Target - analysis rule selector. type Target struct { Model diff --git a/migration/v8/model/application.go b/migration/v8/model/application.go index f604ccfe0..8625ae812 100644 --- a/migration/v8/model/application.go +++ b/migration/v8/model/application.go @@ -39,7 +39,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -50,14 +49,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -69,7 +66,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -78,7 +74,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -99,7 +94,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v8/model/core.go b/migration/v8/model/core.go index c18e5663e..f1b742361 100644 --- a/migration/v8/model/core.go +++ b/migration/v8/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -135,7 +134,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -146,11 +144,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -161,7 +157,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -191,7 +186,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -228,7 +222,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -265,7 +258,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v8/model/pkg.go b/migration/v8/model/pkg.go index 615ee9e66..07446cd47 100644 --- a/migration/v8/model/pkg.go +++ b/migration/v8/model/pkg.go @@ -2,7 +2,6 @@ package model import "github.com/konveyor/tackle2-hub/settings" -// // JSON field (data) type. type JSON = []byte @@ -10,7 +9,6 @@ var ( Settings = &settings.Settings ) -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/migration/v9/model/analysis.go b/migration/v9/model/analysis.go index 3c9e2e52e..abe025661 100644 --- a/migration/v9/model/analysis.go +++ b/migration/v9/model/analysis.go @@ -2,7 +2,6 @@ package model import "gorm.io/gorm" -// // Analysis report. type Analysis struct { Model @@ -13,7 +12,6 @@ type Analysis struct { Application *Application } -// // TechDependency report dependency. type TechDependency struct { Model @@ -27,7 +25,6 @@ type TechDependency struct { Analysis *Analysis } -// // Issue report issue (violation). type Issue struct { Model @@ -45,7 +42,6 @@ type Issue struct { Analysis *Analysis } -// // Incident report an issue incident. type Incident struct { Model @@ -58,14 +54,12 @@ type Incident struct { Issue *Issue } -// // Link URL link. type Link struct { URL string `json:"url"` Title string `json:"title,omitempty"` } -// // RuleSet - Analysis ruleset. type RuleSet struct { Model @@ -84,7 +78,6 @@ func (r *RuleSet) Builtin() bool { return r.UUID != nil } -// // BeforeUpdate hook to avoid cyclic dependencies. func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { seen := make(map[uint]bool) @@ -118,7 +111,6 @@ func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { return } -// // Rule - Analysis rule. type Rule struct { Model @@ -131,7 +123,6 @@ type Rule struct { File *File } -// // Target - analysis rule selector. type Target struct { Model diff --git a/migration/v9/model/application.go b/migration/v9/model/application.go index 64e1e52a2..76ea4900b 100644 --- a/migration/v9/model/application.go +++ b/migration/v9/model/application.go @@ -40,7 +40,6 @@ type Fact struct { Application *Application } -// // ApplicationTag represents a row in the join table for the // many-to-many relationship between Applications and Tags. type ApplicationTag struct { @@ -51,14 +50,12 @@ type ApplicationTag struct { Tag Tag `gorm:"constraint:OnDelete:CASCADE"` } -// // TableName must return "ApplicationTags" to ensure compatibility // with the autogenerated join table name. func (ApplicationTag) TableName() string { return "ApplicationTags" } -// // depMutex ensures Dependency.Create() is not executed concurrently. var depMutex sync.Mutex @@ -70,7 +67,6 @@ type Dependency struct { From *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"` } -// // Create a dependency synchronized using a mutex. func (r *Dependency) Create(db *gorm.DB) (err error) { depMutex.Lock() @@ -79,7 +75,6 @@ func (r *Dependency) Create(db *gorm.DB) (err error) { return } -// // Validation Hook to avoid cyclic dependencies. func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { var nextDeps []*Dependency @@ -100,7 +95,6 @@ func (r *Dependency) BeforeCreate(db *gorm.DB) (err error) { return } -// // Custom error type to allow API recognize Cyclic Dependency error and assign proper status code. type DependencyCyclicError struct{} diff --git a/migration/v9/model/core.go b/migration/v9/model/core.go index c18e5663e..f1b742361 100644 --- a/migration/v9/model/core.go +++ b/migration/v9/model/core.go @@ -12,7 +12,6 @@ import ( "time" ) -// // Model Base model. type Model struct { ID uint `gorm:"<-:create;primaryKey"` @@ -135,7 +134,6 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { return } -// // Error appends an error. func (m *Task) Error(severity, description string, x ...interface{}) { var list []TaskError @@ -146,11 +144,9 @@ func (m *Task) Error(severity, description string, x ...interface{}) { m.Errors, _ = json.Marshal(list) } -// // Map alias. type Map = map[string]interface{} -// // TTL time-to-live. type TTL struct { Created int `json:"created,omitempty"` @@ -161,7 +157,6 @@ type TTL struct { Failed int `json:"failed,omitempty"` } -// // TaskError used in Task.Errors. type TaskError struct { Severity string `json:"severity"` @@ -191,7 +186,6 @@ type TaskGroup struct { State string } -// // Propagate group data into the task. func (m *TaskGroup) Propagate() (err error) { for i := range m.Tasks { @@ -228,7 +222,6 @@ func (m *TaskGroup) Propagate() (err error) { return } -// // merge maps B into A. // The B map is the authority. func (m *TaskGroup) merge(a, b Map) (out Map) { @@ -265,7 +258,6 @@ func (m *TaskGroup) merge(a, b Map) (out Map) { return } -// // Proxy configuration. // kind = (http|https) type Proxy struct { diff --git a/migration/v9/model/pkg.go b/migration/v9/model/pkg.go index 5bc918d1c..9a3b3f765 100644 --- a/migration/v9/model/pkg.go +++ b/migration/v9/model/pkg.go @@ -2,7 +2,6 @@ package model import "github.com/konveyor/tackle2-hub/settings" -// // JSON field (data) type. type JSON = []byte @@ -10,7 +9,6 @@ var ( Settings = &settings.Settings ) -// // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. diff --git a/model/pkg.go b/model/pkg.go index 17524f962..b2689ce16 100644 --- a/model/pkg.go +++ b/model/pkg.go @@ -5,11 +5,9 @@ import ( "gorm.io/datatypes" ) -// // Field (data) types. type JSON = datatypes.JSON -// // Models type Model = model.Model type Application = model.Application @@ -49,13 +47,10 @@ type TaskReport = model.TaskReport type Ticket = model.Ticket type Tracker = model.Tracker -// type TTL = model.TTL -// // Join tables type ApplicationTag = model.ApplicationTag -// // Errors type DependencyCyclicError = model.DependencyCyclicError diff --git a/model/query.go b/model/query.go index 49226d163..4729fa9be 100644 --- a/model/query.go +++ b/model/query.go @@ -5,7 +5,6 @@ import ( "strings" ) -// // Intersect returns an SQL intersect of the queries. func Intersect(q ...*gorm.DB) (intersect *gorm.DB) { var part []string diff --git a/settings/addon.go b/settings/addon.go index f9e47cfb9..94c30c57a 100644 --- a/settings/addon.go +++ b/settings/addon.go @@ -12,7 +12,6 @@ const ( EnvTask = "TASK" ) -// // Addon settings. type Addon struct { // Hub settings. diff --git a/settings/all.go b/settings/all.go index f6140043f..e69e9adb7 100644 --- a/settings/all.go +++ b/settings/all.go @@ -34,7 +34,6 @@ func (r *TackleSettings) Load() (err error) { return } -// // Get boolean. func getEnvBool(name string, def bool) bool { boolean := def diff --git a/settings/auth.go b/settings/auth.go index b0dae0811..56512c09b 100644 --- a/settings/auth.go +++ b/settings/auth.go @@ -4,7 +4,6 @@ import ( "os" ) -// // Environment variables const ( EnvAuthRequired = "AUTH_REQUIRED" diff --git a/settings/hub.go b/settings/hub.go index deaf0c00f..e6255a706 100644 --- a/settings/hub.go +++ b/settings/hub.go @@ -201,7 +201,6 @@ func (r *Hub) Load() (err error) { return } -// // namespace determines the namespace. func (r *Hub) namespace() (ns string, err error) { ns, found := os.LookupEnv(EnvNamespace) diff --git a/settings/metrics.go b/settings/metrics.go index 89c418fb5..df84141b0 100644 --- a/settings/metrics.go +++ b/settings/metrics.go @@ -6,14 +6,12 @@ import ( "strconv" ) -// // Environment variables. const ( MetricsEnabled = "METRICS_ENABLED" MetricsPort = "METRICS_PORT" ) -// // Metrics settings type Metrics struct { // Metrics port. @@ -22,7 +20,6 @@ type Metrics struct { Enabled bool } -// // Load settings. func (r *Metrics) Load() error { // Enabled @@ -37,7 +34,6 @@ func (r *Metrics) Load() error { return nil } -// // Address on which to serve metrics. func (r *Metrics) Address() string { return fmt.Sprintf(":%d", r.Port) diff --git a/task/auth.go b/task/auth.go index 1b2254e4d..5cc52a264 100644 --- a/task/auth.go +++ b/task/auth.go @@ -12,18 +12,16 @@ import ( k8s "sigs.k8s.io/controller-runtime/pkg/client" ) -// // Validator validates task tokens. type Validator struct { // k8s client. Client k8s.Client } -// // Valid token when: -// - The token references a task. -// - The task is valid and running. -// - The task pod valid and pending|running. +// - The token references a task. +// - The task is valid and running. +// - The task pod valid and pending|running. func (r *Validator) Valid(token *jwt.Token, db *gorm.DB) (err error) { claims := token.Claims.(jwt.MapClaims) v, found := claims["task"] diff --git a/task/manager.go b/task/manager.go index 172fc0f8b..b57da0a96 100644 --- a/task/manager.go +++ b/task/manager.go @@ -22,7 +22,6 @@ import ( "time" ) -// // States const ( Created = "Created" @@ -35,7 +34,6 @@ const ( Canceled = "Canceled" ) -// // Policies const ( Isolated = "isolated" @@ -50,7 +48,6 @@ var ( Log = logr.WithName("task-scheduler") ) -// // AddonNotFound used to report addon referenced // by a task but cannot be found. type AddonNotFound struct { @@ -66,7 +63,6 @@ func (e *AddonNotFound) Is(err error) (matched bool) { return } -// // Manager provides task management. type Manager struct { // DB @@ -77,7 +73,6 @@ type Manager struct { Scopes []string } -// // Run the manager. func (m *Manager) Run(ctx context.Context) { auth.Validators = append( @@ -101,14 +96,12 @@ func (m *Manager) Run(ctx context.Context) { }() } -// // Pause. func (m *Manager) pause() { d := Unit * time.Duration(Settings.Frequency.Task) time.Sleep(d) } -// // startReady starts pending tasks. func (m *Manager) startReady() { list := []model.Task{} @@ -178,7 +171,6 @@ func (m *Manager) startReady() { } } -// // updateRunning tasks to reflect pod state. func (m *Manager) updateRunning() { list := []model.Task{} @@ -214,7 +206,6 @@ func (m *Manager) updateRunning() { } } -// // postpone Postpones a task as needed based on rules. func (m *Manager) postpone(ready *model.Task, list []model.Task) (postponed bool) { ruleSet := []Rule{ @@ -241,7 +232,6 @@ func (m *Manager) postpone(ready *model.Task, list []model.Task) (postponed bool return } -// // The task has been canceled. func (m *Manager) canceled(task *model.Task) { rt := Task{task} @@ -258,14 +248,12 @@ func (m *Manager) canceled(task *model.Task) { return } -// // Task is an runtime task. type Task struct { // model. *model.Task } -// // Run the specified task. func (r *Task) Run(client k8s.Client) (err error) { mark := time.Now() @@ -328,7 +316,6 @@ func (r *Task) Run(client k8s.Client) (err error) { return } -// // Reflect finds the associated pod and updates the task state. func (r *Task) Reflect(client k8s.Client) (err error) { pod := &core.Pod{} @@ -381,7 +368,6 @@ func (r *Task) Reflect(client k8s.Client) (err error) { return } -// // Delete the associated pod as needed. func (r *Task) Delete(client k8s.Client) (err error) { if r.Pod == "" { @@ -411,7 +397,6 @@ func (r *Task) Delete(client k8s.Client) (err error) { return } -// // Cancel the task. func (r *Task) Cancel(client k8s.Client) (err error) { err = r.Delete(client) @@ -427,7 +412,6 @@ func (r *Task) Cancel(client k8s.Client) (err error) { return } -// // findAddon by name. func (r *Task) findAddon(client k8s.Client, name string) (addon *crd.Addon, err error) { addon = &crd.Addon{} @@ -450,7 +434,6 @@ func (r *Task) findAddon(client k8s.Client, name string) (addon *crd.Addon, err return } -// // findTackle returns the tackle CR. func (r *Task) findTackle(client k8s.Client) (owner *crd.Tackle, err error) { list := crd.TackleList{} @@ -470,7 +453,6 @@ func (r *Task) findTackle(client k8s.Client) (owner *crd.Tackle, err error) { return } -// // pod build the pod. func (r *Task) pod(addon *crd.Addon, owner *crd.Tackle, secret *core.Secret) (pod core.Pod) { pod = core.Pod{ @@ -493,7 +475,6 @@ func (r *Task) pod(addon *crd.Addon, owner *crd.Tackle, secret *core.Secret) (po return } -// // specification builds a Pod specification. func (r *Task) specification(addon *crd.Addon, secret *core.Secret) (specification core.PodSpec) { cache := core.Volume{ @@ -524,7 +505,6 @@ func (r *Task) specification(addon *crd.Addon, secret *core.Secret) (specificati return } -// // container builds the pod container. func (r *Task) container(addon *crd.Addon, secret *core.Secret) (container core.Container) { userid := int64(0) @@ -572,7 +552,6 @@ func (r *Task) container(addon *crd.Addon, secret *core.Secret) (container core. return } -// // secret builds the pod secret. func (r *Task) secret(addon *crd.Addon) (secret core.Secret) { user := "addon:" + addon.Name @@ -596,13 +575,11 @@ func (r *Task) secret(addon *crd.Addon) (secret core.Secret) { return } -// // k8sName returns a name suitable to be used for k8s resources. func (r *Task) k8sName() string { return fmt.Sprintf("task-%d-", r.ID) } -// // labels builds k8s labels. func (r *Task) labels() map[string]string { return map[string]string{ diff --git a/task/rule.go b/task/rule.go index eed0bb651..1eca14a3a 100644 --- a/task/rule.go +++ b/task/rule.go @@ -5,13 +5,11 @@ import ( "strings" ) -// // Rule defines postpone rules. type Rule interface { Match(candidate, other *model.Task) bool } -// // RuleUnique running tasks must be unique by: // - application // - variant @@ -19,7 +17,6 @@ type Rule interface { type RuleUnique struct { } -// // Match determines the match. func (r *RuleUnique) Match(candidate, other *model.Task) (matched bool) { if candidate.ApplicationID == nil || other.ApplicationID == nil { @@ -42,12 +39,10 @@ func (r *RuleUnique) Match(candidate, other *model.Task) (matched bool) { return } -// // RuleIsolated policy. type RuleIsolated struct { } -// // Match determines the match. func (r *RuleIsolated) Match(candidate, other *model.Task) (matched bool) { matched = r.hasPolicy(candidate, Isolated) || r.hasPolicy(other, Isolated) @@ -63,7 +58,6 @@ func (r *RuleIsolated) Match(candidate, other *model.Task) (matched bool) { return } -// // Returns true if the task policy includes: isolated func (r *RuleIsolated) hasPolicy(task *model.Task, name string) (matched bool) { for _, p := range strings.Split(task.Policy, ";") { diff --git a/tracker/jira.go b/tracker/jira.go index ff3a22dfa..8c757acd6 100644 --- a/tracker/jira.go +++ b/tracker/jira.go @@ -26,20 +26,17 @@ const ( JiraEndpointMyself = JiraEndpointBase + "/myself" ) -// // JiraConnector for the Jira Cloud API type JiraConnector struct { tracker *model.Tracker } -// // With updates the connector with the Tracker model. func (r *JiraConnector) With(t *model.Tracker) { r.tracker = t _ = r.tracker.Identity.Decrypt() } -// // Create the ticket in Jira. func (r *JiraConnector) Create(t *model.Ticket) (err error) { client, err := r.client() @@ -82,7 +79,6 @@ func (r *JiraConnector) Create(t *model.Ticket) (err error) { return } -// // RefreshAll retrieves fresh status information for all the tracker's tickets. func (r *JiraConnector) RefreshAll() (tickets map[*model.Ticket]bool, err error) { client, err := r.client() @@ -143,7 +139,6 @@ func (r *JiraConnector) RefreshAll() (tickets map[*model.Ticket]bool, err error) return } -// // Projects returns a list of Projects. func (r *JiraConnector) Projects() (projects []Project, err error) { client, err := r.client() @@ -172,7 +167,6 @@ func (r *JiraConnector) Projects() (projects []Project, err error) { return } -// // Project returns a Project. func (r *JiraConnector) Project(id string) (project Project, err error) { client, err := r.client() @@ -199,7 +193,6 @@ func (r *JiraConnector) Project(id string) (project Project, err error) { return } -// // IssueTypes returns a list of IssueTypes for a Project. func (r *JiraConnector) IssueTypes(id string) (issueTypes []IssueType, err error) { client, err := r.client() @@ -231,7 +224,6 @@ func (r *JiraConnector) IssueTypes(id string) (issueTypes []IssueType, err error return } -// // client builds a Jira API client for the tracker. func (r *JiraConnector) client() (client *jira.Client, err error) { transport := http.DefaultTransport.(*http.Transport).Clone() @@ -267,7 +259,6 @@ func (r *JiraConnector) client() (client *jira.Client, err error) { return } -// // TestConnection to Jira Cloud. func (r *JiraConnector) TestConnection() (connected bool, err error) { client, err := r.client() @@ -292,7 +283,6 @@ func (r *JiraConnector) TestConnection() (connected bool, err error) { return } -// // status returns a normalized status based on the issue status category. func status(issue *jira.Issue) (s string) { key := "" @@ -313,7 +303,6 @@ func status(issue *jira.Issue) (s string) { return } -// // handleJiraError simplifies dealing with errors from the Jira API. func handleJiraError(response *jira.Response, in error) (out error) { if in == nil { @@ -343,13 +332,11 @@ func handleJiraError(response *jira.Response, in error) (out error) { return } -// // clientWrapper wraps the http client used by the jira client. type clientWrapper struct { client *http.Client } -// // Do applies an Accept header before performing the request. func (r *clientWrapper) Do(req *http.Request) (*http.Response, error) { req.Header.Add("Accept", "application/json") @@ -357,7 +344,6 @@ func (r *clientWrapper) Do(req *http.Request) (*http.Response, error) { return resp, err } -// // jiraError is a catch-all structure for the various ways that the // Jira API can report an error in JSON format. type jiraError struct { @@ -366,7 +352,6 @@ type jiraError struct { Errors map[string]string `json:"errors"` } -// // Error reports the consolidated error message. func (r *jiraError) Error() (error string) { if len(r.Message) > 0 { diff --git a/tracker/pkg.go b/tracker/pkg.go index 996de6f1e..45a0d793d 100644 --- a/tracker/pkg.go +++ b/tracker/pkg.go @@ -11,7 +11,6 @@ const ( JiraOnPrem = "jira-onprem" ) -// // Ticket status const ( New = "New" @@ -20,7 +19,6 @@ const ( Unknown = "Unknown" ) -// // Auth kinds const ( BearerAuth = "bearer" @@ -57,7 +55,6 @@ func NewConnector(t *model.Tracker) (conn Connector, err error) { return } -// // Project represents an external ticket tracker's project // in which an issue can be created. type Project struct { @@ -65,7 +62,6 @@ type Project struct { Name string } -// // IssueType represents a type of issue that can be created on // an external issue tracker. type IssueType struct { From 05ea6dcd8cf20990f7afced7d91a1c7808c7f420 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Thu, 18 Jan 2024 11:18:46 -0800 Subject: [PATCH 02/10] formatted with 1.20 and goimports. Signed-off-by: Jeff Ortel --- Makefile | 18 +++++++- addon/adapter.go | 3 +- addon/task.go | 3 +- api/addon.go | 3 +- api/adoptionplan.go | 5 ++- api/analysis.go | 13 +++--- api/api_test.go | 5 ++- api/auth.go | 3 +- api/base.go | 9 ++-- api/batch.go | 3 +- api/bucket.go | 11 ++--- api/businessservice.go | 3 +- api/cache.go | 7 ++-- api/context.go | 3 +- api/error.go | 5 ++- api/file.go | 5 ++- api/filter/filter.go | 5 ++- api/filter/filter_test.go | 3 +- api/group.go | 3 +- api/identity.go | 5 ++- api/import.go | 5 ++- api/jobfunction.go | 3 +- api/metric.go | 3 +- api/migrationwave.go | 5 ++- api/proxy.go | 3 +- api/review.go | 3 +- api/ruleset.go | 3 +- api/schema.go | 3 +- api/setting.go | 5 ++- api/sort/sort.go | 3 +- api/stakeholder.go | 3 +- api/tag.go | 3 +- api/tagcategory.go | 3 +- api/target.go | 3 +- api/task.go | 13 +++--- api/taskgroup.go | 3 +- api/ticket.go | 5 ++- api/tracker.go | 7 ++-- assessment/assessment_test.go | 3 +- assessment/pkg.go | 1 + assessment/set_test.go | 3 +- auth/auth_test.go | 3 +- auth/builtin.go | 3 +- auth/keycloak.go | 5 ++- auth/provider.go | 3 +- auth/reconcile.go | 5 ++- auth/request.go | 1 + binding/application.go | 36 ++-------------- binding/archetype.go | 6 --- binding/assessment.go | 5 --- binding/bucket.go | 10 ----- binding/businessservice.go | 6 --- binding/client.go | 45 +++----------------- binding/dependency.go | 5 --- binding/error.go | 3 -- binding/file.go | 10 +---- binding/filter/builder.go | 17 +------- binding/filter/filter_test.go | 3 +- binding/identity.go | 6 --- binding/jobfunction.go | 6 --- binding/migrationwave.go | 6 --- binding/proxy.go | 7 ---- binding/questionnaire.go | 6 --- binding/review.go | 7 ---- binding/richclient.go | 5 +-- binding/ruleset.go | 7 ---- binding/setting.go | 9 ---- binding/stakeholder.go | 6 --- binding/stakeholdergroup.go | 6 --- binding/tag.go | 8 ---- binding/tagcategory.go | 8 ---- binding/target.go | 6 --- binding/task.go | 7 ---- binding/ticket.go | 5 --- binding/tracker.go | 9 ---- cmd/main.go | 5 ++- controller/addon.go | 1 + database/db_test.go | 3 +- database/pkg.go | 1 + encryption/aes_test.go | 3 +- importer/manager.go | 5 ++- k8s/client.go | 1 + metrics/manager.go | 3 +- migration/migrate.go | 11 ++--- migration/migrate_test.go | 5 ++- migration/pkg.go | 2 +- migration/v10/model/application.go | 3 +- migration/v10/model/core.go | 7 ++-- migration/v11/model/application.go | 3 +- migration/v11/model/core.go | 7 ++-- migration/v12/model/application.go | 3 +- migration/v12/model/core.go | 7 ++-- migration/v2/model/application.go | 3 +- migration/v2/model/core.go | 7 ++-- migration/v3/migrate.go | 1 + migration/v3/model/application.go | 3 +- migration/v3/model/core.go | 7 ++-- migration/v3/seed/bundle.go | 3 +- migration/v4/model/application.go | 3 +- migration/v4/model/core.go | 7 ++-- migration/v5/migrate.go | 1 + migration/v5/model/application.go | 3 +- migration/v5/model/core.go | 7 ++-- migration/v6/migrate.go | 1 + migration/v6/model/application.go | 3 +- migration/v6/model/core.go | 7 ++-- migration/v7/model/application.go | 3 +- migration/v7/model/core.go | 7 ++-- migration/v8/migrate.go | 1 + migration/v8/model/application.go | 3 +- migration/v8/model/core.go | 7 ++-- migration/v9/model/application.go | 3 +- migration/v9/model/core.go | 7 ++-- model/query.go | 3 +- nas/dir.go | 7 +--- reaper/bucket.go | 9 ++-- reaper/file.go | 9 ++-- reaper/manager.go | 7 +--- reaper/ref.go | 7 ++-- reaper/task.go | 66 ++++++++++++++---------------- seed/jobfunction.go | 6 +-- seed/pkg.go | 6 +-- seed/questionnaire.go | 6 +-- seed/ruleset.go | 14 ++----- seed/seed.go | 9 +--- seed/tag.go | 7 +--- seed/target.go | 17 +++----- seed/target_test.go | 3 +- tar/filter.go | 10 ----- tar/reader.go | 8 ++-- tar/tar_test.go | 9 ++-- tar/writer.go | 11 +---- task/auth.go | 3 +- task/manager.go | 7 ++-- task/rule.go | 3 +- test/api/application/facts_test.go | 8 ++-- test/api/application/pkg.go | 5 +-- test/api/application/samples.go | 27 ++++++------ test/api/archetype/pkg.go | 3 +- test/api/assessment/api_test.go | 2 +- test/api/assessment/pkg.go | 3 +- test/api/businesservice/pkg.go | 3 +- test/api/businesservice/samples.go | 2 +- test/api/client/client.go | 30 +++++++------- test/api/file/api_test.go | 5 ++- test/api/file/pkg.go | 3 +- test/api/identity/pkg.go | 3 +- test/api/importcsv/api_test.go | 20 +++++---- test/api/jobfunction/api_test.go | 1 - test/api/jobfunction/pkg.go | 3 +- test/api/proxy/api_test.go | 2 +- test/api/proxy/pkg.go | 3 +- test/api/questionnaire/pkg.go | 3 +- test/api/questionnaire/samples.go | 2 +- test/api/ruleset/pkg.go | 3 +- test/api/schema/pkg.go | 1 - test/api/setting/pkg.go | 3 +- test/api/setting/samples.go | 4 +- test/api/stakeholder/pkg.go | 3 +- test/api/stakeholdergroup/pkg.go | 3 +- test/api/tag/api_test.go | 3 +- test/api/tag/pkg.go | 3 +- test/api/tagcategory/api_test.go | 1 - test/api/tagcategory/pkg.go | 3 +- test/api/task/pkg.go | 3 +- test/assert/equality.go | 1 - test/assert/error.go | 2 - test/assert/file.go | 1 - tracker/manager.go | 3 +- 169 files changed, 408 insertions(+), 619 deletions(-) diff --git a/Makefile b/Makefile index 6d7b410ff..623a63789 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ GOBIN ?= ${GOPATH}/bin +GOIMPORTS = ${GOBIN}/goimports IMG ?= tackle2-hub:latest HUB_BASE_URL ?= http://localhost:8080 @@ -6,6 +7,8 @@ PKG = ./addon/... \ ./api/... \ ./assessment/... \ ./auth/... \ + ./binding/... \ + ./controller/... \ ./cmd/... \ ./database/... \ ./encryption/... \ @@ -14,18 +17,25 @@ PKG = ./addon/... \ ./metrics/... \ ./migration/... \ ./model/... \ + ./nas/... \ + ./reaper/... \ + ./seed/... \ ./settings/... \ - ./controller/... \ + ./tar/... \ ./task/... \ + ./test/... \ ./tracker/... +DIR = $(subst /...,,${PKG}) + BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd # Build ALL commands. cmd: hub addon # Run go fmt against code -fmt: +fmt: ${GOIMPORTS} + goimports -w ${DIR} go fmt ${PKG} # Run go vet against code @@ -78,6 +88,10 @@ controller-gen: rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ fi ;\ +# Ensure goimports installed. +${GOIMPORTS}: + go install golang.org/x/tools/cmd/goimports@latest + # Build SAMPLE ADDON addon: fmt vet go build -o bin/addon github.com/konveyor/tackle2-hub/hack/cmd/addon diff --git a/addon/adapter.go b/addon/adapter.go index 5a75e1cdc..f9ffab673 100644 --- a/addon/adapter.go +++ b/addon/adapter.go @@ -5,13 +5,14 @@ Tackle hub/addon integration. package addon import ( + "os" + logapi "github.com/go-logr/logr" "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/binding" "github.com/konveyor/tackle2-hub/settings" "github.com/konveyor/tackle2-hub/task" "golang.org/x/sys/unix" - "os" ) var ( diff --git a/addon/task.go b/addon/task.go index b1b9cd7bd..0f3a91c64 100644 --- a/addon/task.go +++ b/addon/task.go @@ -3,10 +3,11 @@ package addon import ( "encoding/json" "fmt" + "strings" + "github.com/konveyor/tackle2-hub/api" "github.com/konveyor/tackle2-hub/binding" "github.com/konveyor/tackle2-hub/task" - "strings" ) // Task API. diff --git a/api/addon.go b/api/addon.go index a1788ed58..4f11a88a4 100644 --- a/api/addon.go +++ b/api/addon.go @@ -2,10 +2,11 @@ package api import ( "context" + "net/http" + "github.com/gin-gonic/gin" crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" - "net/http" k8s "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/api/adoptionplan.go b/api/adoptionplan.go index 0dd4cd9df..9ac005c38 100644 --- a/api/adoptionplan.go +++ b/api/adoptionplan.go @@ -1,11 +1,12 @@ package api import ( + "net/http" + "strings" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" - "strings" ) // Effort estimates diff --git a/api/analysis.go b/api/analysis.go index 9bea1c1d8..b8b5a12be 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -4,6 +4,13 @@ import ( "bytes" "encoding/json" "errors" + "io" + "net/http" + "os" + "sort" + "strconv" + "strings" + "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" qf "github.com/konveyor/tackle2-hub/api/filter" @@ -13,12 +20,6 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/logger" - "io" - "net/http" - "os" - "sort" - "strconv" - "strings" ) // Routes diff --git a/api/api_test.go b/api/api_test.go index 09a314a32..cb19399ec 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -1,10 +1,11 @@ package api import ( - "github.com/gin-gonic/gin" - "github.com/onsi/gomega" "net/http" "testing" + + "github.com/gin-gonic/gin" + "github.com/onsi/gomega" ) func TestAccepted(t *testing.T) { diff --git a/api/auth.go b/api/auth.go index e247dae1b..5876143fc 100644 --- a/api/auth.go +++ b/api/auth.go @@ -1,9 +1,10 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/auth" - "net/http" ) // Routes diff --git a/api/base.go b/api/base.go index 40a6fb53a..073cdda82 100644 --- a/api/base.go +++ b/api/base.go @@ -6,6 +6,11 @@ import ( "encoding/json" "errors" "fmt" + "io" + "strconv" + "strings" + "time" + "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" liberr "github.com/jortel/go-utils/error" @@ -16,11 +21,7 @@ import ( "github.com/konveyor/tackle2-hub/model" "gopkg.in/yaml.v2" "gorm.io/gorm" - "io" "sigs.k8s.io/controller-runtime/pkg/client" - "strconv" - "strings" - "time" ) var Log = logr.WithName("api") diff --git a/api/batch.go b/api/batch.go index e71a4cb8b..c569655f0 100644 --- a/api/batch.go +++ b/api/batch.go @@ -3,9 +3,10 @@ package api import ( "bytes" "encoding/json" - "github.com/gin-gonic/gin" "io" "net/http" + + "github.com/gin-gonic/gin" ) // Routes diff --git a/api/bucket.go b/api/bucket.go index 7775cd26c..56d5e1e13 100644 --- a/api/bucket.go +++ b/api/bucket.go @@ -1,16 +1,17 @@ package api import ( - "github.com/gin-gonic/gin" - "github.com/gin-gonic/gin/binding" - "github.com/konveyor/tackle2-hub/model" - "github.com/konveyor/tackle2-hub/nas" - "github.com/konveyor/tackle2-hub/tar" "io" "net/http" "os" pathlib "path" "time" + + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + "github.com/konveyor/tackle2-hub/model" + "github.com/konveyor/tackle2-hub/nas" + "github.com/konveyor/tackle2-hub/tar" ) // Routes diff --git a/api/businessservice.go b/api/businessservice.go index 940b6f966..41caf95b5 100644 --- a/api/businessservice.go +++ b/api/businessservice.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/cache.go b/api/cache.go index d7ad30586..ed36b61a3 100644 --- a/api/cache.go +++ b/api/cache.go @@ -1,14 +1,15 @@ package api import ( - "github.com/gin-gonic/gin" - liberr "github.com/jortel/go-utils/error" - "github.com/konveyor/tackle2-hub/nas" "net/http" "os" "os/exec" pathlib "path" "strings" + + "github.com/gin-gonic/gin" + liberr "github.com/jortel/go-utils/error" + "github.com/konveyor/tackle2-hub/nas" ) // Routes diff --git a/api/context.go b/api/context.go index f9670ccac..0a144c7cc 100644 --- a/api/context.go +++ b/api/context.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/auth" "gorm.io/gorm" - "net/http" "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/api/error.go b/api/error.go index 1c2b797fd..2425c2344 100644 --- a/api/error.go +++ b/api/error.go @@ -2,6 +2,9 @@ package api import ( "errors" + "net/http" + "os" + "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/konveyor/tackle2-hub/api/filter" @@ -9,8 +12,6 @@ import ( "github.com/konveyor/tackle2-hub/model" "github.com/mattn/go-sqlite3" "gorm.io/gorm" - "net/http" - "os" ) // BadRequestError reports bad request errors. diff --git a/api/file.go b/api/file.go index b633753ec..827cc8a68 100644 --- a/api/file.go +++ b/api/file.go @@ -1,14 +1,15 @@ package api import ( - "github.com/gin-gonic/gin" - "github.com/konveyor/tackle2-hub/model" "io" "mime" "net/http" "os" pathlib "path" "time" + + "github.com/gin-gonic/gin" + "github.com/konveyor/tackle2-hub/model" ) // Routes diff --git a/api/filter/filter.go b/api/filter/filter.go index e86a0ec2f..94d1fcdf9 100644 --- a/api/filter/filter.go +++ b/api/filter/filter.go @@ -1,10 +1,11 @@ package filter import ( - "github.com/gin-gonic/gin" - "gorm.io/gorm" "strconv" "strings" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" ) const ( diff --git a/api/filter/filter_test.go b/api/filter/filter_test.go index 09def2252..03ecad85e 100644 --- a/api/filter/filter_test.go +++ b/api/filter/filter_test.go @@ -1,8 +1,9 @@ package filter import ( - "github.com/onsi/gomega" "testing" + + "github.com/onsi/gomega" ) func TestLexer(t *testing.T) { diff --git a/api/group.go b/api/group.go index c9f26bd41..4e92337b3 100644 --- a/api/group.go +++ b/api/group.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/identity.go b/api/identity.go index 5a6185325..39cfd1e2f 100644 --- a/api/identity.go +++ b/api/identity.go @@ -1,10 +1,11 @@ package api import ( - "github.com/gin-gonic/gin" - "github.com/konveyor/tackle2-hub/model" "net/http" "strconv" + + "github.com/gin-gonic/gin" + "github.com/konveyor/tackle2-hub/model" ) // Routes diff --git a/api/import.go b/api/import.go index bf91ebd81..53a6d445d 100644 --- a/api/import.go +++ b/api/import.go @@ -3,12 +3,13 @@ package api import ( "bytes" "encoding/csv" - "github.com/gin-gonic/gin" - "github.com/konveyor/tackle2-hub/model" "io" "net/http" "strconv" "time" + + "github.com/gin-gonic/gin" + "github.com/konveyor/tackle2-hub/model" ) // Record types diff --git a/api/jobfunction.go b/api/jobfunction.go index 4af8b3f9f..82e615956 100644 --- a/api/jobfunction.go +++ b/api/jobfunction.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/metric.go b/api/metric.go index 4774b68b6..eb576b027 100644 --- a/api/metric.go +++ b/api/metric.go @@ -1,8 +1,9 @@ package api import ( - "github.com/prometheus/client_golang/prometheus/promhttp" "net/http" + + "github.com/prometheus/client_golang/prometheus/promhttp" ) // MetricsHandler godoc diff --git a/api/migrationwave.go b/api/migrationwave.go index c819012a5..24835e5e9 100644 --- a/api/migrationwave.go +++ b/api/migrationwave.go @@ -1,11 +1,12 @@ package api import ( + "net/http" + "time" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" - "time" ) // Routes diff --git a/api/proxy.go b/api/proxy.go index 6308fc0f6..72f3dd67b 100644 --- a/api/proxy.go +++ b/api/proxy.go @@ -2,10 +2,11 @@ package api import ( "encoding/json" + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/review.go b/api/review.go index 172b3aaa6..85fbbdcb8 100644 --- a/api/review.go +++ b/api/review.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/ruleset.go b/api/ruleset.go index 843e3b1b7..95bfabb58 100644 --- a/api/ruleset.go +++ b/api/ruleset.go @@ -2,12 +2,13 @@ package api import ( "encoding/json" + "net/http" + "github.com/gin-gonic/gin" qf "github.com/konveyor/tackle2-hub/api/filter" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/schema.go b/api/schema.go index d3270b8d3..3c02423f1 100644 --- a/api/schema.go +++ b/api/schema.go @@ -1,8 +1,9 @@ package api import ( - "github.com/gin-gonic/gin" "net/http" + + "github.com/gin-gonic/gin" ) // SchemaHandler providers schema (route) handler. diff --git a/api/setting.go b/api/setting.go index d043f5a30..ab35709c2 100644 --- a/api/setting.go +++ b/api/setting.go @@ -3,10 +3,11 @@ package api import ( "encoding/json" "fmt" - "github.com/gin-gonic/gin" - "github.com/konveyor/tackle2-hub/model" "net/http" "strings" + + "github.com/gin-gonic/gin" + "github.com/konveyor/tackle2-hub/model" ) // Routes diff --git a/api/sort/sort.go b/api/sort/sort.go index 483ea26e0..08d93e81b 100644 --- a/api/sort/sort.go +++ b/api/sort/sort.go @@ -1,10 +1,11 @@ package sort import ( + "strings" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/api/reflect" "gorm.io/gorm" - "strings" ) // Clause sort clause. diff --git a/api/stakeholder.go b/api/stakeholder.go index f459f1552..4cb659310 100644 --- a/api/stakeholder.go +++ b/api/stakeholder.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/tag.go b/api/tag.go index 56702f9ea..17d472444 100644 --- a/api/tag.go +++ b/api/tag.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/tagcategory.go b/api/tagcategory.go index b28f210bd..8ae7799b2 100644 --- a/api/tagcategory.go +++ b/api/tagcategory.go @@ -1,10 +1,11 @@ package api import ( + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/target.go b/api/target.go index 190f00877..efccc4d10 100644 --- a/api/target.go +++ b/api/target.go @@ -4,12 +4,13 @@ import ( "encoding/json" "errors" "fmt" + "net/http" + "github.com/gin-gonic/gin" uuid2 "github.com/google/uuid" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" "gorm.io/gorm/clause" - "net/http" ) // Routes diff --git a/api/task.go b/api/task.go index a8b815a3f..ef20cef6e 100644 --- a/api/task.go +++ b/api/task.go @@ -2,19 +2,20 @@ package api import ( "encoding/json" + "io/ioutil" + "net/http" + "sort" + "strconv" + "strings" + "time" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" tasking "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm" "gorm.io/gorm/clause" - "io/ioutil" k8serr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/utils/strings/slices" - "net/http" - "sort" - "strconv" - "strings" - "time" ) // Routes diff --git a/api/taskgroup.go b/api/taskgroup.go index d3d442723..04d936b5d 100644 --- a/api/taskgroup.go +++ b/api/taskgroup.go @@ -2,12 +2,13 @@ package api import ( "encoding/json" + "net/http" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" tasking "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm/clause" k8serr "k8s.io/apimachinery/pkg/api/errors" - "net/http" ) // Routes diff --git a/api/ticket.go b/api/ticket.go index 4ec664bc1..d42617b02 100644 --- a/api/ticket.go +++ b/api/ticket.go @@ -2,11 +2,12 @@ package api import ( "encoding/json" + "net/http" + "time" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm/clause" - "net/http" - "time" ) // Routes diff --git a/api/tracker.go b/api/tracker.go index 18d6918c2..650607bac 100644 --- a/api/tracker.go +++ b/api/tracker.go @@ -1,13 +1,14 @@ package api import ( + "net/http" + "strconv" + "time" + "github.com/gin-gonic/gin" "github.com/konveyor/tackle2-hub/model" "github.com/konveyor/tackle2-hub/tracker" "gorm.io/gorm/clause" - "net/http" - "strconv" - "time" ) // Routes diff --git a/assessment/assessment_test.go b/assessment/assessment_test.go index f63c7d537..fc8cbf4db 100644 --- a/assessment/assessment_test.go +++ b/assessment/assessment_test.go @@ -1,9 +1,10 @@ package assessment import ( + "testing" + "github.com/konveyor/tackle2-hub/model" "github.com/onsi/gomega" - "testing" ) func TestPrepareSections(t *testing.T) { diff --git a/assessment/pkg.go b/assessment/pkg.go index 9d9367a00..18671e4c0 100644 --- a/assessment/pkg.go +++ b/assessment/pkg.go @@ -2,6 +2,7 @@ package assessment import ( "encoding/json" + "github.com/konveyor/tackle2-hub/model" ) diff --git a/assessment/set_test.go b/assessment/set_test.go index b87df2ac2..1fd856079 100644 --- a/assessment/set_test.go +++ b/assessment/set_test.go @@ -1,8 +1,9 @@ package assessment import ( - "github.com/onsi/gomega" "testing" + + "github.com/onsi/gomega" ) func TestSet_Superset(t *testing.T) { diff --git a/auth/auth_test.go b/auth/auth_test.go index c8458b95f..4420ef146 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -1,9 +1,10 @@ package auth import ( + "testing" + "github.com/golang-jwt/jwt/v4" "github.com/onsi/gomega" - "testing" ) type _TestProvider struct { diff --git a/auth/builtin.go b/auth/builtin.go index 76aabfb3e..3a444c9d0 100644 --- a/auth/builtin.go +++ b/auth/builtin.go @@ -1,10 +1,11 @@ package auth import ( + "strings" + "github.com/golang-jwt/jwt/v4" liberr "github.com/jortel/go-utils/error" "gorm.io/gorm" - "strings" ) // Validators provide token validation based on claims. diff --git a/auth/keycloak.go b/auth/keycloak.go index 3bcc8ef6f..8fcc5482c 100644 --- a/auth/keycloak.go +++ b/auth/keycloak.go @@ -3,11 +3,12 @@ package auth import ( "context" "crypto/tls" + "strings" + "time" + "github.com/Nerzal/gocloak/v10" "github.com/golang-jwt/jwt/v4" liberr "github.com/jortel/go-utils/error" - "strings" - "time" ) // NewKeycloak builds a new Keycloak auth provider. diff --git a/auth/provider.go b/auth/provider.go index 7a74bc235..a2066e9ec 100644 --- a/auth/provider.go +++ b/auth/provider.go @@ -3,9 +3,10 @@ package auth import ( "errors" "fmt" + "strings" + "github.com/golang-jwt/jwt/v4" "github.com/jortel/go-utils/logr" - "strings" ) var ( diff --git a/auth/reconcile.go b/auth/reconcile.go index 5a87ecb7f..db27f9c4e 100644 --- a/auth/reconcile.go +++ b/auth/reconcile.go @@ -4,10 +4,11 @@ import ( "context" "crypto/tls" "fmt" - "github.com/Nerzal/gocloak/v10" - liberr "github.com/jortel/go-utils/error" "strings" "time" + + "github.com/Nerzal/gocloak/v10" + liberr "github.com/jortel/go-utils/error" ) // NewReconciler builds a new Keycloak realm reconciler. diff --git a/auth/request.go b/auth/request.go index e4bea3654..ab8c53150 100644 --- a/auth/request.go +++ b/auth/request.go @@ -2,6 +2,7 @@ package auth import ( "errors" + "github.com/golang-jwt/jwt/v4" "gorm.io/gorm" ) diff --git a/binding/application.go b/binding/application.go index 881d991b0..ff66ffa61 100644 --- a/binding/application.go +++ b/binding/application.go @@ -3,29 +3,27 @@ package binding import ( "bytes" "errors" + "io" + "net/http" + "strconv" + mime "github.com/gin-gonic/gin/binding" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/api" "gopkg.in/yaml.v2" - "io" - "net/http" - "strconv" ) -// // Application API. type Application struct { client *Client } -// // Create an Application. func (h *Application) Create(r *api.Application) (err error) { err = h.client.Post(api.ApplicationsRoot, &r) return } -// // Get an Application by ID. func (h *Application) Get(id uint) (r *api.Application, err error) { r = &api.Application{} @@ -34,7 +32,6 @@ func (h *Application) Get(id uint) (r *api.Application, err error) { return } -// // List Applications. func (h *Application) List() (list []api.Application, err error) { list = []api.Application{} @@ -42,7 +39,6 @@ func (h *Application) List() (list []api.Application, err error) { return } -// // Update an Application. func (h *Application) Update(r *api.Application) (err error) { path := Path(api.ApplicationRoot).Inject(Params{api.ID: r.ID}) @@ -50,14 +46,12 @@ func (h *Application) Update(r *api.Application) (err error) { return } -// // Delete an Application. func (h *Application) Delete(id uint) (err error) { err = h.client.Delete(Path(api.ApplicationRoot).Inject(Params{api.ID: id})) return } -// // Bucket returns the bucket API. func (h *Application) Bucket(id uint) (b *BucketContent) { params := Params{ @@ -72,7 +66,6 @@ func (h *Application) Bucket(id uint) (b *BucketContent) { return } -// // FindIdentity by kind. func (h *Application) FindIdentity(id uint, kind string) (r *api.Identity, found bool, err error) { list := []api.Identity{} @@ -101,7 +94,6 @@ func (h *Application) FindIdentity(id uint, kind string) (r *api.Identity, found return } -// // Tags returns the tags API. func (h *Application) Tags(id uint) (tg AppTags) { tg = AppTags{ @@ -111,7 +103,6 @@ func (h *Application) Tags(id uint) (tg AppTags) { return } -// // AppTags sub-resource API. // Provides association management of tags to applications by name. type AppTags struct { @@ -120,13 +111,11 @@ type AppTags struct { source *string } -// // Source sets the source for other operations on the associated tags. func (h *AppTags) Source(name string) { h.source = &name } -// // Replace the associated tags for the source with a new set. // Returns an error if the source is not set. func (h *AppTags) Replace(ids []uint) (err error) { @@ -152,7 +141,6 @@ func (h *AppTags) Replace(ids []uint) (err error) { return } -// // List associated tags. // Returns a list of tag names. func (h *AppTags) List() (list []api.TagRef, err error) { @@ -171,7 +159,6 @@ func (h *AppTags) List() (list []api.TagRef, err error) { return } -// // Add associates a tag with the application. func (h *AppTags) Add(id uint) (err error) { path := Path(api.ApplicationTagsRoot).Inject(Params{api.ID: h.appId}) @@ -183,7 +170,6 @@ func (h *AppTags) Add(id uint) (err error) { return } -// // Ensure ensures tag is associated with the application. func (h *AppTags) Ensure(id uint) (err error) { err = h.Add(id) @@ -193,7 +179,6 @@ func (h *AppTags) Ensure(id uint) (err error) { return } -// // Delete ensures the tag is not associated with the application. func (h *AppTags) Delete(id uint) (err error) { path := Path( @@ -209,7 +194,6 @@ func (h *AppTags) Delete(id uint) (err error) { return } -// // unique ensures unique ids. func (h *AppTags) unique(ids []uint) (u []uint) { mp := map[uint]int{} @@ -222,7 +206,6 @@ func (h *AppTags) unique(ids []uint) (u []uint) { return } -// // Facts returns the tags API. func (h *Application) Facts(id uint) (f AppFacts) { f = AppFacts{ @@ -232,7 +215,6 @@ func (h *Application) Facts(id uint) (f AppFacts) { return } -// // AppFacts sub-resource API. // Provides association management of facts. type AppFacts struct { @@ -241,13 +223,11 @@ type AppFacts struct { source string } -// // Source sets the source for other operations on the facts. func (h *AppFacts) Source(source string) { h.source = source } -// // List facts. func (h *AppFacts) List() (facts api.FactMap, err error) { facts = api.FactMap{} @@ -258,7 +238,6 @@ func (h *AppFacts) List() (facts api.FactMap, err error) { return } -// // Get a fact. func (h *AppFacts) Get(name string, value interface{}) (err error) { key := api.FactKey(name) @@ -272,7 +251,6 @@ func (h *AppFacts) Get(name string, value interface{}) (err error) { return } -// // Set a fact (created as needed). func (h *AppFacts) Set(name string, value interface{}) (err error) { key := api.FactKey(name) @@ -286,7 +264,6 @@ func (h *AppFacts) Set(name string, value interface{}) (err error) { return } -// // Delete a fact. func (h *AppFacts) Delete(name string) (err error) { key := api.FactKey(name) @@ -300,7 +277,6 @@ func (h *AppFacts) Delete(name string) (err error) { return } -// // Replace facts. func (h *AppFacts) Replace(facts api.FactMap) (err error) { key := api.FactKey("") @@ -319,7 +295,6 @@ func (h *Application) Analysis(id uint) (a Analysis) { return } -// // Create an Application Assessment. func (h *Application) CreateAssesment(id uint, r *api.Assessment) (err error) { path := Path(api.AppAssessmentsRoot).Inject(Params{api.ID: id}) @@ -327,7 +302,6 @@ func (h *Application) CreateAssesment(id uint, r *api.Assessment) (err error) { return } -// // Get Application Assessments. func (h *Application) GetAssesments(id uint) (list []api.Assessment, err error) { list = []api.Assessment{} @@ -336,14 +310,12 @@ func (h *Application) GetAssesments(id uint) (list []api.Assessment, err error) return } -// // Analysis API. type Analysis struct { client *Client appId uint } -// // Create an analysis report. func (h *Analysis) Create(r *api.Analysis, encoding string, issues, deps io.Reader) (err error) { path := Path(api.AppAnalysesRoot).Inject(Params{api.ID: h.appId}) diff --git a/binding/archetype.go b/binding/archetype.go index cecaca248..911561eeb 100644 --- a/binding/archetype.go +++ b/binding/archetype.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Archetype API. type Archetype struct { client *Client } -// // Create a Archetype. func (h *Archetype) Create(r *api.Archetype) (err error) { err = h.client.Post(api.ArchetypesRoot, &r) return } -// // Get a Archetype by ID. func (h *Archetype) Get(id uint) (r *api.Archetype, err error) { r = &api.Archetype{} @@ -26,7 +23,6 @@ func (h *Archetype) Get(id uint) (r *api.Archetype, err error) { return } -// // List Archetypes. func (h *Archetype) List() (list []api.Archetype, err error) { list = []api.Archetype{} @@ -34,7 +30,6 @@ func (h *Archetype) List() (list []api.Archetype, err error) { return } -// // Update a Archetype. func (h *Archetype) Update(r *api.Archetype) (err error) { path := Path(api.ArchetypeRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *Archetype) Update(r *api.Archetype) (err error) { return } -// // Delete a Archetype. func (h *Archetype) Delete(id uint) (err error) { err = h.client.Delete(Path(api.ArchetypeRoot).Inject(Params{api.ID: id})) diff --git a/binding/assessment.go b/binding/assessment.go index 184d987f7..c8a6637c6 100644 --- a/binding/assessment.go +++ b/binding/assessment.go @@ -4,13 +4,11 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Assessment API. type Assessment struct { client *Client } -// // Get a Assessment by ID. func (h *Assessment) Get(id uint) (r *api.Assessment, err error) { r = &api.Assessment{} @@ -19,7 +17,6 @@ func (h *Assessment) Get(id uint) (r *api.Assessment, err error) { return } -// // List Assessments. func (h *Assessment) List() (list []api.Assessment, err error) { list = []api.Assessment{} @@ -27,7 +24,6 @@ func (h *Assessment) List() (list []api.Assessment, err error) { return } -// // Update a Assessment. func (h *Assessment) Update(r *api.Assessment) (err error) { path := Path(api.AssessmentRoot).Inject(Params{api.ID: r.ID}) @@ -35,7 +31,6 @@ func (h *Assessment) Update(r *api.Assessment) (err error) { return } -// // Delete a Assessment. func (h *Assessment) Delete(id uint) (err error) { err = h.client.Delete(Path(api.AssessmentRoot).Inject(Params{api.ID: id})) diff --git a/binding/bucket.go b/binding/bucket.go index cb096f065..a25043f1c 100644 --- a/binding/bucket.go +++ b/binding/bucket.go @@ -6,20 +6,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Bucket API. type Bucket struct { client *Client } -// // Create a Bucket. func (h *Bucket) Create(r *api.Bucket) (err error) { err = h.client.Post(api.BucketsRoot, &r) return } -// // Get a bucket. func (h *Bucket) Get(id uint) (r *api.Bucket, err error) { r = &api.Bucket{} @@ -28,7 +25,6 @@ func (h *Bucket) Get(id uint) (r *api.Bucket, err error) { return } -// // List buckets. func (h *Bucket) List() (list []api.Bucket, err error) { list = []api.Bucket{} @@ -36,14 +32,12 @@ func (h *Bucket) List() (list []api.Bucket, err error) { return } -// // Delete a bucket. func (h *Bucket) Delete(id uint) (err error) { err = h.client.Delete(Path(api.BucketRoot).Inject(Params{api.ID: id})) return } -// // Content returns content API. func (h *Bucket) Content(id uint) (b *BucketContent) { params := Params{ @@ -58,14 +52,12 @@ func (h *Bucket) Content(id uint) (b *BucketContent) { return } -// // BucketContent API. type BucketContent struct { client *Client root string } -// // Get reads from the bucket. // The source (root) is relative to the bucket root. func (h *BucketContent) Get(source, destination string) (err error) { @@ -73,7 +65,6 @@ func (h *BucketContent) Get(source, destination string) (err error) { return } -// // Put writes to the bucket. // The destination (root) is relative to the bucket root. func (h *BucketContent) Put(source, destination string) (err error) { @@ -81,7 +72,6 @@ func (h *BucketContent) Put(source, destination string) (err error) { return } -// // Delete deletes content at the specified root. // The source is relative to the bucket root. func (h *BucketContent) Delete(path string) (err error) { diff --git a/binding/businessservice.go b/binding/businessservice.go index 62a9f8147..812ddb61e 100644 --- a/binding/businessservice.go +++ b/binding/businessservice.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // BusinessService API. type BusinessService struct { client *Client } -// // Create a BusinessService. func (h *BusinessService) Create(r *api.BusinessService) (err error) { err = h.client.Post(api.BusinessServicesRoot, &r) return } -// // Get a BusinessService by ID. func (h *BusinessService) Get(id uint) (r *api.BusinessService, err error) { r = &api.BusinessService{} @@ -26,7 +23,6 @@ func (h *BusinessService) Get(id uint) (r *api.BusinessService, err error) { return } -// // List BusinessServices. func (h *BusinessService) List() (list []api.BusinessService, err error) { list = []api.BusinessService{} @@ -34,7 +30,6 @@ func (h *BusinessService) List() (list []api.BusinessService, err error) { return } -// // Update a BusinessService. func (h *BusinessService) Update(r *api.BusinessService) (err error) { path := Path(api.BusinessServiceRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *BusinessService) Update(r *api.BusinessService) (err error) { return } -// // Delete a BusinessService. func (h *BusinessService) Delete(id uint) (err error) { err = h.client.Delete(Path(api.BusinessServiceRoot).Inject(Params{api.ID: id})) diff --git a/binding/client.go b/binding/client.go index 0dbf72784..4a502aea1 100644 --- a/binding/client.go +++ b/binding/client.go @@ -5,11 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/gin-gonic/gin/binding" - liberr "github.com/jortel/go-utils/error" - "github.com/konveyor/tackle2-hub/api" - qf "github.com/konveyor/tackle2-hub/binding/filter" - "github.com/konveyor/tackle2-hub/tar" "io" "mime/multipart" "net" @@ -20,6 +15,12 @@ import ( pathlib "path" "strings" "time" + + "github.com/gin-gonic/gin/binding" + liberr "github.com/jortel/go-utils/error" + "github.com/konveyor/tackle2-hub/api" + qf "github.com/konveyor/tackle2-hub/binding/filter" + "github.com/konveyor/tackle2-hub/tar" ) const ( @@ -27,20 +28,17 @@ const ( RetryDelay = time.Second * 10 ) -// // Param. type Param struct { Key string Value string } -// // Filter type Filter struct { qf.Filter } -// // Param returns a filter parameter. func (r *Filter) Param() (p Param) { p.Key = api.Filter @@ -48,15 +46,12 @@ func (r *Filter) Param() (p Param) { return } -// // Params mapping. type Params map[string]interface{} -// // Path API path. type Path string -// // Inject named parameters. func (s Path) Inject(p Params) (out string) { in := strings.Split(string(s), "/") @@ -73,7 +68,6 @@ func (s Path) Inject(p Params) (out string) { return } -// // NewClient Constructs a new client func NewClient(url, token string) (client *Client) { client = &Client{ @@ -84,7 +78,6 @@ func NewClient(url, token string) (client *Client) { return } -// // Client provides a REST client. type Client struct { // baseURL for the nub. @@ -99,19 +92,16 @@ type Client struct { Error error } -// // SetToken sets hub token on client func (r *Client) SetToken(token string) { r.token = token } -// // Reset the client. func (r *Client) Reset() { r.Error = nil } -// // Get a resource. func (r *Client) Get(path string, object interface{}, params ...Param) (err error) { request := func() (request *http.Request, err error) { @@ -158,7 +148,6 @@ func (r *Client) Get(path string, object interface{}, params ...Param) (err erro return } -// // Post a resource. func (r *Client) Post(path string, object interface{}) (err error) { request := func() (request *http.Request, err error) { @@ -203,7 +192,6 @@ func (r *Client) Post(path string, object interface{}) (err error) { return } -// // Put a resource. func (r *Client) Put(path string, object interface{}, params ...Param) (err error) { request := func() (request *http.Request, err error) { @@ -256,7 +244,6 @@ func (r *Client) Put(path string, object interface{}, params ...Param) (err erro return } -// // Delete a resource. func (r *Client) Delete(path string, params ...Param) (err error) { request := func() (request *http.Request, err error) { @@ -293,7 +280,6 @@ func (r *Client) Delete(path string, params ...Param) (err error) { return } -// // BucketGet downloads a file/directory. // The source (path) is relative to the bucket root. func (r *Client) BucketGet(source, destination string) (err error) { @@ -329,7 +315,6 @@ func (r *Client) BucketGet(source, destination string) (err error) { return } -// // BucketPut uploads a file/directory. // The destination (path) is relative to the bucket root. func (r *Client) BucketPut(source, destination string) (err error) { @@ -390,7 +375,6 @@ func (r *Client) BucketPut(source, destination string) (err error) { return } -// // FileGet downloads a file. func (r *Client) FileGet(path, destination string) (err error) { request := func() (request *http.Request, err error) { @@ -421,7 +405,6 @@ func (r *Client) FileGet(path, destination string) (err error) { return } -// // FilePost uploads a file. // Returns the created File resource. func (r *Client) FilePost(path, source string, object interface{}) (err error) { @@ -454,7 +437,6 @@ func (r *Client) FilePost(path, source string, object interface{}) (err error) { return } -// // FilePut uploads a file. // Returns the created File resource. func (r *Client) FilePut(path, source string, object interface{}) (err error) { @@ -487,7 +469,6 @@ func (r *Client) FilePut(path, source string, object interface{}) (err error) { return } -// // FilePatch appends file. // Returns the created File resource. func (r *Client) FilePatch(path string, buffer []byte) (err error) { @@ -501,7 +482,6 @@ func (r *Client) FilePatch(path string, buffer []byte) (err error) { return } -// // FileSend sends file upload from. func (r *Client) FileSend(path, method string, fields []Field, object interface{}) (err error) { request := func() (request *http.Request, err error) { @@ -567,7 +547,6 @@ func (r *Client) FileSend(path, method string, fields []Field, object interface{ return } -// // getDir downloads and expands a directory. func (r *Client) getDir(body io.Reader, output string) (err error) { tarReader := tar.NewReader() @@ -575,7 +554,6 @@ func (r *Client) getDir(body io.Reader, output string) (err error) { return } -// // putDir archive and uploads a directory. func (r *Client) putDir(writer io.Writer, input string) (err error) { tarWriter := tar.NewWriter(writer) @@ -584,7 +562,6 @@ func (r *Client) putDir(writer io.Writer, input string) (err error) { return } -// // getFile downloads plain file. func (r *Client) getFile(body io.Reader, path, output string) (err error) { isDir, err := r.IsDir(output, false) @@ -608,7 +585,6 @@ func (r *Client) getFile(body io.Reader, path, output string) (err error) { return } -// // putFile uploads plain file. func (r *Client) putFile(writer io.Writer, input string) (err error) { file, err := os.Open(input) @@ -623,7 +599,6 @@ func (r *Client) putFile(writer io.Writer, input string) (err error) { return } -// // IsDir determines if the path is a directory. // The `must` specifies if the path must exist. func (r *Client) IsDir(path string, must bool) (b bool, err error) { @@ -644,7 +619,6 @@ func (r *Client) IsDir(path string, must bool) (b bool, err error) { return } -// // Send the request. // Resilient against transient hub availability. func (r *Client) send(rb func() (*http.Request, error)) (response *http.Response, err error) { @@ -694,7 +668,6 @@ func (r *Client) send(rb func() (*http.Request, error)) (response *http.Response return } -// // buildTransport builds transport. func (r *Client) buildTransport() (err error) { if r.transport != nil { @@ -714,7 +687,6 @@ func (r *Client) buildTransport() (err error) { return } -// // Join the URL. func (r *Client) join(path string) (parsedURL *url.URL) { parsedURL, _ = url.Parse(r.baseURL) @@ -722,7 +694,6 @@ func (r *Client) join(path string) (parsedURL *url.URL) { return } -// // restError returns an error based on status. func (r *Client) restError(response *http.Response) (err error) { status := response.StatusCode @@ -746,7 +717,6 @@ func (r *Client) restError(response *http.Response) (err error) { return } -// // Field file upload form field. type Field struct { Name string @@ -755,7 +725,6 @@ type Field struct { Encoding string } -// // Write the field content. // When Reader is not set, the path is opened and copied. func (f *Field) Write(writer io.Writer) (err error) { @@ -774,7 +743,6 @@ func (f *Field) Write(writer io.Writer) (err error) { return } -// // encoding returns MIME. func (f *Field) encoding() (mt string) { if f.Encoding != "" { @@ -792,7 +760,6 @@ func (f *Field) encoding() (mt string) { return } -// // disposition returns content-disposition. func (f *Field) disposition() (d string) { d = fmt.Sprintf(`form-data; name="%s"; filename="%s"`, f.Name, pathlib.Base(f.Path)) diff --git a/binding/dependency.go b/binding/dependency.go index a5b1459fa..b9df2ca79 100644 --- a/binding/dependency.go +++ b/binding/dependency.go @@ -4,21 +4,18 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Dependency API. type Dependency struct { // hub API client. client *Client } -// // Create a Dependency. func (h *Dependency) Create(r *api.Dependency) (err error) { err = h.client.Post(api.DependenciesRoot, &r) return } -// // Get a Dependency by ID. func (h *Dependency) Get(id uint) (r *api.Dependency, err error) { r = &api.Dependency{} @@ -27,7 +24,6 @@ func (h *Dependency) Get(id uint) (r *api.Dependency, err error) { return } -// // List Dependencies. func (h *Dependency) List() (list []api.Dependency, err error) { list = []api.Dependency{} @@ -35,7 +31,6 @@ func (h *Dependency) List() (list []api.Dependency, err error) { return } -// // Delete a Dependency. func (h *Dependency) Delete(id uint) (err error) { err = h.client.Delete(Path(api.DependencyRoot).Inject(Params{api.ID: id})) diff --git a/binding/error.go b/binding/error.go index 12d550ae6..831a8de10 100644 --- a/binding/error.go +++ b/binding/error.go @@ -7,7 +7,6 @@ import ( "strings" ) -// // RestError reports REST errors. type RestError struct { Reason string @@ -52,7 +51,6 @@ func (e *RestError) With(r *http.Response) { e.Reason = s } -// // Conflict reports 409 error. type Conflict struct { RestError @@ -63,7 +61,6 @@ func (e *Conflict) Is(err error) (matched bool) { return } -// // NotFound reports 404 error. type NotFound struct { RestError diff --git a/binding/file.go b/binding/file.go index 6e9f258f1..22bdcb80b 100644 --- a/binding/file.go +++ b/binding/file.go @@ -1,17 +1,16 @@ package binding import ( - "github.com/konveyor/tackle2-hub/api" pathlib "path" + + "github.com/konveyor/tackle2-hub/api" ) -// // File API. type File struct { client *Client } -// // Get downloads a file. func (h *File) Get(id uint, destination string) (err error) { path := Path(api.FileRoot).Inject(Params{api.ID: id}) @@ -33,7 +32,6 @@ func (h *File) Get(id uint, destination string) (err error) { return } -// // Touch creates an empty file. func (h *File) Touch(name string) (r *api.File, err error) { r = &api.File{} @@ -42,7 +40,6 @@ func (h *File) Touch(name string) (r *api.File, err error) { return } -// // Post uploads a file. func (h *File) Post(source string) (r *api.File, err error) { r = &api.File{} @@ -51,7 +48,6 @@ func (h *File) Post(source string) (r *api.File, err error) { return } -// // Put uploads a file. func (h *File) Put(source string) (r *api.File, err error) { r = &api.File{} @@ -60,7 +56,6 @@ func (h *File) Put(source string) (r *api.File, err error) { return } -// // Patch appends a file. func (h *File) Patch(id uint, buffer []byte) (err error) { path := Path(api.FileRoot).Inject(Params{api.ID: id}) @@ -68,7 +63,6 @@ func (h *File) Patch(id uint, buffer []byte) (err error) { return } -// // Delete a file. func (h *File) Delete(id uint) (err error) { path := Path(api.FileRoot).Inject(Params{api.ID: id}) diff --git a/binding/filter/builder.go b/binding/filter/builder.go index 36c5ac66b..180b348bc 100644 --- a/binding/filter/builder.go +++ b/binding/filter/builder.go @@ -12,10 +12,11 @@ filter.And("friend").Eq(Any{"Sam","Ed"}) */ import ( - qf "github.com/konveyor/tackle2-hub/api/filter" "reflect" "strconv" "strings" + + qf "github.com/konveyor/tackle2-hub/api/filter" ) const ( @@ -28,21 +29,17 @@ const ( OR = string(qf.OR) ) -// // Any match any. type Any []interface{} -// // All match all. type All []interface{} -// // Filter builder. type Filter struct { predicates []*Predicate } -// // And adds a predicate. // Example: filter.And("name").Equals("Elmer") func (f *Filter) And(field string) (p *Predicate) { @@ -54,7 +51,6 @@ func (f *Filter) And(field string) (p *Predicate) { return p } -// // String returns string representation. func (f *Filter) String() (s string) { var preds []string @@ -65,7 +61,6 @@ func (f *Filter) String() (s string) { return } -// // Predicate is a filter query predicate. type Predicate struct { field string @@ -73,14 +68,12 @@ type Predicate struct { value string } -// // String returns a string representation of the predicate. func (p *Predicate) String() (s string) { s = p.field + p.operator + p.value return } -// // Eq returns a (=) predicate. func (p *Predicate) Eq(object interface{}) *Predicate { p.operator = EQ @@ -88,7 +81,6 @@ func (p *Predicate) Eq(object interface{}) *Predicate { return p } -// // NotEq returns a (!=) predicate. func (p *Predicate) NotEq(object interface{}) *Predicate { p.operator = NOT + EQ @@ -96,7 +88,6 @@ func (p *Predicate) NotEq(object interface{}) *Predicate { return p } -// // Like returns a (~) predicate. func (p *Predicate) Like(object interface{}) *Predicate { p.operator = LIKE @@ -104,7 +95,6 @@ func (p *Predicate) Like(object interface{}) *Predicate { return p } -// // Gt returns a (>) predicate. func (p *Predicate) Gt(object interface{}) *Predicate { p.operator = GT @@ -112,7 +102,6 @@ func (p *Predicate) Gt(object interface{}) *Predicate { return p } -// // GtEq returns a (>=) predicate. func (p *Predicate) GtEq(object interface{}) *Predicate { p.operator = GT + EQ @@ -120,7 +109,6 @@ func (p *Predicate) GtEq(object interface{}) *Predicate { return p } -// // Lt returns a (<) predicate. func (p *Predicate) Lt(object interface{}) *Predicate { p.operator = LT @@ -128,7 +116,6 @@ func (p *Predicate) Lt(object interface{}) *Predicate { return p } -// // LtEq returns a (<) predicate. func (p *Predicate) LtEq(object interface{}) *Predicate { p.operator = LT + EQ diff --git a/binding/filter/filter_test.go b/binding/filter/filter_test.go index 6c935e5e0..3b37847fe 100644 --- a/binding/filter/filter_test.go +++ b/binding/filter/filter_test.go @@ -1,8 +1,9 @@ package filter import ( - "github.com/onsi/gomega" "testing" + + "github.com/onsi/gomega" ) func TestFilter(t *testing.T) { diff --git a/binding/identity.go b/binding/identity.go index 2fa93c965..e7dcb73c3 100644 --- a/binding/identity.go +++ b/binding/identity.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Identity API. type Identity struct { client *Client } -// // Create a Identity. func (h *Identity) Create(r *api.Identity) (err error) { err = h.client.Post(api.IdentitiesRoot, &r) return } -// // Get a decrypted Identity by ID. func (h *Identity) Get(id uint) (r *api.Identity, err error) { r = &api.Identity{} @@ -30,7 +27,6 @@ func (h *Identity) Get(id uint) (r *api.Identity, err error) { return } -// // List decrypted Identities. func (h *Identity) List() (list []api.Identity, err error) { list = []api.Identity{} @@ -42,7 +38,6 @@ func (h *Identity) List() (list []api.Identity, err error) { return } -// // Update a Identity. func (h *Identity) Update(r *api.Identity) (err error) { path := Path(api.IdentityRoot).Inject(Params{api.ID: r.ID}) @@ -50,7 +45,6 @@ func (h *Identity) Update(r *api.Identity) (err error) { return } -// // Delete a Identity. func (h *Identity) Delete(id uint) (err error) { err = h.client.Delete(Path(api.IdentityRoot).Inject(Params{api.ID: id})) diff --git a/binding/jobfunction.go b/binding/jobfunction.go index dee90506d..be1948ee4 100644 --- a/binding/jobfunction.go +++ b/binding/jobfunction.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // JobFunction API. type JobFunction struct { client *Client } -// // Create a JobFunction. func (h *JobFunction) Create(r *api.JobFunction) (err error) { err = h.client.Post(api.JobFunctionsRoot, &r) return } -// // Get a JobFunction by ID. func (h *JobFunction) Get(id uint) (r *api.JobFunction, err error) { r = &api.JobFunction{} @@ -26,7 +23,6 @@ func (h *JobFunction) Get(id uint) (r *api.JobFunction, err error) { return } -// // List JobFunctions. func (h *JobFunction) List() (list []api.JobFunction, err error) { list = []api.JobFunction{} @@ -34,7 +30,6 @@ func (h *JobFunction) List() (list []api.JobFunction, err error) { return } -// // Update a JobFunction. func (h *JobFunction) Update(r *api.JobFunction) (err error) { path := Path(api.JobFunctionRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *JobFunction) Update(r *api.JobFunction) (err error) { return } -// // Delete a JobFunction. func (h *JobFunction) Delete(id uint) (err error) { err = h.client.Delete(Path(api.JobFunctionRoot).Inject(Params{api.ID: id})) diff --git a/binding/migrationwave.go b/binding/migrationwave.go index abacc3711..9c380d136 100644 --- a/binding/migrationwave.go +++ b/binding/migrationwave.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // MigrationWave API. type MigrationWave struct { client *Client } -// // Create a MigrationWave. func (h *MigrationWave) Create(r *api.MigrationWave) (err error) { err = h.client.Post(api.MigrationWavesRoot, &r) return } -// // Get a MigrationWave by ID. func (h *MigrationWave) Get(id uint) (r *api.MigrationWave, err error) { r = &api.MigrationWave{} @@ -26,7 +23,6 @@ func (h *MigrationWave) Get(id uint) (r *api.MigrationWave, err error) { return } -// // List MigrationWaves. func (h *MigrationWave) List() (list []api.MigrationWave, err error) { list = []api.MigrationWave{} @@ -34,7 +30,6 @@ func (h *MigrationWave) List() (list []api.MigrationWave, err error) { return } -// // Update a MigrationWave. func (h *MigrationWave) Update(r *api.MigrationWave) (err error) { path := Path(api.MigrationWaveRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *MigrationWave) Update(r *api.MigrationWave) (err error) { return } -// // Delete a MigrationWave. func (h *MigrationWave) Delete(id uint) (err error) { err = h.client.Delete(Path(api.MigrationWaveRoot).Inject(Params{api.ID: id})) diff --git a/binding/proxy.go b/binding/proxy.go index 26ecb18d1..2ed9d1a48 100644 --- a/binding/proxy.go +++ b/binding/proxy.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Proxy API. type Proxy struct { client *Client } -// // Create a Proxy. func (h *Proxy) Create(r *api.Proxy) (err error) { err = h.client.Post(api.ProxiesRoot, &r) return } -// // Get a Proxy by ID. func (h *Proxy) Get(id uint) (r *api.Proxy, err error) { r = &api.Proxy{} @@ -26,7 +23,6 @@ func (h *Proxy) Get(id uint) (r *api.Proxy, err error) { return } -// // List Proxies. func (h *Proxy) List() (list []api.Proxy, err error) { list = []api.Proxy{} @@ -34,7 +30,6 @@ func (h *Proxy) List() (list []api.Proxy, err error) { return } -// // Update a Proxy. func (h *Proxy) Update(r *api.Proxy) (err error) { path := Path(api.ProxyRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *Proxy) Update(r *api.Proxy) (err error) { return } -// // Delete a Proxy. func (h *Proxy) Delete(id uint) (err error) { err = h.client.Delete(Path(api.ProxyRoot).Inject(Params{api.ID: id})) return } -// // Find by Kind. // Returns nil when not found. func (h *Proxy) Find(kind string) (r *api.Proxy, err error) { diff --git a/binding/questionnaire.go b/binding/questionnaire.go index 1dd529b8c..932e0c377 100644 --- a/binding/questionnaire.go +++ b/binding/questionnaire.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Questionnaire API. type Questionnaire struct { client *Client } -// // Create a Questionnaire. func (h *Questionnaire) Create(r *api.Questionnaire) (err error) { err = h.client.Post(api.QuestionnairesRoot, &r) return } -// // Get a Questionnaire by ID. func (h *Questionnaire) Get(id uint) (r *api.Questionnaire, err error) { r = &api.Questionnaire{} @@ -26,7 +23,6 @@ func (h *Questionnaire) Get(id uint) (r *api.Questionnaire, err error) { return } -// // List Questionnaires. func (h *Questionnaire) List() (list []api.Questionnaire, err error) { list = []api.Questionnaire{} @@ -34,7 +30,6 @@ func (h *Questionnaire) List() (list []api.Questionnaire, err error) { return } -// // Update a Questionnaire. func (h *Questionnaire) Update(r *api.Questionnaire) (err error) { path := Path(api.QuestionnaireRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *Questionnaire) Update(r *api.Questionnaire) (err error) { return } -// // Delete a Questionnaire. func (h *Questionnaire) Delete(id uint) (err error) { err = h.client.Delete(Path(api.QuestionnaireRoot).Inject(Params{api.ID: id})) diff --git a/binding/review.go b/binding/review.go index 775f87c24..37cfd6049 100644 --- a/binding/review.go +++ b/binding/review.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Review API. type Review struct { client *Client } -// // Create a Review. func (h *Review) Create(r *api.Review) (err error) { err = h.client.Post(api.ReviewsRoot, &r) return } -// // Get a Review by ID. func (h *Review) Get(id uint) (r *api.Review, err error) { r = &api.Review{} @@ -26,7 +23,6 @@ func (h *Review) Get(id uint) (r *api.Review, err error) { return } -// // List Reviews. func (h *Review) List() (list []api.Review, err error) { list = []api.Review{} @@ -34,7 +30,6 @@ func (h *Review) List() (list []api.Review, err error) { return } -// // Update a Review. func (h *Review) Update(r *api.Review) (err error) { path := Path(api.ReviewRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *Review) Update(r *api.Review) (err error) { return } -// // Delete a Review. func (h *Review) Delete(id uint) (err error) { err = h.client.Delete(Path(api.ReviewRoot).Inject(Params{api.ID: id})) return } -// // Copy a Review. func (h *Review) Copy(reviewID uint, appID uint) (err error) { copyRequest := api.CopyRequest{ diff --git a/binding/richclient.go b/binding/richclient.go index 4a47c29ed..6bfc03854 100644 --- a/binding/richclient.go +++ b/binding/richclient.go @@ -61,11 +61,11 @@ func New(baseUrl string) (r *RichClient) { Application: Application{ client: client, }, - Archetype: Archetype{ + Archetype: Archetype{ client: client, }, Assessment: Assessment{ - client: client, + client: client, }, Bucket: Bucket{ client: client, @@ -135,7 +135,6 @@ func New(baseUrl string) (r *RichClient) { return } -// // Login set token. func (r *RichClient) Login(user, password string) (err error) { login := api.Login{User: user, Password: password} diff --git a/binding/ruleset.go b/binding/ruleset.go index fef167c74..cc79c0079 100644 --- a/binding/ruleset.go +++ b/binding/ruleset.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // RuleSet API. type RuleSet struct { client *Client } -// // Create a RuleSet. func (h *RuleSet) Create(r *api.RuleSet) (err error) { err = h.client.Post(api.RuleSetsRoot, &r) return } -// // Get a RuleSet by ID. func (h *RuleSet) Get(id uint) (r *api.RuleSet, err error) { r = &api.RuleSet{} @@ -26,7 +23,6 @@ func (h *RuleSet) Get(id uint) (r *api.RuleSet, err error) { return } -// // List RuleSets. func (h *RuleSet) List() (list []api.RuleSet, err error) { list = []api.RuleSet{} @@ -34,7 +30,6 @@ func (h *RuleSet) List() (list []api.RuleSet, err error) { return } -// // Find RuleSets with filter. func (h *RuleSet) Find(filter Filter) (list []api.RuleSet, err error) { list = []api.RuleSet{} @@ -42,7 +37,6 @@ func (h *RuleSet) Find(filter Filter) (list []api.RuleSet, err error) { return } -// // Update a RuleSet. func (h *RuleSet) Update(r *api.RuleSet) (err error) { path := Path(api.RuleSetRoot).Inject(Params{api.ID: r.ID}) @@ -50,7 +44,6 @@ func (h *RuleSet) Update(r *api.RuleSet) (err error) { return } -// // Delete a RuleSet. func (h *RuleSet) Delete(id uint) (err error) { err = h.client.Delete(Path(api.RuleSetRoot).Inject(Params{api.ID: id})) diff --git a/binding/setting.go b/binding/setting.go index 012f8f0fc..c1359155c 100644 --- a/binding/setting.go +++ b/binding/setting.go @@ -4,13 +4,11 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Setting API. type Setting struct { client *Client } -// // Get a setting by key. func (h *Setting) Get(key string, v interface{}) (err error) { path := Path(api.SettingRoot).Inject(Params{api.Key: key}) @@ -18,35 +16,30 @@ func (h *Setting) Get(key string, v interface{}) (err error) { return } -// // Bool setting value. func (h *Setting) Bool(key string) (b bool, err error) { err = h.Get(key, &b) return } -// // Str setting value. func (h *Setting) Str(key string) (s string, err error) { err = h.Get(key, &s) return } -// // Int setting value. func (h *Setting) Int(key string) (n int, err error) { err = h.Get(key, &n) return } -// // Create a Setting. func (h *Setting) Create(r *api.Setting) (err error) { err = h.client.Post(api.SettingsRoot, &r) return } -// // List Settings. func (h *Setting) List() (list []api.Setting, err error) { list = []api.Setting{} @@ -54,7 +47,6 @@ func (h *Setting) List() (list []api.Setting, err error) { return } -// // Update a Setting. func (h *Setting) Update(r *api.Setting) (err error) { path := Path(api.SettingRoot).Inject(Params{api.Key: r.Key}) @@ -62,7 +54,6 @@ func (h *Setting) Update(r *api.Setting) (err error) { return } -// // Delete a Setting. func (h *Setting) Delete(key string) (err error) { path := Path(api.SettingRoot).Inject(Params{api.Key: key}) diff --git a/binding/stakeholder.go b/binding/stakeholder.go index e4827872b..ffff81e32 100644 --- a/binding/stakeholder.go +++ b/binding/stakeholder.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Stakeholder API. type Stakeholder struct { client *Client } -// // Create a Stakeholder. func (h *Stakeholder) Create(r *api.Stakeholder) (err error) { err = h.client.Post(api.StakeholdersRoot, &r) return } -// // Get a Stakeholder by ID. func (h *Stakeholder) Get(id uint) (r *api.Stakeholder, err error) { r = &api.Stakeholder{} @@ -26,7 +23,6 @@ func (h *Stakeholder) Get(id uint) (r *api.Stakeholder, err error) { return } -// // List Stakeholders. func (h *Stakeholder) List() (list []api.Stakeholder, err error) { list = []api.Stakeholder{} @@ -34,7 +30,6 @@ func (h *Stakeholder) List() (list []api.Stakeholder, err error) { return } -// // Update a Stakeholder. func (h *Stakeholder) Update(r *api.Stakeholder) (err error) { path := Path(api.StakeholderRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *Stakeholder) Update(r *api.Stakeholder) (err error) { return } -// // Delete a Stakeholder. func (h *Stakeholder) Delete(id uint) (err error) { err = h.client.Delete(Path(api.StakeholderRoot).Inject(Params{api.ID: id})) diff --git a/binding/stakeholdergroup.go b/binding/stakeholdergroup.go index 0ec3dd17e..128ce623f 100644 --- a/binding/stakeholdergroup.go +++ b/binding/stakeholdergroup.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // StakeholderGroup API. type StakeholderGroup struct { client *Client } -// // Create a StakeholderGroup. func (h *StakeholderGroup) Create(r *api.StakeholderGroup) (err error) { err = h.client.Post(api.StakeholderGroupsRoot, &r) return } -// // Get a StakeholderGroup by ID. func (h *StakeholderGroup) Get(id uint) (r *api.StakeholderGroup, err error) { r = &api.StakeholderGroup{} @@ -26,7 +23,6 @@ func (h *StakeholderGroup) Get(id uint) (r *api.StakeholderGroup, err error) { return } -// // List StakeholderGroups. func (h *StakeholderGroup) List() (list []api.StakeholderGroup, err error) { list = []api.StakeholderGroup{} @@ -34,7 +30,6 @@ func (h *StakeholderGroup) List() (list []api.StakeholderGroup, err error) { return } -// // Update a StakeholderGroup. func (h *StakeholderGroup) Update(r *api.StakeholderGroup) (err error) { path := Path(api.StakeholderGroupRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *StakeholderGroup) Update(r *api.StakeholderGroup) (err error) { return } -// // Delete a StakeholderGroup. func (h *StakeholderGroup) Delete(id uint) (err error) { err = h.client.Delete(Path(api.StakeholderGroupRoot).Inject(Params{api.ID: id})) diff --git a/binding/tag.go b/binding/tag.go index cf1243fd4..f7f1973d8 100644 --- a/binding/tag.go +++ b/binding/tag.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Tag API. type Tag struct { client *Client } -// // Create a Tag. func (h *Tag) Create(r *api.Tag) (err error) { err = h.client.Post(api.TagsRoot, &r) return } -// // Get a Tag by ID. func (h *Tag) Get(id uint) (r *api.Tag, err error) { r = &api.Tag{} @@ -26,7 +23,6 @@ func (h *Tag) Get(id uint) (r *api.Tag, err error) { return } -// // List Tags. func (h *Tag) List() (list []api.Tag, err error) { list = []api.Tag{} @@ -34,7 +30,6 @@ func (h *Tag) List() (list []api.Tag, err error) { return } -// // Update a Tag. func (h *Tag) Update(r *api.Tag) (err error) { path := Path(api.TagRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *Tag) Update(r *api.Tag) (err error) { return } -// // Delete a Tag. func (h *Tag) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TagRoot).Inject(Params{api.ID: id})) return } -// // Find by name and type. func (h *Tag) Find(name string, category uint) (r *api.Tag, found bool, err error) { list := []api.Tag{} @@ -71,7 +64,6 @@ func (h *Tag) Find(name string, category uint) (r *api.Tag, found bool, err erro return } -// // Ensure a tag exists. func (h *Tag) Ensure(wanted *api.Tag) (err error) { tag, found, err := h.Find(wanted.Name, wanted.Category.ID) diff --git a/binding/tagcategory.go b/binding/tagcategory.go index 1aaac65e3..3b06c28e6 100644 --- a/binding/tagcategory.go +++ b/binding/tagcategory.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // TagCategory API. type TagCategory struct { client *Client } -// // Create a TagCategory. func (h *TagCategory) Create(r *api.TagCategory) (err error) { err = h.client.Post(api.TagCategoriesRoot, &r) return } -// // Get a TagCategory by ID. func (h *TagCategory) Get(id uint) (r *api.TagCategory, err error) { r = &api.TagCategory{} @@ -26,7 +23,6 @@ func (h *TagCategory) Get(id uint) (r *api.TagCategory, err error) { return } -// // List TagCategories. func (h *TagCategory) List() (list []api.TagCategory, err error) { list = []api.TagCategory{} @@ -34,7 +30,6 @@ func (h *TagCategory) List() (list []api.TagCategory, err error) { return } -// // Update a TagCategory. func (h *TagCategory) Update(r *api.TagCategory) (err error) { path := Path(api.TagCategoryRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *TagCategory) Update(r *api.TagCategory) (err error) { return } -// // Delete a TagCategory. func (h *TagCategory) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TagCategoryRoot).Inject(Params{api.ID: id})) return } -// // Find by name. func (h *TagCategory) Find(name string) (r *api.TagCategory, found bool, err error) { list := []api.TagCategory{} @@ -70,7 +63,6 @@ func (h *TagCategory) Find(name string) (r *api.TagCategory, found bool, err err return } -// // Ensure a tag-type exists. func (h *TagCategory) Ensure(wanted *api.TagCategory) (err error) { tp, found, err := h.Find(wanted.Name) diff --git a/binding/target.go b/binding/target.go index 417375a7f..0d2e1c22c 100644 --- a/binding/target.go +++ b/binding/target.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Target API. type Target struct { client *Client } -// // Create a Target. func (h *Target) Create(r *api.Target) (err error) { err = h.client.Post(api.TargetsRoot, &r) return } -// // Get a Target by ID. func (h *Target) Get(id uint) (r *api.Target, err error) { r = &api.Target{} @@ -26,7 +23,6 @@ func (h *Target) Get(id uint) (r *api.Target, err error) { return } -// // List Targets. func (h *Target) List() (list []api.Target, err error) { list = []api.Target{} @@ -34,7 +30,6 @@ func (h *Target) List() (list []api.Target, err error) { return } -// // Update a Target. func (h *Target) Update(r *api.Target) (err error) { path := Path(api.TargetRoot).Inject(Params{api.ID: r.ID}) @@ -42,7 +37,6 @@ func (h *Target) Update(r *api.Target) (err error) { return } -// // Delete a Target. func (h *Target) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TargetRoot).Inject(Params{api.ID: id})) diff --git a/binding/task.go b/binding/task.go index adef4590f..8cd08fb0a 100644 --- a/binding/task.go +++ b/binding/task.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Task API. type Task struct { client *Client } -// // Create a Task. func (h *Task) Create(r *api.Task) (err error) { err = h.client.Post(api.TasksRoot, &r) return } -// // Get a Task by ID. func (h *Task) Get(id uint) (r *api.Task, err error) { r = &api.Task{} @@ -26,7 +23,6 @@ func (h *Task) Get(id uint) (r *api.Task, err error) { return } -// // List Tasks. func (h *Task) List() (list []api.Task, err error) { list = []api.Task{} @@ -34,7 +30,6 @@ func (h *Task) List() (list []api.Task, err error) { return } -// // Update a Task. func (h *Task) Update(r *api.Task) (err error) { path := Path(api.TaskRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *Task) Update(r *api.Task) (err error) { return } -// // Delete a Task. func (h *Task) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TaskRoot).Inject(Params{api.ID: id})) return } -// // Bucket returns the bucket API. func (h *Task) Bucket(id uint) (b *BucketContent) { params := Params{ diff --git a/binding/ticket.go b/binding/ticket.go index 60c294dd1..3edad23b7 100644 --- a/binding/ticket.go +++ b/binding/ticket.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Ticket API. type Ticket struct { client *Client } -// // Create a Ticket. func (h *Ticket) Create(r *api.Ticket) (err error) { err = h.client.Post(api.TicketsRoot, &r) return } -// // Get a Ticket by ID. func (h *Ticket) Get(id uint) (r *api.Ticket, err error) { r = &api.Ticket{} @@ -26,7 +23,6 @@ func (h *Ticket) Get(id uint) (r *api.Ticket, err error) { return } -// // List Tickets.. func (h *Ticket) List() (list []api.Ticket, err error) { list = []api.Ticket{} @@ -34,7 +30,6 @@ func (h *Ticket) List() (list []api.Ticket, err error) { return } -// // Delete a Ticket. func (h *Ticket) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TicketRoot).Inject(Params{api.ID: id})) diff --git a/binding/tracker.go b/binding/tracker.go index 561a45f28..b1c095fa6 100644 --- a/binding/tracker.go +++ b/binding/tracker.go @@ -4,20 +4,17 @@ import ( "github.com/konveyor/tackle2-hub/api" ) -// // Tracker API. type Tracker struct { client *Client } -// // Create a Tracker. func (h *Tracker) Create(r *api.Tracker) (err error) { err = h.client.Post(api.TrackersRoot, &r) return } -// // Get a Tracker by ID. func (h *Tracker) Get(id uint) (r *api.Tracker, err error) { r = &api.Tracker{} @@ -26,7 +23,6 @@ func (h *Tracker) Get(id uint) (r *api.Tracker, err error) { return } -// // List Trackers. func (h *Tracker) List() (list []api.Tracker, err error) { list = []api.Tracker{} @@ -34,7 +30,6 @@ func (h *Tracker) List() (list []api.Tracker, err error) { return } -// // Update a Tracker. func (h *Tracker) Update(r *api.Tracker) (err error) { path := Path(api.TrackerRoot).Inject(Params{api.ID: r.ID}) @@ -42,14 +37,12 @@ func (h *Tracker) Update(r *api.Tracker) (err error) { return } -// // Delete a Tracker. func (h *Tracker) Delete(id uint) (err error) { err = h.client.Delete(Path(api.TrackerRoot).Inject(Params{api.ID: id})) return } -// // List Projects. func (h *Tracker) ListProjects(id uint) (projectList []api.Project, err error) { projectList = []api.Project{} @@ -57,7 +50,6 @@ func (h *Tracker) ListProjects(id uint) (projectList []api.Project, err error) { return } -// // Get Projects. func (h *Tracker) GetProjects(id1 uint, id2 uint) (project api.Project, err error) { project = api.Project{} @@ -65,7 +57,6 @@ func (h *Tracker) GetProjects(id1 uint, id2 uint) (project api.Project, err erro return } -// // List Project Issue Types. func (h *Tracker) ListProjectIssueTypes(id1 uint, id2 uint) (issueType []api.IssueType, err error) { issueType = []api.IssueType{} diff --git a/cmd/main.go b/cmd/main.go index 56d0e3cfe..86980f8e0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -2,6 +2,9 @@ package main import ( "context" + "net/http" + "syscall" + "github.com/gin-gonic/gin" liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" @@ -21,10 +24,8 @@ import ( "github.com/konveyor/tackle2-hub/tracker" "gorm.io/gorm" "k8s.io/client-go/kubernetes/scheme" - "net/http" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" - "syscall" ) var Settings = &settings.Settings diff --git a/controller/addon.go b/controller/addon.go index 9823d5046..08d29af7d 100644 --- a/controller/addon.go +++ b/controller/addon.go @@ -2,6 +2,7 @@ package controller import ( "context" + "github.com/go-logr/logr" logr2 "github.com/jortel/go-utils/logr" api "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" diff --git a/database/db_test.go b/database/db_test.go index e763936d3..36555f21b 100644 --- a/database/db_test.go +++ b/database/db_test.go @@ -3,9 +3,10 @@ package database import ( "encoding/json" "fmt" - "github.com/konveyor/tackle2-hub/model" "os" "testing" + + "github.com/konveyor/tackle2-hub/model" ) var N = 800 diff --git a/database/pkg.go b/database/pkg.go index 3f215a9d4..9f0b29cb2 100644 --- a/database/pkg.go +++ b/database/pkg.go @@ -3,6 +3,7 @@ package database import ( "database/sql" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/model" diff --git a/encryption/aes_test.go b/encryption/aes_test.go index 7b48640f7..e7c502652 100644 --- a/encryption/aes_test.go +++ b/encryption/aes_test.go @@ -1,8 +1,9 @@ package encryption import ( - "github.com/onsi/gomega" "testing" + + "github.com/onsi/gomega" ) func TestAES(t *testing.T) { diff --git a/importer/manager.go b/importer/manager.go index e18384c94..651eedf15 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -6,12 +6,13 @@ import ( "fmt" "regexp" + "strings" + "time" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/api" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" - "strings" - "time" ) // Manager for processing application imports. diff --git a/k8s/client.go b/k8s/client.go index a756a98b2..3051d86c8 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -2,6 +2,7 @@ package k8s import ( "context" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/settings" "k8s.io/apimachinery/pkg/api/meta" diff --git a/metrics/manager.go b/metrics/manager.go index ee60684be..72d75f5cb 100644 --- a/metrics/manager.go +++ b/metrics/manager.go @@ -2,10 +2,11 @@ package metrics import ( "context" + "time" + "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" - "time" ) var ( diff --git a/migration/migrate.go b/migration/migrate.go index 06a152a27..cc68493d6 100644 --- a/migration/migrate.go +++ b/migration/migrate.go @@ -3,16 +3,17 @@ package migration import ( "encoding/json" "errors" - liberr "github.com/jortel/go-utils/error" - "github.com/konveyor/tackle2-hub/database" - "github.com/konveyor/tackle2-hub/model" - "github.com/konveyor/tackle2-hub/nas" - "gorm.io/gorm" "os" "path" "regexp" "strconv" "strings" + + liberr "github.com/jortel/go-utils/error" + "github.com/konveyor/tackle2-hub/database" + "github.com/konveyor/tackle2-hub/model" + "github.com/konveyor/tackle2-hub/nas" + "gorm.io/gorm" ) // Migrate the hub by applying all necessary Migrations. diff --git a/migration/migrate_test.go b/migration/migrate_test.go index c3d34f37d..7fcb1f6ad 100644 --- a/migration/migrate_test.go +++ b/migration/migrate_test.go @@ -2,12 +2,13 @@ package migration import ( "encoding/json" + "os" + "testing" + "github.com/konveyor/tackle2-hub/database" "github.com/konveyor/tackle2-hub/model" "github.com/onsi/gomega" "gorm.io/gorm" - "os" - "testing" ) func TestFreshInstall(t *testing.T) { diff --git a/migration/pkg.go b/migration/pkg.go index 0def8250b..1bb72b55f 100644 --- a/migration/pkg.go +++ b/migration/pkg.go @@ -5,7 +5,7 @@ import ( v10 "github.com/konveyor/tackle2-hub/migration/v10" v11 "github.com/konveyor/tackle2-hub/migration/v11" v12 "github.com/konveyor/tackle2-hub/migration/v12" - "github.com/konveyor/tackle2-hub/migration/v2" + v2 "github.com/konveyor/tackle2-hub/migration/v2" v3 "github.com/konveyor/tackle2-hub/migration/v3" v4 "github.com/konveyor/tackle2-hub/migration/v4" v5 "github.com/konveyor/tackle2-hub/migration/v5" diff --git a/migration/v10/model/application.go b/migration/v10/model/application.go index 76ea4900b..f68476e8a 100644 --- a/migration/v10/model/application.go +++ b/migration/v10/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v10/model/core.go b/migration/v10/model/core.go index 17016a248..637c0d879 100644 --- a/migration/v10/model/core.go +++ b/migration/v10/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v11/model/application.go b/migration/v11/model/application.go index 285eff3b3..1bd928758 100644 --- a/migration/v11/model/application.go +++ b/migration/v11/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v11/model/core.go b/migration/v11/model/core.go index 17016a248..637c0d879 100644 --- a/migration/v11/model/core.go +++ b/migration/v11/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v12/model/application.go b/migration/v12/model/application.go index 285eff3b3..1bd928758 100644 --- a/migration/v12/model/application.go +++ b/migration/v12/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v12/model/core.go b/migration/v12/model/core.go index becf51693..60464a929 100644 --- a/migration/v12/model/core.go +++ b/migration/v12/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v2/model/application.go b/migration/v2/model/application.go index dead21df1..8d9416969 100644 --- a/migration/v2/model/application.go +++ b/migration/v2/model/application.go @@ -2,8 +2,9 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v2/model/core.go b/migration/v2/model/core.go index 6d568fbb1..bd485a6b8 100644 --- a/migration/v2/model/core.go +++ b/migration/v2/model/core.go @@ -2,12 +2,13 @@ package model import ( "encoding/json" - "github.com/google/uuid" - liberr "github.com/jortel/go-utils/error" - "gorm.io/gorm" "os" "path" "time" + + "github.com/google/uuid" + liberr "github.com/jortel/go-utils/error" + "gorm.io/gorm" ) // Model Base model. diff --git a/migration/v3/migrate.go b/migration/v3/migrate.go index d258418b5..00f048c94 100644 --- a/migration/v3/migrate.go +++ b/migration/v3/migrate.go @@ -2,6 +2,7 @@ package v3 import ( "encoding/json" + liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" v2 "github.com/konveyor/tackle2-hub/migration/v2/model" diff --git a/migration/v3/model/application.go b/migration/v3/model/application.go index dd1e6a201..84050367c 100644 --- a/migration/v3/model/application.go +++ b/migration/v3/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v3/model/core.go b/migration/v3/model/core.go index 72418ef9f..ac43b6966 100644 --- a/migration/v3/model/core.go +++ b/migration/v3/model/core.go @@ -2,12 +2,13 @@ package model import ( "encoding/json" - "github.com/google/uuid" - liberr "github.com/jortel/go-utils/error" - "gorm.io/gorm" "os" "path" "time" + + "github.com/google/uuid" + liberr "github.com/jortel/go-utils/error" + "gorm.io/gorm" ) // Model Base model. diff --git a/migration/v3/seed/bundle.go b/migration/v3/seed/bundle.go index 3f34eb5b9..1c3025e3e 100644 --- a/migration/v3/seed/bundle.go +++ b/migration/v3/seed/bundle.go @@ -2,9 +2,10 @@ package seed import ( "encoding/json" + "os" + "github.com/konveyor/tackle2-hub/migration/v3/model" "gorm.io/gorm" - "os" ) // RuleBundle seed object. diff --git a/migration/v4/model/application.go b/migration/v4/model/application.go index 3cf8509d1..70e12e1a8 100644 --- a/migration/v4/model/application.go +++ b/migration/v4/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v4/model/core.go b/migration/v4/model/core.go index 72418ef9f..ac43b6966 100644 --- a/migration/v4/model/core.go +++ b/migration/v4/model/core.go @@ -2,12 +2,13 @@ package model import ( "encoding/json" - "github.com/google/uuid" - liberr "github.com/jortel/go-utils/error" - "gorm.io/gorm" "os" "path" "time" + + "github.com/google/uuid" + liberr "github.com/jortel/go-utils/error" + "gorm.io/gorm" ) // Model Base model. diff --git a/migration/v5/migrate.go b/migration/v5/migrate.go index 7f221f67a..c81705292 100644 --- a/migration/v5/migrate.go +++ b/migration/v5/migrate.go @@ -3,6 +3,7 @@ package v5 import ( "encoding/json" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" v3 "github.com/konveyor/tackle2-hub/migration/v3/model" diff --git a/migration/v5/model/application.go b/migration/v5/model/application.go index 865eb643f..6049278da 100644 --- a/migration/v5/model/application.go +++ b/migration/v5/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v5/model/core.go b/migration/v5/model/core.go index 4a34f2771..0fb5a3312 100644 --- a/migration/v5/model/core.go +++ b/migration/v5/model/core.go @@ -2,13 +2,14 @@ package model import ( "encoding/json" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v6/migrate.go b/migration/v6/migrate.go index de8f9e4b2..b285e559a 100644 --- a/migration/v6/migrate.go +++ b/migration/v6/migrate.go @@ -2,6 +2,7 @@ package v6 import ( "encoding/json" + "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/migration/v6/model" "gorm.io/gorm" diff --git a/migration/v6/model/application.go b/migration/v6/model/application.go index 865eb643f..6049278da 100644 --- a/migration/v6/model/application.go +++ b/migration/v6/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v6/model/core.go b/migration/v6/model/core.go index 89db28c8c..f0b2d05a5 100644 --- a/migration/v6/model/core.go +++ b/migration/v6/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v7/model/application.go b/migration/v7/model/application.go index 8625ae812..672391cd6 100644 --- a/migration/v7/model/application.go +++ b/migration/v7/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v7/model/core.go b/migration/v7/model/core.go index f1b742361..4989ad63b 100644 --- a/migration/v7/model/core.go +++ b/migration/v7/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v8/migrate.go b/migration/v8/migrate.go index e6034a70d..a67372b6a 100644 --- a/migration/v8/migrate.go +++ b/migration/v8/migrate.go @@ -2,6 +2,7 @@ package v8 import ( "encoding/json" + liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" v7 "github.com/konveyor/tackle2-hub/migration/v7/model" diff --git a/migration/v8/model/application.go b/migration/v8/model/application.go index 8625ae812..672391cd6 100644 --- a/migration/v8/model/application.go +++ b/migration/v8/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v8/model/core.go b/migration/v8/model/core.go index f1b742361..4989ad63b 100644 --- a/migration/v8/model/core.go +++ b/migration/v8/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/migration/v9/model/application.go b/migration/v9/model/application.go index 76ea4900b..f68476e8a 100644 --- a/migration/v9/model/application.go +++ b/migration/v9/model/application.go @@ -2,9 +2,10 @@ package model import ( "fmt" - "gorm.io/gorm" "sync" "time" + + "gorm.io/gorm" ) type Application struct { diff --git a/migration/v9/model/core.go b/migration/v9/model/core.go index f1b742361..4989ad63b 100644 --- a/migration/v9/model/core.go +++ b/migration/v9/model/core.go @@ -3,13 +3,14 @@ package model import ( "encoding/json" "fmt" + "os" + "path" + "time" + "github.com/google/uuid" liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/encryption" "gorm.io/gorm" - "os" - "path" - "time" ) // Model Base model. diff --git a/model/query.go b/model/query.go index 4729fa9be..e0d9ff93c 100644 --- a/model/query.go +++ b/model/query.go @@ -1,8 +1,9 @@ package model import ( - "gorm.io/gorm" "strings" + + "gorm.io/gorm" ) // Intersect returns an SQL intersect of the queries. diff --git a/nas/dir.go b/nas/dir.go index 277699cf1..b8c6790b4 100644 --- a/nas/dir.go +++ b/nas/dir.go @@ -6,12 +6,12 @@ package nas import ( "errors" - liberr "github.com/jortel/go-utils/error" "os" "os/exec" + + liberr "github.com/jortel/go-utils/error" ) -// // RmDir deletes the directory. func RmDir(path string) (err error) { cmd := exec.Command("/usr/bin/rm", "-rf", path) @@ -19,14 +19,12 @@ func RmDir(path string) (err error) { return } -// // HasDir return if the path exists. func HasDir(path string) (found bool, err error) { found, err = Exists(path) return } -// // MkDir ensures the directory exists. func MkDir(path string, mode os.FileMode) (err error) { err = os.MkdirAll(path, mode) @@ -43,7 +41,6 @@ func MkDir(path string, mode os.FileMode) (err error) { return } -// // Exists return if the path exists. func Exists(path string) (found bool, err error) { _, err = os.Stat(path) diff --git a/reaper/bucket.go b/reaper/bucket.go index da9a9c90f..33eb99801 100644 --- a/reaper/bucket.go +++ b/reaper/bucket.go @@ -1,22 +1,21 @@ package reaper import ( + "os" + "time" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" "github.com/konveyor/tackle2-hub/nas" "gorm.io/gorm" - "os" - "time" ) -// // BucketReaper bucket reaper. type BucketReaper struct { // DB DB *gorm.DB } -// // Run Executes the reaper. // A bucket is deleted when it is no longer referenced and the TTL has expired. func (r *BucketReaper) Run() { @@ -60,7 +59,6 @@ func (r *BucketReaper) Run() { } } -// // busy determines if anything references the bucket. func (r *BucketReaper) busy(bucket *model.Bucket) (busy bool, err error) { nRef := int64(0) @@ -82,7 +80,6 @@ func (r *BucketReaper) busy(bucket *model.Bucket) (busy bool, err error) { return } -// // Delete bucket. func (r *BucketReaper) delete(bucket *model.Bucket) (err error) { err = nas.RmDir(bucket.Path) diff --git a/reaper/file.go b/reaper/file.go index 2f0a68749..b13767df4 100644 --- a/reaper/file.go +++ b/reaper/file.go @@ -1,21 +1,20 @@ package reaper import ( + "os" + "time" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" - "os" - "time" ) -// // FileReaper file reaper. type FileReaper struct { // DB DB *gorm.DB } -// // Run Executes the reaper. // A file is deleted when it is no longer referenced and the TTL has expired. func (r *FileReaper) Run() { @@ -59,7 +58,6 @@ func (r *FileReaper) Run() { } } -// // busy determines if anything references the file. func (r *FileReaper) busy(file *model.File) (busy bool, err error) { nRef := int64(0) @@ -82,7 +80,6 @@ func (r *FileReaper) busy(file *model.File) (busy bool, err error) { return } -// // Delete file. func (r *FileReaper) delete(file *model.File) (err error) { err = os.Remove(file.Path) diff --git a/reaper/manager.go b/reaper/manager.go index bebc6cfef..c3efb7095 100644 --- a/reaper/manager.go +++ b/reaper/manager.go @@ -2,12 +2,13 @@ package reaper import ( "context" + "time" + "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/settings" "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm" k8s "sigs.k8s.io/controller-runtime/pkg/client" - "time" ) const ( @@ -21,7 +22,6 @@ var ( type Task = task.Task -// // Manager provides task management. type Manager struct { // DB @@ -30,7 +30,6 @@ type Manager struct { Client k8s.Client } -// // Run the manager. func (m *Manager) Run(ctx context.Context) { registered := []Reaper{ @@ -65,14 +64,12 @@ func (m *Manager) Run(ctx context.Context) { }() } -// // Pause. func (m *Manager) pause() { d := Unit * time.Duration(Settings.Frequency.Reaper) time.Sleep(d) } -// // Reaper interface. type Reaper interface { Run() diff --git a/reaper/ref.go b/reaper/ref.go index 1c0a9f427..7b70fd83f 100644 --- a/reaper/ref.go +++ b/reaper/ref.go @@ -1,13 +1,13 @@ package reaper import ( + "fmt" + "reflect" + liberr "github.com/jortel/go-utils/error" "gorm.io/gorm" - "reflect" - "fmt" ) -// // RefCounter provides model inspection for files // tagged with: ref:. type RefCounter struct { @@ -15,7 +15,6 @@ type RefCounter struct { DB *gorm.DB } -// // Count find & count references. func (r *RefCounter) Count(m interface{}, kind string, pk uint) (nRef int64, err error) { db := r.DB.Model(m) diff --git a/reaper/task.go b/reaper/task.go index c968c1822..100ef5047 100644 --- a/reaper/task.go +++ b/reaper/task.go @@ -2,16 +2,16 @@ package reaper import ( "encoding/json" + "time" + "github.com/konveyor/tackle2-hub/api" "github.com/konveyor/tackle2-hub/model" "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm" "gorm.io/gorm/clause" k8s "sigs.k8s.io/controller-runtime/pkg/client" - "time" ) -// // TaskReaper reaps tasks. type TaskReaper struct { // DB @@ -20,30 +20,30 @@ type TaskReaper struct { Client k8s.Client } -// // Run Executes the reaper. // Rules by state: -// Created -// - Deleted after TTL.Created > created timestamp or -// settings.Task.Reaper.Created. -// Pending -// - Deleted after TTL.Pending > created timestamp or -// settings.Task.Reaper.Created. -// Postponed -// - Deleted after TTL.Postponed > created timestamp or -// settings.Task.Reaper.Created. -// Running -// - Deleted after TTL.Running > started timestamp. -// Succeeded -// - Deleted after TTL > terminated timestamp or -// settings.Task.Reaper.Succeeded. -// - Bucket is released after the defined period. -// - Pod is deleted after the defined period. -// Failed -// - Deleted after TTL > terminated timestamp or -// settings.Task.Reaper.Failed. -// - Bucket is released after the defined period. -// - Pod is deleted after the defined period. +// +// Created +// - Deleted after TTL.Created > created timestamp or +// settings.Task.Reaper.Created. +// Pending +// - Deleted after TTL.Pending > created timestamp or +// settings.Task.Reaper.Created. +// Postponed +// - Deleted after TTL.Postponed > created timestamp or +// settings.Task.Reaper.Created. +// Running +// - Deleted after TTL.Running > started timestamp. +// Succeeded +// - Deleted after TTL > terminated timestamp or +// settings.Task.Reaper.Succeeded. +// - Bucket is released after the defined period. +// - Pod is deleted after the defined period. +// Failed +// - Deleted after TTL > terminated timestamp or +// settings.Task.Reaper.Failed. +// - Bucket is released after the defined period. +// - Pod is deleted after the defined period. func (r *TaskReaper) Run() { Log.V(1).Info("Reaping tasks.") list := []model.Task{} @@ -130,7 +130,6 @@ func (r *TaskReaper) Run() { } } -// // release resources. func (r *TaskReaper) release(m *model.Task) { nChanged := 0 @@ -158,7 +157,6 @@ func (r *TaskReaper) release(m *model.Task) { return } -// // delete task. func (r *TaskReaper) delete(m *model.Task) { rt := Task{m} @@ -174,7 +172,6 @@ func (r *TaskReaper) delete(m *model.Task) { } } -// // TTL returns the task TTL. func (r *TaskReaper) TTL(m *model.Task) (ttl api.TTL) { if m.TTL != nil { @@ -187,21 +184,20 @@ func (r *TaskReaper) TTL(m *model.Task) (ttl api.TTL) { // // -// // GroupReaper reaps task groups. type GroupReaper struct { // DB DB *gorm.DB } -// // Run Executes the reaper. // Rules by state: -// Created -// - Deleted after the defined period. -// Ready (submitted) -// - Deleted when all of its task have been deleted. -// - Bucket is released immediately. +// +// Created +// - Deleted after the defined period. +// Ready (submitted) +// - Deleted when all of its task have been deleted. +// - Bucket is released immediately. func (r *GroupReaper) Run() { Log.V(1).Info("Reaping groups.") list := []model.TaskGroup{} @@ -232,7 +228,6 @@ func (r *GroupReaper) Run() { } } -// // release resources. func (r *GroupReaper) release(m *model.TaskGroup) { m.SetBucket(nil) @@ -244,7 +239,6 @@ func (r *GroupReaper) release(m *model.TaskGroup) { } } -// // delete task. func (r *GroupReaper) delete(m *model.TaskGroup) { err := r.DB.Delete(m).Error diff --git a/seed/jobfunction.go b/seed/jobfunction.go index 6bd2cb98d..dbad0b6bd 100644 --- a/seed/jobfunction.go +++ b/seed/jobfunction.go @@ -3,19 +3,18 @@ package seed import ( "errors" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" ) -// // JobFunction applies JobFunction seeds. type JobFunction struct { jobFunctions []libseed.JobFunction } -// // With collects all the JobFunction seeds. func (r *JobFunction) With(seed libseed.Seed) (err error) { items, err := seed.DecodeItems() @@ -28,7 +27,6 @@ func (r *JobFunction) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with JobFunctions. func (r *JobFunction) Apply(db *gorm.DB) (err error) { log.Info("Applying JobFunctions", "count", len(r.jobFunctions)) @@ -82,7 +80,6 @@ func (r *JobFunction) Apply(db *gorm.DB) (err error) { return } -// // Convenience method to find a JobFunction. func (r *JobFunction) find(db *gorm.DB, conditions ...interface{}) (jf *model.JobFunction, found bool, err error) { jf = &model.JobFunction{} @@ -98,7 +95,6 @@ func (r *JobFunction) find(db *gorm.DB, conditions ...interface{}) (jf *model.Jo return } -// // Rename a JobFunction by adding a suffix. func (r *JobFunction) rename(db *gorm.DB, jf *model.JobFunction) (err error) { suffix := 0 diff --git a/seed/pkg.go b/seed/pkg.go index 64b2dc7a6..114b9d5b1 100644 --- a/seed/pkg.go +++ b/seed/pkg.go @@ -2,29 +2,27 @@ package seed import ( "errors" + "io/fs" + liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/database" "github.com/konveyor/tackle2-hub/settings" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" - "io/fs" ) var log = logr.WithName("seeding") -// // SeedKey identifies the setting containing the applied seed digest. const SeedKey = ".hub.db.seed" -// // Seeder specifies an interface for seeding DB models. type Seeder interface { With(libseed.Seed) error Apply(*gorm.DB) error } -// // Seed applies DB seeds. func Seed() (err error) { var db *gorm.DB diff --git a/seed/questionnaire.go b/seed/questionnaire.go index fa1c943ba..a3b0c3121 100644 --- a/seed/questionnaire.go +++ b/seed/questionnaire.go @@ -4,19 +4,18 @@ import ( "encoding/json" "errors" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" ) -// // Questionnaire applies Questionnaire seeds. type Questionnaire struct { questionnaires []libseed.Questionnaire } -// // With collects all the Questionnaire seeds. func (r *Questionnaire) With(seed libseed.Seed) (err error) { items, err := seed.DecodeItems() @@ -29,7 +28,6 @@ func (r *Questionnaire) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with Questionnaires. func (r *Questionnaire) Apply(db *gorm.DB) (err error) { log.Info("Applying Questionnaires", "count", len(r.questionnaires)) @@ -91,7 +89,6 @@ func (r *Questionnaire) Apply(db *gorm.DB) (err error) { return } -// // Convenience method to find a Questionnaire. func (r *Questionnaire) find(db *gorm.DB, conditions ...interface{}) (q *model.Questionnaire, found bool, err error) { q = &model.Questionnaire{} @@ -107,7 +104,6 @@ func (r *Questionnaire) find(db *gorm.DB, conditions ...interface{}) (q *model.Q return } -// // Rename a Questionnaire by adding a suffix. func (r *Questionnaire) rename(db *gorm.DB, q *model.Questionnaire) (err error) { suffix := 0 diff --git a/seed/ruleset.go b/seed/ruleset.go index ab8afb7b3..97bcd614f 100644 --- a/seed/ruleset.go +++ b/seed/ruleset.go @@ -4,22 +4,21 @@ import ( "encoding/json" "errors" "fmt" + "io" + "os" + "path" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" - "io" - "os" - "path" ) -// // RuleSet applies RuleSet seeds. type RuleSet struct { ruleSets []libseed.RuleSet } -// // With collects all the RuleSet seeds. func (r *RuleSet) With(seed libseed.Seed) (err error) { items, err := seed.DecodeItems() @@ -33,7 +32,6 @@ func (r *RuleSet) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with RuleSets. func (r *RuleSet) Apply(db *gorm.DB) (err error) { log.Info("Applying RuleSets", "count", len(r.ruleSets)) @@ -122,7 +120,6 @@ func (r *RuleSet) Apply(db *gorm.DB) (err error) { return } -// // Seed a RuleSet's Rules. func (r *RuleSet) applyRules(db *gorm.DB, ruleSet *model.RuleSet, rs libseed.RuleSet) (err error) { result := db.Delete(&model.Rule{}, "RuleSetID = ?", ruleSet.ID) @@ -151,7 +148,6 @@ func (r *RuleSet) applyRules(db *gorm.DB, ruleSet *model.RuleSet, rs libseed.Rul return } -// // Create a File model and copy a real file to its path. func file(db *gorm.DB, filePath string) (file *model.File, err error) { file = &model.File{ @@ -182,7 +178,6 @@ func file(db *gorm.DB, filePath string) (file *model.File, err error) { return } -// // Convenience method to find a RuleSet. func (r *RuleSet) find(db *gorm.DB, conditions ...interface{}) (rs *model.RuleSet, found bool, err error) { rs = &model.RuleSet{} @@ -198,7 +193,6 @@ func (r *RuleSet) find(db *gorm.DB, conditions ...interface{}) (rs *model.RuleSe return } -// // Rename a RuleSet by adding a suffix. func (r *RuleSet) rename(db *gorm.DB, rs *model.RuleSet) (err error) { suffix := 0 diff --git a/seed/seed.go b/seed/seed.go index 94bfab2f3..1ae605a9d 100644 --- a/seed/seed.go +++ b/seed/seed.go @@ -3,15 +3,15 @@ package seed import ( "encoding/json" "fmt" + "strings" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/migration" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" - "strings" ) -// // Hub is responsible for collecting and applying Hub seeds. type Hub struct { TagCategory @@ -21,7 +21,6 @@ type Hub struct { Questionnaire } -// // With collects the resources to be seeded. func (r *Hub) With(seed libseed.Seed) (err error) { switch strings.ToLower(seed.Kind) { @@ -41,7 +40,6 @@ func (r *Hub) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with resources from the seed files. func (r *Hub) Apply(db *gorm.DB) (err error) { err = r.TagCategory.Apply(db) @@ -68,7 +66,6 @@ func (r *Hub) Apply(db *gorm.DB) (err error) { return } -// // compareChecksum compares the seed checksum to the stored checksum. func compareChecksum(db *gorm.DB, checksum []byte) (match bool, err error) { setting := &model.Setting{} @@ -90,7 +87,6 @@ func compareChecksum(db *gorm.DB, checksum []byte) (match bool, err error) { return } -// // saveChecksum saves the seed checksum to the setting specified by SeedKey. func saveChecksum(db *gorm.DB, checksum []byte) (err error) { setting := &model.Setting{Key: SeedKey} @@ -104,7 +100,6 @@ func saveChecksum(db *gorm.DB, checksum []byte) (err error) { return } -// // migrationVersion gets the current migration version. func migrationVersion(db *gorm.DB) (version uint, err error) { setting := &model.Setting{} diff --git a/seed/tag.go b/seed/tag.go index bc84674e0..7673338df 100644 --- a/seed/tag.go +++ b/seed/tag.go @@ -3,19 +3,18 @@ package seed import ( "errors" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" "gorm.io/gorm" ) -// // TagCategory applies TagCategory seeds. type TagCategory struct { categories []libseed.TagCategory } -// // With collects all the TagCategory seeds. func (r *TagCategory) With(seed libseed.Seed) (err error) { items, err := seed.DecodeItems() @@ -28,7 +27,6 @@ func (r *TagCategory) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with TagCategories and Tags. func (r *TagCategory) Apply(db *gorm.DB) (err error) { log.Info("Applying TagCategories", "count", len(r.categories)) @@ -89,7 +87,6 @@ func (r *TagCategory) Apply(db *gorm.DB) (err error) { return } -// // Seed a TagCategory's tags. func (r *TagCategory) applyTags(db *gorm.DB, category *model.TagCategory, tc libseed.TagCategory) (err error) { for i := range tc.Tags { @@ -120,7 +117,6 @@ func (r *TagCategory) applyTags(db *gorm.DB, category *model.TagCategory, tc lib return } -// // Convenience method to find a TagCategory. func (r *TagCategory) find(db *gorm.DB, conditions ...interface{}) (category *model.TagCategory, found bool, err error) { category = &model.TagCategory{} @@ -136,7 +132,6 @@ func (r *TagCategory) find(db *gorm.DB, conditions ...interface{}) (category *mo return } -// // Rename a TagCategory by adding a suffix. func (r *TagCategory) rename(db *gorm.DB, category *model.TagCategory) (err error) { suffix := 0 diff --git a/seed/target.go b/seed/target.go index d3deb2266..554f79e5a 100644 --- a/seed/target.go +++ b/seed/target.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + liberr "github.com/jortel/go-utils/error" "github.com/konveyor/tackle2-hub/model" libseed "github.com/konveyor/tackle2-seed/pkg" @@ -13,13 +14,11 @@ import ( const UITargetOrder = "ui.target.order" -// // Target applies Target seeds. type Target struct { targets []libseed.Target } -// // With collects all the Target seeds. func (r *Target) With(seed libseed.Seed) (err error) { items, err := seed.DecodeItems() @@ -32,7 +31,6 @@ func (r *Target) With(seed libseed.Seed) (err error) { return } -// // Apply seeds the database with JobFunctions. func (r *Target) Apply(db *gorm.DB) (err error) { log.Info("Applying Targets", "count", len(r.targets)) @@ -106,7 +104,6 @@ func (r *Target) Apply(db *gorm.DB) (err error) { return } -// // reorder updates the value of the ui.target.order setting // to add any missing target ids. (namely, newly added targets.) func (r *Target) reorder(db *gorm.DB, seedIds []uint) (err error) { @@ -139,12 +136,12 @@ func (r *Target) reorder(db *gorm.DB, seedIds []uint) (err error) { return } -// // merge new targets into the user's custom target order. -// params: -// userOrder: slice of target IDs in the user's desired order -// seedOrder: slice of target IDs in seedfile order -// ids: slice of ids of all the targets in the DB +// +// params: +// userOrder: slice of target IDs in the user's desired order +// seedOrder: slice of target IDs in seedfile order +// ids: slice of ids of all the targets in the DB func merge(userOrder []uint, seedOrder []uint, ids []uint) (mergedOrder []uint) { ll := list.New() known := make(map[uint]*list.Element) @@ -178,7 +175,6 @@ func merge(userOrder []uint, seedOrder []uint, ids []uint) (mergedOrder []uint) return } -// // Convenience method to find a Target. func (r *Target) find(db *gorm.DB, conditions ...interface{}) (t *model.Target, found bool, err error) { t = &model.Target{} @@ -194,7 +190,6 @@ func (r *Target) find(db *gorm.DB, conditions ...interface{}) (t *model.Target, return } -// // Rename a Target by adding a suffix. func (r *Target) rename(db *gorm.DB, t *model.Target) (err error) { suffix := 0 diff --git a/seed/target_test.go b/seed/target_test.go index 3a7681ae5..0505b55d5 100644 --- a/seed/target_test.go +++ b/seed/target_test.go @@ -1,8 +1,9 @@ package seed import ( - "github.com/onsi/gomega" "testing" + + "github.com/onsi/gomega" ) func TestMerge(t *testing.T) { diff --git a/tar/filter.go b/tar/filter.go index 63fdd5a1c..f91094b48 100644 --- a/tar/filter.go +++ b/tar/filter.go @@ -5,14 +5,12 @@ import ( "path/filepath" ) -// // NewFilter returns a filter. func NewFilter(root string) (f Filter) { f = Filter{Root: root} return } -// // Filter supports glob-style filtering. type Filter struct { included FilterSet @@ -20,7 +18,6 @@ type Filter struct { Root string } -// // Match determines if path matches the filter. func (r *Filter) Match(path string) (b bool) { r.included.root = r.Root @@ -42,21 +39,18 @@ func (r *Filter) Match(path string) (b bool) { return } -// // Include adds included patterns. // Empty ("") patterns are ignored. func (r *Filter) Include(patterns ...string) { r.included.Add(patterns...) } -// // Exclude adds excluded patterns. // Empty ("") patterns are ignored. func (r *Filter) Exclude(patterns ...string) { r.excluded.Add(patterns...) } -// // FilterSet is a collection of filter patterns. type FilterSet struct { root string @@ -64,7 +58,6 @@ type FilterSet struct { cache map[string]bool } -// // Match returns true when the path matches. func (r *FilterSet) Match(path string) (match bool) { r.build() @@ -72,7 +65,6 @@ func (r *FilterSet) Match(path string) (match bool) { return } -// // Add pattern. // Empty ("") patterns are ignored. func (r *FilterSet) Add(patterns ...string) { @@ -87,13 +79,11 @@ func (r *FilterSet) Add(patterns ...string) { } } -// // Len returns number of patterns. func (r *FilterSet) Len() (n int) { return len(r.patterns) } -// // build populates the cache as needed. func (r *FilterSet) build() { if r.cache != nil { diff --git a/tar/reader.go b/tar/reader.go index 91b056b3d..3f3524e31 100644 --- a/tar/reader.go +++ b/tar/reader.go @@ -3,27 +3,25 @@ package tar import ( "archive/tar" "compress/gzip" - liberr "github.com/jortel/go-utils/error" - "github.com/konveyor/tackle2-hub/nas" "io" "os" pathlib "path" + + liberr "github.com/jortel/go-utils/error" + "github.com/konveyor/tackle2-hub/nas" ) -// // NewReader returns a new reader. func NewReader() (reader *Reader) { reader = &Reader{} return } -// // Reader archive reader. type Reader struct { Filter Filter } -// // Extract archive content to the destination path. func (r *Reader) Extract(outDir string, reader io.Reader) (err error) { zipReader, err := gzip.NewReader(reader) diff --git a/tar/tar_test.go b/tar/tar_test.go index 027e67f76..0c43d41c4 100644 --- a/tar/tar_test.go +++ b/tar/tar_test.go @@ -1,14 +1,15 @@ package tar import ( - liberr "github.com/jortel/go-utils/error" - "github.com/konveyor/tackle2-hub/nas" - "github.com/konveyor/tackle2-hub/test/assert" - "github.com/onsi/gomega" "os" "path" "path/filepath" "testing" + + liberr "github.com/jortel/go-utils/error" + "github.com/konveyor/tackle2-hub/nas" + "github.com/konveyor/tackle2-hub/test/assert" + "github.com/onsi/gomega" ) func TestWriter(t *testing.T) { diff --git a/tar/writer.go b/tar/writer.go index 8b55708d4..5e0ba4e77 100644 --- a/tar/writer.go +++ b/tar/writer.go @@ -3,15 +3,15 @@ package tar import ( "archive/tar" "compress/gzip" - liberr "github.com/jortel/go-utils/error" "io" "os" "path/filepath" "runtime" "strings" + + liberr "github.com/jortel/go-utils/error" ) -// // NewWriter returns a new writer. func NewWriter(output io.Writer) (writer *Writer) { writer = &Writer{} @@ -24,7 +24,6 @@ func NewWriter(output io.Writer) (writer *Writer) { return } -// // Writer is a Zipped TAR streamed writer. type Writer struct { Filter Filter @@ -37,7 +36,6 @@ type Writer struct { } } -// // Open the writer. func (r *Writer) Open(output io.Writer) { if r.tarWriter != nil { @@ -56,7 +54,6 @@ func (r *Writer) Open(output io.Writer) { }() } -// // AssertDir validates the path is a readable directory. func (r *Writer) AssertDir(pathIn string) (err error) { st, err := os.Stat(pathIn) @@ -100,7 +97,6 @@ func (r *Writer) AssertDir(pathIn string) (err error) { return } -// // AddDir adds a directory. func (r *Writer) AddDir(pathIn string) (err error) { if r.tarWriter == nil { @@ -162,7 +158,6 @@ func (r *Writer) AddDir(pathIn string) (err error) { return } -// // AssertFile validates the path is a readable file. func (r *Writer) AssertFile(pathIn string) (err error) { st, err := os.Stat(pathIn) @@ -183,7 +178,6 @@ func (r *Writer) AssertFile(pathIn string) (err error) { return } -// // AddFile adds a file. func (r *Writer) AddFile(pathIn, destPath string) (err error) { if r.tarWriter == nil { @@ -226,7 +220,6 @@ func (r *Writer) AddFile(pathIn, destPath string) (err error) { return } -// // Close the writer. func (r *Writer) Close() { if r.tarWriter == nil { diff --git a/task/auth.go b/task/auth.go index 5cc52a264..83601dbc1 100644 --- a/task/auth.go +++ b/task/auth.go @@ -3,12 +3,13 @@ package task import ( "context" "fmt" + "path" + "github.com/golang-jwt/jwt/v4" "github.com/konveyor/tackle2-hub/auth" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" core "k8s.io/api/core/v1" - "path" k8s "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/task/manager.go b/task/manager.go index b57da0a96..c2e66fa1d 100644 --- a/task/manager.go +++ b/task/manager.go @@ -4,6 +4,10 @@ import ( "context" "errors" "fmt" + "path" + "strconv" + "time" + "github.com/golang-jwt/jwt/v4" liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" @@ -16,10 +20,7 @@ import ( core "k8s.io/api/core/v1" k8serr "k8s.io/apimachinery/pkg/api/errors" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "path" k8s "sigs.k8s.io/controller-runtime/pkg/client" - "strconv" - "time" ) // States diff --git a/task/rule.go b/task/rule.go index 1eca14a3a..f627d9adf 100644 --- a/task/rule.go +++ b/task/rule.go @@ -1,8 +1,9 @@ package task import ( - "github.com/konveyor/tackle2-hub/model" "strings" + + "github.com/konveyor/tackle2-hub/model" ) // Rule defines postpone rules. diff --git a/test/api/application/facts_test.go b/test/api/application/facts_test.go index 3dd5c74c2..e68705b1f 100644 --- a/test/api/application/facts_test.go +++ b/test/api/application/facts_test.go @@ -11,13 +11,13 @@ import ( var SampleFacts = []*api.Fact{ { - Key: "pet", - Value: "{\"kind\":\"dog\",\"Age\":4}", + Key: "pet", + Value: "{\"kind\":\"dog\",\"Age\":4}", Source: "test", }, { - Key: "address", - Value: "{\"street\":\"Maple\",\"State\":\"AL\"}", + Key: "address", + Value: "{\"street\":\"Maple\",\"State\":\"AL\"}", Source: "test", }, } diff --git a/test/api/application/pkg.go b/test/api/application/pkg.go index 9a863a8e9..83342b7f7 100644 --- a/test/api/application/pkg.go +++ b/test/api/application/pkg.go @@ -6,12 +6,11 @@ import ( ) var ( - Client *binding.Client - RichClient *binding.RichClient + Client *binding.Client + RichClient *binding.RichClient Application binding.Application ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/application/samples.go b/test/api/application/samples.go index 0faa42260..84340b67c 100644 --- a/test/api/application/samples.go +++ b/test/api/application/samples.go @@ -7,18 +7,17 @@ import ( // Set of valid Application resources for tests and reuse. // Important: initialize test application from this samples, not use it directly to not affect other tests. var ( - Minimal = api.Application{ - Name: "Minimal application", - } - PathfinderGit = api.Application{ - Name: "Pathfinder", - Description: "Tackle Pathfinder application.", - Repository: &api.Repository{ - Kind: "git", - URL: "https://github.com/konveyor/tackle-pathfinder.git", - Branch: "1.2.0", - }, - } - Samples = []api.Application{Minimal, PathfinderGit} + Minimal = api.Application{ + Name: "Minimal application", + } + PathfinderGit = api.Application{ + Name: "Pathfinder", + Description: "Tackle Pathfinder application.", + Repository: &api.Repository{ + Kind: "git", + URL: "https://github.com/konveyor/tackle-pathfinder.git", + Branch: "1.2.0", + }, + } + Samples = []api.Application{Minimal, PathfinderGit} ) - diff --git a/test/api/archetype/pkg.go b/test/api/archetype/pkg.go index 9aea4744d..cc5a622c8 100644 --- a/test/api/archetype/pkg.go +++ b/test/api/archetype/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Archetype binding.Archetype + Archetype binding.Archetype ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/assessment/api_test.go b/test/api/assessment/api_test.go index 33815dcfe..c131d1296 100644 --- a/test/api/assessment/api_test.go +++ b/test/api/assessment/api_test.go @@ -26,7 +26,7 @@ func TestAssessmentCRUD(t *testing.T) { if err != nil { t.Errorf(err.Error()) } - + } // Get. diff --git a/test/api/assessment/pkg.go b/test/api/assessment/pkg.go index dedc942e3..c6419e490 100644 --- a/test/api/assessment/pkg.go +++ b/test/api/assessment/pkg.go @@ -10,7 +10,6 @@ var ( Assessment binding.Assessment ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() @@ -21,4 +20,4 @@ func init() { func uint2ptr(u uint) *uint { return &u -} \ No newline at end of file +} diff --git a/test/api/businesservice/pkg.go b/test/api/businesservice/pkg.go index 57e8d16ee..480fd8c65 100644 --- a/test/api/businesservice/pkg.go +++ b/test/api/businesservice/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient BusinessService binding.BusinessService ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/businesservice/samples.go b/test/api/businesservice/samples.go index 4118c900d..523358c61 100644 --- a/test/api/businesservice/samples.go +++ b/test/api/businesservice/samples.go @@ -13,4 +13,4 @@ var ( Description: "Sales support service.", } Samples = []api.BusinessService{Marketing, Sales} -) \ No newline at end of file +) diff --git a/test/api/client/client.go b/test/api/client/client.go index 2ae200195..e450720bc 100644 --- a/test/api/client/client.go +++ b/test/api/client/client.go @@ -8,27 +8,27 @@ import ( "github.com/konveyor/tackle2-hub/settings" ) -const( +const ( Username = "HUB_USERNAME" Password = "HUB_PASSWORD" ) -// // Create RichClient to interact with Hub API // Parameters are read environment variables: -// HUB_BASE_URL (required) -// HUB_USERNAME, HUB_PASSWORD (optional, depends on Require Auth option in Konveyor installation) +// +// HUB_BASE_URL (required) +// HUB_USERNAME, HUB_PASSWORD (optional, depends on Require Auth option in Konveyor installation) func PrepareRichClient() (richClient *binding.RichClient) { - // Prepare RichClient and login to Hub API - richClient = binding.New(settings.Settings.Addon.Hub.URL) - err := richClient.Login(os.Getenv(Username), os.Getenv(Password)) + // Prepare RichClient and login to Hub API + richClient = binding.New(settings.Settings.Addon.Hub.URL) + err := richClient.Login(os.Getenv(Username), os.Getenv(Password)) + + if err != nil { + panic(fmt.Sprintf("Cannot login to API: %v.", err.Error())) + } - if err != nil { - panic(fmt.Sprintf("Cannot login to API: %v.", err.Error())) - } - - // Disable HTTP requests retry for network-related errors to fail quickly. - richClient.Client.Retry = 0 + // Disable HTTP requests retry for network-related errors to fail quickly. + richClient.Client.Retry = 0 - return -} \ No newline at end of file + return +} diff --git a/test/api/file/api_test.go b/test/api/file/api_test.go index 84a4d0ad5..703012d9b 100644 --- a/test/api/file/api_test.go +++ b/test/api/file/api_test.go @@ -6,10 +6,11 @@ import ( "path/filepath" "testing" - "github.com/konveyor/tackle2-hub/test/assert" - "k8s.io/apimachinery/pkg/util/rand" "io/ioutil" "strings" + + "github.com/konveyor/tackle2-hub/test/assert" + "k8s.io/apimachinery/pkg/util/rand" ) func TestFilePutGetDelete(t *testing.T) { diff --git a/test/api/file/pkg.go b/test/api/file/pkg.go index 320cfb10d..d60ff96da 100644 --- a/test/api/file/pkg.go +++ b/test/api/file/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - File binding.File + File binding.File ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/identity/pkg.go b/test/api/identity/pkg.go index 34663fc94..4b70d73cf 100644 --- a/test/api/identity/pkg.go +++ b/test/api/identity/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Identity binding.Identity + Identity binding.Identity ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/importcsv/api_test.go b/test/api/importcsv/api_test.go index 2f7c96752..3c98e1051 100644 --- a/test/api/importcsv/api_test.go +++ b/test/api/importcsv/api_test.go @@ -1,13 +1,14 @@ package importcsv import ( - "github.com/konveyor/tackle2-hub/api" - "github.com/konveyor/tackle2-hub/binding" - "github.com/konveyor/tackle2-hub/test/assert" "io/ioutil" "os" "testing" "time" + + "github.com/konveyor/tackle2-hub/api" + "github.com/konveyor/tackle2-hub/binding" + "github.com/konveyor/tackle2-hub/test/assert" ) func TestImportCSV(t *testing.T) { @@ -26,14 +27,14 @@ func TestImportCSV(t *testing.T) { var outputImportSummaries []api.ImportSummary outputMatchingSummary := api.ImportSummary{} - for{ + for { assert.Should(t, Client.Get(api.SummariesRoot, &outputImportSummaries)) for _, gotImport := range outputImportSummaries { if uint(gotImport.ID) == inputData.ID { outputMatchingSummary = gotImport } } - if(outputMatchingSummary.ValidCount + outputMatchingSummary.InvalidCount == len(r.ExpectedApplications)+len(r.ExpectedDependencies)){ + if outputMatchingSummary.ValidCount+outputMatchingSummary.InvalidCount == len(r.ExpectedApplications)+len(r.ExpectedDependencies) { break } time.Sleep(time.Second) @@ -79,7 +80,8 @@ func TestImportCSV(t *testing.T) { t.Errorf("Mismatch in number of Contributors: Expected %d, Actual %d", len(r.ExpectedApplications[i].Contributors), len(gotApp.Contributors)) } else { for j, contributor := range gotApp.Contributors { - if contributor.Name != r.ExpectedApplications[i].Contributors[j].Name {} + if contributor.Name != r.ExpectedApplications[i].Contributors[j].Name { + } } } } @@ -98,7 +100,7 @@ func TestImportCSV(t *testing.T) { t.Errorf("Mismatch in imported Dependency: Expected %s, Actual %s", r.ExpectedDependencies[i].From.Name, importedDep.From.Name) } } - } + } // Get summaries of the Input ID. outputImportSummary := api.ImportSummary{} @@ -107,12 +109,12 @@ func TestImportCSV(t *testing.T) { // Get all imports. var outputImports []api.Import assert.Should(t, Client.Get(api.ImportsRoot, &outputImports)) - + // Check for number of imports. if len(outputImports) != len(r.ExpectedApplications)+len(r.ExpectedDependencies) { t.Errorf("Mismatch in number of imports") } - + // Checks for individual applications and dependencies. j, k := 0, 0 for _, imp := range outputImports { diff --git a/test/api/jobfunction/api_test.go b/test/api/jobfunction/api_test.go index 6e27c265d..b3cf12f16 100644 --- a/test/api/jobfunction/api_test.go +++ b/test/api/jobfunction/api_test.go @@ -75,7 +75,6 @@ func TestJobFunctionList(t *testing.T) { } } - func TestJobFunctionSeed(t *testing.T) { got, err := JobFunction.List() if err != nil { diff --git a/test/api/jobfunction/pkg.go b/test/api/jobfunction/pkg.go index 9514bd97a..0953a0c3f 100644 --- a/test/api/jobfunction/pkg.go +++ b/test/api/jobfunction/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient JobFunction binding.JobFunction ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/proxy/api_test.go b/test/api/proxy/api_test.go index eecb73b72..b4f003ec8 100644 --- a/test/api/proxy/api_test.go +++ b/test/api/proxy/api_test.go @@ -6,7 +6,7 @@ import ( ) func TestProxyGetUpdate(t *testing.T) { - for _, id := range []uint{1,2} { // Existing proxies in Hub have IDs 1, 2 + for _, id := range []uint{1, 2} { // Existing proxies in Hub have IDs 1, 2 t.Run(fmt.Sprint(id), func(t *testing.T) { // Get. orig, err := Proxy.Get(id) diff --git a/test/api/proxy/pkg.go b/test/api/proxy/pkg.go index 2a44c86ff..1762fd86f 100644 --- a/test/api/proxy/pkg.go +++ b/test/api/proxy/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Proxy binding.Proxy + Proxy binding.Proxy ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/questionnaire/pkg.go b/test/api/questionnaire/pkg.go index 479a880a6..2d443115c 100644 --- a/test/api/questionnaire/pkg.go +++ b/test/api/questionnaire/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient Questionnaire binding.Questionnaire ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/questionnaire/samples.go b/test/api/questionnaire/samples.go index 213bdfb41..988dbf0c9 100644 --- a/test/api/questionnaire/samples.go +++ b/test/api/questionnaire/samples.go @@ -50,4 +50,4 @@ var ( func uint2ptr(u uint) *uint { return &u -} \ No newline at end of file +} diff --git a/test/api/ruleset/pkg.go b/test/api/ruleset/pkg.go index 85c2911b9..e86d90eaf 100644 --- a/test/api/ruleset/pkg.go +++ b/test/api/ruleset/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - RuleSet binding.RuleSet + RuleSet binding.RuleSet ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/schema/pkg.go b/test/api/schema/pkg.go index 938d6cd83..852b6d133 100644 --- a/test/api/schema/pkg.go +++ b/test/api/schema/pkg.go @@ -9,7 +9,6 @@ var ( RichClient *binding.RichClient ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/setting/pkg.go b/test/api/setting/pkg.go index 05b9acfef..5b63c4949 100644 --- a/test/api/setting/pkg.go +++ b/test/api/setting/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Setting binding.Setting + Setting binding.Setting ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/setting/samples.go b/test/api/setting/samples.go index f49a73768..b360cbd1f 100644 --- a/test/api/setting/samples.go +++ b/test/api/setting/samples.go @@ -7,9 +7,9 @@ import ( // Set of valid resources for tests and reuse. var ( SampleSetting = api.Setting{ - Key: "sample.setting.1", + Key: "sample.setting.1", Value: "data-123", } - + Samples = []api.Setting{SampleSetting} ) diff --git a/test/api/stakeholder/pkg.go b/test/api/stakeholder/pkg.go index af5451a69..f1cdac79b 100644 --- a/test/api/stakeholder/pkg.go +++ b/test/api/stakeholder/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient Stakeholder binding.Stakeholder ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/stakeholdergroup/pkg.go b/test/api/stakeholdergroup/pkg.go index b6c68f3d3..64e037759 100644 --- a/test/api/stakeholdergroup/pkg.go +++ b/test/api/stakeholdergroup/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient StakeholderGroup binding.StakeholderGroup ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/tag/api_test.go b/test/api/tag/api_test.go index 5e28b1de7..1b9dd2aa8 100644 --- a/test/api/tag/api_test.go +++ b/test/api/tag/api_test.go @@ -75,7 +75,6 @@ func TestTagList(t *testing.T) { } } - func TestTagSeed(t *testing.T) { got, err := Tag.List() if err != nil { @@ -84,4 +83,4 @@ func TestTagSeed(t *testing.T) { if len(got) < 1 { t.Errorf("Seed looks empty, but it shouldn't.") } -} \ No newline at end of file +} diff --git a/test/api/tag/pkg.go b/test/api/tag/pkg.go index 4233d6337..57e2254e5 100644 --- a/test/api/tag/pkg.go +++ b/test/api/tag/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Tag binding.Tag + Tag binding.Tag ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/tagcategory/api_test.go b/test/api/tagcategory/api_test.go index fa0ca44e9..30b1532e9 100644 --- a/test/api/tagcategory/api_test.go +++ b/test/api/tagcategory/api_test.go @@ -75,7 +75,6 @@ func TestTagCategoryList(t *testing.T) { } } - func TestTagCategorySeed(t *testing.T) { got, err := TagCategory.List() if err != nil { diff --git a/test/api/tagcategory/pkg.go b/test/api/tagcategory/pkg.go index 0e51b55a0..a3ffeb75f 100644 --- a/test/api/tagcategory/pkg.go +++ b/test/api/tagcategory/pkg.go @@ -6,11 +6,10 @@ import ( ) var ( - RichClient *binding.RichClient + RichClient *binding.RichClient TagCategory binding.TagCategory ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/api/task/pkg.go b/test/api/task/pkg.go index d32bde185..02359226e 100644 --- a/test/api/task/pkg.go +++ b/test/api/task/pkg.go @@ -7,10 +7,9 @@ import ( var ( RichClient *binding.RichClient - Task binding.Task + Task binding.Task ) - func init() { // Prepare RichClient and login to Hub API (configured from env variables). RichClient = client.PrepareRichClient() diff --git a/test/assert/equality.go b/test/assert/equality.go index cc860065e..7167a52c0 100644 --- a/test/assert/equality.go +++ b/test/assert/equality.go @@ -4,7 +4,6 @@ import ( "fmt" ) -// // Simple equality check working for flat types (no nested types passed by reference). func FlatEqual(got, expected interface{}) bool { return fmt.Sprintf("%v", got) == fmt.Sprintf("%v", expected) diff --git a/test/assert/error.go b/test/assert/error.go index 1316167c0..31ef8f001 100644 --- a/test/assert/error.go +++ b/test/assert/error.go @@ -4,7 +4,6 @@ import ( "testing" ) -// // Check error and if present, fail the test case. // Examples usage: client.Should(t, task.Create(&r)) func Should(t *testing.T, err error) { @@ -13,7 +12,6 @@ func Should(t *testing.T, err error) { } } -// // Check error and if present, fail and stop the test suite. // Examples usage: client.Must(t, task.Create(&r)) func Must(t *testing.T, err error) { diff --git a/test/assert/file.go b/test/assert/file.go index d5ff51530..593314baf 100644 --- a/test/assert/file.go +++ b/test/assert/file.go @@ -7,7 +7,6 @@ import ( "os" ) -// // Compare two files content using sha256sum function. func EqualFileContent(gotPath, expectedPath string) bool { got, err := os.Open(gotPath) diff --git a/tracker/manager.go b/tracker/manager.go index e5948aedc..7a451d8f6 100644 --- a/tracker/manager.go +++ b/tracker/manager.go @@ -2,11 +2,12 @@ package tracker import ( "context" + "time" + "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/model" "gorm.io/gorm" "gorm.io/gorm/clause" - "time" ) var ( From 33edfef2b81858f3ccc217b890843af4b3155280 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Thu, 18 Jan 2024 11:23:03 -0800 Subject: [PATCH 03/10] checkpoint Signed-off-by: Jeff Ortel --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 623a63789..8edffbcd9 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ PKG = ./addon/... \ ./test/... \ ./tracker/... -DIR = $(subst /...,,${PKG}) +PKGDIR = $(subst /...,,${PKG}) BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd @@ -35,7 +35,7 @@ cmd: hub addon # Run go fmt against code fmt: ${GOIMPORTS} - goimports -w ${DIR} + goimports -w ${PKGDIR} go fmt ${PKG} # Run go vet against code From d82343840b786ae50362e74a6d9f91ad7b2e5658 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Thu, 18 Jan 2024 11:32:18 -0800 Subject: [PATCH 04/10] Fix vet issue in reaper. Signed-off-by: Jeff Ortel --- reaper/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reaper/task.go b/reaper/task.go index 100ef5047..df89da766 100644 --- a/reaper/task.go +++ b/reaper/task.go @@ -159,7 +159,7 @@ func (r *TaskReaper) release(m *model.Task) { // delete task. func (r *TaskReaper) delete(m *model.Task) { - rt := Task{m} + rt := Task{Task: m} err := rt.Delete(r.Client) if err != nil { Log.Error(err, "") From 28243ce1e0eef54a8b441d470da98c7b191e1a1c Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Thu, 18 Jan 2024 11:38:49 -0800 Subject: [PATCH 05/10] checkpoint. Signed-off-by: Jeff Ortel --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8edffbcd9..6bd5f5cb7 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +33,9 @@ BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd # Build ALL commands. cmd: hub addon -# Run go fmt against code +# Format the code. fmt: ${GOIMPORTS} goimports -w ${PKGDIR} - go fmt ${PKG} # Run go vet against code vet: From 2fa215cbccc94be8876045abef0df1c1b2b76481 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 19 Jan 2024 05:32:27 -0800 Subject: [PATCH 06/10] Fix controller-gen target. Signed-off-by: Jeff Ortel --- Makefile | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6bd5f5cb7..db0127b67 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ GOBIN ?= ${GOPATH}/bin GOIMPORTS = ${GOBIN}/goimports +CONTROLLERGEN = ${GOBIN}/controller-gen IMG ?= tackle2-hub:latest HUB_BASE_URL ?= http://localhost:8080 @@ -67,25 +68,18 @@ run-addon: go run ./hack/cmd/addon/main.go # Generate manifests e.g. CRD, Webhooks -manifests: controller-gen - controller-gen ${CRD_OPTIONS} \ +manifests: ${CONTROLLERGEN} + ${CONTROLLERGEN} ${CRD_OPTIONS} \ crd rbac:roleName=manager-role \ paths="./..." output:crd:artifacts:config=generated/crd/bases output:crd:dir=generated/crd # Generate code -generate: controller-gen - controller-gen object:headerFile="./generated/boilerplate" paths="./..." - -# Find or download controller-gen. -controller-gen: - if [ "$(shell which controller-gen)" = "" ]; then \ - set -e ;\ - CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ - cd $$CONTROLLER_GEN_TMP_DIR ;\ - go mod init tmp ;\ - go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0 ;\ - rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ - fi ;\ +generate: ${CONTROLLERGEN} + ${CONTROLLERGEN} object:headerFile="./generated/boilerplate" paths="./..." + +# Ensure controller-gen installed. +${CONTROLLERGEN}: + go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0 # Ensure goimports installed. ${GOIMPORTS}: From 5084fea3371c421357b873fc08351ca92dd9f09c Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 19 Jan 2024 05:56:48 -0800 Subject: [PATCH 07/10] Using more traditional variable syntax. Signed-off-by: Jeff Ortel --- Makefile | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index db0127b67..9acf6744a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -GOBIN ?= ${GOPATH}/bin -GOIMPORTS = ${GOBIN}/goimports -CONTROLLERGEN = ${GOBIN}/controller-gen +GOBIN ?= $(GOPATH)/bin +GOIMPORTS = $(GOBIN)/goimports +CONTROLLERGEN = $(GOBIN)/controller-gen IMG ?= tackle2-hub:latest HUB_BASE_URL ?= http://localhost:8080 @@ -27,7 +27,7 @@ PKG = ./addon/... \ ./test/... \ ./tracker/... -PKGDIR = $(subst /...,,${PKG}) +PKGDIR = $(subst /...,,$(PKG)) BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd @@ -35,30 +35,30 @@ BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd cmd: hub addon # Format the code. -fmt: ${GOIMPORTS} - goimports -w ${PKGDIR} +fmt: $(GOIMPORTS) + goimports -w $(PKGDIR) # Run go vet against code vet: - go vet ${PKG} + go vet $(PKG) # Build hub hub: generate fmt vet - go build ${BUILD} + go build $(BUILD) # Build image docker-build: - docker build -t ${IMG} . + docker build -t $(IMG) . podman-build: - podman build -t ${IMG} . + podman build -t $(IMG) . # Build manager binary with compiler optimizations disabled debug: generate fmt vet - go build -gcflags=all="-N -l" ${BUILD} + go build -gcflags=all="-N -l" $(BUILD) docker: vet - go build ${BUILD} + go build $(BUILD) # Run against the configured Kubernetes cluster in ~/.kube/config run: fmt vet @@ -68,21 +68,21 @@ run-addon: go run ./hack/cmd/addon/main.go # Generate manifests e.g. CRD, Webhooks -manifests: ${CONTROLLERGEN} - ${CONTROLLERGEN} ${CRD_OPTIONS} \ +manifests: $(CONTROLLERGEN) + $(CONTROLLERGEN) $(CRD_OPTIONS) \ crd rbac:roleName=manager-role \ paths="./..." output:crd:artifacts:config=generated/crd/bases output:crd:dir=generated/crd # Generate code -generate: ${CONTROLLERGEN} - ${CONTROLLERGEN} object:headerFile="./generated/boilerplate" paths="./..." +generate: $(CONTROLLERGEN) + $(CONTROLLERGEN) object:headerFile="./generated/boilerplate" paths="./..." # Ensure controller-gen installed. -${CONTROLLERGEN}: +$(CONTROLLERGEN): go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0 # Ensure goimports installed. -${GOIMPORTS}: +$(GOIMPORTS): go install golang.org/x/tools/cmd/goimports@latest # Build SAMPLE ADDON @@ -93,7 +93,7 @@ docs: docs-html docs-openapi3 docs-binding # Build Swagger API spec into ./docs directory docs-swagger: - ${GOBIN}/swag init -g pkg.go --dir api,assessment + $(GOBIN)/swag init -g pkg.go --dir api,assessment # Build OpenAPI 3.0 docs docs-openapi3: docs-swagger @@ -111,12 +111,12 @@ docs-binding: START_MINIKUBE_SH = ./bin/start-minikube.sh start-minikube: ifeq (,$(wildcard $(START_MINIKUBE_SH))) - @{ \ + @( \ set -e ;\ mkdir -p $(dir $(START_MINIKUBE_SH)) ;\ curl -sSLo $(START_MINIKUBE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/start-minikube.sh ;\ chmod +x $(START_MINIKUBE_SH) ;\ - } + ) endif $(START_MINIKUBE_SH); @@ -124,12 +124,12 @@ endif INSTALL_TACKLE_SH = ./bin/install-tackle.sh install-tackle: ifeq (,$(wildcard $(INSTALL_TACKLE_SH))) - @{ \ + @( \ set -e ;\ mkdir -p $(dir $(INSTALL_TACKLE_SH)) ;\ curl -sSLo $(INSTALL_TACKLE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/install-tackle.sh ;\ chmod +x $(INSTALL_TACKLE_SH) ;\ - } + ) endif $(INSTALL_TACKLE_SH); @@ -142,7 +142,7 @@ test: # Run Hub REST API tests. test-api: - HUB_BASE_URL=${HUB_BASE_URL} go test -count=1 -p=1 -v ./test/api/... + HUB_BASE_URL=$(HUB_BASE_URL) go test -count=1 -p=1 -v ./test/api/... # Run Hub test suite. test-all: test-unit test-api From 143bbb013a791627f4ba5bedc9404713270dafd7 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 19 Jan 2024 06:00:01 -0800 Subject: [PATCH 08/10] checkpoint Signed-off-by: Jeff Ortel --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9acf6744a..1e71af669 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ cmd: hub addon # Format the code. fmt: $(GOIMPORTS) - goimports -w $(PKGDIR) + $(GOIMPORTS) -w $(PKGDIR) # Run go vet against code vet: From 2b4c472dae64ab92ce4d632a7e7b4d8ad1752b07 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 19 Jan 2024 06:06:04 -0800 Subject: [PATCH 09/10] checkpoint Signed-off-by: Jeff Ortel --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1e71af669..66aabe302 100644 --- a/Makefile +++ b/Makefile @@ -111,12 +111,12 @@ docs-binding: START_MINIKUBE_SH = ./bin/start-minikube.sh start-minikube: ifeq (,$(wildcard $(START_MINIKUBE_SH))) - @( \ + @{ \ set -e ;\ mkdir -p $(dir $(START_MINIKUBE_SH)) ;\ curl -sSLo $(START_MINIKUBE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/start-minikube.sh ;\ chmod +x $(START_MINIKUBE_SH) ;\ - ) + } endif $(START_MINIKUBE_SH); @@ -124,12 +124,12 @@ endif INSTALL_TACKLE_SH = ./bin/install-tackle.sh install-tackle: ifeq (,$(wildcard $(INSTALL_TACKLE_SH))) - @( \ + @{ \ set -e ;\ mkdir -p $(dir $(INSTALL_TACKLE_SH)) ;\ curl -sSLo $(INSTALL_TACKLE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/install-tackle.sh ;\ chmod +x $(INSTALL_TACKLE_SH) ;\ - ) + } endif $(INSTALL_TACKLE_SH); From 2e2003eed7efa77cf4cff570ecd0c709a448abf9 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 19 Jan 2024 07:19:14 -0800 Subject: [PATCH 10/10] checkpoint Signed-off-by: Jeff Ortel --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 66aabe302..0de4b1910 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +GOPATH ?= $(HOME)/go GOBIN ?= $(GOPATH)/bin GOIMPORTS = $(GOBIN)/goimports CONTROLLERGEN = $(GOBIN)/controller-gen