Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/config/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type DocumentationConfig struct {
// ResourceDocsConfig represents the configuration for the documentation
// overrides of a single resource
type ResourceDocsConfig struct {
// Note specifies a resource-level documentation note that describes
// special considerations for the resource
Note *string `json:"note,omitempty"`
Fields map[string]*FieldDocsConfig `json:"fields,omitempty"`
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/model/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ func (r *CRD) Documentation() string {
return docString
}

// Note returns the resource-level documentation note if one is configured,
// otherwise returns an empty string.
func (r *CRD) Note() string {
if r.docCfg == nil {
return ""
}
resourceConfig, exists := r.docCfg.Resources[r.Names.Camel]
if !exists || resourceConfig.Note == nil {
return ""
}
return *resourceConfig.Note
}

// HasShapeAsMember returns true if the supplied Shape name appears in *any*
// payload shape of *any* Operation for the resource. It recurses down through
// the resource's Operation Input and Output shapes and their member shapes
Expand Down
27 changes: 27 additions & 0 deletions pkg/model/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,33 @@ func TestFieldDocumentation(t *testing.T) {

}

func TestResourceNote(t *testing.T) {
require := require.New(t)

g := testutil.NewModelForServiceWithOptions(t, "eks",
&testutil.TestingModelOptions{
GeneratorConfigFile: "generator.yaml",
DocumentationConfigFile: "documentation.yaml",
},
)

crds, err := g.GetCRDs()
require.Nil(err)

crd := getCRDByName("Cluster", crds)
require.NotNil(crd)

require.Equal(
"This resource does not support direct updates to the Kubernetes version.\nUse the UpdateClusterVersion API to upgrade.\n",
crd.Note(),
)

// A resource without a note should return empty string
addonCRD := getCRDByName("AddOn", crds)
require.NotNil(addonCRD)
require.Equal("", addonCRD.Note())
}

func TestMemberFields(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
Expand Down
3 changes: 3 additions & 0 deletions pkg/testdata/models/apis/eks/0000-00-00/documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
resources:
Cluster:
note: |
This resource does not support direct updates to the Kubernetes version.
Use the UpdateClusterVersion API to upgrade.
fields:
RoleARN:
append: |
Expand Down