feat: provider v0.1.9 — namespace removed from resources, moved to provider block
This commit is contained in:
@@ -51,7 +51,6 @@ func NewFunctionResource() resource.Resource {
|
||||
|
||||
// FunctionModel — модель состояния terraform для sless_function.
|
||||
type FunctionModel struct {
|
||||
Namespace types.String `tfsdk:"namespace"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Runtime types.String `tfsdk:"runtime"`
|
||||
Entrypoint types.String `tfsdk:"entrypoint"`
|
||||
@@ -75,13 +74,7 @@ func (r *FunctionResource) Metadata(_ context.Context, req resource.MetadataRequ
|
||||
func (r *FunctionResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
|
||||
resp.Schema = schema.Schema{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
// namespace + name — immutable, смена требует пересоздания ресурса
|
||||
"namespace": schema.StringAttribute{
|
||||
Required: true,
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.RequiresReplace(),
|
||||
},
|
||||
},
|
||||
// name — immutable, смена требует пересоздания ресурса
|
||||
"name": schema.StringAttribute{
|
||||
Required: true,
|
||||
PlanModifiers: []planmodifier.String{
|
||||
@@ -175,7 +168,7 @@ func (r *FunctionResource) Create(ctx context.Context, req resource.CreateReques
|
||||
return
|
||||
}
|
||||
|
||||
ns := plan.Namespace.ValueString()
|
||||
ns := r.client.Namespace
|
||||
envVars, d := mapToStringMap(ctx, plan.EnvVars)
|
||||
resp.Diagnostics.Append(d...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
@@ -221,7 +214,7 @@ func (r *FunctionResource) Read(ctx context.Context, req resource.ReadRequest, r
|
||||
return
|
||||
}
|
||||
|
||||
fn, err := r.client.GetFunction(ctx, state.Namespace.ValueString(), state.Name.ValueString())
|
||||
fn, err := r.client.GetFunction(ctx, r.client.Namespace, state.Name.ValueString())
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("read function", err.Error())
|
||||
return
|
||||
@@ -243,7 +236,7 @@ func (r *FunctionResource) Update(ctx context.Context, req resource.UpdateReques
|
||||
return
|
||||
}
|
||||
|
||||
ns := plan.Namespace.ValueString()
|
||||
ns := r.client.Namespace
|
||||
name := plan.Name.ValueString()
|
||||
|
||||
envVars, d := mapToStringMap(ctx, plan.EnvVars)
|
||||
@@ -293,7 +286,7 @@ func (r *FunctionResource) Delete(ctx context.Context, req resource.DeleteReques
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.client.DeleteFunction(ctx, state.Namespace.ValueString(), state.Name.ValueString()); err != nil {
|
||||
if err := r.client.DeleteFunction(ctx, r.client.Namespace, state.Name.ValueString()); err != nil {
|
||||
resp.Diagnostics.AddError("delete function", err.Error())
|
||||
}
|
||||
}
|
||||
@@ -307,7 +300,6 @@ func fnToModel(plan FunctionModel, fn *client.FunctionResponse) FunctionModel {
|
||||
buildTimeoutSec = types.Int64Value(defaultBuildTimeoutSec)
|
||||
}
|
||||
return FunctionModel{
|
||||
Namespace: types.StringValue(fn.Namespace),
|
||||
Name: types.StringValue(fn.Name),
|
||||
Runtime: types.StringValue(fn.Runtime),
|
||||
Entrypoint: types.StringValue(fn.Entrypoint),
|
||||
|
||||
Reference in New Issue
Block a user