This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 7534015a340c1f2b73d41b842ff2b1bbd3954a58 Author: Mike Dobozy <[email protected]> AuthorDate: Sun Apr 26 11:26:36 2020 -0400 initial fix for #1358. --- addons/zz_desc_generated.go | 1 + cmd/util/doc-gen/generators/generators.go | 3 +- cmd/util/doc-gen/generators/traitmetadatagen.go | 174 ++++++ cmd/util/doc-gen/main.go | 1 + deploy/resources.go | 32 +- deploy/traits.yaml | 708 ++++++++++++++++++++++++ docs/modules/ROOT/nav.adoc | 2 - docs/modules/ROOT/pages/traits/cron.adoc | 2 +- docs/modules/ROOT/pages/traits/gc.adoc | 2 +- docs/modules/ROOT/pages/traits/knative.adoc | 4 + docs/modules/ROOT/pages/traits/traits.adoc | 2 - pkg/cmd/trait_help.go | 50 +- pkg/trait/zz_desc_generated.go | 1 + 13 files changed, 956 insertions(+), 26 deletions(-) diff --git a/addons/zz_desc_generated.go b/addons/zz_desc_generated.go new file mode 100644 index 0000000..1890561 --- /dev/null +++ b/addons/zz_desc_generated.go @@ -0,0 +1 @@ +package addons diff --git a/cmd/util/doc-gen/generators/generators.go b/cmd/util/doc-gen/generators/generators.go index 84a898b..9c10088 100644 --- a/cmd/util/doc-gen/generators/generators.go +++ b/cmd/util/doc-gen/generators/generators.go @@ -29,6 +29,7 @@ import ( // CustomArgs -- type CustomArgs struct { DocDir string + DeployDir string TraitPath string NavPath string ListPath string @@ -59,7 +60,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) (packag PackageName: strings.Split(filepath.Base(pkg.Path), ".")[0], PackagePath: pkg.Path, GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { - generators = append(generators, NewTraitDocGen(arguments)) + generators = append(generators, NewTraitDocGen(arguments), NewtraitMetaDataGen(arguments)) return generators }, }) diff --git a/cmd/util/doc-gen/generators/traitmetadatagen.go b/cmd/util/doc-gen/generators/traitmetadatagen.go new file mode 100644 index 0000000..ca892ae --- /dev/null +++ b/cmd/util/doc-gen/generators/traitmetadatagen.go @@ -0,0 +1,174 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You 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 generators + +import ( + "fmt" + "io" + "os" + "path" + "reflect" + "gopkg.in/yaml.v2" + "strings" + + "k8s.io/gengo/args" + "k8s.io/gengo/generator" + "k8s.io/gengo/types" +) + +// traitMetaDataGen produces YAML documentation about trait descriptions +type traitMetaDataGen struct { + generator.DefaultGen + arguments *args.GeneratorArgs + Root *traitMetaDataRoot +} + +type traitMetaDataRoot struct { + Traits []traitMetaData `yaml:traits` +} + +type traitMetaData struct { + Name string `yaml:"name"` + Platform bool `yaml:platform` + Profiles []string `yaml:profiles` + Description string `yaml:"description"` + Properties []traitPropertyMetaData `yaml:"properties"` +} + +type traitPropertyMetaData struct { + Name string `yaml:"name"` + TypeName string `yaml:"type"` + Description string `yaml:"description"` +} + +// NewtraitMetaDataGen -- +func NewtraitMetaDataGen(arguments *args.GeneratorArgs) generator.Generator { + return &traitMetaDataGen { + DefaultGen: generator.DefaultGen{}, + arguments: arguments, + Root: &traitMetaDataRoot{}, + } +} + +func (g *traitMetaDataGen) Filename() string { + return "zz_desc_generated.go" +} + +func (g *traitMetaDataGen) Filter(context *generator.Context, t *types.Type) bool { + for _, c := range t.CommentLines { + if strings.Contains(c, tagTrait) { + return true + } + } + return false +} + +func (g *traitMetaDataGen) GenerateType(context *generator.Context, t *types.Type, out io.Writer) error { + traitID := g.getTraitID(t) + td := &traitMetaData{} + g.buildDescription(t, traitID, td) + g.buildFields(t, traitID, td) + g.Root.Traits = append(g.Root.Traits, *td) + return nil +} + +func (g *traitMetaDataGen) Finalize(c *generator.Context, w io.Writer) error { + + deployDir := g.arguments.CustomArgs.(*CustomArgs).DeployDir + traitFile := "traits.yaml" + filename := path.Join(deployDir, traitFile) + + var file *os.File + var err error + if file, err = os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0777); err != nil { + return err + } + if err = file.Truncate(0); err != nil { + return err + } + defer file.Close() + + data, err := yaml.Marshal(g.Root) + if err != nil { + fmt.Fprintf(file, "error: %v", err) + } + fmt.Fprintf(file, "%s", string(data)) + return nil +} + +func (g *traitMetaDataGen) getTraitID(t *types.Type) string { + for _, s := range t.CommentLines { + if strings.Contains(s, tagTrait) { + matches := tagTraitID.FindStringSubmatch(s) + if len(matches) < 2 { + panic(fmt.Sprintf("unable to extract trait ID from tag line `%s`", s)) + } + return matches[1] + } + } + panic(fmt.Sprintf("trait ID not found in type %s", t.Name.Name)) +} + +func (g *traitMetaDataGen) buildDescription(t *types.Type, traitID string, td *traitMetaData) { + var desc = []string(nil) + desc = append(desc, g.filterOutTagsAndComments(t.CommentLines)...) + td.Name = traitID + td.Description = strings.Join(desc, "") + td.Profiles = determineProfiles(traitID) + td.Platform = isPlatformTrait(traitID) +} + +func (g *traitMetaDataGen) buildFields(t *types.Type, traitID string, td *traitMetaData) { + if len(t.Members) > 1 { + var res = []string(nil) + g.buildMembers(t, traitID, &res, td) + } +} + +func (g *traitMetaDataGen) buildMembers(t *types.Type, traitID string, content *[]string, td *traitMetaData) { + for _, m := range t.Members { + res := append([]string(nil), *content...) + prop := reflect.StructTag(m.Tags).Get("property") + if prop != "" { + if strings.Contains(prop, "squash") { + g.buildMembers(m.Type, traitID, &res, td) + } else { + pd := traitPropertyMetaData{} + pd.Name = prop + pd.TypeName = strings.TrimPrefix(m.Type.Name.Name, "*") + + for _, line := range filterOutTagsAndComments(m.CommentLines) { + res = append(res, line) + } + pd.Description = strings.Join(res, "") + td.Properties = append(td.Properties, pd) + } + } + } +} + +func (g *traitMetaDataGen) filterOutTagsAndComments(comments []string) []string { + res := make([]string, 0, len(comments)) + for _, l := range comments { + if !strings.HasPrefix(strings.TrimLeft(l, " \t"), "+") && + !strings.HasPrefix(strings.TrimLeft(l, " \t"), "TODO:") { + res = append(res, l) + } + } + return res +} diff --git a/cmd/util/doc-gen/main.go b/cmd/util/doc-gen/main.go index 95732e8..84e7515 100644 --- a/cmd/util/doc-gen/main.go +++ b/cmd/util/doc-gen/main.go @@ -31,6 +31,7 @@ func main() { // Custom args. customArgs := &generators.CustomArgs{} pflag.CommandLine.StringVar(&customArgs.DocDir, "doc-dir", "./docs", "Root of the document directory.") + pflag.CommandLine.StringVar(&customArgs.DeployDir, "deploy-dir", "./deploy", "Root of the deploy directory.") pflag.CommandLine.StringVar(&customArgs.TraitPath, "traits-path", "modules/ROOT/pages/traits", "Path to the traits directory.") pflag.CommandLine.StringVar(&customArgs.NavPath, "nav-path", "modules/ROOT/nav.adoc", "Path to the navigation file.") pflag.CommandLine.StringVar(&customArgs.ListPath, "list-path", "modules/ROOT/pages/traits/traits.adoc", "Path to the trait list file.") diff --git a/deploy/resources.go b/deploy/resources.go index 04a586e..430db9f 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -298,44 +298,51 @@ var assets = func() http.FileSystem { "/templates/groovy.tmpl": &vfsgen۰CompressedFileInfo{ name: "groovy.tmpl", modTime: time.Time{}, - uncompressedSize: 207, + uncompressedSize: 1010, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\xc1\x6a\xc3\x30\x0c\x86\xef\x7e\x8a\xff\x30\xb0\x03\xdb\x9c\x5d\x0d\x61\xb0\x5d\x36\xf6\x00\x3b\x9b\x46\x71\x4d\xed\x28\x28\x4e\x69\x28\x7d\xf7\xe2\xa6\x39\xea\x43\xdf\x27\x59\x8b\x83\xcf\x94\xde\x4e\x0e\xc9\x8f\x61\xf1\x81\xba\x20\xcc\xe7\x55\x29\x6b\xf1\x2f\xb1\x10\x56\x5e\x04\xc2\x4b\xa1\x19\x47\x12\x7a\xc5\xc0\x02\xba\xf8\x3c\x25\x72\x6a\x10\xce\x46\x97\x98\x49\xdc\xe6\x7e\x4e\x24\x91\xfb\xee\xa3\x6d\x5b\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x53\x5d\x6f\xea\x46\x10\x7d\xf7\xaf\x38\x42\x95\x80\x2b\x2e\xa6\x7d\xa4\xba\xaa\x08\x01\xc5\x4a\x04\x52\x4c\x1a\xe5\x71\xb1\x07\x7b\x14\x7b\xc7\x9d\x5d\xc7\x41\x55\xff\x7b\xb5\x36\xa4\x54\xd7\x6f\xbb\x9e\x39\x1f\x7b\x66\xe2\x18\x99\xa9\xa9\xfa\xfe\xbe\x44\x65\x6c\xd1\x9a\x82\x7e\x14\x2a\xf2\x71\x8e\xe2\x6f\x11\xbe\xe1\x89\x33\xb2\x8e\x72\x78\x81\x2f\x09\xab\xc6\x64\x25\x21\x95\x93\xef\x8c\x12\xb6\xd2\xda\xdc\x78\x [...] }, "/templates/java.tmpl": &vfsgen۰CompressedFileInfo{ name: "java.tmpl", modTime: time.Time{}, - uncompressedSize: 390, + uncompressedSize: 1193, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x90\x41\x4b\xf3\x40\x10\x86\xef\xfb\x2b\x5e\xc2\x77\x48\xe1\x33\xa9\xd7\x94\xa2\x54\x04\x45\x50\xf0\xe2\x79\x9b\x9d\xa4\xa3\x9b\x4c\x98\x6c\x6a\x4b\xc8\x7f\x97\x8d\x01\xb3\xb7\x9d\x7d\xf6\x79\x79\x27\xcf\x51\xda\x86\xfc\xcd\x57\x01\x6f\xdb\x7a\xb0\x35\xed\x3f\xed\xd9\x1a\xc3\x4d\x27\x1a\x20\x5a\x67\xb6\xb3\xe5\x89\xb2\x99\xcc\x8e\x03\x7b\x47\x9a\xbd\xcb\x10\xe8\xf0\x7b\xd9\x19\xd3\x0d\x47\xcf\x25\x4a\x6f\xfb\x1e\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x94\x41\x6f\xdb\x46\x10\x85\xef\xfc\x15\x0f\x44\x0f\x72\xe0\x90\x6e\x8f\x32\x82\x56\x76\x64\x84\x48\x20\x01\xa6\x52\x23\xc7\x15\x39\x22\xa7\x59\xee\xb0\xb3\x4b\xd3\x82\xa0\xff\x5e\x2c\x25\x25\x2a\xa2\x1b\xc9\xd9\x6f\xe6\xcd\x7b\xab\x3c\x47\x65\x3a\xb2\xef\xbf\xcf\x61\x8d\x6b\x06\xd3\xd0\x87\x7f\xcc\xab\x49\xf2\x77\x09\xde\xe1\x0b\x57\xe4\x3c\xd5\x08\x82\xd0\x12\x16\xbd\xa9\x5a\x42\x29\xbb\x30\x1a\x25\x3c\xc9\xe0\x [...] }, "/templates/js.tmpl": &vfsgen۰CompressedFileInfo{ name: "js.tmpl", modTime: time.Time{}, - uncompressedSize: 195, + uncompressedSize: 991, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\x8e\xb1\x6a\xc3\x30\x14\x45\x77\x7d\xc5\x1d\x0a\x92\xa1\xad\xdc\x55\x60\x0a\xed\xd2\xd2\x0f\xe8\x2c\xe2\x67\x47\x8e\xe4\x67\x9e\x64\x88\x09\xf9\xf7\xa0\x24\x1e\xef\x81\x73\xb8\xd6\xe2\xe0\x13\xc5\xb7\x93\x43\xf4\xf3\xb8\xfa\x91\xba\x29\x2b\x65\x2d\xfe\x25\x14\xc2\xc6\xab\x40\x78\x2d\x94\x71\x24\xa1\x57\x0c\x2c\xa0\xb3\x4f\x4b\x24\xa7\x06\xe1\x64\x74\x09\x89\xc4\x4d\xf9\x73\x21\x09\xdc\x77\x1f\x6d\xdb\xea\x46\x01\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x93\x51\x6f\xea\x38\x10\x85\xdf\xf9\x15\x47\x68\x25\x40\xa2\x09\xbb\x8f\xac\xaa\x15\xa5\xa0\x46\xad\x40\x6a\xe8\x56\x7d\x34\xc9\x90\x4c\x9b\x78\xb2\x63\x67\x53\x74\x75\xff\xfb\x95\x03\xf4\x72\x75\xf3\x66\xc7\xf3\xcd\x39\x3e\xe3\x38\x46\x66\x6a\xaa\x6e\x3e\xe6\xa8\x8c\x2d\x5a\x53\xd0\xed\xbb\x1b\xc4\x31\x9e\x38\x23\xeb\x28\x87\x17\xf8\x92\xb0\x68\x4c\x56\x12\x52\x39\xf8\xce\x28\x61\x2d\xad\xcd\x8d\x67\xb1\x18\x2f\x [...] }, "/templates/kts.tmpl": &vfsgen۰CompressedFileInfo{ name: "kts.tmpl", modTime: time.Time{}, - uncompressedSize: 200, + uncompressedSize: 1003, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\x8e\x41\xca\xc2\x30\x10\x46\xf7\x39\xc5\x10\xfe\x45\x0a\xbf\xa6\x6e\x03\x45\xd0\x8d\xe2\x01\xdc\xb8\x09\x76\x5a\x43\x27\x9d\x32\x4d\xc1\x22\xde\x5d\x62\x5c\xbe\x61\xde\xe3\xb3\x16\xee\x3e\x22\x6d\x06\x07\xe4\xc7\x7e\xf1\x3d\x36\x03\x27\x0a\xa3\x52\xd6\xc2\x55\x42\x42\x58\x79\x11\x10\x5e\x12\xce\xf0\x40\xc1\x7f\xe8\x58\x00\x9f\x3e\x4e\x84\x4e\x75\xc2\xd1\xe8\x14\x22\x8a\x2b\xee\x7e\x42\x09\xdc\x36\xbb\xba\xae\x75\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x93\x41\x6f\xda\x4e\x10\xc5\xef\xfe\x14\x4f\xd6\xff\x00\x11\xc1\xfc\x7b\xa4\x8a\x2a\x42\x40\xb1\x12\x81\x14\x93\x46\x91\x7a\x59\xec\xc1\x1e\x65\xbd\xe3\xee\xae\xeb\xa0\xaa\xdf\xbd\x5a\x1b\x52\xaa\x72\x5b\x3c\xf3\x9b\xf7\xf6\xcd\x26\x09\x72\x55\x93\xbe\x7e\x9b\x43\x2b\x53\xb6\xaa\xa4\x9b\x37\xf1\x9a\x4d\x94\x5c\x45\xb8\xc2\x23\xe7\x64\x1c\x15\xf0\x02\x5f\x11\x16\x8d\xca\x2b\x42\x26\x07\xdf\x29\x4b\x58\x4b\x6b\x0a\x [...] }, "/templates/xml.tmpl": &vfsgen۰CompressedFileInfo{ name: "xml.tmpl", modTime: time.Time{}, - uncompressedSize: 597, + uncompressedSize: 1408, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x92\x4f\x4b\xf4\x30\x10\xc6\xcf\x6f\x3f\xc5\xbc\xe1\x3d\xbe\x69\xba\x7a\x91\x92\x76\x41\x41\x14\xd7\x93\x8a\x5e\x43\x3b\xdb\x06\xf3\xa7\x24\xa9\xcd\x22\x7e\x77\x69\xba\xae\x2b\x5e\x74\x4e\x2d\x33\xbf\xe7\x99\x79\x08\x5f\x47\xad\xe0\x05\x9d\x97\xd6\x54\x64\x95\x17\x04\xd0\x34\xb6\x95\xa6\xab\xc8\xc3\xfd\x25\x3d\x23\xeb\x3a\xe3\x7f\x29\x85\x46\x68\x54\xf4\xb9\x04\x25\x4c\x37\x8a\x0e\xab\x99\xa5\xb4\xce\x32\xee\xec\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x54\xc1\x8e\xdb\x36\x10\x3d\xd7\x5f\xf1\x2a\xf4\x90\x00\xb6\xe4\x4d\x2f\x85\x6b\x7b\xe1\x6c\xd6\x88\x90\xad\x0d\xac\xbc\xdd\xe6\xc8\x95\xc6\xd2\x20\x14\xa9\x92\x54\x24\xa3\xe8\xbf\x17\xa4\x6c\xaf\x82\x00\x05\xa2\x93\x88\x99\x79\xf3\xde\xbc\x21\x97\xb7\x7d\x2d\xf1\x95\x8c\x65\xad\x56\xd1\x4d\x3c\x8f\x40\x2a\xd7\x05\xab\x72\x15\x3d\x1d\xb6\xb3\xdf\xa2\xdb\xf5\x64\xf9\xf3\x6c\x86\x5c\xd4\x24\x67\x5f\x16\x90\x42\x95\x [...] }, "/templates/yaml.tmpl": &vfsgen۰CompressedFileInfo{ name: "yaml.tmpl", modTime: time.Time{}, - uncompressedSize: 230, + uncompressedSize: 1168, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x44\x8e\x31\x4e\x04\x31\x0c\x45\xfb\x9c\xe2\x2b\xdb\x32\xd2\xd0\x5a\xa2\xa2\x41\xe2\x00\xd4\x66\xd7\x33\x44\x24\x71\xe4\x38\x12\x73\x7b\x94\x1d\xc1\xba\xfc\x7e\xf6\x7f\x17\x5c\xb9\x48\x5e\xbe\x09\x99\xeb\x3e\x78\x97\x97\x83\x4b\x0e\xe1\x82\x0f\x4b\x2e\x38\x74\x18\x4c\x87\x4b\xc7\x97\x98\x3c\x61\x53\x83\xfc\x70\x69\x59\x28\x2c\xd8\x4c\x0b\x05\x00\x18\x96\x08\xd1\x53\x11\xa3\xf9\x24\xde\xd3\xc6\xc6\x45\x5c\xac\x9f\x14\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x54\x4d\x8f\xe3\x36\x0c\xbd\xfb\x57\x3c\xd8\x97\x5d\x20\x5f\xed\xd1\x45\x0f\x69\x36\xc1\x1a\xbb\x48\x80\x71\xb6\x83\x39\x2a\x36\x63\x13\x23\x8b\x2e\x25\xd7\x93\x7f\x5f\xc8\x49\xe6\x03\xbd\x0e\x6f\x96\x28\xf2\x3d\xbe\x47\x67\xa8\x4c\x47\x76\xfe\x9c\xc3\x1a\xd7\x0c\xa6\xa1\x3f\x2f\xa6\xb3\x49\x86\xf9\xe7\x45\x92\xe1\x27\x57\xe4\x3c\xd5\x08\x82\xd0\x12\xd6\xbd\xa9\x5a\x42\x29\xe7\x30\x1a\x25\xec\x64\x70\xb5\x09\x2c\x [...] + }, + "/traits.yaml": &vfsgen۰CompressedFileInfo{ + name: "traits.yaml", + modTime: time.Time{}, + uncompressedSize: 28770, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x7d\x6d\x73\x1b\x37\x92\xf0\x77\xff\x0a\x94\x9e\x0f\x7a\x59\x72\x64\x67\x6b\x37\x59\x3d\xe5\x4a\xe9\x94\x64\x57\x49\x6c\xeb\x2c\x27\x7b\x57\xb9\xd4\x12\x9c\x69\x72\x60\x62\x80\x59\x00\x43\x99\xfb\xe9\xfe\xc6\xfd\xbd\xfb\x25\x57\xdd\x78\x19\xcc\x90\x92\x28\x3b\x4a\x59\xf1\x87\x88\xd4\x4c\xa3\xbb\xd1\xef\xdd\x80\x9c\xe1\xc2\xd9\xb3\x67\x53\xa6\x78\x03\x67\x8c\x2f\x16\x42\x09\xb7\x79\xc6\x58\x2b\xb9\x5b\x68\xd3\x9c\x [...] }, "/user-cluster-role.yaml": &vfsgen۰CompressedFileInfo{ name: "user-cluster-role.yaml", @@ -381,6 +388,7 @@ var assets = func() http.FileSystem { fs["/platform-integration-kit-yaml.yaml"].(os.FileInfo), fs["/prometheus-jmx-exporter.yaml"].(os.FileInfo), fs["/templates"].(os.FileInfo), + fs["/traits.yaml"].(os.FileInfo), fs["/user-cluster-role.yaml"].(os.FileInfo), } fs["/addons"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ diff --git a/deploy/traits.yaml b/deploy/traits.yaml new file mode 100755 index 0000000..70753eb --- /dev/null +++ b/deploy/traits.yaml @@ -0,0 +1,708 @@ +traits: +- name: affinity + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: Allows to constrain which nodes the integration pod(s) are eligible + to be scheduled on, based on labels on the node,or with inter-pod affinity and + anti-affinity, based on labels on pods that are already running on the nodes.It’s + disabled by default. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: pod-affinity + type: bool + description: Always co-locates multiple replicas of the integration in the same + node (default *false*). + - name: pod-anti-affinity + type: bool + description: Never co-locates multiple replicas of the integration in the same + node (default *false*). + - name: node-affinity-labels + type: string + description: Defines a set of nodes the integration pod(s) are eligible to be + scheduled on, based on labels on the node. + - name: pod-affinity-labels + type: string + description: Defines a set of pods (namely those matching the label selector, + relative to the given namespace) that theintegration pod(s) should be co-located + with. + - name: pod-anti-affinity-labels + type: string + description: Defines a set of pods (namely those matching the label selector, + relative to the given namespace) that theintegration pod(s) should not be co-located + with. +- name: builder + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The builder trait is internally used to determine the best strategy + tobuild and configure IntegrationKits. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: verbose + type: bool + description: Enable verbose logging on build components that support it (e.g. + Kaniko build pod). +- name: camel + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Camel trait can be used to configure versions of Apache Camel K + runtime and related libraries, it cannot be disabled. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: runtime-version + type: string + description: The camel-k-runtime version to use for the integration. It overrides + the default version set in the Integration Platform. +- name: container + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Container trait can be used to configure properties of the container + where the integration will run.It also provides configuration for Services associated + to the container. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: auto + type: bool + description: "" + - name: request-cpu + type: string + description: The minimum amount of CPU required. + - name: request-memory + type: string + description: The minimum amount of memory required. + - name: limit-cpu + type: string + description: The maximum amount of CPU required. + - name: limit-memory + type: string + description: The maximum amount of memory required. + - name: expose + type: bool + description: Can be used to enable/disable exposure via kubernetes Service. + - name: port + type: int + description: To configure a different port exposed by the container (default `8080`). + - name: port-name + type: string + description: To configure a different port name for the port exposed by the container + (default `http`). + - name: service-port + type: int + description: To configure under which service port the container port is to be + exposed (default `80`). + - name: service-port-name + type: string + description: To configure under which service port name the container port is + to be exposed (default `http`). + - name: name + type: string + description: The main container name. It's named `integration` by default. + - name: probes-enabled + type: bool + description: ProbesEnabled enable/disable probes on the container (default `false`) + - name: probe-path + type: string + description: Path to access on the probe ( default `/health`). Note that this + property is not supportedon quarkus runtime and setting it will result in the + integration failing to start. + - name: liveness-initial-delay + type: int32 + description: Number of seconds after the container has started before liveness + probes are initiated. + - name: liveness-timeout + type: int32 + description: Number of seconds after which the probe times out. Applies to the + liveness probe. + - name: liveness-period + type: int32 + description: How often to perform the probe. Applies to the liveness probe. + - name: liveness-success-threshold + type: int32 + description: Minimum consecutive successes for the probe to be considered successful + after having failed.Applies to the liveness probe. + - name: liveness-failure-threshold + type: int32 + description: Minimum consecutive failures for the probe to be considered failed + after having succeeded.Applies to the liveness probe. + - name: readiness-initial-delay + type: int32 + description: Number of seconds after the container has started before readiness + probes are initiated. + - name: readiness-timeout + type: int32 + description: Number of seconds after which the probe times out. Applies to the + readiness probe. + - name: readiness-period + type: int32 + description: How often to perform the probe. Applies to the readiness probe. + - name: readiness-success-threshold + type: int32 + description: Minimum consecutive successes for the probe to be considered successful + after having failed.Applies to the readiness probe. + - name: readiness-failure-threshold + type: int32 + description: Minimum consecutive failures for the probe to be considered failed + after having succeeded.Applies to the readiness probe. +- name: cron + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: 'The Cron trait can be used to customize the behaviour of periodic + timer/cron based integrations.While normally an integration requires a pod to + be always up and running, some periodic tasks, such as batch jobs,require to be + activated at specific hours of the day or with a periodic delay of minutes.For + such tasks, the cron trait can materialize the integration as a Kubernetes CronJob + instead of a standard deployment,in order to save resources when the integration + does not need to be executed.Integrations that start from the following components + are evaluated by the cron trait: `timer`, `cron`, `quartz`.The rules for using + a Kubernetes CronJob are the following:- `timer`: when periods can be written + as cron expressions. E.g. `timer:tick?period=60000`.- `cron`, `quartz`: when the + cron expression does not contain seconds (or the "seconds" part is set to 0). + E.g. `cron:tab?schedule=0/2+*+*+*+?` or `quartz:trigger?cron=0+0/2+*+*+*+?`.' + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: schedule + type: string + description: The CronJob schedule for the whole integration. If multiple routes + are declared, they must have the same schedule for thismechanism to work correctly. + - name: components + type: string + description: 'A comma separated list of the Camel components that need to be customized + in order for them to work when the schedule is triggered externally by Kubernetes.A + specific customizer is activated for each specified component. E.g. for the + `timer` component, the `cron-timer` customizer isactivated (it''s present in + the `org.apache.camel.k:camel-k-runtime-cron` library).Supported components + are currently: `cron`, `timer` and `quartz`.' + - name: fallback + type: bool + description: Use the default Camel implementation of the `cron` endpoint (`quartz`) + instead of trying to materialize the integrationas Kubernetes CronJob. + - name: concurrency-policy + type: string + description: 'Specifies how to treat concurrent executions of a Job.Valid values + are:- "Allow": allows CronJobs to run concurrently;- "Forbid" (default): forbids + concurrent runs, skipping next run if previous run hasn''t finished yet;- "Replace": + cancels currently running job and replaces it with a new one' + - name: auto + type: bool + description: Automatically deploy the integration as CronJob when all routes areeither + starting from a periodic consumer (only `cron`, `timer` and `quartz` are supported) + or a passive consumer (e.g. `direct` is a passive consumer).It's required that + all periodic consumers have the same period and it can be expressed as cron + schedule (e.g. `1m` can be expressed as `0/1 * * * *`,while `35m` or `50s` cannot). +- name: dependencies + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Dependencies trait is internally used to automatically add runtime + dependencies based on theintegration that the user wants to run. + properties: [] +- name: deployer + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The deployer trait can be used to explicitly select the kind of high + level resource thatwill deploy the integration. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: kind + type: string + description: Allows to explicitly select the desired deployment kind between `deployment`, + `cron-job` or `knative-service` when creating the resources for running the + integration. +- name: deployment + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Deployment trait is responsible for generating the Kubernetes deployment + that will make surethe integration will run in the cluster. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. +- name: environment + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The environment trait is used internally to inject standard environment + variables in the integration container,such as `NAMESPACE`, `POD_NAME` and others. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: container-meta + type: bool + description: "" +- name: gc + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: The GC Trait garbage-collects all resources that are no longer necessary + upon integration updates. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: discovery-cache + type: ./pkg/trait.discoveryCacheType + description: Discovery client cache to be used, either `disabled`, `disk` or `memory` + (default `memory`) +- name: ingress + platform: false + profiles: + - Kubernetes + description: The Ingress trait can be used to expose the service associated with + the integrationto the outside world with a Kubernetes Ingress.It's enabled by + default whenever a Service is added to the integration (through the `service` + trait). + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: host + type: string + description: '**Required**. To configure the host exposed by the ingress.' + - name: auto + type: bool + description: To automatically add an ingress whenever the integration uses a HTTP + endpoint consumer. +- name: istio + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Istio trait allows to configure properties related to the Istio + service mesh,such as sidecar injection and outbound IP ranges. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: allow + type: string + description: Configures a (comma-separated) list of CIDR subnets that should not + be intercepted by the Istio proxy (`10.0.0.0/8,172.16.0.0/12,192.168.0.0/16` + by default). + - name: inject + type: bool + description: Forces the value for labels `sidecar.istio.io/inject`. By default + the label is set to `true` on deployment and not set on Knative Service. +- name: jolokia + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Jolokia trait activates and configures the Jolokia Java agent.See + https://jolokia.org/reference/html/agents.html + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: ca-cert + type: string + description: The PEM encoded CA certification file path, used to verify client + certificates,applicable when `protocol` is `https` and `use-ssl-client-authentication` + is `true`(default `/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt` + for OpenShift). + - name: client-principal + type: '[]string' + description: The principal(s) which must be given in a client certificate to allow + access to the Jolokia endpoint,applicable when `protocol` is `https` and `use-ssl-client-authentication` + is `true`(default `clientPrincipal=cn=system:master-proxy`, `cn=hawtio-online.hawtio.svc` + and `cn=fuse-console.fuse.svc` for OpenShift). + - name: discovery-enabled + type: bool + description: Listen for multicast requests (default `false`) + - name: extended-client-check + type: bool + description: Mandate the client certificate contains a client flag in the extended + key usage section,applicable when `protocol` is `https` and `use-ssl-client-authentication` + is `true`(default `true` for OpenShift). + - name: host + type: string + description: The Host address to which the Jolokia agent should bind to. If `"\*"` + or `"0.0.0.0"` is given,the servers binds to every network interface (default + `"*"`). + - name: password + type: string + description: The password used for authentication, applicable when the `user` + option is set. + - name: port + type: int + description: The Jolokia endpoint port (default `8778`). + - name: protocol + type: string + description: The protocol to use, either `http` or `https` (default `https` for + OpenShift) + - name: user + type: string + description: The user to be used for authentication + - name: use-ssl-client-authentication + type: bool + description: Whether client certificates should be used for authentication (default + `true` for OpenShift). + - name: options + type: string + description: 'A comma-separated list of additional Jolokia options as definedin + https://jolokia.org/reference/html/agents.html#agent-jvm-config[JVM agent configuration + options],e.g.: `keystore=...,executor=...`' +- name: jvm + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The JVM trait is used to configure the JVM that runs the integration. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: debug + type: bool + description: Activates remote debugging, so that a debugger can be attached to + the JVM, e.g., using port-forwarding + - name: debug-suspend + type: bool + description: Suspends the target JVM immediately before the main class is loaded + - name: debug-address + type: string + description: Transport address at which to listen for the newly launched JVM + - name: options + type: string + description: A comma-separated list of JVM options +- name: knative-service + platform: false + profiles: + - Knative + description: The Knative Service trait allows to configure options when running + the integration as Knative service instead ofa standard Kubernetes Deployment.Running + integrations as Knative Services adds auto-scaling (and scaling-to-zero) features, + but those featuresare only meaningful when the routes use a HTTP endpoint consumer. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: autoscaling-class + type: string + description: Configures the Knative autoscaling class property (e.g. to set `hpa.autoscaling.knative.dev` + or `kpa.autoscaling.knative.dev` autoscaling).Refer to the Knative documentation + for more information. + - name: autoscaling-metric + type: string + description: Configures the Knative autoscaling metric property (e.g. to set `concurrency` + based or `cpu` based autoscaling).Refer to the Knative documentation for more + information. + - name: autoscaling-target + type: int + description: Sets the allowed concurrency level or CPU percentage (depending on + the autoscaling metric) for each Pod.Refer to the Knative documentation for + more information. + - name: min-scale + type: int + description: The minimum number of Pods that should be running at any time for + the integration. It's **zero** by default, meaning thatthe integration is scaled + down to zero when not used for a configured amount of time.Refer to the Knative + documentation for more information. + - name: max-scale + type: int + description: An upper bound for the number of Pods that can be running in parallel + for the integration.Knative has its own cap value that depends on the installation.Refer + to the Knative documentation for more information. + - name: auto + type: bool + description: Automatically deploy the integration as Knative service when all + conditions hold:* Integration is using the Knative profile* All routes are either + starting from a HTTP based consumer or a passive consumer (e.g. `direct` is + a passive consumer) +- name: knative + platform: false + profiles: + - Knative + description: The Knative trait automatically discovers addresses of Knative resources + and inject them into therunning integration.The full Knative configuration is + injected in the CAMEL_KNATIVE_CONFIGURATION in JSON format.The Camel Knative component + will then use the full configuration to configure the routes.The trait is enabled + by default when the Knative profile is active. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: configuration + type: string + description: Can be used to inject a Knative complete configuration in JSON format. + - name: channel-sources + type: string + description: Comma-separated list of channels used as source of integration routes.Can + contain simple channel names or full Camel URIs. + - name: channel-sinks + type: string + description: Comma-separated list of channels used as destination of integration + routes.Can contain simple channel names or full Camel URIs. + - name: endpoint-sources + type: string + description: Comma-separated list of channels used as source of integration routes. + - name: endpoint-sinks + type: string + description: Comma-separated list of endpoints used as destination of integration + routes.Can contain simple endpoint names or full Camel URIs. + - name: event-sources + type: string + description: Comma-separated list of event types that the integration will be + subscribed to.Can contain simple event types or full Camel URIs (to use a specific + broker different from "default"). + - name: event-sinks + type: string + description: Comma-separated list of event types that the integration will produce.Can + contain simple event types or full Camel URIs (to use a specific broker). + - name: filter-source-channels + type: bool + description: Enables filtering on events based on the header "ce-knativehistory". + Since this is an experimental headerthat can be removed in a future version + of Knative, filtering is enabled only when the integration islistening from + more than 1 channel. + - name: camel-source-compat + type: bool + description: Enables Knative CamelSource pre 0.15 compatibility fixes (will be + removed in future versions). + - name: auto + type: bool + description: Enable automatic discovery of all trait properties. +- name: openapi + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The OpenAPI DSL trait is internally used to allow creating integrations + from a OpenAPI specs. + properties: [] +- name: owner + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Owner trait ensures that all created resources belong to the integration + being createdand transfers annotations and labels on the integration onto these + owned resources. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: target-annotations + type: string + description: The annotations to be transferred (A comma-separated list of label + keys) + - name: target-labels + type: string + description: The labels to be transferred (A comma-separated list of label keys) +- name: platform + platform: true + profiles: + - Kubernetes + - Knative + - OpenShift + description: The platform trait is a base trait that is used to assign an integration + platform to an integration.In case the platform is missing, the trait is allowed + to create a default platform.This feature is especially useful in contexts where + there's no need to provide a custom configuration for the platform(e.g. on OpenShift + the default settings work, since there's an embedded container image registry). + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: create-default + type: bool + description: To create a default (empty) platform when the platform is missing. + - name: auto + type: bool + description: To automatically detect from the environment if a default platform + can be created (it will be created on OpenShift only). +- name: prometheus + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: 'The Prometheus trait configures the Prometheus JMX exporter and exposes + the integration with a `Service`and a `ServiceMonitor` resources so that the Prometheus + endpoint can be scraped.WARNING: The creation of the `ServiceMonitor` resource + requires the https://github.com/coreos/prometheus-operator[Prometheus Operator]custom + resource definition to be installed.You can set `service-monitor` to `false` for + the Prometheus trait to work without the Prometheus operator.It''s disabled by + default.' + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: port + type: int + description: The Prometheus endpoint port (default `9779`). + - name: service-monitor + type: bool + description: Whether a `ServiceMonitor` resource is created (default `true`). + - name: service-monitor-labels + type: string + description: The `ServiceMonitor` resource labels, applicable when `service-monitor` + is `true`. + - name: configmap + type: string + description: To use a custom ConfigMap containing the Prometheus exporter configuration + (under the `content` ConfigMap key). When this property is left empty (default),Camel + K generates a standard Prometheus configuration for the integration. +- name: pull-secret + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Pull Secret trait sets a pull secret on the pod,to allow Kubernetes + to retrieve the container image from an external registry.The pull secret can + be specified manually or, in case you've configured authentication for an external + container registryon the `IntegrationPlatform`, the same secret is used to pull + images.It's enabled by default whenever you configure authentication for an external + container registry,so it assumes that external registries are private.If your + registry does not need authentication for pulling images, you can disable this + trait. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: secret-name + type: string + description: The pull secret name to set on the Pod. If left empty this is automatically + taken from the `IntegrationPlatform` registry configuration. + - name: auto + type: bool + description: Automatically configures the platform registry secret on the pod + if it is of type `kubernetes.io/dockerconfigjson`. +- name: quarkus + platform: false + profiles: + - Kubernetes + - Knative + - OpenShift + description: The Quarkus trait activates the Quarkus runtime.It's disabled by default. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: native + type: bool + description: The Quarkus runtime type (reserved for future use) +- name: route + platform: false + profiles: + - OpenShift + description: The Route trait can be used to configure the creation of OpenShift + routes for the integration. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: host + type: string + description: To configure the host exposed by the route. + - name: tls-termination + type: string + description: The TLS termination type, like `edge`, `passthrough` or `reencrypt`.Refer + to the OpenShift documentation for additional information. + - name: tls-certificate + type: string + description: The TLS certificate contents.Refer to the OpenShift documentation + for additional information. + - name: tls-key + type: string + description: The TLS certificate key contents.Refer to the OpenShift documentation + for additional information. + - name: tls-ca-certificate + type: string + description: The TLS cert authority certificate contents.Refer to the OpenShift + documentation for additional information. + - name: tls-destination-ca-certificate + type: string + description: The destination CA certificate provides the contents of the ca certificate + of the final destination. When using reencrypttermination this file should + be provided in order to have routers use it for health checks on the secure + connection.If this field is not specified, the router may provide its own destination + CA and perform hostname validation usingthe short service name (service.namespace.svc), + which allows infrastructure generated certificates to automaticallyverify.Refer + to the OpenShift documentation for additional information. + - name: tls-insecure-edge-termination-policy + type: string + description: To configure how to deal with insecure traffic, e.g. `Allow`, `Disable` + or `Redirect` traffic.Refer to the OpenShift documentation for additional information. +- name: service + platform: false + profiles: + - Kubernetes + - OpenShift + description: The Service trait exposes the integration with a Service resource so + that it can be accessed by other applications(or integrations) in the same namespace.It's + enabled by default if the integration depends on a Camel component that can expose + a HTTP endpoint. + properties: + - name: enabled + type: bool + description: Can be used to enable or disable a trait. All traits share this common + property. + - name: auto + type: bool + description: To automatically detect from the code if a Service needs to be created. diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 9d9daa5..1f7374a 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -16,7 +16,6 @@ ** xref:configuration/configmap-secret.adoc[ConfigMap/Secret] * xref:traits/traits.adoc[Traits] // Start of autogenerated code - DO NOT EDIT! (trait-nav) -** xref:traits/3scale.adoc[3scale] ** xref:traits/affinity.adoc[Affinity] ** xref:traits/builder.adoc[Builder] ** xref:traits/camel.adoc[Camel] @@ -33,7 +32,6 @@ ** xref:traits/jvm.adoc[Jvm] ** xref:traits/knative-service.adoc[Knative Service] ** xref:traits/knative.adoc[Knative] -** xref:traits/master.adoc[Master] ** xref:traits/openapi.adoc[Openapi] ** xref:traits/owner.adoc[Owner] ** xref:traits/platform.adoc[Platform] diff --git a/docs/modules/ROOT/pages/traits/cron.adoc b/docs/modules/ROOT/pages/traits/cron.adoc index e1f5441..6e6b1ba 100755 --- a/docs/modules/ROOT/pages/traits/cron.adoc +++ b/docs/modules/ROOT/pages/traits/cron.adoc @@ -13,7 +13,7 @@ Integrations that start from the following components are evaluated by the cron The rules for using a Kubernetes CronJob are the following: - `timer`: when periods can be written as cron expressions. E.g. `timer:tick?period=60000`. - `cron`, `quartz`: when the cron expression does not contain seconds (or the "seconds" part is set to 0). E.g. - `cron:tab?schedule=0/2{plus}*{plus}*{plus}*{plus}?` or `quartz:trigger?cron=0{plus}0/2{plus}*{plus}*{plus}*{plus}?`. + `cron:tab?schedule=0/2+*+*+*+?` or `quartz:trigger?cron=0+0/2+*+*+*+?`. This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**. diff --git a/docs/modules/ROOT/pages/traits/gc.adoc b/docs/modules/ROOT/pages/traits/gc.adoc index 3f2a864..0b61f3e 100755 --- a/docs/modules/ROOT/pages/traits/gc.adoc +++ b/docs/modules/ROOT/pages/traits/gc.adoc @@ -25,7 +25,7 @@ The following configuration options are available: | Can be used to enable or disable a trait. All traits share this common property. | gc.discovery-cache -| github.com/apache/camel-k/pkg/trait.discoveryCacheType +| ./pkg/trait.discoveryCacheType | Discovery client cache to be used, either `disabled`, `disk` or `memory` (default `memory`) |=== diff --git a/docs/modules/ROOT/pages/traits/knative.adoc b/docs/modules/ROOT/pages/traits/knative.adoc index e8a9f67..2d77cc1 100755 --- a/docs/modules/ROOT/pages/traits/knative.adoc +++ b/docs/modules/ROOT/pages/traits/knative.adoc @@ -69,6 +69,10 @@ Can contain simple event types or full Camel URIs (to use a specific broker). that can be removed in a future version of Knative, filtering is enabled only when the integration is listening from more than 1 channel. +| knative.camel-source-compat +| bool +| Enables Knative CamelSource pre 0.15 compatibility fixes (will be removed in future versions). + | knative.auto | bool | Enable automatic discovery of all trait properties. diff --git a/docs/modules/ROOT/pages/traits/traits.adoc b/docs/modules/ROOT/pages/traits/traits.adoc index e2e663c..cbe1d72 100644 --- a/docs/modules/ROOT/pages/traits/traits.adoc +++ b/docs/modules/ROOT/pages/traits/traits.adoc @@ -34,7 +34,6 @@ A trait may have additional properties that can be configured by the end user. See the trait description pages for more information on a specific trait: // Start of autogenerated code - DO NOT EDIT! (trait-list) -* xref:traits/3scale.adoc[3scale Trait] * xref:traits/affinity.adoc[Affinity Trait] * xref:traits/builder.adoc[Builder Trait] * xref:traits/camel.adoc[Camel Trait] @@ -51,7 +50,6 @@ See the trait description pages for more information on a specific trait: * xref:traits/jvm.adoc[Jvm Trait] * xref:traits/knative-service.adoc[Knative Service Trait] * xref:traits/knative.adoc[Knative Trait] -* xref:traits/master.adoc[Master Trait] * xref:traits/openapi.adoc[Openapi Trait] * xref:traits/owner.adoc[Owner Trait] * xref:traits/platform.adoc[Platform Trait] diff --git a/pkg/cmd/trait_help.go b/pkg/cmd/trait_help.go index 48a84e4..9669fb2 100644 --- a/pkg/cmd/trait_help.go +++ b/pkg/cmd/trait_help.go @@ -26,6 +26,7 @@ import ( "strings" "github.com/apache/camel-k/pkg/util/indentedwriter" + "github.com/apache/camel-k/deploy" "github.com/fatih/structs" "gopkg.in/yaml.v2" @@ -70,16 +71,22 @@ type traitHelpCommandOptions struct { } type traitDescription struct { - Name trait.ID `json:"name" yaml:"name"` - Platform bool `json:"platform" yaml:"platform"` - Profiles []string `json:"profiles" yaml:"profiles"` - Properties []traitPropertyDescription `json:"properties" yaml:"properties"` + Name trait.ID `json:"name" yaml:"name"` + Platform bool `json:"platform" yaml:"platform"` + Profiles []string `json:"profiles" yaml:"profiles"` + Properties []traitPropertyDescription `json:"properties" yaml:"properties"` + Description string `json:"description" yaml:"description"` } type traitPropertyDescription struct { Name string `json:"name" yaml:"name"` TypeName string `json:"type" yaml:"type"` DefaultValue interface{} `json:"defaultValue,omitempty" yaml:"defaultValue,omitempty"` + Description string `json:"description" yaml:"description"` +} + +type traitMetaData struct { + Traits []traitDescription `yaml:traits` } func (command *traitHelpCommandOptions) validate(args []string) error { @@ -96,6 +103,17 @@ func (command *traitHelpCommandOptions) run(cmd *cobra.Command, args []string) e var traitDescriptions []*traitDescription var catalog = trait.NewCatalog(command.Context, nil) + var traitMetaData = &traitMetaData{} + err := yaml.Unmarshal(deploy.Resource("/traits.yaml"), traitMetaData) + if err != nil { + return err + } + res, err := yaml.Marshal(traitMetaData) + if err != nil { + return err + } + fmt.Fprintln(cmd.OutOrStdout(), string(res)) + for _, tp := range v1.AllTraitProfiles { traits := catalog.TraitsForProfile(tp) for _, t := range traits { @@ -110,7 +128,16 @@ func (command *traitHelpCommandOptions) run(cmd *cobra.Command, args []string) e Platform: t.IsPlatformTrait(), Profiles: make([]string, 0), } - computeTraitProperties(structs.Fields(t), &td.Properties) + + var targetTrait *traitDescription + for _, item := range traitMetaData.Traits { + if item.Name == t.ID() { + targetTrait = &item + td.Description = item.Description + break + } + } + computeTraitProperties(structs.Fields(t), &td.Properties, targetTrait) traitDescriptions = append(traitDescriptions, td) } td.addProfile(string(tp)) @@ -159,10 +186,10 @@ func findTraitDescription(id trait.ID, traitDescriptions []*traitDescription) *t return nil } -func computeTraitProperties(fields []*structs.Field, properties *[]traitPropertyDescription) { +func computeTraitProperties(fields []*structs.Field, properties *[]traitPropertyDescription, targetTrait *traitDescription) { for _, f := range fields { if f.IsEmbedded() && f.IsExported() && f.Kind() == reflect.Struct { - computeTraitProperties(f.Fields(), properties) + computeTraitProperties(f.Fields(), properties, targetTrait) } if !f.IsExported() || f.IsEmbedded() { @@ -196,6 +223,15 @@ func computeTraitProperties(fields []*structs.Field, properties *[]traitProperty tp.DefaultValue = f.Value() } + // apply the description from metadata + if (targetTrait != nil) { + for _, item := range targetTrait.Properties { + if item.Name == tp.Name { + tp.Description = item.Description + } + } + } + *properties = append(*properties, tp) } } diff --git a/pkg/trait/zz_desc_generated.go b/pkg/trait/zz_desc_generated.go new file mode 100644 index 0000000..8bb8d44 --- /dev/null +++ b/pkg/trait/zz_desc_generated.go @@ -0,0 +1 @@ +package trait
