Skip to content

Commit

Permalink
Rename "require" tag to "mandatory"
Browse files Browse the repository at this point in the history
  • Loading branch information
tliron committed Feb 3, 2022
1 parent 1fff175 commit d2a635d
Show file tree
Hide file tree
Showing 31 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions tosca/grammars/cloudify_v1_3/dsl-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
type DSLResource struct {
*Entity `name:"DSL resource"`

SourcePath *string `read:"source_path" require:""`
DestinationPath *string `read:"destination_path" require:""`
SourcePath *string `read:"source_path" mandatory:""`
DestinationPath *string `read:"destination_path" mandatory:""`
}

func NewDSLResource(context *tosca.Context) *DSLResource {
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/group-policy-trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type GroupPolicyTrigger struct {
*Entity `name:"group policy trigger"`

PolicyTriggerTypeName *string `read:"type" require:""`
PolicyTriggerTypeName *string `read:"type" mandatory:""`
Parameters Values `read:"parameters,Value"`

PolicyTriggerType *PolicyTriggerType `lookup:"type,PolicyTriggerTypeName" json:"-" yaml:"-"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/group-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type GroupPolicy struct {
*Entity `name:"group policy"`

PolicyTypeName *string `read:"type" require:""`
PolicyTypeName *string `read:"type" mandatory:""`
Properties Values `read:"properties,Value"`
Triggers GroupPolicyTriggers `read:"triggers,GroupPolicyTrigger"`

Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Group struct {
*Entity `name:"group"`
Name string `namespace:""`

MemberNodeTemplateNames *[]string `read:"members" require:""`
MemberNodeTemplateNames *[]string `read:"members" mandatory:""`
Policies GroupPolicies `read:"policies,GroupPolicy"`

MemberNodeTemplates NodeTemplates `lookup:"members,MemberNodeTemplateNames" json:"-" yaml:"-"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/node-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type NodeTemplate struct {
*Entity `name:"node template"`
Name string `namespace:""`

NodeTypeName *string `read:"type" require:""`
NodeTypeName *string `read:"type" mandatory:""`
Properties Values `read:"properties,Value"`
Instances *NodeTemplateInstances `read:"instances,NodeTemplateInstances"` // deprecated in Cloudify DSL 1.3
Interfaces InterfaceAssignments `read:"interfaces,InterfaceAssignment"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/operation-assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type OperationAssignment struct {
*Entity `name:"operation assignment"`
Name string

Implementation *string `read:"implementation" require:""`
Implementation *string `read:"implementation" mandatory:""`
Inputs Values `read:"inputs,Value"`
Executor *string `read:"executor"`
MaxRetries *int64 `read:"max_retries"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Plugin struct {
*Entity `name:"plugin"`
Name string `namespace:""`

Executor *string `read:"executor" require:""`
Executor *string `read:"executor" mandatory:""`
Source *string `read:"source"`
InstallArguments *string `read:"install_arguments"`
Install *bool `read:"install"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/policy-trigger-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type PolicyTriggerType struct {
*Entity `name:"policy trigger type"`
Name string `namespace:""`

Source *string `read:"source" require:""`
Source *string `read:"source" mandatory:""`
Parameters PropertyDefinitions `read:"parameters,PropertyDefinition"`
}

Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/policy-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type PolicyType struct {
*Entity `name:"policy type"`
Name string `namespace:""`

Source *string `read:"source" require:""`
Source *string `read:"source" mandatory:""`
PropertyDefinitions PropertyDefinitions `read:"properties,PropertyDefinition"`
}

Expand Down
4 changes: 2 additions & 2 deletions tosca/grammars/cloudify_v1_3/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type Policy struct {
*Entity `name:"policy"`
Name string `namespace:""`

PolicyTypeName *string `read:"type" require:""`
PolicyTypeName *string `read:"type" mandatory:""`
Properties Values `read:"properties,Value"`
TargetGroupNames *[]string `read:"targets" require:""`
TargetGroupNames *[]string `read:"targets" mandatory:""`

PolicyType *PolicyType `lookup:"type,PolicyTypeName" json:"-" yaml:"-"`
TargetGroups Groups `lookup:"targets,TargetGroupNames" json:"-" yaml:"-"`
Expand Down
4 changes: 2 additions & 2 deletions tosca/grammars/cloudify_v1_3/relationship-assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
type RelationshipAssignment struct {
*Entity `name:"relationship assignment"`

RelationshipTypeName *string `read:"type" require:""`
TargetNodeTemplateName *string `read:"target" require:""`
RelationshipTypeName *string `read:"type" mandatory:""`
TargetNodeTemplateName *string `read:"target" mandatory:""`
Properties Values `read:"properties,Value"`
SourceInterfaces InterfaceAssignments `read:"source_interfaces,InterfaceAssignment"`
TargetInterfaces InterfaceAssignments `read:"target_interfaces,InterfaceAssignment"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type Unit struct {
*Entity `name:"unit"`

ToscaDefinitionsVersion *string `read:"tosca_definitions_version" require:""`
ToscaDefinitionsVersion *string `read:"tosca_definitions_version" mandatory:""`
Metadata Metadata `read:"metadata,!Metadata"` // not in spec, but in code
Imports Imports `read:"imports,[]Import"`
Inputs Inputs `read:"inputs,Input"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/cloudify_v1_3/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Workflow struct {
*Entity `name:"workflow"`
Name string `namespace:""`

Mapping *string `read:"mapping" require:""`
Mapping *string `read:"mapping" mandatory:""`
ParameterDefinitions ParameterDefinitions `read:"parameters,ParameterDefinition"`
IsCascading *bool `read:"is_cascading"` // See: https://docs.cloudify.co/5.0.5/working_with/service_composition/component/
}
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/hot/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Output struct {
Name string `namespace:""`

Description *string `read:"description"`
Value *Value `read:"value,Value" require:""`
Value *Value `read:"value,Value" mandatory:""`
Condition *Condition `read:"condition,Condition"`
}

Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/hot/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Parameter struct {
*Entity `name:"parameter"`
Name string `namespace:""`

Type *string `read:"type" require:""`
Type *string `read:"type" mandatory:""`
Label *string `read:"label"`
Description *string `read:"description"`
Default *Value `read:"default,Value"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/hot/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Resource struct {
*Entity `name:"resource"`
Name string `namespace:""`

Type *string `read:"type" require:""`
Type *string `read:"type" mandatory:""`
Properties Values `read:"properties,Value"`
Metadata *Data `read:"metadata,Data"`
DependsOn *[]string `read:"depends_on"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Group struct {
*Entity `name:"group"`
Name string `namespace:""`

GroupTypeName *string `read:"type" require:""`
GroupTypeName *string `read:"type" mandatory:""`
Metadata Metadata `read:"metadata,Metadata"` // introduced in TOSCA 1.1
Description *string `read:"description"`
Properties Values `read:"properties,Value"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
type Import struct {
*Entity `name:"import" json:"-" yaml:"-"`

URL *string `read:"url" require:""` // renamed in TOSCA 2.0
URL *string `read:"url" mandatory:""` // renamed in TOSCA 2.0
RepositoryName *string `read:"repository"`
Namespace *string `read:"namespace"` // renamed in TOSCA 2.0
NamespaceURI *string /// removed in TOSCA 2.0
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/node-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type NodeTemplate struct {

Directives *[]string `read:"directives"`
CopyNodeTemplateName *string `read:"copy"`
NodeTypeName *string `read:"type" require:""`
NodeTypeName *string `read:"type" mandatory:""`
Metadata Metadata `read:"metadata,Metadata"` // introduced in TOSCA 1.1
Description *string `read:"description"`
Properties Values `read:"properties,Value"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Policy struct {
*Entity `name:"policy"`
Name string `namespace:""`

PolicyTypeName *string `read:"type" require:""`
PolicyTypeName *string `read:"type" mandatory:""`
Metadata Metadata `read:"metadata,Metadata"` // introduced in TOSCA 1.1
Description *string `read:"description"`
Properties Values `read:"properties,Value"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/relationship-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RelationshipTemplate struct {
Name string `namespace:""`

CopyRelationshipTemplateName *string `read:"copy"`
RelationshipTypeName *string `read:"type" require:""`
RelationshipTypeName *string `read:"type" mandatory:""`
Metadata Metadata `read:"metadata,Metadata"` // introduced in TOSCA 1.1
Description *string `read:"description"`
Properties Values `read:"properties,Value"`
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Repository struct {
Name string `namespace:""`

Description *string `read:"description"`
URL *string `read:"url" require:""`
URL *string `read:"url" mandatory:""`
Credential *Value `read:"credential,Value"` // tosca:Credential

url urlpkg.URL
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type Schema struct {
*Entity `name:"schema"`

DataTypeName *string `read:"type" require:""`
DataTypeName *string `read:"type" mandatory:""`
Description *string `read:"description"`
ConstraintClauses ConstraintClauses `read:"constraints,[]ConstraintClause" traverse:"ignore"`

Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/substitution-mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
type SubstitutionMappings struct {
*Entity `name:"substitution mappings"`

NodeTypeName *string `read:"node_type" require:""`
NodeTypeName *string `read:"node_type" mandatory:""`
CapabilityMappings CapabilityMappings `read:"capabilities,CapabilityMapping"`
RequirementMappings RequirementMappings `read:"requirements,RequirementMapping"`
PropertyMappings PropertyMappings `read:"properties,PropertyMapping"` // introduced in TOSCA 1.2
Expand Down
4 changes: 2 additions & 2 deletions tosca/grammars/tosca_v2_0/trigger-definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ type TriggerDefinition struct {
Name string

Description *string `read:"description"`
Event *string `read:"event" require:""`
Event *string `read:"event" mandatory:""`
Schedule *Value `read:"schedule,Value"` // tosca:TimeInterval
TargetFilter *EventFilter `read:"target_filter,EventFilter"`
Condition *TriggerDefinitionCondition `read:"condition,TriggerDefinitionCondition"`
Action WorkflowActivityDefinitions `read:"action,[]WorkflowActivityDefinition" require:""`
Action WorkflowActivityDefinitions `read:"action,[]WorkflowActivityDefinition" mandatory:""`
}

func NewTriggerDefinition(context *tosca.Context) *TriggerDefinition {
Expand Down
2 changes: 1 addition & 1 deletion tosca/grammars/tosca_v2_0/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
type Unit struct {
*Entity `name:"unit"`

ToscaDefinitionsVersion *string `read:"tosca_definitions_version" require:""`
ToscaDefinitionsVersion *string `read:"tosca_definitions_version" mandatory:""`
Profile *string `read:"profile"` // introduced in TOSCA 1.2 as "namespace", renamed in TOSCA 2.0
Metadata Metadata `read:"metadata,!Metadata"`
Description *string `read:"description"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type WorkflowPreconditionDefinition struct {
*Entity `name:"workflow precondition definition"`

TargetNodeTemplateOrGroupName *string `read:"target" require:""`
TargetNodeTemplateOrGroupName *string `read:"target" mandatory:""`
TargetNodeRequirementName *string `read:"target_relationship"`
ConditionClause *ConditionClause `read:"condition,ConditionClauseAnd"`

Expand Down
4 changes: 2 additions & 2 deletions tosca/grammars/tosca_v2_0/workflow-step-definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type WorkflowStepDefinition struct {
*Entity `name:"workflow step definition"`
Name string

TargetNodeTemplateOrGroupName *string `read:"target" require:""`
TargetNodeTemplateOrGroupName *string `read:"target" mandatory:""`
TargetNodeRequirementName *string `read:"target_relationship"`
OperationHost *string `read:"operation_host"`
FilterConditionClauses *ConditionClause `read:"filter,ConditionClauseAnd"` // spec is wrong, says constraint clause
ActivityDefinitions WorkflowActivityDefinitions `read:"activities,[]WorkflowActivityDefinition" require:""`
ActivityDefinitions WorkflowActivityDefinitions `read:"activities,[]WorkflowActivityDefinition" mandatory:""`
OnSuccessStepNames *[]string `read:"on_success"`
OnFailureStepNames *[]string `read:"on_failure"`

Expand Down
4 changes: 2 additions & 2 deletions tosca/parser/TAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ sequenced lists, because actually you cannot repeat the same definition name mor
The reason the TOSCA spec has this inconsistency is likely to make the syntax more like the
syntax in node\_template.)

### require:"key"
### mandatory:"key"

Read phase. Reports a problem if the key is not in the ARD. (Works in combination with "read" tag.)

The "key" value is optional. If not provided it will be read from the "read" tag.
The "key" value is optional. If not provided its value will be copied from the "read" tag.

### namespace:""

Expand Down
4 changes: 2 additions & 2 deletions tosca/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (self *ReadField) Read() {
if !ok {
if reflection.IsSliceOfPtrToStruct(fieldType) {
// If we have no items, at least have an empty slice
// so that "require" will not see a nil here
// so that "mandatory" will not see a nil here
field.Set(reflect.MakeSlice(fieldType, 0, 0))
}
return
Expand Down Expand Up @@ -232,7 +232,7 @@ func (self *ReadField) Read() {
}
if slice.IsNil() {
// If we have no items, at least have an empty slice
// so that "require" will not see a nil here
// so that "mandatory" will not see a nil here
slice = reflect.MakeSlice(fieldType, 0, 0)
}
field.Set(slice)
Expand Down
4 changes: 2 additions & 2 deletions tosca/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func (self *Context) ValidateType(requiredTypeNames ...ard.TypeName) bool {
return is
}

// From "require" tags
// From "mandatory" tags
// reflection.EntityTraverser signature
func ValidateRequiredFields(entityPtr EntityPtr) bool {
context := GetContext(entityPtr)
entity := reflect.ValueOf(entityPtr).Elem()
for fieldName, tag := range reflection.GetFieldTagsForValue(entity, "require") {
for fieldName, tag := range reflection.GetFieldTagsForValue(entity, "mandatory") {
field := entity.FieldByName(fieldName)
if reflection.IsNil(field) {
// Try to use the "read" tag for the problem report
Expand Down

0 comments on commit d2a635d

Please sign in to comment.