Skip to content

Commit

Permalink
Rename pkg/meta module as pkg/registry
Browse files Browse the repository at this point in the history
- Rename Resource.TitleName as Title
- Add field documentation for Resource

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed Jun 23, 2022
1 parent d5053ea commit 81bfd3e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
tfjson "github.com/hashicorp/terraform-json"
"github.com/pkg/errors"

"github.com/upbound/upjet/pkg/meta"
"github.com/upbound/upjet/pkg/registry"
conversiontfjson "github.com/upbound/upjet/pkg/types/conversion/tfjson"
)

Expand Down Expand Up @@ -221,7 +221,7 @@ func (p *Provider) loadMetadata() error {
return nil
}
metadataPath := filepath.Join(p.RootDir, p.ProviderMetadataPath)
providerMetadata, err := meta.NewProviderMetadataFromFile(metadataPath)
providerMetadata, err := registry.NewProviderMetadataFromFile(metadataPath)
if err != nil {
return errors.Wrapf(err, "cannot load provider metadata from file: %s", metadataPath)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
xpresource "github.com/crossplane/crossplane-runtime/pkg/resource"

"github.com/upbound/upjet/pkg/meta"
"github.com/upbound/upjet/pkg/registry"
)

// SetIdentifierArgumentsFn sets the name of the resource in Terraform attributes map,
Expand Down Expand Up @@ -295,5 +295,5 @@ type Resource struct {

// MetaResource is the metadata associated with the resource scraped from
// the Terraform registry.
MetaResource *meta.Resource
MetaResource *registry.Resource
}
41 changes: 31 additions & 10 deletions pkg/meta/resource.go → pkg/registry/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright 2022 Upbound Inc.
*/

package meta
package registry

import (
"io/ioutil"
Expand All @@ -16,7 +16,7 @@ import (
const (
// RandRFC1123Subdomain represents a template variable to be substituted
// by the test runner at runtime with a random RFC1123 subdomain string.
RandRFC1123Subdomain = "{{ .Rand.RFC1123Subdomain }}"
RandRFC1123Subdomain = "${Rand.RFC1123Subdomain}"
)

// Dependencies are the example manifests for the dependency resources.
Expand All @@ -34,14 +34,35 @@ type ResourceExample struct {

// Resource represents the scraped metadata for a Terraform resource
type Resource struct {
SubCategory string `yaml:"subCategory"`
Description string `yaml:"description,omitempty"`
Name string `yaml:"name"`
TitleName string `yaml:"titleName"`
Examples []ResourceExample `yaml:"examples,omitempty"`
ArgumentDocs map[string]string `yaml:"argumentDocs"`
ImportStatements []string `yaml:"importStatements"`
ExternalName string `yaml:"-"`
// SubCategory is the category name under which this Resource resides in
// Terraform registry docs. Example:"Key Vault" for Azure Vault resources.
// In Terraform docs, resources are grouped (categorized) using this field.
SubCategory string `yaml:"subCategory"`
// Description is a short description for the resource as it appears in
// Terraform registry. Example: "Manages a Key Vault Key." for the
// azurerm_key_vault_key resource.
// This field is suitable for use in generating CRD Kind documentation.
Description string `yaml:"description,omitempty"`
// Name is the Terraform name of the resource. Example: azurerm_key_vault_key
Name string `yaml:"name"`
// Title is the title name of the resource that appears in
// the Terraform registry doc page for a Terraform resource.
Title string `yaml:"title"`
// Examples are the example HCL configuration blocks for the resource
// that appear in the resource's registry page. They are in the same
// order as they appear on the registry page.
Examples []ResourceExample `yaml:"examples,omitempty"`
// ArgumentDocs maps resource attributes to their documentation in the
// resource's registry page.
ArgumentDocs map[string]string `yaml:"argumentDocs"`
// ImportStatements are the example Terraform import statements as they
// appear in the resource's registry page.
// Example: terraform import azurerm_key_vault.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.KeyVault/vaults/vault1
ImportStatements []string `yaml:"importStatements"`
// ExternalName configured for this resource. This allows the
// external name used in the generated example manifests to be
// overridden for a specific resource via configuration.
ExternalName string `yaml:"-"`
}

// ProviderMetadata metadata for a Terraform native provider
Expand Down

0 comments on commit 81bfd3e

Please sign in to comment.