diff --git a/docs/resources/module.md b/docs/resources/module.md index 0a48900..ad3cb16 100644 --- a/docs/resources/module.md +++ b/docs/resources/module.md @@ -53,7 +53,9 @@ resource "terrakube_module" "module" { ### Optional +- `folder` (String) Folder to look into for module files. Need to preprend a / and append a / to work properly. - `ssh_id` (String) Ssh connection ID for private modules +- `tag_prefix` (String) Prefix tag mono-repository modules. module/ will pick up any tag starting with 'module/*' - `vcs_id` (String) VCS connection ID for private modules ### Read-Only diff --git a/internal/client/client.go b/internal/client/client.go index a4f8b97..5e721b3 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -114,6 +114,8 @@ type ModuleEntity struct { Source string `jsonapi:"attr,source"` Vcs *VcsEntity `jsonapi:"relation,vcs,omitempty"` Ssh *SshEntity `jsonapi:"relation,ssh,omitempty"` + Folder string `jsonapi:"attr,folder"` + TagPrefix string `jsonapi:"attr,tagPrefix"` } type WorkspaceWebhookEntity struct { diff --git a/internal/provider/module_resource.go b/internal/provider/module_resource.go index a11d398..3210fcd 100644 --- a/internal/provider/module_resource.go +++ b/internal/provider/module_resource.go @@ -39,6 +39,8 @@ type ModuleResourceModel struct { Source types.String `tfsdk:"source"` VcsId types.String `tfsdk:"vcs_id"` SshId types.String `tfsdk:"ssh_id"` + TagPrefix types.String `tfsdk:"tag_prefix"` + Folder types.String `tfsdk:"folder"` } func NewModuleResource() resource.Resource { @@ -87,6 +89,14 @@ func (r *ModuleResource) Schema(ctx context.Context, req resource.SchemaRequest, Optional: true, Description: "Ssh connection ID for private modules", }, + "tag_prefix": schema.StringAttribute{ + Optional: true, + Description: "Prefix tag mono-repository modules. module/ will pick up any tag starting with 'module/*'", + }, + "folder": schema.StringAttribute{ + Optional: true, + Description: "Folder to look into for module files. Need to preprend a / and append a / to work properly.", + }, }, } } @@ -138,6 +148,8 @@ func (r *ModuleResource) Create(ctx context.Context, req resource.CreateRequest, Description: plan.Description.ValueString(), Provider: plan.ProviderName.ValueString(), Source: plan.Source.ValueString(), + TagPrefix: plan.TagPrefix.ValueString(), + Folder: plan.Folder.ValueString(), } if !plan.VcsId.IsNull() { @@ -197,6 +209,8 @@ func (r *ModuleResource) Create(ctx context.Context, req resource.CreateRequest, plan.Description = types.StringValue(newModule.Description) plan.ProviderName = types.StringValue(newModule.Provider) plan.Source = types.StringValue(newModule.Source) + plan.TagPrefix = types.StringValue(newModule.TagPrefix) + plan.Folder = types.StringValue(newModule.Folder) tflog.Info(ctx, "Module Resource Created", map[string]any{"success": true}) @@ -245,6 +259,8 @@ func (r *ModuleResource) Read(ctx context.Context, req resource.ReadRequest, res state.Description = types.StringValue(module.Description) state.ProviderName = types.StringValue(module.Provider) state.Source = types.StringValue(module.Source) + state.Folder = types.StringValue(module.Folder) + state.TagPrefix = types.StringValue(module.TagPrefix) if module.Vcs != nil { state.VcsId = types.StringValue(module.Vcs.ID) @@ -280,6 +296,8 @@ func (r *ModuleResource) Update(ctx context.Context, req resource.UpdateRequest, Description: plan.Name.ValueString(), Provider: plan.ProviderName.ValueString(), Source: plan.Source.ValueString(), + Folder: plan.Folder.ValueString(), + TagPrefix: plan.TagPrefix.ValueString(), } if !plan.VcsId.IsNull() { @@ -355,6 +373,8 @@ func (r *ModuleResource) Update(ctx context.Context, req resource.UpdateRequest, plan.Description = types.StringValue(module.Description) plan.ProviderName = types.StringValue(module.Provider) plan.Source = types.StringValue(module.Source) + plan.TagPrefix = types.StringValue(module.TagPrefix) + plan.Folder = types.StringValue(module.Folder) resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) }