diff --git a/helm-framework/helm/data_source_helm_template.go b/helm-framework/helm/data_source_helm_template.go index db0a5229f..5be6707d0 100644 --- a/helm-framework/helm/data_source_helm_template.go +++ b/helm-framework/helm/data_source_helm_template.go @@ -31,20 +31,20 @@ import ( "sigs.k8s.io/yaml" ) -var _ datasource.DataSource = &DataTemplate{} -var _ datasource.DataSourceWithConfigure = &DataTemplate{} +var _ datasource.DataSource = &HelmTemplate{} +var _ datasource.DataSourceWithConfigure = &HelmTemplate{} -func NewDataTemplate() datasource.DataSource { - return &DataTemplate{} +func NewHelmTemplate() datasource.DataSource { + return &HelmTemplate{} } -// DataTemplate represents the data source for rendering Helm chart templates -type DataTemplate struct { +// HelmTemplate represents the data source for rendering Helm chart templates +type HelmTemplate struct { meta *Meta } -// DataTemplateModel holds the attributes for configuring the Helm chart templates -type DataTemplateModel struct { +// HelmTemplateModel holds the attributes for configuring the Helm chart templates +type HelmTemplateModel struct { ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` Repository types.String `tfsdk:"repository"` @@ -122,17 +122,17 @@ type Postrender struct { BinaryPath types.String `tfsdk:"binary_path"` } -func (d *DataTemplate) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (d *HelmTemplate) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData != nil { d.meta = req.ProviderData.(*Meta) } } -func (d *DataTemplate) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (d *HelmTemplate) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_template" } -func (d *DataTemplate) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (d *HelmTemplate) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Data source to render Helm chart templates.", Attributes: map[string]schema.Attribute{ @@ -402,8 +402,8 @@ func convertStringsToTypesStrings(input []string) []types.String { } // Reads the current state of the data template and will update the state with the data fetched -func (d *DataTemplate) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var state DataTemplateModel +func (d *HelmTemplate) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state HelmTemplateModel resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) if resp.Diagnostics.HasError() { return @@ -656,7 +656,7 @@ func (d *DataTemplate) Read(ctx context.Context, req datasource.ReadRequest, res resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } -func getTemplateValues(ctx context.Context, model *DataTemplateModel) (map[string]interface{}, diag.Diagnostics) { +func getTemplateValues(ctx context.Context, model *HelmTemplateModel) (map[string]interface{}, diag.Diagnostics) { base := map[string]interface{}{} var diags diag.Diagnostics @@ -823,7 +823,7 @@ func getDataValue(base map[string]interface{}, set SetValue) diag.Diagnostics { return diags } -func logDataValues(ctx context.Context, values map[string]interface{}, model *DataTemplateModel) diag.Diagnostics { +func logDataValues(ctx context.Context, values map[string]interface{}, model *HelmTemplateModel) diag.Diagnostics { var diags diag.Diagnostics asJSON, err := json.Marshal(values) @@ -851,7 +851,7 @@ func logDataValues(ctx context.Context, values map[string]interface{}, model *Da return diags } -func cloakDataSetValues(ctx context.Context, config map[string]interface{}, model *DataTemplateModel) diag.Diagnostics { +func cloakDataSetValues(ctx context.Context, config map[string]interface{}, model *HelmTemplateModel) diag.Diagnostics { var diags diag.Diagnostics if !model.SetSensitive.IsNull() && !model.SetSensitive.IsUnknown() { diff --git a/helm-framework/helm/provider.go b/helm-framework/helm/provider.go index 2c7c9740f..5b6927268 100644 --- a/helm-framework/helm/provider.go +++ b/helm-framework/helm/provider.go @@ -637,13 +637,13 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ func (p *HelmProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ - NewDataTemplate, + NewHelmTemplate, } } func (p *HelmProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ - NewHelmReleaseResource, + NewHelmRelease, } } diff --git a/helm-framework/helm/resource_helm_release.go b/helm-framework/helm/resource_helm_release.go index bbb22e230..670928594 100644 --- a/helm-framework/helm/resource_helm_release.go +++ b/helm-framework/helm/resource_helm_release.go @@ -41,18 +41,18 @@ import ( ) var ( - _ resource.Resource = &HelmReleaseResource{} - _ resource.ResourceWithUpgradeState = &HelmReleaseResource{} - _ resource.ResourceWithModifyPlan = &HelmReleaseResource{} - _ resource.ResourceWithImportState = &HelmReleaseResource{} + _ resource.Resource = &HelmRelease{} + _ resource.ResourceWithUpgradeState = &HelmRelease{} + _ resource.ResourceWithModifyPlan = &HelmRelease{} + _ resource.ResourceWithImportState = &HelmRelease{} ) -type HelmReleaseResource struct { +type HelmRelease struct { meta *Meta } -func NewHelmReleaseResource() resource.Resource { - return &HelmReleaseResource{} +func NewHelmRelease() resource.Resource { + return &HelmRelease{} } type HelmReleaseModel struct { @@ -252,11 +252,11 @@ func NewNamespacePlanModifier() planmodifier.String { return &NamespacePlanModifier{} } -func (r *HelmReleaseResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *HelmRelease) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_release" } -func (r *HelmReleaseResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *HelmRelease) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Schema to define attributes that are available in the resource", Attributes: map[string]schema.Attribute{ @@ -595,7 +595,7 @@ func (r *HelmReleaseResource) Schema(ctx context.Context, req resource.SchemaReq } } -func (r *HelmReleaseResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *HelmRelease) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Ensure that the ProviderData is not nil if req.ProviderData == nil { return @@ -616,7 +616,7 @@ func (r *HelmReleaseResource) Configure(ctx context.Context, req resource.Config // maps version 0 state to the upgrade function. // If terraform detects data with version 0, we call upgrade to upgrade the state to the current schema version "1" -func (r *HelmReleaseResource) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { +func (r *HelmRelease) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { return map[int64]resource.StateUpgrader{ 0: { StateUpgrader: stateUpgradeV0toV1, @@ -679,7 +679,7 @@ func mergeMaps(a, b map[string]interface{}) map[string]interface{} { return out } -func (r *HelmReleaseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *HelmRelease) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var state HelmReleaseModel diags := req.Plan.Get(ctx, &state) resp.Diagnostics.Append(diags...) @@ -836,7 +836,7 @@ func (r *HelmReleaseResource) Create(ctx context.Context, req resource.CreateReq } } -func (r *HelmReleaseResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *HelmRelease) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state HelmReleaseModel diags := req.State.Get(ctx, &state) @@ -899,7 +899,7 @@ func (r *HelmReleaseResource) Read(ctx context.Context, req resource.ReadRequest resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } -func (r *HelmReleaseResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *HelmRelease) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan HelmReleaseModel diags := req.Plan.Get(ctx, &plan) resp.Diagnostics.Append(diags...) @@ -1035,7 +1035,7 @@ func (r *HelmReleaseResource) Update(ctx context.Context, req resource.UpdateReq } } -func (r *HelmReleaseResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r *HelmRelease) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state HelmReleaseModel diags := req.State.Get(ctx, &state) @@ -1664,7 +1664,7 @@ func checkChartDependencies(ctx context.Context, model *HelmReleaseModel, c *cha return false, diags } -func (r *HelmReleaseResource) StateUpgrade(ctx context.Context, version int, state map[string]interface{}, meta interface{}) (map[string]interface{}, diag.Diagnostics) { +func (r *HelmRelease) StateUpgrade(ctx context.Context, version int, state map[string]interface{}, meta interface{}) (map[string]interface{}, diag.Diagnostics) { var diags diag.Diagnostics if state["pass_credentials"] == nil { @@ -1677,7 +1677,7 @@ func (r *HelmReleaseResource) StateUpgrade(ctx context.Context, version int, sta return state, diags } -func (r *HelmReleaseResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { +func (r *HelmRelease) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { if req.Plan.Raw.IsNull() { // resource is being destroyed return @@ -2056,7 +2056,7 @@ func resultToError(r *action.LintResult) error { return fmt.Errorf("malformed chart or values: \n\t%s", strings.Join(messages, "\n\t")) } -func (r *HelmReleaseResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *HelmRelease) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { namespace, name, err := parseImportIdentifier(req.ID) if err != nil { resp.Diagnostics.AddError(