|
1 | 1 | package provider |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "bytes" |
4 | 5 | "context" |
5 | 6 | "fmt" |
6 | 7 | "regexp" |
@@ -743,27 +744,44 @@ func flattenDataSourceList(d *schema.ResourceData, dataSourceList []*v1pb.DataSo |
743 | 744 | } |
744 | 745 |
|
745 | 746 | func dataSourceHash(rawDataSource interface{}) int { |
746 | | - dataSource := rawDataSource.(map[string]interface{}) |
747 | | - // Include id and SSL-related field presence to detect configuration changes |
748 | | - hashStr := dataSource["id"].(string) |
| 747 | + var buf bytes.Buffer |
| 748 | + raw := rawDataSource.(map[string]interface{}) |
749 | 749 |
|
750 | | - // Include use_ssl in hash to detect SSL enablement changes |
751 | | - if v, ok := dataSource["use_ssl"].(bool); ok { |
752 | | - hashStr = fmt.Sprintf("%s-ssl_%t", hashStr, v) |
| 750 | + if v, ok := raw["id"].(string); ok { |
| 751 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
| 752 | + } |
| 753 | + if v, ok := raw["username"].(string); ok { |
| 754 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
| 755 | + } |
| 756 | + if v, ok := raw["password"].(string); ok { |
| 757 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
| 758 | + } |
| 759 | + if v, ok := raw["host"].(string); ok { |
| 760 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
| 761 | + } |
| 762 | + if v, ok := raw["port"].(string); ok { |
| 763 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
| 764 | + } |
| 765 | + if v, ok := raw["database"].(string); ok { |
| 766 | + _, _ = buf.WriteString(fmt.Sprintf("%s-", v)) |
753 | 767 | } |
754 | 768 |
|
| 769 | + // Include use_ssl in hash to detect SSL enablement changes |
| 770 | + if v, ok := raw["use_ssl"].(bool); ok { |
| 771 | + _, _ = buf.WriteString(fmt.Sprintf("ssl_%v-", v)) |
| 772 | + } |
755 | 773 | // Include whether SSL certificates are present (not the values themselves) |
756 | | - if v, ok := dataSource["ssl_ca"].(string); ok && v != "" { |
757 | | - hashStr = fmt.Sprintf("%s-ca_present", hashStr) |
| 774 | + if v, ok := raw["ssl_ca"].(string); ok && v != "" { |
| 775 | + _, _ = buf.WriteString(fmt.Sprintf("ca_present_%s-", v)) |
758 | 776 | } |
759 | | - if v, ok := dataSource["ssl_cert"].(string); ok && v != "" { |
760 | | - hashStr = fmt.Sprintf("%s-cert_present", hashStr) |
| 777 | + if v, ok := raw["ssl_cert"].(string); ok && v != "" { |
| 778 | + _, _ = buf.WriteString(fmt.Sprintf("cert_present_%s-", v)) |
761 | 779 | } |
762 | | - if v, ok := dataSource["ssl_key"].(string); ok && v != "" { |
763 | | - hashStr = fmt.Sprintf("%s-key_present", hashStr) |
| 780 | + if v, ok := raw["ssl_key"].(string); ok && v != "" { |
| 781 | + _, _ = buf.WriteString(fmt.Sprintf("key_present_%s-", v)) |
764 | 782 | } |
765 | 783 |
|
766 | | - return internal.ToHashcodeInt(hashStr) |
| 784 | + return internal.ToHashcodeInt(buf.String()) |
767 | 785 | } |
768 | 786 |
|
769 | 787 | func convertDataSourceCreateList(d *schema.ResourceData, validate bool) ([]*v1pb.DataSource, error) { |
|
0 commit comments