diff --git a/addon/task.go b/addon/task.go index 87bcc9c9d..f2caa4c45 100644 --- a/addon/task.go +++ b/addon/task.go @@ -88,7 +88,7 @@ func (h *Task) Data() (d any) { } // DataWith populates the addon data object. -func (h *Task) DataWith(object interface{}) (err error) { +func (h *Task) DataWith(object any) (err error) { b, _ := json.Marshal(h.task.Data) err = json.Unmarshal(b, object) return @@ -114,7 +114,7 @@ func (h *Task) Succeeded() { // Failed report addon failed. // The reason can be a printf style format. -func (h *Task) Failed(reason string, v ...interface{}) { +func (h *Task) Failed(reason string, v ...any) { reason = fmt.Sprintf(reason, v...) h.Error(api.TaskError{ Severity: "Error", @@ -128,7 +128,7 @@ func (h *Task) Failed(reason string, v ...interface{}) { } // Errorf report addon error. -func (h *Task) Errorf(severity, description string, v ...interface{}) { +func (h *Task) Errorf(severity, description string, v ...any) { h.Error(api.TaskError{ Severity: severity, Description: fmt.Sprintf(description, v...), @@ -153,7 +153,7 @@ func (h *Task) Error(error ...api.TaskError) { // Activity report addon activity. // The description can be a printf style format. -func (h *Task) Activity(entry string, v ...interface{}) { +func (h *Task) Activity(entry string, v ...any) { entry = fmt.Sprintf(entry, v...) lines := strings.Split(entry, "\n") for i := range lines { diff --git a/api/addon.go b/api/addon.go index d08d5cb1a..152fa57ef 100644 --- a/api/addon.go +++ b/api/addon.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" core "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" k8s "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/api/analysis.go b/api/analysis.go index 43dd0d899..ece4b2f62 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -2368,7 +2368,7 @@ type DepAppReport struct { } // FactMap map. -type FactMap map[string]interface{} +type FactMap map[string]any // IssueWriter used to create a file containing issues. type IssueWriter struct { diff --git a/api/application.go b/api/application.go index 56217bcd0..c4132cc2c 100644 --- a/api/application.go +++ b/api/application.go @@ -683,7 +683,7 @@ func (h ApplicationHandler) FactList(ctx *gin.Context, key FactKey) { facts := FactMap{} for i := range list { fact := &list[i] - var v interface{} + var v any _ = json.Unmarshal(fact.Value, &v) facts[fact.Key] = v } @@ -730,7 +730,7 @@ func (h ApplicationHandler) FactGet(ctx *gin.Context) { return } - var v interface{} + var v any _ = json.Unmarshal(list[0].Value, &v) h.Respond(ctx, http.StatusOK, v) } @@ -929,7 +929,7 @@ func (h ApplicationHandler) StakeholdersUpdate(ctx *gin.Context) { } db = h.DB(ctx).Model(m).Omit(clause.Associations, "BucketID") - result = db.Updates(map[string]interface{}{"OwnerID": r.ownerID()}) + result = db.Updates(map[string]any{"OwnerID": r.ownerID()}) if result.Error != nil { _ = ctx.Error(result.Error) return @@ -1246,9 +1246,9 @@ type Repository struct { // Fact REST nested resource. type Fact struct { - Key string `json:"key"` - Value interface{} `json:"value"` - Source string `json:"source"` + Key string `json:"key"` + Value any `json:"value"` + Source string `json:"source"` } func (r *Fact) With(m *model.Fact) { diff --git a/api/base.go b/api/base.go index b14594938..186c894d0 100644 --- a/api/base.go +++ b/api/base.go @@ -85,7 +85,7 @@ func (h *BaseHandler) preLoad(db *gorm.DB, fields ...string) (tx *gorm.DB) { } // fields builds a map of fields. -func (h *BaseHandler) fields(m interface{}) (mp map[string]interface{}) { +func (h *BaseHandler) fields(m any) (mp map[string]any) { mp = reflect.Fields(m) return } @@ -125,7 +125,7 @@ func (h *BaseHandler) HasScope(ctx *gin.Context, scope string) (b bool) { // Bind based on Content-Type header. // Opinionated towards json. -func (h *BaseHandler) Bind(ctx *gin.Context, r interface{}) (err error) { +func (h *BaseHandler) Bind(ctx *gin.Context, r any) (err error) { switch ctx.ContentType() { case "", binding.MIMEPOSTForm, @@ -144,7 +144,7 @@ func (h *BaseHandler) Bind(ctx *gin.Context, r interface{}) (err error) { // 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) { +func (h *BaseHandler) BindJSON(ctx *gin.Context, r any) (err error) { if ctx.Request == nil || ctx.Request.Body == nil { err = errors.New("invalid request") return @@ -162,7 +162,7 @@ func (h *BaseHandler) BindJSON(ctx *gin.Context, r interface{}) (err error) { // 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) { +func (h *BaseHandler) BindYAML(ctx *gin.Context, r any) (err error) { if ctx.Request == nil || ctx.Request.Body == nil { err = errors.New("invalid request") return @@ -179,7 +179,7 @@ func (h *BaseHandler) BindYAML(ctx *gin.Context, r interface{}) (err error) { } // Validate that the struct field values obey the binding field tags. -func (h *BaseHandler) Validate(r interface{}) (err error) { +func (h *BaseHandler) Validate(r any) (err error) { if binding.Validator == nil { return } @@ -220,7 +220,7 @@ func (h *BaseHandler) Status(ctx *gin.Context, code int) { } // Respond sets the response. -func (h *BaseHandler) Respond(ctx *gin.Context, code int, r interface{}) { +func (h *BaseHandler) Respond(ctx *gin.Context, code int, r any) { rtx := WithContext(ctx) rtx.Respond(code, r) } @@ -308,14 +308,14 @@ func (r *Resource) With(m *model.Model) { } // ref with id and named model. -func (r *Resource) ref(id uint, m interface{}) (ref Ref) { +func (r *Resource) ref(id uint, m any) (ref Ref) { ref.ID = id ref.Name = r.nameOf(m) return } // refPtr with id and named model. -func (r *Resource) refPtr(id *uint, m interface{}) (ref *Ref) { +func (r *Resource) refPtr(id *uint, m any) (ref *Ref) { if id == nil { return } @@ -334,7 +334,7 @@ func (r *Resource) idPtr(ref *Ref) (id *uint) { } // nameOf model. -func (r *Resource) nameOf(m interface{}) (name string) { +func (r *Resource) nameOf(m any) (name string) { name = reflect.NameOf(m) return } @@ -406,7 +406,7 @@ type Sort = sort.Sort // Decoder binding decoder. type Decoder interface { - Decode(r interface{}) (err error) + Decode(r any) (err error) } // Cursor Paginated rows iterator. @@ -419,7 +419,7 @@ type Cursor struct { } // Next returns true when has next row. -func (r *Cursor) Next(m interface{}) (next bool) { +func (r *Cursor) Next(m any) (next bool) { if r.Error != nil { next = true return diff --git a/api/batch.go b/api/batch.go index c569655f0..e0349989a 100644 --- a/api/batch.go +++ b/api/batch.go @@ -55,7 +55,7 @@ func (h BatchHandler) TagsCreate(ctx *gin.Context) { } func (h BatchHandler) create(ctx *gin.Context, create gin.HandlerFunc) { - var resources []interface{} + var resources []any err := h.Bind(ctx, &resources) if err != nil { _ = ctx.Error(err) diff --git a/api/context.go b/api/context.go index 6b601d507..5aff997a3 100644 --- a/api/context.go +++ b/api/context.go @@ -30,7 +30,7 @@ type Context struct { // Response values. type Response struct { Status int - Body interface{} + Body any } // Status sets the values to respond to the request with. @@ -42,7 +42,7 @@ func (r *Context) Status(status int) { } // Respond sets the values to respond to the request with. -func (r *Context) Respond(status int, body interface{}) { +func (r *Context) Respond(status int, body any) { r.Response = Response{ Status: status, Body: body, diff --git a/api/error.go b/api/error.go index 65be15509..79dd9b7a2 100644 --- a/api/error.go +++ b/api/error.go @@ -37,7 +37,7 @@ type BatchError struct { type BatchErrorItem struct { Error error - Resource interface{} + Resource any } func (r BatchError) Error() string { diff --git a/api/filter/error.go b/api/filter/error.go index 105a2756b..15050cd0f 100644 --- a/api/filter/error.go +++ b/api/filter/error.go @@ -17,7 +17,7 @@ func (r *Error) Is(err error) (matched bool) { } // Errorf build error. -func Errorf(s string, v ...interface{}) (err error) { +func Errorf(s string, v ...any) (err error) { err = &Error{fmt.Sprintf(s, v...)} return } diff --git a/api/filter/filter.go b/api/filter/filter.go index 444abd84c..920d783d3 100644 --- a/api/filter/filter.go +++ b/api/filter/filter.go @@ -252,7 +252,7 @@ func (f *Field) Where(in *gorm.DB) (out *gorm.DB) { // SQL builds SQL. // Returns statement and values (for ?). -func (f *Field) SQL() (s string, vList []interface{}) { +func (f *Field) SQL() (s string, vList []any) { name := f.Name() switch len(f.Value) { case 0: @@ -296,7 +296,7 @@ func (f *Field) SQL() (s string, vList []interface{}) { s += ")" default: values := f.Value.ByKind(LITERAL, STRING) - var collection []interface{} + var collection []any for i := range values { v := AsValue(values[i]) collection = append(collection, v) @@ -395,7 +395,7 @@ func (r *Assert) assert(p *Predicate) (err error) { } // AsValue returns the real value. -func AsValue(t Token) (object interface{}) { +func AsValue(t Token) (object any) { v := t.Value object = v switch t.Kind { diff --git a/api/filter/filter_test.go b/api/filter/filter_test.go index 03ecad85e..03516ed0d 100644 --- a/api/filter/filter_test.go +++ b/api/filter/filter_test.go @@ -230,7 +230,7 @@ func TestFilter(t *testing.T) { })) sql, values := f.SQL() g.Expect(sql).To(gomega.Equal("category IN ?")) - g.Expect(values[0]).To(gomega.Equal([]interface{}{"a", "b", "c"})) + g.Expect(values[0]).To(gomega.Equal([]any{"a", "b", "c"})) f, found = filter.Field("name.first") g.Expect(found).To(gomega.BeTrue()) @@ -265,7 +265,7 @@ func TestFilter(t *testing.T) { g.Expect(found).To(gomega.BeTrue()) sql, values = f.SQL() g.Expect(sql).To(gomega.Equal("(category LIKE ? OR category LIKE ?)")) - g.Expect(values).To(gomega.Equal([]interface{}{"a", "b"})) + g.Expect(values).To(gomega.Equal([]any{"a", "b"})) } func TestValidation(t *testing.T) { diff --git a/api/import.go b/api/import.go index 53a6d445d..baaaf7f5f 100644 --- a/api/import.go +++ b/api/import.go @@ -409,7 +409,7 @@ func (h ImportHandler) applicationFromRow(fileName string, row []string) (app mo } // Import REST resource. -type Import map[string]interface{} +type Import map[string]any // ImportSummary REST resource. type ImportSummary struct { diff --git a/api/questionnaire.go b/api/questionnaire.go index c7f69935c..1dcb8c50d 100644 --- a/api/questionnaire.go +++ b/api/questionnaire.go @@ -167,9 +167,9 @@ func (h QuestionnaireHandler) Update(ctx *gin.Context) { updated := r.Model() updated.ID = id updated.UpdateUser = h.CurrentUser(ctx) - var fields map[string]interface{} + var fields map[string]any if m.Builtin() { - fields = map[string]interface{}{ + fields = map[string]any{ "updateUser": updated.UpdateUser, "required": updated.Required, } diff --git a/api/reflect/fields.go b/api/reflect/fields.go index f89c21764..933c7e73d 100644 --- a/api/reflect/fields.go +++ b/api/reflect/fields.go @@ -6,9 +6,9 @@ import ( ) // Fields returns a map of fields. -func Fields(m interface{}) (mp map[string]interface{}) { - var inspect func(r interface{}) - inspect = func(r interface{}) { +func Fields(m any) (mp map[string]any) { + var inspect func(r any) + inspect = func(r any) { mt := reflect.TypeOf(r) mv := reflect.ValueOf(r) if mt.Kind() == reflect.Ptr { @@ -55,13 +55,13 @@ func Fields(m interface{}) (mp map[string]interface{}) { } } } - mp = map[string]interface{}{} + mp = map[string]any{} inspect(m) return } // NameOf returns the name of a model. -func NameOf(m interface{}) (name string) { +func NameOf(m any) (name string) { mt := reflect.TypeOf(m) mv := reflect.ValueOf(m) if mv.IsNil() { diff --git a/api/setting.go b/api/setting.go index ab35709c2..a758f4b81 100644 --- a/api/setting.go +++ b/api/setting.go @@ -229,8 +229,8 @@ func (h SettingHandler) Delete(ctx *gin.Context) { // Setting REST Resource type Setting struct { - Key string `json:"key"` - Value interface{} `json:"value"` + Key string `json:"key"` + Value any `json:"value"` } func (r *Setting) With(m *model.Setting) { diff --git a/api/task.go b/api/task.go index 95e827615..dc60ac87c 100644 --- a/api/task.go +++ b/api/task.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" qf "github.com/konveyor/tackle2-hub/api/filter" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "github.com/konveyor/tackle2-hub/model" "github.com/konveyor/tackle2-hub/tar" tasking "github.com/konveyor/tackle2-hub/task" diff --git a/api/taskgroup.go b/api/taskgroup.go index 2432b8b8d..ff6f9ea26 100644 --- a/api/taskgroup.go +++ b/api/taskgroup.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "github.com/konveyor/tackle2-hub/model" tasking "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm/clause" diff --git a/api/ticket.go b/api/ticket.go index d42617b02..e25af5611 100644 --- a/api/ticket.go +++ b/api/ticket.go @@ -194,4 +194,4 @@ func (r *Ticket) Model() (m *model.Ticket) { return } -type Fields map[string]interface{} +type Fields map[string]any diff --git a/auth/builtin.go b/auth/builtin.go index f1f363f19..ef34830bf 100644 --- a/auth/builtin.go +++ b/auth/builtin.go @@ -86,7 +86,7 @@ func (r *Builtin) Authenticate(request *Request) (jwToken *jwt.Token, err error) } jwToken, err = jwt.Parse( token, - func(jwToken *jwt.Token) (secret interface{}, err error) { + func(jwToken *jwt.Token) (secret any, err error) { _, cast := jwToken.Method.(*jwt.SigningMethodHMAC) if !cast { err = liberr.Wrap(&NotAuthenticated{Token: token}) diff --git a/binding/application.go b/binding/application.go index ff66ffa61..b8b02fd62 100644 --- a/binding/application.go +++ b/binding/application.go @@ -239,7 +239,7 @@ func (h *AppFacts) List() (facts api.FactMap, err error) { } // Get a fact. -func (h *AppFacts) Get(name string, value interface{}) (err error) { +func (h *AppFacts) Get(name string, value any) (err error) { key := api.FactKey(name) key.Qualify(h.source) path := Path(api.ApplicationFactRoot).Inject( @@ -252,7 +252,7 @@ func (h *AppFacts) Get(name string, value interface{}) (err error) { } // Set a fact (created as needed). -func (h *AppFacts) Set(name string, value interface{}) (err error) { +func (h *AppFacts) Set(name string, value any) (err error) { key := api.FactKey(name) key.Qualify(h.source) path := Path(api.ApplicationFactRoot).Inject( diff --git a/binding/client.go b/binding/client.go index 354c12537..521b96967 100644 --- a/binding/client.go +++ b/binding/client.go @@ -47,7 +47,7 @@ func (r *Filter) Param() (p Param) { } // Params mapping. -type Params map[string]interface{} +type Params map[string]any // Path API path. type Path string @@ -103,7 +103,7 @@ func (r *Client) Reset() { } // Get a resource. -func (r *Client) Get(path string, object interface{}, params ...Param) (err error) { +func (r *Client) Get(path string, object any, params ...Param) (err error) { request := func() (request *http.Request, err error) { request = &http.Request{ Header: http.Header{}, @@ -149,7 +149,7 @@ func (r *Client) Get(path string, object interface{}, params ...Param) (err erro } // Post a resource. -func (r *Client) Post(path string, object interface{}) (err error) { +func (r *Client) Post(path string, object any) (err error) { request := func() (request *http.Request, err error) { bfr, err := json.Marshal(object) if err != nil { @@ -194,7 +194,7 @@ func (r *Client) Post(path string, object interface{}) (err error) { } // Put a resource. -func (r *Client) Put(path string, object interface{}, params ...Param) (err error) { +func (r *Client) Put(path string, object any, params ...Param) (err error) { request := func() (request *http.Request, err error) { bfr, err := json.Marshal(object) if err != nil { @@ -247,7 +247,7 @@ func (r *Client) Put(path string, object interface{}, params ...Param) (err erro } // Patch a resource. -func (r *Client) Patch(path string, object interface{}, params ...Param) (err error) { +func (r *Client) Patch(path string, object any, params ...Param) (err error) { request := func() (request *http.Request, err error) { bfr, err := json.Marshal(object) if err != nil { @@ -462,7 +462,7 @@ func (r *Client) FileGet(path, destination string) (err error) { // FilePost uploads a file. // Returns the created File resource. -func (r *Client) FilePost(path, source string, object interface{}) (err error) { +func (r *Client) FilePost(path, source string, object any) (err error) { if source == "" { fields := []Field{ { @@ -494,7 +494,7 @@ func (r *Client) FilePost(path, source string, object interface{}) (err error) { // FilePut uploads a file. // Returns the created File resource. -func (r *Client) FilePut(path, source string, object interface{}) (err error) { +func (r *Client) FilePut(path, source string, object any) (err error) { if source == "" { fields := []Field{ { @@ -538,7 +538,7 @@ func (r *Client) FilePatch(path string, buffer []byte) (err error) { } // FileSend sends file upload from. -func (r *Client) FileSend(path, method string, fields []Field, object interface{}) (err error) { +func (r *Client) FileSend(path, method string, fields []Field, object any) (err error) { request := func() (request *http.Request, err error) { pr, pw := io.Pipe() request = &http.Request{ diff --git a/binding/filter/builder.go b/binding/filter/builder.go index 180b348bc..8c7b5c591 100644 --- a/binding/filter/builder.go +++ b/binding/filter/builder.go @@ -30,10 +30,10 @@ const ( ) // Any match any. -type Any []interface{} +type Any []any // All match all. -type All []interface{} +type All []any // Filter builder. type Filter struct { @@ -75,55 +75,55 @@ func (p *Predicate) String() (s string) { } // Eq returns a (=) predicate. -func (p *Predicate) Eq(object interface{}) *Predicate { +func (p *Predicate) Eq(object any) *Predicate { p.operator = EQ p.value = p.valueOf(object) return p } // NotEq returns a (!=) predicate. -func (p *Predicate) NotEq(object interface{}) *Predicate { +func (p *Predicate) NotEq(object any) *Predicate { p.operator = NOT + EQ p.value = p.valueOf(object) return p } // Like returns a (~) predicate. -func (p *Predicate) Like(object interface{}) *Predicate { +func (p *Predicate) Like(object any) *Predicate { p.operator = LIKE p.value = p.valueOf(object) return p } // Gt returns a (>) predicate. -func (p *Predicate) Gt(object interface{}) *Predicate { +func (p *Predicate) Gt(object any) *Predicate { p.operator = GT p.value = p.valueOf(object) return p } // GtEq returns a (>=) predicate. -func (p *Predicate) GtEq(object interface{}) *Predicate { +func (p *Predicate) GtEq(object any) *Predicate { p.operator = GT + EQ p.value = p.valueOf(object) return p } // Lt returns a (<) predicate. -func (p *Predicate) Lt(object interface{}) *Predicate { +func (p *Predicate) Lt(object any) *Predicate { p.operator = LT p.value = p.valueOf(object) return p } // LtEq returns a (<) predicate. -func (p *Predicate) LtEq(object interface{}) *Predicate { +func (p *Predicate) LtEq(object any) *Predicate { p.operator = LT + EQ p.value = p.valueOf(object) return p } -func (p *Predicate) valueOf(object interface{}) (result string) { +func (p *Predicate) valueOf(object any) (result string) { kind := reflect.TypeOf(object).Kind() value := reflect.ValueOf(object) switch kind { diff --git a/binding/setting.go b/binding/setting.go index c1359155c..b526449f7 100644 --- a/binding/setting.go +++ b/binding/setting.go @@ -10,7 +10,7 @@ type Setting struct { } // Get a setting by key. -func (h *Setting) Get(key string, v interface{}) (err error) { +func (h *Setting) Get(key string, v any) (err error) { path := Path(api.SettingRoot).Inject(Params{api.Key: key}) err = h.client.Get(path, v) return diff --git a/controller/addon.go b/controller/addon.go index 08d29af7d..7754eaa4a 100644 --- a/controller/addon.go +++ b/controller/addon.go @@ -5,7 +5,7 @@ import ( "github.com/go-logr/logr" logr2 "github.com/jortel/go-utils/logr" - api "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + api "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "github.com/konveyor/tackle2-hub/settings" "gorm.io/gorm" k8serr "k8s.io/apimachinery/pkg/api/errors" @@ -86,14 +86,16 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r } return } - - // + // migrate + migrated, err := r.alpha2Migration(addon) + if migrated || err != nil { + return + } // changed. err = r.addonChanged(addon) if err != nil { return } - // Apply changes. addon.Status.ObservedGeneration = addon.Generation err = r.Status().Update(context.TODO(), addon) @@ -113,3 +115,33 @@ func (r *Reconciler) addonChanged(addon *api.Addon) (err error) { func (r *Reconciler) addonDeleted(name string) (err error) { return } + +// alpha2Migration migrates to alpha2. +func (r *Reconciler) alpha2Migration(addon *api.Addon) (migrated bool, err error) { + if addon.Spec.Container.Image == "" && addon.Spec.Image != nil { + addon.Spec.Container.Image = *addon.Spec.Image + addon.Spec.Image = nil + migrated = true + } else { + return + } + if len(addon.Spec.Container.Resources.Limits) == 0 && + len(addon.Spec.Container.Resources.Requests) == 0 && + addon.Spec.Resources != nil { + addon.Spec.Container.Resources = *addon.Spec.Resources + addon.Spec.Resources = nil + migrated = true + } + if addon.Spec.Container.ImagePullPolicy == "" && addon.Spec.ImagePullPolicy != nil { + addon.Spec.Container.ImagePullPolicy = *addon.Spec.ImagePullPolicy + addon.Spec.ImagePullPolicy = nil + migrated = true + } + if migrated { + err = r.Update(context.TODO(), addon) + if err != nil { + return + } + } + return +} diff --git a/generated/crd/tackle.konveyor.io_addons.yaml b/generated/crd/tackle.konveyor.io_addons.yaml index 20e44294c..76ccf4c6a 100644 --- a/generated/crd/tackle.konveyor.io_addons.yaml +++ b/generated/crd/tackle.konveyor.io_addons.yaml @@ -15,14 +15,79 @@ spec: singular: addon scope: Namespaced versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha1 + - name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: AddonSpec defines the desired state of Addon + properties: + image: + description: Addon fqin. + type: string + imagePullPolicy: + default: IfNotPresent + description: ImagePullPolicy an optional image pull policy. + enum: + - IfNotPresent + - Always + - Never + type: string + resources: + description: Resource requirements. + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + required: + - image + type: object + status: + description: AddonStatus defines the observed state of Addon + properties: + observedGeneration: + description: The most recent generation observed by the controller. + format: int64 + type: integer + type: object + type: object + served: false + storage: false + subresources: + status: {} + - name: v1alpha2 schema: openAPIV3Schema: properties: @@ -1239,10 +1304,42 @@ spec: required: - name type: object + image: + description: 'Deprecated: Addon is deprecated.' + type: string + imagePullPolicy: + description: 'Deprecated: ImagePullPolicy is deprecated.' + type: string metadata: description: Metadata details. type: object x-kubernetes-preserve-unknown-fields: true + resources: + description: 'Deprecated: Resources is deprecated.' + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object selector: description: Selector type: string diff --git a/generated/crd/tackle.konveyor.io_extensions.yaml b/generated/crd/tackle.konveyor.io_extensions.yaml index fa5f746f6..af47906ad 100644 --- a/generated/crd/tackle.konveyor.io_extensions.yaml +++ b/generated/crd/tackle.konveyor.io_extensions.yaml @@ -15,14 +15,28 @@ spec: singular: extension scope: Namespaced versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha1 + - name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + type: object + served: false + storage: false + subresources: + status: {} + - name: v1alpha2 schema: openAPIV3Schema: properties: diff --git a/generated/crd/tackle.konveyor.io_tasks.yaml b/generated/crd/tackle.konveyor.io_tasks.yaml index e8dcb2cff..9f8129f46 100644 --- a/generated/crd/tackle.konveyor.io_tasks.yaml +++ b/generated/crd/tackle.konveyor.io_tasks.yaml @@ -16,6 +16,27 @@ spec: scope: Namespaced versions: - name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + type: object + served: false + storage: false + subresources: + status: {} + - name: v1alpha2 schema: openAPIV3Schema: properties: diff --git a/k8s/api/all.go b/k8s/api/all.go index 3eac0fa82..83ccee910 100644 --- a/k8s/api/all.go +++ b/k8s/api/all.go @@ -17,7 +17,8 @@ limitations under the License. package api import ( - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "k8s.io/apimachinery/pkg/runtime" ) @@ -26,7 +27,8 @@ var AddToSchemes runtime.SchemeBuilder func init() { AddToSchemes = append( AddToSchemes, - crd.SchemeBuilder.AddToScheme) + v1alpha1.SchemeBuilder.AddToScheme, + v1alpha2.SchemeBuilder.AddToScheme) } func AddToScheme(s *runtime.Scheme) error { diff --git a/k8s/api/tackle/v1alpha1/addon.go b/k8s/api/tackle/v1alpha1/addon.go index deaf695ea..3338ab938 100644 --- a/k8s/api/tackle/v1alpha1/addon.go +++ b/k8s/api/tackle/v1alpha1/addon.go @@ -19,19 +19,18 @@ package v1alpha1 import ( core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" ) // AddonSpec defines the desired state of Addon type AddonSpec struct { - // Task (kind) compatibility. - Task string `json:"task,omitempty"` - // Selector - Selector string `json:"selector,omitempty"` - // Container details. - Container core.Container `json:"container"` - // Metadata details. - Metadata runtime.RawExtension `json:"metadata,omitempty"` + // Addon fqin. + Image string `json:"image"` + // ImagePullPolicy an optional image pull policy. + // +kubebuilder:default=IfNotPresent + // +kubebuilder:validation:Enum=IfNotPresent;Always;Never + ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` + // Resource requirements. + Resources core.ResourceRequirements `json:"resources,omitempty"` } // AddonStatus defines the observed state of Addon @@ -44,9 +43,8 @@ type AddonStatus struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true +// +kubebuilder:unservedversion // +kubebuilder:subresource:status -// +kubebuilder:printcolumn:name="READY",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status" -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" type Addon struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` diff --git a/k8s/api/tackle/v1alpha1/extension.go b/k8s/api/tackle/v1alpha1/extension.go index 4076a66e4..cc39b2eb3 100644 --- a/k8s/api/tackle/v1alpha1/extension.go +++ b/k8s/api/tackle/v1alpha1/extension.go @@ -17,41 +17,17 @@ limitations under the License. package v1alpha1 import ( - core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" ) -// ExtensionSpec defines the desired state of Extension -type ExtensionSpec struct { - // Addon compatibility. - Addon string `json:"addon"` - // Container details. - Container core.Container `json:"container"` - // Selector - Selector string `json:"selector,omitempty"` - // Metadata details. - Metadata runtime.RawExtension `json:"metadata,omitempty"` -} - -// ExtensionStatus defines the observed state of Extension -type ExtensionStatus struct { - // The most recent generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true +// +kubebuilder:unservedversion // +kubebuilder:subresource:status -// +kubebuilder:printcolumn:name="READY",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status" -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" type Extension struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` - Spec ExtensionSpec `json:"spec,omitempty"` - Status ExtensionStatus `json:"status,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/k8s/api/tackle/v1alpha1/tackle.go b/k8s/api/tackle/v1alpha1/tackle.go index fbbe22c90..7c1d511f3 100644 --- a/k8s/api/tackle/v1alpha1/tackle.go +++ b/k8s/api/tackle/v1alpha1/tackle.go @@ -18,18 +18,18 @@ package v1alpha1 import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true // +kubebuilder:subresource:status -// +kubebuilder:printcolumn:name="READY",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status" -// +kubebuilder:printcolumn:name="CONNECTED",type=string,JSONPath=".status.conditions[?(@.type=='ConnectionTestSucceeded')].status" -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" type Tackle struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` + Spec runtime.RawExtension `json:"spec"` + Status runtime.RawExtension `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/k8s/api/tackle/v1alpha1/task.go b/k8s/api/tackle/v1alpha1/task.go index 9ab658489..c44ac0c2c 100644 --- a/k8s/api/tackle/v1alpha1/task.go +++ b/k8s/api/tackle/v1alpha1/task.go @@ -18,47 +18,16 @@ package v1alpha1 import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" ) -// TaskSpec defines the desired state of Task -type TaskSpec struct { - // Priority - Priority int `json:"priority,omitempty"` - // Dependencies - Dependencies []string `json:"dependencies,omitempty"` - // Data object passed to the addon.. - Data runtime.RawExtension `json:"data,omitempty"` -} - -// TaskStatus defines the observed state of Task -type TaskStatus struct { - // The most recent generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true +// +kubebuilder:unservedversion // +kubebuilder:subresource:status type Task struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` - Spec TaskSpec `json:"spec,omitempty"` - Status TaskStatus `json:"status,omitempty"` -} - -// HasDep return true if the task has the dependency. -func (r *Task) HasDep(name string) (found bool) { - for i := range r.Spec.Dependencies { - n := r.Spec.Dependencies[i] - if n == name { - found = true - break - } - } - return } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go index 2ab858602..ec96a5bfa 100644 --- a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go +++ b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go @@ -87,8 +87,7 @@ func (in *AddonList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AddonSpec) DeepCopyInto(out *AddonSpec) { *out = *in - in.Container.DeepCopyInto(&out.Container) - in.Metadata.DeepCopyInto(&out.Metadata) + in.Resources.DeepCopyInto(&out.Resources) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec. @@ -121,8 +120,6 @@ func (in *Extension) DeepCopyInto(out *Extension) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension. @@ -175,43 +172,13 @@ func (in *ExtensionList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExtensionSpec) DeepCopyInto(out *ExtensionSpec) { - *out = *in - in.Container.DeepCopyInto(&out.Container) - in.Metadata.DeepCopyInto(&out.Metadata) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionSpec. -func (in *ExtensionSpec) DeepCopy() *ExtensionSpec { - if in == nil { - return nil - } - out := new(ExtensionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionStatus. -func (in *ExtensionStatus) DeepCopy() *ExtensionStatus { - if in == nil { - return nil - } - out := new(ExtensionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Tackle) DeepCopyInto(out *Tackle) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tackle. @@ -269,8 +236,6 @@ func (in *Task) DeepCopyInto(out *Task) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Task. @@ -322,39 +287,3 @@ func (in *TaskList) DeepCopyObject() runtime.Object { } return nil } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TaskSpec) DeepCopyInto(out *TaskSpec) { - *out = *in - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make([]string, len(*in)) - copy(*out, *in) - } - in.Data.DeepCopyInto(&out.Data) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskSpec. -func (in *TaskSpec) DeepCopy() *TaskSpec { - if in == nil { - return nil - } - out := new(TaskSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TaskStatus) DeepCopyInto(out *TaskStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskStatus. -func (in *TaskStatus) DeepCopy() *TaskStatus { - if in == nil { - return nil - } - out := new(TaskStatus) - in.DeepCopyInto(out) - return out -} diff --git a/k8s/api/tackle/v1alpha2/addon.go b/k8s/api/tackle/v1alpha2/addon.go new file mode 100644 index 000000000..d9f1bb23a --- /dev/null +++ b/k8s/api/tackle/v1alpha2/addon.go @@ -0,0 +1,72 @@ +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + core "k8s.io/api/core/v1" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// AddonSpec defines the desired state of Addon +type AddonSpec struct { + // Deprecated: Addon is deprecated. + Image *string `json:"image,omitempty"` + // Deprecated: ImagePullPolicy is deprecated. + ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"` + // Deprecated: Resources is deprecated. + Resources *core.ResourceRequirements `json:"resources,omitempty"` + // + // Task (kind) compatibility. + Task string `json:"task,omitempty"` + // Selector + Selector string `json:"selector,omitempty"` + // Container details. + Container core.Container `json:"container"` + // Metadata details. + Metadata runtime.RawExtension `json:"metadata,omitempty"` +} + +// AddonStatus defines the observed state of Addon +type AddonStatus struct { + // The most recent generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +type Addon struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + Spec AddonSpec `json:"spec,omitempty"` + Status AddonStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type AddonList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + Items []Addon `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Addon{}, &AddonList{}) +} diff --git a/k8s/api/tackle/v1alpha2/extension.go b/k8s/api/tackle/v1alpha2/extension.go new file mode 100644 index 000000000..cbd02d138 --- /dev/null +++ b/k8s/api/tackle/v1alpha2/extension.go @@ -0,0 +1,65 @@ +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + core "k8s.io/api/core/v1" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// ExtensionSpec defines the desired state of Extension +type ExtensionSpec struct { + // Addon compatibility. + Addon string `json:"addon"` + // Container details. + Container core.Container `json:"container"` + // Selector + Selector string `json:"selector,omitempty"` + // Metadata details. + Metadata runtime.RawExtension `json:"metadata,omitempty"` +} + +// ExtensionStatus defines the observed state of Extension +type ExtensionStatus struct { + // The most recent generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +type Extension struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + Spec ExtensionSpec `json:"spec,omitempty"` + Status ExtensionStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ExtensionList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + Items []Extension `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Extension{}, &ExtensionList{}) +} diff --git a/k8s/api/tackle/v1alpha2/register.go b/k8s/api/tackle/v1alpha2/register.go new file mode 100644 index 000000000..4d8dd0a30 --- /dev/null +++ b/k8s/api/tackle/v1alpha2/register.go @@ -0,0 +1,35 @@ +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 contains API Schema definitions for the migration v1alpha1 API group. +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/konveyor/tackle2-controller/pkg/apis/migration +// +k8s:defaulter-gen=TypeMeta +// +groupName=tackle.konveyor.io +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var SchemeGroupVersion = schema.GroupVersion{ + Group: "tackle.konveyor.io", + Version: "v1alpha2", +} + +var SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} diff --git a/k8s/api/tackle/v1alpha2/tackle.go b/k8s/api/tackle/v1alpha2/tackle.go new file mode 100644 index 000000000..733792df6 --- /dev/null +++ b/k8s/api/tackle/v1alpha2/tackle.go @@ -0,0 +1,45 @@ +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +type Tackle struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + Spec runtime.RawExtension `json:"spec"` + Status runtime.RawExtension `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type TackleList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + Items []Tackle `json:"items"` +} + +func init() { + SchemeBuilder.Register(&TackleList{}, &Tackle{}) +} diff --git a/k8s/api/tackle/v1alpha2/task.go b/k8s/api/tackle/v1alpha2/task.go new file mode 100644 index 000000000..b11cf236a --- /dev/null +++ b/k8s/api/tackle/v1alpha2/task.go @@ -0,0 +1,74 @@ +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// TaskSpec defines the desired state of Task +type TaskSpec struct { + // Priority + Priority int `json:"priority,omitempty"` + // Dependencies + Dependencies []string `json:"dependencies,omitempty"` + // Data object passed to the addon.. + Data runtime.RawExtension `json:"data,omitempty"` +} + +// TaskStatus defines the observed state of Task +type TaskStatus struct { + // The most recent generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +type Task struct { + meta.TypeMeta `json:",inline"` + meta.ObjectMeta `json:"metadata,omitempty"` + Spec TaskSpec `json:"spec,omitempty"` + Status TaskStatus `json:"status,omitempty"` +} + +// HasDep return true if the task has the dependency. +func (r *Task) HasDep(name string) (found bool) { + for i := range r.Spec.Dependencies { + n := r.Spec.Dependencies[i] + if n == name { + found = true + break + } + } + return +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type TaskList struct { + meta.TypeMeta `json:",inline"` + meta.ListMeta `json:"metadata,omitempty"` + Items []Task `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Task{}, &TaskList{}) +} diff --git a/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 000000000..244028496 --- /dev/null +++ b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,378 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2019 Red Hat Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Addon) DeepCopyInto(out *Addon) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. +func (in *Addon) DeepCopy() *Addon { + if in == nil { + return nil + } + out := new(Addon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Addon) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonList) DeepCopyInto(out *AddonList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Addon, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonList. +func (in *AddonList) DeepCopy() *AddonList { + if in == nil { + return nil + } + out := new(AddonList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddonList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonSpec) DeepCopyInto(out *AddonSpec) { + *out = *in + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.ImagePullPolicy != nil { + in, out := &in.ImagePullPolicy, &out.ImagePullPolicy + *out = new(v1.PullPolicy) + **out = **in + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + in.Container.DeepCopyInto(&out.Container) + in.Metadata.DeepCopyInto(&out.Metadata) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec. +func (in *AddonSpec) DeepCopy() *AddonSpec { + if in == nil { + return nil + } + out := new(AddonSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. +func (in *AddonStatus) DeepCopy() *AddonStatus { + if in == nil { + return nil + } + out := new(AddonStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Extension) DeepCopyInto(out *Extension) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension. +func (in *Extension) DeepCopy() *Extension { + if in == nil { + return nil + } + out := new(Extension) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Extension) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtensionList) DeepCopyInto(out *ExtensionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Extension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionList. +func (in *ExtensionList) DeepCopy() *ExtensionList { + if in == nil { + return nil + } + out := new(ExtensionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ExtensionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtensionSpec) DeepCopyInto(out *ExtensionSpec) { + *out = *in + in.Container.DeepCopyInto(&out.Container) + in.Metadata.DeepCopyInto(&out.Metadata) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionSpec. +func (in *ExtensionSpec) DeepCopy() *ExtensionSpec { + if in == nil { + return nil + } + out := new(ExtensionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionStatus. +func (in *ExtensionStatus) DeepCopy() *ExtensionStatus { + if in == nil { + return nil + } + out := new(ExtensionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Tackle) DeepCopyInto(out *Tackle) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tackle. +func (in *Tackle) DeepCopy() *Tackle { + if in == nil { + return nil + } + out := new(Tackle) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Tackle) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TackleList) DeepCopyInto(out *TackleList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Tackle, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TackleList. +func (in *TackleList) DeepCopy() *TackleList { + if in == nil { + return nil + } + out := new(TackleList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TackleList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Task) DeepCopyInto(out *Task) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Task. +func (in *Task) DeepCopy() *Task { + if in == nil { + return nil + } + out := new(Task) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Task) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskList) DeepCopyInto(out *TaskList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Task, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskList. +func (in *TaskList) DeepCopy() *TaskList { + if in == nil { + return nil + } + out := new(TaskList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TaskList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskSpec) DeepCopyInto(out *TaskSpec) { + *out = *in + if in.Dependencies != nil { + in, out := &in.Dependencies, &out.Dependencies + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Data.DeepCopyInto(&out.Data) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskSpec. +func (in *TaskSpec) DeepCopy() *TaskSpec { + if in == nil { + return nil + } + out := new(TaskSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskStatus) DeepCopyInto(out *TaskStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskStatus. +func (in *TaskStatus) DeepCopy() *TaskStatus { + if in == nil { + return nil + } + out := new(TaskStatus) + in.DeepCopyInto(out) + return out +} diff --git a/migration/migrate.go b/migration/migrate.go index cc68493d6..4c8ec8b71 100644 --- a/migration/migrate.go +++ b/migration/migrate.go @@ -124,7 +124,7 @@ func setVersion(db *gorm.DB, version int) (err error) { } // AutoMigrate the database. -func autoMigrate(db *gorm.DB, models []interface{}) (err error) { +func autoMigrate(db *gorm.DB, models []any) (err error) { db, err = database.Open(false) if err != nil { err = liberr.Wrap(err) diff --git a/migration/migrate_test.go b/migration/migrate_test.go index 7fcb1f6ad..943a85a1a 100644 --- a/migration/migrate_test.go +++ b/migration/migrate_test.go @@ -110,7 +110,7 @@ func (r *TestMigration) Apply(db *gorm.DB) (err error) { return } -func (r *TestMigration) Models() (models []interface{}) { +func (r *TestMigration) Models() (models []any) { return } diff --git a/migration/pkg.go b/migration/pkg.go index eab172e66..f80ed8e48 100644 --- a/migration/pkg.go +++ b/migration/pkg.go @@ -37,7 +37,7 @@ type Version struct { // Migration encapsulates the functionality necessary to perform a migration. type Migration interface { Apply(*gorm.DB) error - Models() []interface{} + Models() []any } // All migrations in order. diff --git a/migration/v10/migrate.go b/migration/v10/migrate.go index 14dbc8a3f..7aefd97a2 100644 --- a/migration/v10/migrate.go +++ b/migration/v10/migrate.go @@ -15,6 +15,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v10/model/application.go b/migration/v10/model/application.go index f68476e8a..b01e96d53 100644 --- a/migration/v10/model/application.go +++ b/migration/v10/model/application.go @@ -255,8 +255,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v10/model/core.go b/migration/v10/model/core.go index 637c0d879..98730b2ba 100644 --- a/migration/v10/model/core.go +++ b/migration/v10/model/core.go @@ -29,7 +29,7 @@ type Setting struct { // With updates the value of the Setting with the json representation // of the `value` parameter. -func (r *Setting) With(value interface{}) (err error) { +func (r *Setting) With(value any) (err error) { r.Value, err = json.Marshal(value) if err != nil { err = liberr.Wrap(err) @@ -38,7 +38,7 @@ func (r *Setting) With(value interface{}) (err error) { } // As unmarshalls the value of the Setting into the `ptr` parameter. -func (r *Setting) As(ptr interface{}) (err error) { +func (r *Setting) As(ptr any) (err error) { err = json.Unmarshal(r.Value, ptr) if err != nil { err = liberr.Wrap(err) @@ -155,7 +155,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -165,7 +165,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v10/model/pkg.go b/migration/v10/model/pkg.go index 2ba843598..10b9cfba2 100644 --- a/migration/v10/model/pkg.go +++ b/migration/v10/model/pkg.go @@ -12,8 +12,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v11/migrate.go b/migration/v11/migrate.go index 52ce2523b..c0187e0cf 100644 --- a/migration/v11/migrate.go +++ b/migration/v11/migrate.go @@ -15,6 +15,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v11/model/application.go b/migration/v11/model/application.go index 1bd928758..e824cfc74 100644 --- a/migration/v11/model/application.go +++ b/migration/v11/model/application.go @@ -257,8 +257,8 @@ type Import struct { Contributors string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v11/model/core.go b/migration/v11/model/core.go index 637c0d879..98730b2ba 100644 --- a/migration/v11/model/core.go +++ b/migration/v11/model/core.go @@ -29,7 +29,7 @@ type Setting struct { // With updates the value of the Setting with the json representation // of the `value` parameter. -func (r *Setting) With(value interface{}) (err error) { +func (r *Setting) With(value any) (err error) { r.Value, err = json.Marshal(value) if err != nil { err = liberr.Wrap(err) @@ -38,7 +38,7 @@ func (r *Setting) With(value interface{}) (err error) { } // As unmarshalls the value of the Setting into the `ptr` parameter. -func (r *Setting) As(ptr interface{}) (err error) { +func (r *Setting) As(ptr any) (err error) { err = json.Unmarshal(r.Value, ptr) if err != nil { err = liberr.Wrap(err) @@ -155,7 +155,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -165,7 +165,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v11/model/pkg.go b/migration/v11/model/pkg.go index 2ba843598..10b9cfba2 100644 --- a/migration/v11/model/pkg.go +++ b/migration/v11/model/pkg.go @@ -12,8 +12,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v12/migrate.go b/migration/v12/migrate.go index dc991213b..c7ccc5a05 100644 --- a/migration/v12/migrate.go +++ b/migration/v12/migrate.go @@ -15,6 +15,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v12/model/application.go b/migration/v12/model/application.go index 1bd928758..e824cfc74 100644 --- a/migration/v12/model/application.go +++ b/migration/v12/model/application.go @@ -257,8 +257,8 @@ type Import struct { Contributors string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v12/model/core.go b/migration/v12/model/core.go index 60464a929..e15792a14 100644 --- a/migration/v12/model/core.go +++ b/migration/v12/model/core.go @@ -29,7 +29,7 @@ type Setting struct { // With updates the value of the Setting with the json representation // of the `value` parameter. -func (r *Setting) With(value interface{}) (err error) { +func (r *Setting) With(value any) (err error) { r.Value, err = json.Marshal(value) if err != nil { err = liberr.Wrap(err) @@ -38,7 +38,7 @@ func (r *Setting) With(value interface{}) (err error) { } // As unmarshalls the value of the Setting into the `ptr` parameter. -func (r *Setting) As(ptr interface{}) (err error) { +func (r *Setting) As(ptr any) (err error) { err = json.Unmarshal(r.Value, ptr) if err != nil { err = liberr.Wrap(err) @@ -155,7 +155,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -165,7 +165,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v12/model/pkg.go b/migration/v12/model/pkg.go index 2ba843598..10b9cfba2 100644 --- a/migration/v12/model/pkg.go +++ b/migration/v12/model/pkg.go @@ -12,8 +12,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v13/migrate.go b/migration/v13/migrate.go index b4c0b4f4c..77e3324f3 100644 --- a/migration/v13/migrate.go +++ b/migration/v13/migrate.go @@ -24,6 +24,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v13/model/application.go b/migration/v13/model/application.go index 1bd928758..e824cfc74 100644 --- a/migration/v13/model/application.go +++ b/migration/v13/model/application.go @@ -257,8 +257,8 @@ type Import struct { Contributors string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v13/model/core.go b/migration/v13/model/core.go index 828545aae..af41cfeed 100644 --- a/migration/v13/model/core.go +++ b/migration/v13/model/core.go @@ -28,7 +28,7 @@ type Setting struct { // With updates the value of the Setting with the json representation // of the `value` parameter. -func (r *Setting) With(value interface{}) (err error) { +func (r *Setting) With(value any) (err error) { r.Value, err = json.Marshal(value) if err != nil { err = liberr.Wrap(err) @@ -37,7 +37,7 @@ func (r *Setting) With(value interface{}) (err error) { } // As unmarshalls the value of the Setting into the `ptr` parameter. -func (r *Setting) As(ptr interface{}) (err error) { +func (r *Setting) As(ptr any) (err error) { err = json.Unmarshal(r.Value, ptr) if err != nil { err = liberr.Wrap(err) diff --git a/migration/v13/model/pkg.go b/migration/v13/model/pkg.go index d96155121..6827e3c96 100644 --- a/migration/v13/model/pkg.go +++ b/migration/v13/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v14/migrate.go b/migration/v14/migrate.go index 45df7860d..2d0c499ab 100644 --- a/migration/v14/migrate.go +++ b/migration/v14/migrate.go @@ -15,6 +15,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v14/model/application.go b/migration/v14/model/application.go index 0531fb585..c45ccdf0d 100644 --- a/migration/v14/model/application.go +++ b/migration/v14/model/application.go @@ -257,8 +257,8 @@ type Import struct { Contributors string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v14/model/core.go b/migration/v14/model/core.go index e52c7cf97..474bacb31 100644 --- a/migration/v14/model/core.go +++ b/migration/v14/model/core.go @@ -28,7 +28,7 @@ type Setting struct { // With updates the value of the Setting with the json representation // of the `value` parameter. -func (r *Setting) With(value interface{}) (err error) { +func (r *Setting) With(value any) (err error) { r.Value, err = json.Marshal(value) if err != nil { err = liberr.Wrap(err) @@ -37,7 +37,7 @@ func (r *Setting) With(value interface{}) (err error) { } // As unmarshalls the value of the Setting into the `ptr` parameter. -func (r *Setting) As(ptr interface{}) (err error) { +func (r *Setting) As(ptr any) (err error) { err = json.Unmarshal(r.Value, ptr) if err != nil { err = liberr.Wrap(err) diff --git a/migration/v14/model/pkg.go b/migration/v14/model/pkg.go index d96155121..6827e3c96 100644 --- a/migration/v14/model/pkg.go +++ b/migration/v14/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v2/migrate.go b/migration/v2/migrate.go index 0e8c1507f..3c299c82a 100644 --- a/migration/v2/migrate.go +++ b/migration/v2/migrate.go @@ -36,6 +36,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v2/model/application.go b/migration/v2/model/application.go index 8d9416969..e3d23e760 100644 --- a/migration/v2/model/application.go +++ b/migration/v2/model/application.go @@ -147,8 +147,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v2/model/core.go b/migration/v2/model/core.go index bd485a6b8..af31103be 100644 --- a/migration/v2/model/core.go +++ b/migration/v2/model/core.go @@ -85,7 +85,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v2/model/pkg.go b/migration/v2/model/pkg.go index b3f6211e7..7a59073f3 100644 --- a/migration/v2/model/pkg.go +++ b/migration/v2/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ ImportSummary{}, Import{}, ImportTag{}, diff --git a/migration/v3/migrate.go b/migration/v3/migrate.go index 00f048c94..e7e99d37f 100644 --- a/migration/v3/migrate.go +++ b/migration/v3/migrate.go @@ -82,7 +82,7 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } @@ -103,7 +103,7 @@ func (r Migration) factMigration(db *gorm.DB) (err error) { return } for _, m := range list { - d := map[string]interface{}{} + d := map[string]any{} _ = json.Unmarshal(m.Facts, &d) for k, v := range d { jv, _ := json.Marshal(v) diff --git a/migration/v3/model/application.go b/migration/v3/model/application.go index 84050367c..f4ccba0ca 100644 --- a/migration/v3/model/application.go +++ b/migration/v3/model/application.go @@ -228,8 +228,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v3/model/core.go b/migration/v3/model/core.go index ac43b6966..f23bfd1ad 100644 --- a/migration/v3/model/core.go +++ b/migration/v3/model/core.go @@ -133,7 +133,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v3/model/pkg.go b/migration/v3/model/pkg.go index 72de00566..62f7c8217 100644 --- a/migration/v3/model/pkg.go +++ b/migration/v3/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ ImportSummary{}, Import{}, ImportTag{}, diff --git a/migration/v4/migrate.go b/migration/v4/migrate.go index f6491da4b..734e27c0a 100644 --- a/migration/v4/migrate.go +++ b/migration/v4/migrate.go @@ -21,6 +21,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v4/model/application.go b/migration/v4/model/application.go index 70e12e1a8..f87914c09 100644 --- a/migration/v4/model/application.go +++ b/migration/v4/model/application.go @@ -247,8 +247,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v4/model/core.go b/migration/v4/model/core.go index ac43b6966..f23bfd1ad 100644 --- a/migration/v4/model/core.go +++ b/migration/v4/model/core.go @@ -133,7 +133,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v4/model/pkg.go b/migration/v4/model/pkg.go index 2f09a63c7..e8011d78d 100644 --- a/migration/v4/model/pkg.go +++ b/migration/v4/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ ImportSummary{}, Import{}, ImportTag{}, diff --git a/migration/v5/migrate.go b/migration/v5/migrate.go index c81705292..a08e206ad 100644 --- a/migration/v5/migrate.go +++ b/migration/v5/migrate.go @@ -61,7 +61,7 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v5/model/application.go b/migration/v5/model/application.go index 6049278da..9d5d6f4e9 100644 --- a/migration/v5/model/application.go +++ b/migration/v5/model/application.go @@ -234,8 +234,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v5/model/core.go b/migration/v5/model/core.go index 0fb5a3312..1f0012bd5 100644 --- a/migration/v5/model/core.go +++ b/migration/v5/model/core.go @@ -134,7 +134,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v5/model/pkg.go b/migration/v5/model/pkg.go index 17b80b721..13499d8f8 100644 --- a/migration/v5/model/pkg.go +++ b/migration/v5/model/pkg.go @@ -14,8 +14,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ TechDependency{}, Incident{}, Issue{}, diff --git a/migration/v6/migrate.go b/migration/v6/migrate.go index b285e559a..a1f013c5f 100644 --- a/migration/v6/migrate.go +++ b/migration/v6/migrate.go @@ -37,7 +37,7 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v6/model/application.go b/migration/v6/model/application.go index 6049278da..9d5d6f4e9 100644 --- a/migration/v6/model/application.go +++ b/migration/v6/model/application.go @@ -234,8 +234,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v6/model/core.go b/migration/v6/model/core.go index f0b2d05a5..a0a708b6a 100644 --- a/migration/v6/model/core.go +++ b/migration/v6/model/core.go @@ -135,7 +135,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -145,7 +145,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v6/model/pkg.go b/migration/v6/model/pkg.go index 9e842a5b5..07ec8fd4f 100644 --- a/migration/v6/model/pkg.go +++ b/migration/v6/model/pkg.go @@ -12,8 +12,8 @@ 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. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ TechDependency{}, Incident{}, Issue{}, diff --git a/migration/v7/migrate.go b/migration/v7/migrate.go index 124f748ac..34d6f1d8c 100644 --- a/migration/v7/migrate.go +++ b/migration/v7/migrate.go @@ -55,6 +55,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v7/model/application.go b/migration/v7/model/application.go index 672391cd6..d7b442d0b 100644 --- a/migration/v7/model/application.go +++ b/migration/v7/model/application.go @@ -237,8 +237,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v7/model/core.go b/migration/v7/model/core.go index 4989ad63b..143115a4e 100644 --- a/migration/v7/model/core.go +++ b/migration/v7/model/core.go @@ -136,7 +136,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -146,7 +146,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v7/model/pkg.go b/migration/v7/model/pkg.go index 50bfb9d62..b952720d7 100644 --- a/migration/v7/model/pkg.go +++ b/migration/v7/model/pkg.go @@ -12,8 +12,8 @@ var ( // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v8/migrate.go b/migration/v8/migrate.go index a67372b6a..5a0fca3be 100644 --- a/migration/v8/migrate.go +++ b/migration/v8/migrate.go @@ -87,6 +87,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v8/model/application.go b/migration/v8/model/application.go index 672391cd6..d7b442d0b 100644 --- a/migration/v8/model/application.go +++ b/migration/v8/model/application.go @@ -237,8 +237,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v8/model/core.go b/migration/v8/model/core.go index 4989ad63b..143115a4e 100644 --- a/migration/v8/model/core.go +++ b/migration/v8/model/core.go @@ -136,7 +136,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -146,7 +146,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v8/model/pkg.go b/migration/v8/model/pkg.go index 07446cd47..b84271490 100644 --- a/migration/v8/model/pkg.go +++ b/migration/v8/model/pkg.go @@ -12,8 +12,8 @@ var ( // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/migration/v9/migrate.go b/migration/v9/migrate.go index e51b3e522..9c4159da9 100644 --- a/migration/v9/migrate.go +++ b/migration/v9/migrate.go @@ -28,6 +28,6 @@ func (r Migration) Apply(db *gorm.DB) (err error) { return } -func (r Migration) Models() []interface{} { +func (r Migration) Models() []any { return model.All() } diff --git a/migration/v9/model/application.go b/migration/v9/model/application.go index f68476e8a..b01e96d53 100644 --- a/migration/v9/model/application.go +++ b/migration/v9/model/application.go @@ -255,8 +255,8 @@ type Import struct { RepositoryPath string } -func (r *Import) AsMap() (m map[string]interface{}) { - m = make(map[string]interface{}) +func (r *Import) AsMap() (m map[string]any) { + m = make(map[string]any) m["filename"] = r.Filename m["applicationName"] = r.ApplicationName // "Application Name" is necessary in order for diff --git a/migration/v9/model/core.go b/migration/v9/model/core.go index 4989ad63b..143115a4e 100644 --- a/migration/v9/model/core.go +++ b/migration/v9/model/core.go @@ -136,7 +136,7 @@ func (m *Task) BeforeCreate(db *gorm.DB) (err error) { } // Error appends an error. -func (m *Task) Error(severity, description string, x ...interface{}) { +func (m *Task) Error(severity, description string, x ...any) { var list []TaskError description = fmt.Sprintf(description, x...) te := TaskError{Severity: severity, Description: description} @@ -146,7 +146,7 @@ func (m *Task) Error(severity, description string, x ...interface{}) { } // Map alias. -type Map = map[string]interface{} +type Map = map[string]any // TTL time-to-live. type TTL struct { diff --git a/migration/v9/model/pkg.go b/migration/v9/model/pkg.go index 9a3b3f765..95bca7297 100644 --- a/migration/v9/model/pkg.go +++ b/migration/v9/model/pkg.go @@ -12,8 +12,8 @@ var ( // All builds all models. // Models are enumerated such that each are listed after // all the other models on which they may depend. -func All() []interface{} { - return []interface{}{ +func All() []any { + return []any{ Application{}, TechDependency{}, Incident{}, diff --git a/reaper/bucket.go b/reaper/bucket.go index 33eb99801..a6a62a218 100644 --- a/reaper/bucket.go +++ b/reaper/bucket.go @@ -64,7 +64,7 @@ func (r *BucketReaper) busy(bucket *model.Bucket) (busy bool, err error) { nRef := int64(0) var n int64 ref := RefCounter{DB: r.DB} - for _, m := range []interface{}{ + for _, m := range []any{ &model.Application{}, &model.TaskGroup{}, &model.Task{}, diff --git a/reaper/file.go b/reaper/file.go index 244d07c4e..57744ce33 100644 --- a/reaper/file.go +++ b/reaper/file.go @@ -63,7 +63,7 @@ func (r *FileReaper) busy(file *model.File) (busy bool, err error) { nRef := int64(0) var n int64 ref := RefCounter{DB: r.DB} - for _, m := range []interface{}{ + for _, m := range []any{ &model.Task{}, &model.TaskReport{}, &model.RuleSet{}, diff --git a/reaper/ref.go b/reaper/ref.go index 7b70fd83f..8dd9d55d2 100644 --- a/reaper/ref.go +++ b/reaper/ref.go @@ -16,7 +16,7 @@ type RefCounter struct { } // Count find & count references. -func (r *RefCounter) Count(m interface{}, kind string, pk uint) (nRef int64, err error) { +func (r *RefCounter) Count(m any, kind string, pk uint) (nRef int64, err error) { db := r.DB.Model(m) fields := 0 j := 0 @@ -44,8 +44,8 @@ func (r *RefCounter) Count(m interface{}, kind string, pk uint) (nRef int64, err return } } - var find func(interface{}) - find = func(object interface{}) { + var find func(any) + find = func(object any) { mt := reflect.TypeOf(object) mv := reflect.ValueOf(object) if mt.Kind() == reflect.Ptr { diff --git a/seed/jobfunction.go b/seed/jobfunction.go index dbad0b6bd..bdb42eaac 100644 --- a/seed/jobfunction.go +++ b/seed/jobfunction.go @@ -81,7 +81,7 @@ func (r *JobFunction) Apply(db *gorm.DB) (err error) { } // Convenience method to find a JobFunction. -func (r *JobFunction) find(db *gorm.DB, conditions ...interface{}) (jf *model.JobFunction, found bool, err error) { +func (r *JobFunction) find(db *gorm.DB, conditions ...any) (jf *model.JobFunction, found bool, err error) { jf = &model.JobFunction{} result := db.First(jf, conditions...) if result.Error != nil { diff --git a/seed/questionnaire.go b/seed/questionnaire.go index a3b0c3121..87e419817 100644 --- a/seed/questionnaire.go +++ b/seed/questionnaire.go @@ -90,7 +90,7 @@ func (r *Questionnaire) Apply(db *gorm.DB) (err error) { } // Convenience method to find a Questionnaire. -func (r *Questionnaire) find(db *gorm.DB, conditions ...interface{}) (q *model.Questionnaire, found bool, err error) { +func (r *Questionnaire) find(db *gorm.DB, conditions ...any) (q *model.Questionnaire, found bool, err error) { q = &model.Questionnaire{} result := db.First(q, conditions...) if result.Error != nil { diff --git a/seed/ruleset.go b/seed/ruleset.go index 97bcd614f..3354b6aea 100644 --- a/seed/ruleset.go +++ b/seed/ruleset.go @@ -179,7 +179,7 @@ func file(db *gorm.DB, filePath string) (file *model.File, err error) { } // Convenience method to find a RuleSet. -func (r *RuleSet) find(db *gorm.DB, conditions ...interface{}) (rs *model.RuleSet, found bool, err error) { +func (r *RuleSet) find(db *gorm.DB, conditions ...any) (rs *model.RuleSet, found bool, err error) { rs = &model.RuleSet{} result := db.First(rs, conditions...) if result.Error != nil { diff --git a/seed/tag.go b/seed/tag.go index 7673338df..1673e8aec 100644 --- a/seed/tag.go +++ b/seed/tag.go @@ -118,7 +118,7 @@ func (r *TagCategory) applyTags(db *gorm.DB, category *model.TagCategory, tc lib } // Convenience method to find a TagCategory. -func (r *TagCategory) find(db *gorm.DB, conditions ...interface{}) (category *model.TagCategory, found bool, err error) { +func (r *TagCategory) find(db *gorm.DB, conditions ...any) (category *model.TagCategory, found bool, err error) { category = &model.TagCategory{} result := db.First(category, conditions...) if result.Error != nil { diff --git a/seed/target.go b/seed/target.go index 554f79e5a..6e2888091 100644 --- a/seed/target.go +++ b/seed/target.go @@ -176,7 +176,7 @@ func merge(userOrder []uint, seedOrder []uint, ids []uint) (mergedOrder []uint) } // Convenience method to find a Target. -func (r *Target) find(db *gorm.DB, conditions ...interface{}) (t *model.Target, found bool, err error) { +func (r *Target) find(db *gorm.DB, conditions ...any) (t *model.Target, found bool, err error) { t = &model.Target{} result := db.First(t, conditions...) if result.Error != nil { diff --git a/task/manager.go b/task/manager.go index a2c0c9bdc..0ed8989df 100644 --- a/task/manager.go +++ b/task/manager.go @@ -16,7 +16,7 @@ import ( "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/auth" k8s2 "github.com/konveyor/tackle2-hub/k8s" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "github.com/konveyor/tackle2-hub/metrics" "github.com/konveyor/tackle2-hub/model" "github.com/konveyor/tackle2-hub/settings" diff --git a/task/task_test.go b/task/task_test.go index 34a2aef02..fb0eff386 100644 --- a/task/task_test.go +++ b/task/task_test.go @@ -3,7 +3,7 @@ package task import ( "testing" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "github.com/konveyor/tackle2-hub/model" "github.com/onsi/gomega" ) diff --git a/test/api/application/facts_test.go b/test/api/application/facts_test.go index e68705b1f..d6d487bf1 100644 --- a/test/api/application/facts_test.go +++ b/test/api/application/facts_test.go @@ -43,7 +43,7 @@ func TestApplicationFactCRUD(t *testing.T) { } // Get. - var v interface{} + var v any err = Client.Get(factPath, &v) if err != nil { t.Errorf(err.Error()) diff --git a/test/assert/equality.go b/test/assert/equality.go index 7167a52c0..2cd5bf750 100644 --- a/test/assert/equality.go +++ b/test/assert/equality.go @@ -5,6 +5,6 @@ import ( ) // Simple equality check working for flat types (no nested types passed by reference). -func FlatEqual(got, expected interface{}) bool { +func FlatEqual(got, expected any) bool { return fmt.Sprintf("%v", got) == fmt.Sprintf("%v", expected) }