Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AWSFieldConfig ¶
type AWSFieldConfig struct {
}
AWSFieldConfig contains AWS-specific configuration options for this resource
type AWSResourceConfig ¶
type AWSResourceConfig struct {
// Operations contains a list of overrides for this resource's operations
Operations []*AWSResourceOperationConfig `json:"operations"`
}
AWSResourceConfig contains AWS-specific configuration options for this resource
type AWSResourceOperationConfig ¶
type AWSResourceOperationConfig struct {
// Type contains the stringified OpType, e.g. "create" or "READ_ONE"
Type string `json:"type"`
// ID contains the ID/name of the AWS SDK Operation that will serve as the
// OpType for this resource.
ID string `json:"id"`
}
AWSResourceOperationConfig instructs the generator which AWS SDK Operation to use for which type of operation for this resource.
type Config ¶
type Config struct {
// Cloud specifies the cloud service that publishes this resource.
Cloud string `json:"cloud"`
// Resources contains generator instructions for individual CRDs within an
// API
Resources map[string]*ResourceConfig `json:"resources"`
}
Config represents instructions to grm-generate on how to inspect a cloud service API model, how to generate the consistent grm model for that API and how to generate a resource manager that can manage resources in that API.
func New ¶
func New( opts ...option, ) *Config
New returns a new Config object given a supplied path to a config file
func (*Config) GetResourceConfig ¶
func (c *Config) GetResourceConfig(search string) *ResourceConfig
GetResourceConfig returns a ResourceConfig matching the supplied resource name, using case-insensitive matching.
func (*Config) GetResourceConfigs ¶
func (c *Config) GetResourceConfigs() map[string]*ResourceConfig
GetResourceConfigs returns the map, keyed by resource name, of ResourceConfigs, or an empty map if the config is nil
type FieldConfig ¶
type FieldConfig struct {
// Renames instructs the code generator to consider the field to be a
// rename of one or more names.
//
// For example, suppose we are writing a configuration block for the S3
// Bucket resource. The CreateBucket's Input shape has a Bucket member and
// through the normal course of API discovery/inference, the Bucket
// resource would get a field called "Bucket" added to it. If we wanted to
// rename that to just "Name", we could do the following:
//
// “`yaml
// resources:
// Bucket:
// fields:
// Name:
// renames:
// - Bucket
// “`
//
// Any time the generator sees the name "Bucket", it will automatically
// know that the "Name" field is what should be referred to.
Renames []string `json:"renames,omitempty"`
// Type *overrides* the type of the field. This is required for custom
// fields that are not inferred either as a Create Input/Output shape or
// via the SourceFieldConfig attribute.
//
// As an example, assume you have a Role resource where you want to add a
// custom field called Policies that is a slice of string pointers.
//
// The config snippet might look like this:
//
// “`yaml
// resources:
// Role:
// fields:
// Policies:
// type: list
// element_type: string
// “`
Type *string `json:"type,omitempty"`
// ElementType *overrides* the element type of the field when the field is
// of type FieldTypeList.
ElementType *string `json:"element_type,omitempty"`
// KeyType *overrides* the key type of the field when the field is
// of type FieldTypeMap.
KeyType *string `json:"key_type,omitempty"`
// ValueType *overrides* the value type of the field when the field is
// of type FieldTypeMap.
ValueType *string `json:"value_type,omitempty"`
// IsReadOnly indicates the field's value can not be set by a user
IsReadOnly *bool `json:"is_read_only,omitempty"`
// Required indicates whether this field is a required member or not.
IsRequired *bool `json:"is_required,omitempty"`
// IsSecret instructs the code generator that this field's value should be
// considered a secret
IsSecret *bool `json:"is_secret,omitempty"`
// IsImmutable instructs the code generator to treat the field as immutable
// after resource is initially created.
IsImmutable *bool `json:"is_immutable,omitempty"`
// AWS returns the AWS-specific field configuration
AWS *AWSFieldConfig `json:"aws,omitempty"`
}
FieldConfig represents instructions to grm-generate on how to deal with a particular resource field.
func (*FieldConfig) ForAWS ¶
func (c *FieldConfig) ForAWS() *AWSFieldConfig
ForAWS returns the AWS-specific field configuration
type ResourceConfig ¶
type ResourceConfig struct {
// Fields contains a map, keyed by field path, of field configurations
Fields map[string]*FieldConfig `json:"fields"`
// AWS returns the AWS-specific resource configuration
AWS *AWSResourceConfig `json:"aws,omitempty"`
}
ResourceConfig represents instructions to grm-generate on how to deal with a particular resource.
func (*ResourceConfig) ForAWS ¶
func (c *ResourceConfig) ForAWS() *AWSResourceConfig
ForAWS returns the AWS-specific resource configuration
func (*ResourceConfig) GetFieldConfig ¶
func (c *ResourceConfig) GetFieldConfig( path *fieldpath.Path, ) (*FieldConfig, *fieldpath.Path)
GetFieldConfig returns the FieldConfig for a specified field path. This method uses case-insensitive matching AND takes into account any renames that a field might have. If the supplied path matched a renamed field, returns the *renamed* field path as the second return value. If the field is not renamed, nil is returned for the second return value.
For example, assume the following configuration snippet:
```yaml resources:
Bucket:
fields:
Name:
renames:
- Bucket
```
Calling Bucket ResourceConfig's GetFieldConfig("Bucket") would return the FieldConfig struct for the "Name" field, since it has renames for "Bucket" along with a fieldpath.FromString("Name")
func (*ResourceConfig) GetFieldConfigs ¶
func (c *ResourceConfig) GetFieldConfigs() map[string]*FieldConfig
GetFieldConfigs returns a map, keyed by field path, of field configurations