Skip to content

Commit

Permalink
Merge pull request #2 from feloy/dev-v1.17.0
Browse files Browse the repository at this point in the history
v1.17.0
  • Loading branch information
feloy committed Dec 9, 2019
2 parents b91cfa2 + 9729f7a commit a8f4927
Show file tree
Hide file tree
Showing 8 changed files with 4,483 additions and 814 deletions.
21 changes: 19 additions & 2 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"

"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -147,10 +148,26 @@ func LoadConfigFromYAML() *Config {
// characters with HTML entities: <, >, &, ', and ".
func (c *Config) escapeDescriptions() {
for _, d := range c.Definitions.All {
d.DescriptionWithEntities = html.EscapeString(d.Description())
paras := strings.Split(d.Description(), "\n\n")
var sb strings.Builder
for _, para := range paras {
sb.WriteString("<para>")
sb.WriteString(html.EscapeString(EscapeAsterisks(para)))
sb.WriteString("</para>")
}
d.DescriptionWithEntities = sb.String()

// d.DescriptionWithEntities = html.EscapeString(d.Description())

for _, f := range d.Fields {
f.DescriptionWithEntities = html.EscapeString(f.Description)
paras := strings.Split(f.Description, "\n\n")
var sb strings.Builder
for _, para := range paras {
sb.WriteString("<para>")
sb.WriteString(html.EscapeString(EscapeAsterisks(para)))
sb.WriteString("</para>")
}
f.DescriptionWithEntities = sb.String()
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions api/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ func (s *Definitions) GetForSchema(schema spec.Schema) (*Definition, bool) {
// Initializes the fields for a definition
func (s *Definitions) InitializeFields(d *Definition) {
for fieldName, property := range d.schema.Properties {
des := strings.Replace(property.Description, "\n", " ", -1)
f := &Field{
Name: fieldName,
Type: GetTypeName(property),
Description: EscapeAsterisks(des),
Description: EscapeAsterisks(property.Description),
}
if len(property.Extensions) > 0 {
if ps, ok := property.Extensions.GetString(patchStrategyKey); ok {
Expand Down
85 changes: 78 additions & 7 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

resource_categories:
- name: Workloads APIs
- name: Workloads Resources
resources:
- name: Pod
version: v1
Expand Down Expand Up @@ -546,7 +546,7 @@ resource_categories:
- name: metadata
- name: spec
- name: status
- name: Service APIs
- name: Service Resources
resources:
- name: Service
version: v1
Expand All @@ -571,6 +571,7 @@ resource_categories:
- name: sessionAffinityConfig
depth: 2
- name: ipFamily
- name: topologyKeys
- definition: ServiceStatus
list:
- fields:
Expand Down Expand Up @@ -644,7 +645,7 @@ resource_categories:
- name: spec
- name: status
- name: EndpointSlice
version: v1alpha1
version: v1beta1
group: discovery
field_categories:
- definition: EndpointSliceList
Expand All @@ -668,7 +669,7 @@ resource_categories:
depth: 2
- name: ports
depth: 1
- name: Config and Storage APIs
- name: Config and Storage Resources
resources:
- name: ConfigMap
version: v1
Expand Down Expand Up @@ -919,7 +920,7 @@ resource_categories:
- name: metadata
- name: spec
- name: CSINode
version: v1beta1
version: v1
group: storage
field_categories:
- definition: CSINodeSpec
Expand All @@ -941,7 +942,7 @@ resource_categories:
- name: kind
- name: metadata
- name: spec
- name: Metadata APIs
- name: Metadata Resources
resources:
- name: ControllerRevision
version: v1
Expand Down Expand Up @@ -1307,7 +1308,7 @@ resource_categories:
- name: kind
- name: metadata
- name: spec
- name: Cluster APIs
- name: Cluster Resources
resources:
- name: Node
version: v1
Expand Down Expand Up @@ -1963,6 +1964,70 @@ resource_categories:
- name: kind
- name: metadata
- name: spec
- name: FlowSchema
version: v1alpha1
group: flowcontrol
field_categories:
- definition: FlowSchemaSpec
list:
- fields:
- name: priorityLevelConfiguration
depth: 1
- name: matchingPrecedence
- name: distinguisherMethod
depth: 1
- name: rules
depth: -1
- definition: FlowSchemaStatus
list:
- fields:
- name: conditions
depth: 1
- definition: FlowSchemaList
list:
- fields:
- name: apiVersion
- name: kind
- name: metadata
- name: items
- definition: FlowSchema
list:
- fields:
- name: apiVersion
- name: kind
- name: metadata
- name: spec
- name: status
- name: PriorityLevelConfiguration
version: v1alpha1
group: flowcontrol
field_categories:
- definition: PriorityLevelConfigurationSpec
list:
- fields:
- name: type
- name: limited
depth: -1
- definition: PriorityLevelConfigurationStatus
list:
- fields:
- name: conditions
depth: 1
- definition: PriorityLevelConfigurationList
list:
- fields:
- name: apiVersion
- name: kind
- name: metadata
- name: items
- definition: PriorityLevelConfiguration
list:
- fields:
- name: apiVersion
- name: kind
- name: metadata
- name: spec
- name: status
- name: Common Definitions
definitions:
- name: JSONSchemaProps
Expand Down Expand Up @@ -2012,6 +2077,12 @@ resource_categories:
- name: title
- name: type
- name: uniqueItems
- name: x-kubernetes-embedded-resource
- name: x-kubernetes-int-or-string
- name: x-kubernetes-list-map-keys
- name: x-kubernetes-list-type
- name: x-kubernetes-map-type
- name: x-kubernetes-preserve-unknown-fields
- name: Affinity
definitions:
- name: NodeAffinity
Expand Down
10 changes: 5 additions & 5 deletions docbook/docbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func Generate(w io.Writer, config *api.Config, document *structure.Section) {
fmt.Fprintf(w, "<releaseinfo>By the Kubernetes Authors</releaseinfo>")
fmt.Fprintf(w, "<releaseinfo>Edited and published by Philippe Martin</releaseinfo>")
fmt.Fprintf(w, "<copyright><year>2019</year><holder>The Kubernetes Authors</holder></copyright>")
fmt.Fprintf(w, "<legalnotice>Permission is granted to copy, distribute and/or modify this document under the terms of the Apache License version 2. A copy of the license is included in <xref linkend=\"license\"></xref>.</legalnotice>")
fmt.Fprintf(w, "<legalnotice>The tool used to generate this document is available at https://github.com/feloy/kubernetes-resources-reference</legalnotice>")
fmt.Fprintf(w, "<legalnotice>The OpenAPI spec file used to generate this document is available at https://github.com/kubernetes/kubernetes</legalnotice>")
fmt.Fprintf(w, "<legalnotice><para>Permission is granted to copy, distribute and/or modify this document under the terms of the Apache License version 2. A copy of the license is included in <xref linkend=\"license\"></xref>.</para></legalnotice>")
fmt.Fprintf(w, "<legalnotice><para>The tool used to generate this document is available at https://github.com/feloy/kubernetes-resources-reference</para></legalnotice>")
fmt.Fprintf(w, "<legalnotice><para>The OpenAPI spec file used to generate this document is available at https://github.com/kubernetes/kubernetes</para></legalnotice>")
fmt.Fprintf(w, "</bookinfo>\n")
document.AsDocbook(w)
addLicense(w)
fmt.Fprintf(w, "<index type=\"resources\"><title>Index of Resources</title></index>")
fmt.Fprintf(w, "<index type=\"fields\"><title>Index of Fields</title></index>")
fmt.Fprintf(w, "<index type=\"resources\"><title>Resources Index</title></index>")
fmt.Fprintf(w, "<index type=\"fields\"><title>Fields Index</title></index>")
fmt.Fprintf(w, "</book>\n")
}

Expand Down
4 changes: 2 additions & 2 deletions static/license.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</sect1>


<bridgehead>APPENDIX: How to apply the Apache License to your work.</bridgehead>
<sect1 label="Appendix"><title>How to apply the Apache License to your work.</title>

<para>To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
Expand All @@ -121,5 +121,5 @@ 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.
</programlisting>

</sect1>
</appendix>
11 changes: 10 additions & 1 deletion structure/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package structure
import (
"fmt"
"log"
"os"
"sort"

"github.com/feloy/k8s-api/api"
Expand Down Expand Up @@ -185,17 +186,25 @@ func (b *Builder) insertFields(s *Section, definition *api.Definition, categorie
}
} else {
currentSection := s
addedFields := map[string]struct{}{}
for _, fieldCategory := range fieldCategories {
if fieldCategory.Name != nil {
currentSection = NewSection(*fieldCategory.Name, nil)
s.AddSection(currentSection)
}
for _, field := range fieldCategory.Fields {
realField := b.getDefinitionField(definition, field.Name)
addedFields[field.Name] = struct{}{}
b.insertField(currentSection, realField, definition.Name, field.Depth, categories, fieldEntry, &field)
}
}
// TODO add not configured
// Error if some not configured
for _, field := range definition.Fields {
if _, found := addedFields[field.Name]; !found {
fmt.Fprintf(os.Stderr, "Field %s in %s not configured\n", field.Name, s.Name)
}

}
}
}

Expand Down
2 changes: 1 addition & 1 deletion structure/field_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (o *FieldEntry) AsDocbook(w io.Writer, prefixes ...string) {
}
fmt.Fprintf(w, "<listitem>")
if o.Description != nil {
fmt.Fprintf(w, "<para>%s</para>", *o.Description)
fmt.Fprintf(w, "%s", *o.Description)
}

if inline {
Expand Down
Loading

0 comments on commit a8f4927

Please sign in to comment.