@@ -227,7 +227,7 @@ type Resource struct {
227227 ExcludeImport bool `yaml:"exclude_import,omitempty"`
228228
229229 // If true, resource should be autogenerated as a data source
230- GenerateDatasource bool `yaml:"generate_datasource ,omitempty"`
230+ Datasource * resource. Datasource `yaml:"datasource ,omitempty"`
231231
232232 // If true, skip sweeper generation for this resource
233233 ExcludeSweeper bool `yaml:"exclude_sweeper,omitempty"`
@@ -2078,8 +2078,31 @@ func urlContainsOnlyAllowedKeys(templateURL string, allowedKeys []string) bool {
20782078 return true
20792079}
20802080
2081- func (r Resource ) ShouldGenerateSingularDataSource () bool {
2082- return r .GenerateDatasource
2081+ func (r * Resource ) ShouldGenerateSingularDataSource () bool {
2082+
2083+ if r .Datasource == nil {
2084+ return false
2085+ }
2086+
2087+ return r .Datasource .Generate
2088+ }
2089+
2090+ func (r Resource ) ShouldDatasourceSetLabels () bool {
2091+ for _ , p := range r .Properties {
2092+ if p .Name == "labels" && p .Type == "KeyValueLabels" {
2093+ return true
2094+ }
2095+ }
2096+ return false
2097+ }
2098+
2099+ func (r Resource ) ShouldDatasourceSetAnnotations () bool {
2100+ for _ , p := range r .Properties {
2101+ if p .Name == "annotations" && p .Type == "KeyValueAnnotations" {
2102+ return true
2103+ }
2104+ }
2105+ return false
20832106}
20842107
20852108// DatasourceOptionalFields returns a list of fields from the resource's URI
0 commit comments