@@ -326,20 +326,39 @@ type ReconcileConfig struct {
326326 RequeueOnSuccessSeconds int `json:"requeue_on_success_seconds,omitempty"`
327327}
328328
329- // ResourceConfig returns the ResourceConfig for a given resource name
330- func (c * Config ) ResourceConfig (name string ) (* ResourceConfig , bool ) {
329+ // ResourceIsIgnored returns true if resource name is configured to be ignored
330+ // in generator config for the AWS service
331+ func (c * Config ) ResourceIsIgnored (resourceName string ) bool {
332+ if resourceName == "" {
333+ return true
334+ }
335+ if c == nil {
336+ return false
337+ }
338+ return util .InStrings (resourceName , c .Ignore .ResourceNames )
339+ }
340+
341+ // ResourceIsAdoptable returns true if resource name is configured to be adoptable.
342+ // Default behavior is every resource can be adopted using AdoptionReconciler
343+ func (c * Config ) ResourceIsAdoptable (resourceName string ) bool {
331344 if c == nil {
332- return nil , false
345+ return true
346+ }
347+ rConfig , ok := c .Resources [resourceName ]
348+ if ! ok {
349+ return true
333350 }
334- rc , ok := c .Resources [name ]
335- return & rc , ok
351+ if rConfig .IsAdoptable == nil {
352+ return true
353+ }
354+ return * rConfig .IsAdoptable
336355}
337356
338- // UnpacksAttributesMap returns true if the underlying API has
357+ // ResourceContainsAttributesMap returns true if the underlying API has
339358// Get{Resource}Attributes/Set{Resource}Attributes API calls that map real,
340359// schema'd fields to a raw `map[string]*string` for a given resource name (see SNS and
341360// SQS APIs)
342- func (c * Config ) UnpacksAttributesMap (resourceName string ) bool {
361+ func (c * Config ) ResourceContainsAttributesMap (resourceName string ) bool {
343362 if c == nil {
344363 return false
345364 }
@@ -357,12 +376,28 @@ func (c *Config) UnpacksAttributesMap(resourceName string) bool {
357376 return false
358377}
359378
360- // SetAttributesSingleAttribute returns true if the supplied resource name has
379+ // ResourceDisplaysAgeColumn returns true if the resource is
380+ // configured to display resource age (created since date)
381+ func (c * Config ) ResourceDisplaysAgeColumn (resourceName string ) bool {
382+ if c == nil {
383+ return false
384+ }
385+ rConfig , ok := c .Resources [resourceName ]
386+ if ! ok {
387+ return false
388+ }
389+ if rConfig .Print != nil {
390+ return rConfig .Print .AddAgeColumn
391+ }
392+ return false
393+ }
394+
395+ // ResourceSetsSingleAttribute returns true if the supplied resource name has
361396// a SetAttributes operation that only actually changes a single attribute at a
362397// time. See: SNS SetTopicAttributes API call, which is entirely different from
363398// the SNS SetPlatformApplicationAttributes API call, which sets multiple
364399// attributes at once. :shrug:
365- func (c * Config ) SetAttributesSingleAttribute (resourceName string ) bool {
400+ func (c * Config ) ResourceSetsSingleAttribute (resourceName string ) bool {
366401 if c == nil {
367402 return false
368403 }
@@ -373,10 +408,19 @@ func (c *Config) SetAttributesSingleAttribute(resourceName string) bool {
373408 return resGenConfig .UnpackAttributesMapConfig .SetAttributesSingleAttribute
374409}
375410
376- // ResourceFields returns a map, keyed by target/renamed field name, of
411+ // GetResourceConfig returns the ResourceConfig for a given resource name
412+ func (c * Config ) GetResourceConfig (resourceName string ) * ResourceConfig {
413+ if c == nil {
414+ return nil
415+ }
416+ rc , _ := c .Resources [resourceName ]
417+ return & rc
418+ }
419+
420+ // GetResourceFields returns a map, keyed by target/renamed field name, of
377421// FieldConfig struct pointers that instruct the code generator how to handle
378422// the interpretation of special Resource fields (both Spec and Status)
379- func (c * Config ) ResourceFields (resourceName string ) map [string ]* FieldConfig {
423+ func (c * Config ) GetResourceFields (resourceName string ) map [string ]* FieldConfig {
380424 if c == nil {
381425 return map [string ]* FieldConfig {}
382426 }
@@ -387,10 +431,10 @@ func (c *Config) ResourceFields(resourceName string) map[string]*FieldConfig {
387431 return resourceConfig .Fields
388432}
389433
390- // ResourceFieldByPath returns the FieldConfig for a field from
434+ // GetResourceFieldByPath returns the FieldConfig for a field from
391435// "resourceName" crd, where field.Path matches the passed "fieldPath" parameter.
392436// This method performs the case-insensitive resource and fieldPath lookup.
393- func (c * Config ) ResourceFieldByPath (resourceName string , fieldPath string ) * FieldConfig {
437+ func (c * Config ) GetResourceFieldByPath (resourceName string , fieldPath string ) * FieldConfig {
394438 var resourceConfig ResourceConfig
395439 if c == nil {
396440 return nil
@@ -411,13 +455,13 @@ func (c *Config) ResourceFieldByPath(resourceName string, fieldPath string) *Fie
411455 return nil
412456}
413457
414- // GetCompareIgnoredFields returns the list of field path to ignore when
415- // comparing two differnt objects
416- func (c * Config ) GetCompareIgnoredFields ( resName string ) []string {
458+ // GetCompareIgnoredFieldPaths returns the list of field paths to ignore when
459+ // comparing two different objects
460+ func (c * Config ) GetCompareIgnoredFieldPaths ( resourceName string ) []string {
417461 if c == nil {
418462 return nil
419463 }
420- rConfig , ok := c .Resources [resName ]
464+ rConfig , ok := c .Resources [resourceName ]
421465 if ! ok {
422466 return nil
423467 }
@@ -427,52 +471,39 @@ func (c *Config) GetCompareIgnoredFields(resName string) []string {
427471 return rConfig .Compare .Ignore
428472}
429473
430- // IsIgnoredResource returns true if resource name is configured to be ignored
431- // in generator config for the AWS service
432- func (c * Config ) IsIgnoredResource (resourceName string ) bool {
433- if resourceName == "" {
434- return true
435- }
436- if c == nil {
437- return false
438- }
439- return util .InStrings (resourceName , c .Ignore .ResourceNames )
440- }
441-
442- // ResourceFieldRename returns the renamed field for a Resource, a
443- // supplied Operation ID and original field name and whether or not a renamed
444- // override field name was found
445- func (c * Config ) ResourceFieldRename (
446- resName string ,
474+ // GetResourceFieldName returns a resource field name
475+ // after applying rename overrides, if configured
476+ func (c * Config ) GetResourceFieldName (
477+ resourceName string ,
447478 opID string ,
448479 origFieldName string ,
449- ) ( string , bool ) {
480+ ) string {
450481 if c == nil {
451- return origFieldName , false
482+ return origFieldName
452483 }
453- rConfig , ok := c .Resources [resName ]
484+ rConfig , ok := c .Resources [resourceName ]
454485 if ! ok {
455- return origFieldName , false
486+ return origFieldName
456487 }
457488 if rConfig .Renames == nil {
458- return origFieldName , false
489+ return origFieldName
459490 }
460491 oRenames , ok := rConfig .Renames .Operations [opID ]
461492 if ! ok {
462- return origFieldName , false
493+ return origFieldName
463494 }
464495 renamed , ok := oRenames .InputFields [origFieldName ]
465496 if ! ok {
466497 renamed , ok = oRenames .OutputFields [origFieldName ]
467498 if ! ok {
468- return origFieldName , false
499+ return origFieldName
469500 }
470501 }
471- return renamed , true
502+ return renamed
472503}
473504
474- // ResourceShortNames returns the CRD list of aliases
475- func (c * Config ) ResourceShortNames (resourceName string ) []string {
505+ // GetResourceShortNames returns the CRD list of aliases
506+ func (c * Config ) GetResourceShortNames (resourceName string ) []string {
476507 if c == nil {
477508 return nil
478509 }
@@ -483,22 +514,6 @@ func (c *Config) ResourceShortNames(resourceName string) []string {
483514 return rConfig .ShortNames
484515}
485516
486- // ResourceIsAdoptable returns whether the given CRD is adoptable
487- func (c * Config ) ResourceIsAdoptable (resourceName string ) bool {
488- if c == nil {
489- return true
490- }
491- rConfig , ok := c .Resources [resourceName ]
492- if ! ok {
493- return true
494- }
495- // Default to True
496- if rConfig .IsAdoptable == nil {
497- return true
498- }
499- return * rConfig .IsAdoptable
500- }
501-
502517// GetResourcePrintOrderByName returns the Printer Column order-by field name
503518func (c * Config ) GetResourcePrintOrderByName (resourceName string ) string {
504519 if c == nil {
@@ -514,24 +529,9 @@ func (c *Config) GetResourcePrintOrderByName(resourceName string) string {
514529 return ""
515530}
516531
517- // GetResourcePrintAddAgeColumn returns the resource printer AddAgeColumn config
518- func (c * Config ) GetResourcePrintAddAgeColumn (resourceName string ) bool {
519- if c == nil {
520- return false
521- }
522- rConfig , ok := c .Resources [resourceName ]
523- if ! ok {
524- return false
525- }
526- if rConfig .Print != nil {
527- return rConfig .Print .AddAgeColumn
528- }
529- return false
530- }
531-
532- // UpdateConditionsCustomMethodName returns custom update conditions operation
532+ // GetUpdateConditionsCustomMethodName returns custom update conditions operation
533533// as *string for custom resource, if specified in generator config
534- func (c * Config ) UpdateConditionsCustomMethodName (resourceName string ) string {
534+ func (c * Config ) GetUpdateConditionsCustomMethodName (resourceName string ) string {
535535 if c == nil {
536536 return ""
537537 }
@@ -542,9 +542,9 @@ func (c *Config) UpdateConditionsCustomMethodName(resourceName string) string {
542542 return resGenConfig .UpdateConditionsCustomMethodName
543543}
544544
545- // ReconcileRequeuOnSuccessSeconds returns the duration after which to requeue
545+ // GetReconcileRequeueOnSuccessSeconds returns the duration after which to requeue
546546// the custom resource as int, if specified in generator config.
547- func (c * Config ) ReconcileRequeuOnSuccessSeconds (resourceName string ) int {
547+ func (c * Config ) GetReconcileRequeueOnSuccessSeconds (resourceName string ) int {
548548 if c == nil {
549549 return 0
550550 }
@@ -560,10 +560,10 @@ func (c *Config) ReconcileRequeuOnSuccessSeconds(resourceName string) int {
560560 return 0
561561}
562562
563- // CustomUpdateMethodName returns the name of the custom resourceManager method
563+ // GetCustomUpdateMethodName returns the name of the custom resourceManager method
564564// for updating the resource state, if any has been specified in the generator
565565// config
566- func (c * Config ) CustomUpdateMethodName (resourceName string ) string {
566+ func (c * Config ) GetCustomUpdateMethodName (resourceName string ) string {
567567 if c == nil {
568568 return ""
569569 }
@@ -581,17 +581,17 @@ func (c *Config) CustomUpdateMethodName(resourceName string) string {
581581func (c * Config ) GetAllRenames (
582582 resourceName string ,
583583 operations map [string ]* awssdkmodel.Operation ,
584- ) ( map [string ]string , error ) {
584+ ) map [string ]string {
585585 renames := make (map [string ]string )
586586 if c == nil {
587- return renames , nil
587+ return renames
588588 }
589589 resourceConfig , ok := c .Resources [resourceName ]
590590 if ! ok {
591- return renames , nil
591+ return renames
592592 }
593593 if resourceConfig .Renames == nil || resourceConfig .Renames .Operations == nil {
594- return renames , nil
594+ return renames
595595 }
596596
597597 opRenameConfigs := resourceConfig .Renames .Operations
@@ -608,12 +608,12 @@ func (c *Config) GetAllRenames(
608608 }
609609 }
610610 }
611- return renames , nil
611+ return renames
612612}
613613
614- // TerminalExceptionCodes returns terminal exception codes as
614+ // GetTerminalExceptionCodes returns terminal exception codes as
615615// []string for custom resource, if specified in generator config
616- func (c * Config ) TerminalExceptionCodes (resourceName string ) []string {
616+ func (c * Config ) GetTerminalExceptionCodes (resourceName string ) []string {
617617 if c == nil {
618618 return nil
619619 }
@@ -624,10 +624,10 @@ func (c *Config) TerminalExceptionCodes(resourceName string) []string {
624624 return nil
625625}
626626
627- // ListOpMatchFieldNames returns a slice of strings representing the field
627+ // GetListOpMatchFieldNames returns a slice of strings representing the field
628628// names in the List operation's Output shape's element Shape that we should
629629// check a corresponding value in the target Spec exists.
630- func (c * Config ) ListOpMatchFieldNames (
630+ func (c * Config ) GetListOpMatchFieldNames (
631631 resName string ,
632632) []string {
633633 res := []string {}
0 commit comments