MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / processRainResourceModule

Function processRainResourceModule

cft/pkg/module.go:423–461  ·  view source on GitHub ↗

Convert the module into a node for the packaged template This is for !Rain::Module Resources

(
	module *yaml.Node,
	outputNode *yaml.Node,
	t *cft.Template,
	parent node.NodePair,
	source string,
	parsed *ParsedModule)

Source from the content-addressed store, hash-verified

421// Convert the module into a node for the packaged template
422// This is for !Rain::Module Resources
423func processRainResourceModule(
424 module *yaml.Node,
425 outputNode *yaml.Node,
426 t *cft.Template,
427 parent node.NodePair,
428 source string,
429 parsed *ParsedModule) error {
430
431 // The parent arg is the map in the template resource's Content[1] that contains Type, Properties, etc
432
433 if parent.Key == nil {
434 return errors.New("expected parent.Key to not be nil. The !Rain::Module directive should come after Type: ")
435 }
436
437 // Get the logical id of the resource we are transforming
438 logicalId := parent.Key.Value
439
440 // Make a new node that will hold our additions to the original template
441 outputNode.Content = make([]*yaml.Node, 0)
442
443 if module.Kind == yaml.DocumentNode {
444 module = module.Content[0] // ScalarNode !!map
445 }
446
447 if module.Kind != yaml.MappingNode {
448 config.Debugf("%s", node.ToSJson(module))
449 return fmt.Errorf("expected module %s to be a Mapping node", logicalId)
450 }
451
452 templateResource := parent.Value // The !!map node of the resource with Type !Rain::Module
453
454 moduleConfig, err := t.ParseModuleConfig(logicalId, templateResource)
455 if err != nil {
456 return err
457 }
458 moduleConfig.Source = source
459
460 return processModule(parsed, outputNode, t, moduleConfig, nil)
461}
462
463func checkPackageAlias(t *cft.Template, uri string) *cft.PackageAlias {
464 tokens := strings.Split(uri, "/")

Callers 1

moduleFunction · 0.85

Calls 4

DebugfFunction · 0.92
ToSJsonFunction · 0.92
processModuleFunction · 0.85
ParseModuleConfigMethod · 0.80

Tested by

no test coverage detected