diff --git a/internal/framework/provider/corev1/generate_namespace.hcl b/internal/framework/provider/corev1/generate_namespace.hcl index 2cd1d1b423..3713ff92b2 100644 --- a/internal/framework/provider/corev1/generate_namespace.hcl +++ b/internal/framework/provider/corev1/generate_namespace.hcl @@ -22,13 +22,11 @@ // autocrud_options { // wait_for_deletion = true -// } -// autocrud_hooks{ -// before_create = false -// after_create = false // } // } +// default_value_attributes = ["metadata.name"] + // ignored_attributes = [ // "api_version", diff --git a/internal/framework/provider/corev1/generate_secret.hcl b/internal/framework/provider/corev1/generate_secret.hcl index 66c3c6bddf..368d1e0803 100644 --- a/internal/framework/provider/corev1/generate_secret.hcl +++ b/internal/framework/provider/corev1/generate_secret.hcl @@ -38,23 +38,22 @@ computed_attributes = [ "type" ] -// default_values = { -// "id" = "testing" -// } +default_value_attributes = ["metadata.name", "immutable", "metadata.generation"] + generate { schema = true model = true autocrud = true - autocrud_options { - hooks{ - before{ - create = true - } - after{ - - } - } - } + // autocrud_options { + // hooks{ + // before{ + // create = true + // } + // after{ + + // } + // } + // } } } diff --git a/internal/framework/provider/corev1/secret_crud_gen.go b/internal/framework/provider/corev1/secret_crud_gen.go index 24eff51a65..7ec3045c70 100755 --- a/internal/framework/provider/corev1/secret_crud_gen.go +++ b/internal/framework/provider/corev1/secret_crud_gen.go @@ -18,14 +18,11 @@ func (r *Secret) Create(ctx context.Context, req resource.CreateRequest, resp *r return } - r.BeforeCreate(ctx, req, resp, &dataModel) - err := autocrud.Create(ctx, r.clientGetter, r.APIVersion, r.Kind, &dataModel) if err != nil { resp.Diagnostics.AddError("Error creating resource", err.Error()) return } - diags := resp.State.Set(ctx, &dataModel) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { @@ -41,7 +38,6 @@ func (r *Secret) Read(ctx context.Context, req resource.ReadRequest, resp *resou resp.Diagnostics.AddError("Error reading resource", err.Error()) return } - diags := resp.State.Set(ctx, &dataModel) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { @@ -63,7 +59,6 @@ func (r *Secret) Update(ctx context.Context, req resource.UpdateRequest, resp *r resp.Diagnostics.AddError("Error updating resource", err.Error()) return } - diags := resp.State.Set(ctx, &dataModel) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { @@ -73,13 +68,11 @@ func (r *Secret) Update(ctx context.Context, req resource.UpdateRequest, resp *r func (r *Secret) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { waitForDeletion := false - err := autocrud.Delete(ctx, r.clientGetter, r.Kind, r.APIVersion, req, waitForDeletion) if err != nil { resp.Diagnostics.AddError("Error deleting resource", err.Error()) return } - } func (r *Secret) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { diff --git a/internal/framework/provider/corev1/secret_schema_gen.go b/internal/framework/provider/corev1/secret_schema_gen.go index 76ef2acd30..5bd6d94dc7 100755 --- a/internal/framework/provider/corev1/secret_schema_gen.go +++ b/internal/framework/provider/corev1/secret_schema_gen.go @@ -5,6 +5,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -17,7 +19,6 @@ func (r *Secret) Schema(ctx context.Context, req resource.SchemaRequest, resp *r MarkdownDescription: `The unique ID for this terraform resource`, Optional: true, Computed: true, - Default: stringdefault.StaticString("str"), }, "data": schema.MapAttribute{ MarkdownDescription: `Data contains the secret data. Each key must consist of alphanumeric characters, '-', '_' or '.'. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4`, @@ -27,6 +28,8 @@ func (r *Secret) Schema(ctx context.Context, req resource.SchemaRequest, resp *r "immutable": schema.BoolAttribute{ MarkdownDescription: `Immutable, if set to true, ensures that data stored in the Secret cannot be updated (only object metadata can be modified). If not set to true, the field can be modified at any time. Defaulted to nil.`, Optional: true, + Default: booldefault.StaticBool(false), //TODO change to default value + }, "metadata": schema.SingleNestedAttribute{ MarkdownDescription: `Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata`, @@ -49,6 +52,8 @@ Applied only if Name is not specified. More info: https://git.k8s.io/community/c MarkdownDescription: `A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.`, Optional: true, Computed: true, + Default: int64default.StaticInt64(0), //TODO change to default value + }, "labels": schema.MapAttribute{ MarkdownDescription: `Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels`, @@ -59,6 +64,8 @@ Applied only if Name is not specified. More info: https://git.k8s.io/community/c MarkdownDescription: `Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names`, Optional: true, Computed: true, + Default: stringdefault.StaticString(""), // TODO: add default value + }, "namespace": schema.StringAttribute{ MarkdownDescription: `Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. diff --git a/internal/framework/provider/resources_list_gen.go b/internal/framework/provider/resources_list_gen.go index 0a9366dfb1..ce24525591 100755 --- a/internal/framework/provider/resources_list_gen.go +++ b/internal/framework/provider/resources_list_gen.go @@ -2,7 +2,7 @@ // // This file contains the list of constructors for resources that have been autogenerated. // -// This code was written by a robot on Mar 26, 2024 15:25:45 UTC. +// This code was written by a robot on Mar 27, 2024 14:43:34 UTC. package provider