From 2cba3233f3698d7726018211bb45dba4df9094f5 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 14 Jun 2024 16:14:53 -0700 Subject: [PATCH 1/4] using any instead of interface{} introduced in 1.18. Signed-off-by: Jeff Ortel --- addon/task.go | 8 ++++---- api/analysis.go | 2 +- api/application.go | 12 ++++++------ api/base.go | 22 +++++++++++----------- api/batch.go | 2 +- api/context.go | 4 ++-- api/error.go | 2 +- api/filter/error.go | 2 +- api/filter/filter.go | 6 +++--- api/filter/filter_test.go | 4 ++-- api/import.go | 2 +- api/questionnaire.go | 4 ++-- api/reflect/fields.go | 10 +++++----- api/setting.go | 4 ++-- api/ticket.go | 2 +- auth/builtin.go | 2 +- binding/application.go | 4 ++-- binding/client.go | 16 ++++++++-------- binding/filter/builder.go | 20 ++++++++++---------- binding/setting.go | 2 +- migration/migrate.go | 2 +- migration/migrate_test.go | 2 +- migration/pkg.go | 2 +- migration/v10/migrate.go | 2 +- migration/v10/model/application.go | 4 ++-- migration/v10/model/core.go | 8 ++++---- migration/v10/model/pkg.go | 4 ++-- migration/v11/migrate.go | 2 +- migration/v11/model/application.go | 4 ++-- migration/v11/model/core.go | 8 ++++---- migration/v11/model/pkg.go | 4 ++-- migration/v12/migrate.go | 2 +- migration/v12/model/application.go | 4 ++-- migration/v12/model/core.go | 8 ++++---- migration/v12/model/pkg.go | 4 ++-- migration/v13/migrate.go | 2 +- migration/v13/model/application.go | 4 ++-- migration/v13/model/core.go | 4 ++-- migration/v13/model/pkg.go | 4 ++-- migration/v14/migrate.go | 2 +- migration/v14/model/application.go | 4 ++-- migration/v14/model/core.go | 4 ++-- migration/v14/model/pkg.go | 4 ++-- migration/v2/migrate.go | 2 +- migration/v2/model/application.go | 4 ++-- migration/v2/model/core.go | 2 +- migration/v2/model/pkg.go | 4 ++-- migration/v3/migrate.go | 4 ++-- migration/v3/model/application.go | 4 ++-- migration/v3/model/core.go | 2 +- migration/v3/model/pkg.go | 4 ++-- migration/v4/migrate.go | 2 +- migration/v4/model/application.go | 4 ++-- migration/v4/model/core.go | 2 +- migration/v4/model/pkg.go | 4 ++-- migration/v5/migrate.go | 2 +- migration/v5/model/application.go | 4 ++-- migration/v5/model/core.go | 2 +- migration/v5/model/pkg.go | 4 ++-- migration/v6/migrate.go | 2 +- migration/v6/model/application.go | 4 ++-- migration/v6/model/core.go | 4 ++-- migration/v6/model/pkg.go | 4 ++-- migration/v7/migrate.go | 2 +- migration/v7/model/application.go | 4 ++-- migration/v7/model/core.go | 4 ++-- migration/v7/model/pkg.go | 4 ++-- migration/v8/migrate.go | 2 +- migration/v8/model/application.go | 4 ++-- migration/v8/model/core.go | 4 ++-- migration/v8/model/pkg.go | 4 ++-- migration/v9/migrate.go | 2 +- migration/v9/model/application.go | 4 ++-- migration/v9/model/core.go | 4 ++-- migration/v9/model/pkg.go | 4 ++-- reaper/bucket.go | 2 +- reaper/file.go | 2 +- reaper/ref.go | 6 +++--- seed/jobfunction.go | 2 +- seed/questionnaire.go | 2 +- seed/ruleset.go | 2 +- seed/tag.go | 2 +- seed/target.go | 2 +- test/api/application/facts_test.go | 2 +- test/assert/equality.go | 2 +- 85 files changed, 174 insertions(+), 174 deletions(-) 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/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/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/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/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) } From dbf7060beec4c890d38b58365dfc1279544e411a Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Sat, 15 Jun 2024 13:07:31 -0700 Subject: [PATCH 2/4] checkpoint Signed-off-by: Jeff Ortel --- api/addon.go | 2 +- api/task.go | 2 +- api/taskgroup.go | 2 +- controller/addon.go | 38 +- generated/crd/tackle.konveyor.io_addons.yaml | 111 ++ .../crd/tackle.konveyor.io_extensions.yaml | 1251 +++++++++++++++++ generated/crd/tackle.konveyor.io_tasks.yaml | 45 + k8s/api/all.go | 6 +- k8s/api/tackle/v1alpha1/addon.go | 18 +- k8s/api/tackle/v1alpha1/extension.go | 1 + k8s/api/tackle/v1alpha1/task.go | 1 + .../tackle/v1alpha1/zz_generated.deepcopy.go | 3 +- k8s/api/tackle/v1alpha2/addon.go | 74 + k8s/api/tackle/v1alpha2/extension.go | 67 + k8s/api/tackle/v1alpha2/register.go | 35 + k8s/api/tackle/v1alpha2/tackle.go | 45 + k8s/api/tackle/v1alpha2/task.go | 74 + .../tackle/v1alpha2/zz_generated.deepcopy.go | 376 +++++ task/manager.go | 2 +- task/task_test.go | 2 +- 20 files changed, 2133 insertions(+), 22 deletions(-) create mode 100644 k8s/api/tackle/v1alpha2/addon.go create mode 100644 k8s/api/tackle/v1alpha2/extension.go create mode 100644 k8s/api/tackle/v1alpha2/register.go create mode 100644 k8s/api/tackle/v1alpha2/tackle.go create mode 100644 k8s/api/tackle/v1alpha2/task.go create mode 100644 k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go 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/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/controller/addon.go b/controller/addon.go index 08d29af7d..e81ddffb0 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,31 @@ 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 + } + 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..be6fa1390 100644 --- a/generated/crd/tackle.konveyor.io_addons.yaml +++ b/generated/crd/tackle.konveyor.io_addons.yaml @@ -23,6 +23,85 @@ spec: name: AGE type: date 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: {} + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha2 schema: openAPIV3Schema: properties: @@ -1239,10 +1318,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..061f18cc2 100644 --- a/generated/crd/tackle.konveyor.io_extensions.yaml +++ b/generated/crd/tackle.konveyor.io_extensions.yaml @@ -1262,6 +1262,1257 @@ spec: type: integer type: object type: object + served: false + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha2 + 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: ExtensionSpec defines the desired state of Extension + properties: + addon: + description: Addon compatibility. + type: string + container: + description: Container details. + properties: + args: + description: 'Arguments to the entrypoint. The container image''s + CMD is used if this is not provided. Variable references $(VAR_NAME) + are expanded using the container''s environment. If a variable + cannot be resolved, the reference in the input string will be + unchanged. Double $$ are reduced to a single $, which allows + for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references + will never be expanded, regardless of whether the variable exists + or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + command: + description: 'Entrypoint array. Not executed within a shell. The + container image''s ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container''s + environment. If a variable cannot be resolved, the reference + in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: + i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether + the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' + items: + type: string + type: array + env: + description: List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. If + a variable cannot be resolved, the reference in the input + string will be unchanged. Double $$ are reduced to a single + $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless + of whether the variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: List of sources to populate environment variables + in the container. The keys defined within a source must be a + C_IDENTIFIER. All invalid keys will be reported as an event + when the container is starting. When a key exists in multiple + sources, the value associated with the last source will take + precedence. Values defined by an Env with a duplicate key will + take precedence. Cannot be updated. + items: + description: EnvFromSource represents the source of a set of + ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to each key + in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: 'Container image name. More info: https://kubernetes.io/docs/concepts/containers/images + This field is optional to allow higher level config management + to default or override container images in workload controllers + like Deployments and StatefulSets.' + type: string + imagePullPolicy: + description: 'Image pull policy. One of Always, Never, IfNotPresent. + Defaults to Always if :latest tag is specified, or IfNotPresent + otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images' + type: string + lifecycle: + description: Actions that the management system should take in + response to container lifecycle events. Cannot be updated. + properties: + postStart: + description: 'PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. Other management + of the container blocks until the hook completes. More info: + https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's filesystem. + The command is simply exec'd, it is not run inside + a shell, so traditional shell instructions ('|', + etc) won't work. To use a shell, you need to explicitly + call out to that shell. Exit status of 0 is treated + as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range 1 + to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported as + a LifecycleHandler and kept for the backward compatibility. + There are no validation of this field and lifecycle + hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range 1 + to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: 'PreStop is called immediately before a container + is terminated due to an API request or management event + such as liveness/startup probe failure, preemption, resource + contention, etc. The handler is not called if the container + crashes or exits. The Pod''s termination grace period countdown + begins before the PreStop hook is executed. Regardless of + the outcome of the handler, the container will eventually + terminate within the Pod''s termination grace period (unless + delayed by finalizers). Other management of the container + blocks until the hook completes or until the termination + grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's filesystem. + The command is simply exec'd, it is not run inside + a shell, so traditional shell instructions ('|', + etc) won't work. To use a shell, you need to explicitly + call out to that shell. Exit status of 0 is treated + as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range 1 + to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported as + a LifecycleHandler and kept for the backward compatibility. + There are no validation of this field and lifecycle + hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range 1 + to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: 'Periodic probe of container liveness. Container + will be restarted if the probe fails. Cannot be updated. More + info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + name: + description: Name of the container specified as a DNS_LABEL. Each + container in a pod must have a unique name (DNS_LABEL). Cannot + be updated. + type: string + ports: + description: List of ports to expose from the container. Not specifying + a port here DOES NOT prevent that port from being exposed. Any + port which is listening on the default "0.0.0.0" address inside + a container will be accessible from the network. Modifying this + array with strategic merge patch may corrupt the data. For more + information See https://github.com/kubernetes/kubernetes/issues/108255. + Cannot be updated. + items: + description: ContainerPort represents a network port in a single + container. + properties: + containerPort: + description: Number of port to expose on the pod's IP address. + This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + hostPort: + description: Number of port to expose on the host. If specified, + this must be a valid port number, 0 < x < 65536. If HostNetwork + is specified, this must match ContainerPort. Most containers + do not need this. + format: int32 + type: integer + name: + description: If specified, this must be an IANA_SVC_NAME + and unique within the pod. Each named port in a pod must + have a unique name. Name for the port that can be referred + to by services. + type: string + protocol: + default: TCP + description: Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: 'Periodic probe of container service readiness. Container + will be removed from service endpoints if the probe fails. Cannot + be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + resources: + description: 'Compute Resources required by this container. Cannot + be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + 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 + securityContext: + description: 'SecurityContext defines the security options the + container should be run with. If set, the fields of SecurityContext + override the equivalent fields of PodSecurityContext. More info: + https://kubernetes.io/docs/tasks/configure-pod-container/security-context/' + properties: + allowPrivilegeEscalation: + description: 'AllowPrivilegeEscalation controls whether a + process can gain more privileges than its parent process. + This bool directly controls if the no_new_privs flag will + be set on the container process. AllowPrivilegeEscalation + is true always when the container is: 1) run as Privileged + 2) has CAP_SYS_ADMIN Note that this field cannot be set + when spec.os.name is windows.' + type: boolean + capabilities: + description: The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by the + container runtime. Note that this field cannot be set when + spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: Run container in privileged mode. Processes in + privileged containers are essentially equivalent to root + on the host. Defaults to false. Note that this field cannot + be set when spec.os.name is windows. + type: boolean + procMount: + description: procMount denotes the type of proc mount to use + for the containers. The default is DefaultProcMount which + uses the container runtime defaults for readonly paths and + masked paths. This requires the ProcMountType feature flag + to be enabled. Note that this field cannot be set when spec.os.name + is windows. + type: string + readOnlyRootFilesystem: + description: Whether this container has a read-only root filesystem. + Default is false. Note that this field cannot be set when + spec.os.name is windows. + type: boolean + runAsGroup: + description: The GID to run the entrypoint of the container + process. Uses runtime default if unset. May also be set + in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. Note that this field cannot be set when + spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a non-root + user. If true, the Kubelet will validate the image at runtime + to ensure that it does not run as UID 0 (root) and fail + to start the container if it does. If unset or false, no + such validation will be performed. May also be set in PodSecurityContext. If + set in both SecurityContext and PodSecurityContext, the + value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container + process. Defaults to user specified in image metadata if + unspecified. May also be set in PodSecurityContext. If + set in both SecurityContext and PodSecurityContext, the + value specified in SecurityContext takes precedence. Note + that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a random + SELinux context for each container. May also be set in + PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. Note that this field cannot be set when + spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by this container. + If seccomp options are provided at both the pod & container + level, the container options override the pod options. Note + that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile must + be preconfigured on the node to work. Must be a descending + path, relative to the kubelet's configured seccomp profile + location. Must only be set if type is "Localhost". + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - a + profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile + should be used. Unconfined - no profile should be applied." + type: string + required: + - type + type: object + windowsOptions: + description: The Windows specific settings applied to all + containers. If unspecified, the options from the PodSecurityContext + will be used. If set in both SecurityContext and PodSecurityContext, + the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is + linux. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named + by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. This field is + alpha-level and will only be honored by components that + enable the WindowsHostProcessContainers feature flag. + Setting this field without the feature flag will result + in errors when validating the Pod. All of a Pod's containers + must have the same effective HostProcess value (it is + not allowed to have a mix of HostProcess containers + and non-HostProcess containers). In addition, if HostProcess + is true then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set in + PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext + takes precedence. + type: string + type: object + type: object + startupProbe: + description: 'StartupProbe indicates that the Pod has successfully + initialized. If specified, no other probes are executed until + this completes successfully. If this probe fails, the Pod will + be restarted, just as if the livenessProbe failed. This can + be used to provide different probe parameters at the beginning + of a Pod''s lifecycle, when it might take a long time to load + data or warm a cache, than during steady-state operation. This + cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + stdin: + description: Whether this container should allocate a buffer for + stdin in the container runtime. If this is not set, reads from + stdin in the container will always result in EOF. Default is + false. + type: boolean + stdinOnce: + description: Whether the container runtime should close the stdin + channel after it has been opened by a single attach. When stdin + is true the stdin stream will remain open across multiple attach + sessions. If stdinOnce is set to true, stdin is opened on container + start, is empty until the first client attaches to stdin, and + then remains open and accepts data until the client disconnects, + at which time stdin is closed and remains closed until the container + is restarted. If this flag is false, a container processes that + reads from stdin will never receive an EOF. Default is false + type: boolean + terminationMessagePath: + description: 'Optional: Path at which the file to which the container''s + termination message will be written is mounted into the container''s + filesystem. Message written is intended to be brief final status, + such as an assertion failure message. Will be truncated by the + node if greater than 4096 bytes. The total message length across + all containers will be limited to 12kb. Defaults to /dev/termination-log. + Cannot be updated.' + type: string + terminationMessagePolicy: + description: Indicate how the termination message should be populated. + File will use the contents of terminationMessagePath to populate + the container status message on both success and failure. FallbackToLogsOnError + will use the last chunk of container log output if the termination + message file is empty and the container exited with an error. + The log output is limited to 2048 bytes or 80 lines, whichever + is smaller. Defaults to File. Cannot be updated. + type: string + tty: + description: Whether this container should allocate a TTY for + itself, also requires 'stdin' to be true. Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices to be + used by the container. + items: + description: volumeDevice describes a mapping of a raw block + device within a container. + properties: + devicePath: + description: devicePath is the path inside of the container + that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume within + a container. + properties: + mountPath: + description: Path within the container at which the volume + should be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are + propagated from the host to container and the other way + around. When not set, MountPropagationNone is used. This + field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise + (false or unspecified). Defaults to false. + type: boolean + subPath: + description: Path within the volume from which the container's + volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which + the container's volume should be mounted. Behaves similarly + to SubPath but environment variable references $(VAR_NAME) + are expanded using the container's environment. Defaults + to "" (volume's root). SubPathExpr and SubPath are mutually + exclusive. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: Container's working directory. If not specified, + the container runtime's default will be used, which might be + configured in the container image. Cannot be updated. + type: string + required: + - name + type: object + metadata: + description: Metadata details. + type: object + x-kubernetes-preserve-unknown-fields: true + selector: + description: Selector + type: string + required: + - addon + - container + type: object + status: + description: ExtensionStatus defines the observed state of Extension + properties: + observedGeneration: + description: The most recent generation observed by the controller. + format: int64 + type: integer + type: object + type: object served: true storage: true subresources: diff --git a/generated/crd/tackle.konveyor.io_tasks.yaml b/generated/crd/tackle.konveyor.io_tasks.yaml index e8dcb2cff..39da68bea 100644 --- a/generated/crd/tackle.konveyor.io_tasks.yaml +++ b/generated/crd/tackle.konveyor.io_tasks.yaml @@ -16,6 +16,51 @@ 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 + spec: + description: TaskSpec defines the desired state of Task + properties: + data: + description: Data object passed to the addon.. + type: object + x-kubernetes-preserve-unknown-fields: true + dependencies: + description: Dependencies + items: + type: string + type: array + priority: + description: Priority + type: integer + type: object + status: + description: TaskStatus defines the observed state of Task + 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: 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..1c162ae60 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,6 +43,7 @@ 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" diff --git a/k8s/api/tackle/v1alpha1/extension.go b/k8s/api/tackle/v1alpha1/extension.go index 4076a66e4..1ed9119b5 100644 --- a/k8s/api/tackle/v1alpha1/extension.go +++ b/k8s/api/tackle/v1alpha1/extension.go @@ -44,6 +44,7 @@ type ExtensionStatus 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" diff --git a/k8s/api/tackle/v1alpha1/task.go b/k8s/api/tackle/v1alpha1/task.go index 9ab658489..c699b4e94 100644 --- a/k8s/api/tackle/v1alpha1/task.go +++ b/k8s/api/tackle/v1alpha1/task.go @@ -41,6 +41,7 @@ type TaskStatus struct { // +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"` diff --git a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go index 2ab858602..d039768d0 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. diff --git a/k8s/api/tackle/v1alpha2/addon.go b/k8s/api/tackle/v1alpha2/addon.go new file mode 100644 index 000000000..bab8a9f5a --- /dev/null +++ b/k8s/api/tackle/v1alpha2/addon.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 ( + 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 +// +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"` + 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..b19d2eee1 --- /dev/null +++ b/k8s/api/tackle/v1alpha2/extension.go @@ -0,0 +1,67 @@ +/* +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 +// +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 +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..c074b672f --- /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" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:storageversion +// +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"` +} + +// +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..f1b042a9e --- /dev/null +++ b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,376 @@ +//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) +} + +// 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/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" ) From 6bf085ff5f57d0f335299df3d1b97e946a3e50d2 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Sat, 15 Jun 2024 13:29:36 -0700 Subject: [PATCH 3/4] checkpoint Signed-off-by: Jeff Ortel --- generated/crd/tackle.konveyor.io_addons.yaml | 18 +- .../crd/tackle.konveyor.io_extensions.yaml | 1241 +---------------- generated/crd/tackle.konveyor.io_tasks.yaml | 24 - k8s/api/tackle/v1alpha1/addon.go | 2 - k8s/api/tackle/v1alpha1/extension.go | 25 - k8s/api/tackle/v1alpha1/tackle.go | 6 +- k8s/api/tackle/v1alpha1/task.go | 32 - .../tackle/v1alpha1/zz_generated.deepcopy.go | 74 +- k8s/api/tackle/v1alpha2/addon.go | 2 - k8s/api/tackle/v1alpha2/extension.go | 2 - k8s/api/tackle/v1alpha2/tackle.go | 6 +- .../tackle/v1alpha2/zz_generated.deepcopy.go | 2 + 12 files changed, 14 insertions(+), 1420 deletions(-) diff --git a/generated/crd/tackle.konveyor.io_addons.yaml b/generated/crd/tackle.konveyor.io_addons.yaml index be6fa1390..76ccf4c6a 100644 --- a/generated/crd/tackle.konveyor.io_addons.yaml +++ b/generated/crd/tackle.konveyor.io_addons.yaml @@ -15,14 +15,7 @@ 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: @@ -94,14 +87,7 @@ spec: storage: false subresources: status: {} - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha2 + - name: v1alpha2 schema: openAPIV3Schema: properties: diff --git a/generated/crd/tackle.konveyor.io_extensions.yaml b/generated/crd/tackle.konveyor.io_extensions.yaml index 061f18cc2..af47906ad 100644 --- a/generated/crd/tackle.konveyor.io_extensions.yaml +++ b/generated/crd/tackle.konveyor.io_extensions.yaml @@ -15,14 +15,7 @@ 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: @@ -38,1242 +31,12 @@ spec: type: string metadata: type: object - spec: - description: ExtensionSpec defines the desired state of Extension - properties: - addon: - description: Addon compatibility. - type: string - container: - description: Container details. - properties: - args: - description: 'Arguments to the entrypoint. The container image''s - CMD is used if this is not provided. Variable references $(VAR_NAME) - are expanded using the container''s environment. If a variable - cannot be resolved, the reference in the input string will be - unchanged. Double $$ are reduced to a single $, which allows - for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references - will never be expanded, regardless of whether the variable exists - or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' - items: - type: string - type: array - command: - description: 'Entrypoint array. Not executed within a shell. The - container image''s ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container''s - environment. If a variable cannot be resolved, the reference - in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: - i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether - the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' - items: - type: string - type: array - env: - description: List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable present - in a Container. - properties: - name: - description: Name of the environment variable. Must be a - C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in - the container and any service environment variables. If - a variable cannot be resolved, the reference in the input - string will be unchanged. Double $$ are reduced to a single - $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless - of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. - Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, - metadata.namespace, `metadata.labels['''']`, - `metadata.annotations['''']`, spec.nodeName, - spec.serviceAccountName, status.hostIP, status.podIP, - status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath - is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the - specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: 'Selects a resource of the container: only - resources limits and requests (limits.cpu, limits.memory, - limits.ephemeral-storage, requests.cpu, requests.memory - and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, - optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the - exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in the pod's - namespace - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: List of sources to populate environment variables - in the container. The keys defined within a source must be a - C_IDENTIFIER. All invalid keys will be reported as an event - when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take - precedence. Values defined by an Env with a duplicate key will - take precedence. Cannot be updated. - items: - description: EnvFromSource represents the source of a set of - ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend to each key - in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: 'Container image name. More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management - to default or override container images in workload controllers - like Deployments and StatefulSets.' - type: string - imagePullPolicy: - description: 'Image pull policy. One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent - otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images' - type: string - lifecycle: - description: Actions that the management system should take in - response to container lifecycle events. Cannot be updated. - properties: - postStart: - description: 'PostStart is called immediately after a container - is created. If the handler fails, the container is terminated - and restarted according to its restart policy. Other management - of the container blocks until the hook completes. More info: - https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute - inside the container, the working directory for - the command is root ('/') in the container's filesystem. - The command is simply exec'd, it is not run inside - a shell, so traditional shell instructions ('|', - etc) won't work. To use a shell, you need to explicitly - call out to that shell. Exit status of 0 is treated - as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to - the pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: Deprecated. TCPSocket is NOT supported as - a LifecycleHandler and kept for the backward compatibility. - There are no validation of this field and lifecycle - hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: 'PreStop is called immediately before a container - is terminated due to an API request or management event - such as liveness/startup probe failure, preemption, resource - contention, etc. The handler is not called if the container - crashes or exits. The Pod''s termination grace period countdown - begins before the PreStop hook is executed. Regardless of - the outcome of the handler, the container will eventually - terminate within the Pod''s termination grace period (unless - delayed by finalizers). Other management of the container - blocks until the hook completes or until the termination - grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute - inside the container, the working directory for - the command is root ('/') in the container's filesystem. - The command is simply exec'd, it is not run inside - a shell, so traditional shell instructions ('|', - etc) won't work. To use a shell, you need to explicitly - call out to that shell. Exit status of 0 is treated - as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to - the pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: Deprecated. TCPSocket is NOT supported as - a LifecycleHandler and kept for the backward compatibility. - There are no validation of this field and lifecycle - hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: 'Periodic probe of container liveness. Container - will be restarted if the probe fails. Cannot be updated. More - info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - name: - description: Name of the container specified as a DNS_LABEL. Each - container in a pod must have a unique name (DNS_LABEL). Cannot - be updated. - type: string - ports: - description: List of ports to expose from the container. Not specifying - a port here DOES NOT prevent that port from being exposed. Any - port which is listening on the default "0.0.0.0" address inside - a container will be accessible from the network. Modifying this - array with strategic merge patch may corrupt the data. For more - information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network port in a single - container. - properties: - containerPort: - description: Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external port to. - type: string - hostPort: - description: Number of port to expose on the host. If specified, - this must be a valid port number, 0 < x < 65536. If HostNetwork - is specified, this must match ContainerPort. Most containers - do not need this. - format: int32 - type: integer - name: - description: If specified, this must be an IANA_SVC_NAME - and unique within the pod. Each named port in a pod must - have a unique name. Name for the port that can be referred - to by services. - type: string - protocol: - default: TCP - description: Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: 'Periodic probe of container service readiness. Container - will be removed from service endpoints if the probe fails. Cannot - be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - resources: - description: 'Compute Resources required by this container. Cannot - be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - 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 - securityContext: - description: 'SecurityContext defines the security options the - container should be run with. If set, the fields of SecurityContext - override the equivalent fields of PodSecurityContext. More info: - https://kubernetes.io/docs/tasks/configure-pod-container/security-context/' - properties: - allowPrivilegeEscalation: - description: 'AllowPrivilegeEscalation controls whether a - process can gain more privileges than its parent process. - This bool directly controls if the no_new_privs flag will - be set on the container process. AllowPrivilegeEscalation - is true always when the container is: 1) run as Privileged - 2) has CAP_SYS_ADMIN Note that this field cannot be set - when spec.os.name is windows.' - type: boolean - capabilities: - description: The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the - container runtime. Note that this field cannot be set when - spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - type: object - privileged: - description: Run container in privileged mode. Processes in - privileged containers are essentially equivalent to root - on the host. Defaults to false. Note that this field cannot - be set when spec.os.name is windows. - type: boolean - procMount: - description: procMount denotes the type of proc mount to use - for the containers. The default is DefaultProcMount which - uses the container runtime defaults for readonly paths and - masked paths. This requires the ProcMountType feature flag - to be enabled. Note that this field cannot be set when spec.os.name - is windows. - type: string - readOnlyRootFilesystem: - description: Whether this container has a read-only root filesystem. - Default is false. Note that this field cannot be set when - spec.os.name is windows. - type: boolean - runAsGroup: - description: The GID to run the entrypoint of the container - process. Uses runtime default if unset. May also be set - in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. Note that this field cannot be set when - spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: Indicates that the container must run as a non-root - user. If true, the Kubelet will validate the image at runtime - to ensure that it does not run as UID 0 (root) and fail - to start the container if it does. If unset or false, no - such validation will be performed. May also be set in PodSecurityContext. If - set in both SecurityContext and PodSecurityContext, the - value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: The UID to run the entrypoint of the container - process. Defaults to user specified in image metadata if - unspecified. May also be set in PodSecurityContext. If - set in both SecurityContext and PodSecurityContext, the - value specified in SecurityContext takes precedence. Note - that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random - SELinux context for each container. May also be set in - PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. Note that this field cannot be set when - spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies - to the container. - type: string - role: - description: Role is a SELinux role label that applies - to the container. - type: string - type: - description: Type is a SELinux type label that applies - to the container. - type: string - user: - description: User is a SELinux user label that applies - to the container. - type: string - type: object - seccompProfile: - description: The seccomp options to use by this container. - If seccomp options are provided at both the pod & container - level, the container options override the pod options. Note - that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: localhostProfile indicates a profile defined - in a file on the node should be used. The profile must - be preconfigured on the node to work. Must be a descending - path, relative to the kubelet's configured seccomp profile - location. Must only be set if type is "Localhost". - type: string - type: - description: "type indicates which kind of seccomp profile - will be applied. Valid options are: \n Localhost - a - profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile - should be used. Unconfined - no profile should be applied." - type: string - required: - - type - type: object - windowsOptions: - description: The Windows specific settings applied to all - containers. If unspecified, the options from the PodSecurityContext - will be used. If set in both SecurityContext and PodSecurityContext, - the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is - linux. - properties: - gmsaCredentialSpec: - description: GMSACredentialSpec is where the GMSA admission - webhook (https://github.com/kubernetes-sigs/windows-gmsa) - inlines the contents of the GMSA credential spec named - by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name of the - GMSA credential spec to use. - type: string - hostProcess: - description: HostProcess determines if a container should - be run as a 'Host Process' container. This field is - alpha-level and will only be honored by components that - enable the WindowsHostProcessContainers feature flag. - Setting this field without the feature flag will result - in errors when validating the Pod. All of a Pod's containers - must have the same effective HostProcess value (it is - not allowed to have a mix of HostProcess containers - and non-HostProcess containers). In addition, if HostProcess - is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: The UserName in Windows to run the entrypoint - of the container process. Defaults to the user specified - in image metadata if unspecified. May also be set in - PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. - type: string - type: object - type: object - startupProbe: - description: 'StartupProbe indicates that the Pod has successfully - initialized. If specified, no other probes are executed until - this completes successfully. If this probe fails, the Pod will - be restarted, just as if the livenessProbe failed. This can - be used to provide different probe parameters at the beginning - of a Pod''s lifecycle, when it might take a long time to load - data or warm a cache, than during steady-state operation. This - cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - stdin: - description: Whether this container should allocate a buffer for - stdin in the container runtime. If this is not set, reads from - stdin in the container will always result in EOF. Default is - false. - type: boolean - stdinOnce: - description: Whether the container runtime should close the stdin - channel after it has been opened by a single attach. When stdin - is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container - start, is empty until the first client attaches to stdin, and - then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container - is restarted. If this flag is false, a container processes that - reads from stdin will never receive an EOF. Default is false - type: boolean - terminationMessagePath: - description: 'Optional: Path at which the file to which the container''s - termination message will be written is mounted into the container''s - filesystem. Message written is intended to be brief final status, - such as an assertion failure message. Will be truncated by the - node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. Defaults to /dev/termination-log. - Cannot be updated.' - type: string - terminationMessagePolicy: - description: Indicate how the termination message should be populated. - File will use the contents of terminationMessagePath to populate - the container status message on both success and failure. FallbackToLogsOnError - will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever - is smaller. Defaults to File. Cannot be updated. - type: string - tty: - description: Whether this container should allocate a TTY for - itself, also requires 'stdin' to be true. Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices to be - used by the container. - items: - description: volumeDevice describes a mapping of a raw block - device within a container. - properties: - devicePath: - description: devicePath is the path inside of the container - that the device will be mapped to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of a Volume within - a container. - properties: - mountPath: - description: Path within the container at which the volume - should be mounted. Must not contain ':'. - type: string - mountPropagation: - description: mountPropagation determines how mounts are - propagated from the host to container and the other way - around. When not set, MountPropagationNone is used. This - field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: Mounted read-only if true, read-write otherwise - (false or unspecified). Defaults to false. - type: boolean - subPath: - description: Path within the volume from which the container's - volume should be mounted. Defaults to "" (volume's root). - type: string - subPathExpr: - description: Expanded path within the volume from which - the container's volume should be mounted. Behaves similarly - to SubPath but environment variable references $(VAR_NAME) - are expanded using the container's environment. Defaults - to "" (volume's root). SubPathExpr and SubPath are mutually - exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: Container's working directory. If not specified, - the container runtime's default will be used, which might be - configured in the container image. Cannot be updated. - type: string - required: - - name - type: object - metadata: - description: Metadata details. - type: object - x-kubernetes-preserve-unknown-fields: true - selector: - description: Selector - type: string - required: - - addon - - container - type: object - status: - description: ExtensionStatus defines the observed state of Extension - 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: {} - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: READY - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha2 + - name: v1alpha2 schema: openAPIV3Schema: properties: diff --git a/generated/crd/tackle.konveyor.io_tasks.yaml b/generated/crd/tackle.konveyor.io_tasks.yaml index 39da68bea..9f8129f46 100644 --- a/generated/crd/tackle.konveyor.io_tasks.yaml +++ b/generated/crd/tackle.konveyor.io_tasks.yaml @@ -31,30 +31,6 @@ spec: type: string metadata: type: object - spec: - description: TaskSpec defines the desired state of Task - properties: - data: - description: Data object passed to the addon.. - type: object - x-kubernetes-preserve-unknown-fields: true - dependencies: - description: Dependencies - items: - type: string - type: array - priority: - description: Priority - type: integer - type: object - status: - description: TaskStatus defines the observed state of Task - properties: - observedGeneration: - description: The most recent generation observed by the controller. - format: int64 - type: integer - type: object type: object served: false storage: false diff --git a/k8s/api/tackle/v1alpha1/addon.go b/k8s/api/tackle/v1alpha1/addon.go index 1c162ae60..3338ab938 100644 --- a/k8s/api/tackle/v1alpha1/addon.go +++ b/k8s/api/tackle/v1alpha1/addon.go @@ -45,8 +45,6 @@ type AddonStatus struct { // +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 1ed9119b5..cc39b2eb3 100644 --- a/k8s/api/tackle/v1alpha1/extension.go +++ b/k8s/api/tackle/v1alpha1/extension.go @@ -17,42 +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 c699b4e94..c44ac0c2c 100644 --- a/k8s/api/tackle/v1alpha1/task.go +++ b/k8s/api/tackle/v1alpha1/task.go @@ -18,26 +18,8 @@ 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 @@ -46,20 +28,6 @@ type TaskStatus struct { 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 d039768d0..ec96a5bfa 100644 --- a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go +++ b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go @@ -120,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. @@ -174,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. @@ -268,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. @@ -321,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 index bab8a9f5a..d9f1bb23a 100644 --- a/k8s/api/tackle/v1alpha2/addon.go +++ b/k8s/api/tackle/v1alpha2/addon.go @@ -53,8 +53,6 @@ type AddonStatus struct { // +k8s:openapi-gen=true // +kubebuilder:storageversion // +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/v1alpha2/extension.go b/k8s/api/tackle/v1alpha2/extension.go index b19d2eee1..cbd02d138 100644 --- a/k8s/api/tackle/v1alpha2/extension.go +++ b/k8s/api/tackle/v1alpha2/extension.go @@ -46,8 +46,6 @@ type ExtensionStatus struct { // +k8s:openapi-gen=true // +kubebuilder:storageversion // +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"` diff --git a/k8s/api/tackle/v1alpha2/tackle.go b/k8s/api/tackle/v1alpha2/tackle.go index c074b672f..733792df6 100644 --- a/k8s/api/tackle/v1alpha2/tackle.go +++ b/k8s/api/tackle/v1alpha2/tackle.go @@ -18,6 +18,7 @@ package v1alpha2 import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) // +genclient @@ -25,12 +26,11 @@ import ( // +k8s:openapi-gen=true // +kubebuilder:storageversion // +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/v1alpha2/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go index f1b042a9e..244028496 100644 --- a/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go +++ b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go @@ -228,6 +228,8 @@ 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. From 7ae0f7df3cf75923998bb8e650f2dd465338e66f Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Sat, 15 Jun 2024 13:39:14 -0700 Subject: [PATCH 4/4] checkpoint Signed-off-by: Jeff Ortel --- controller/addon.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controller/addon.go b/controller/addon.go index e81ddffb0..7754eaa4a 100644 --- a/controller/addon.go +++ b/controller/addon.go @@ -122,6 +122,8 @@ func (r *Reconciler) alpha2Migration(addon *api.Addon) (migrated bool, err error 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 &&