feat: provider audit — builder support, function tuning, source archive
Аудит провайдера vs каноничный Fission. Добавлено:
Environment:
- builder_image, builder_command для Go и языков с build step
Package:
- deploy_type (literal/source) для переключения deployment/source archive
- loadPackageSourceArchive() — zip-упаковка source_dir
- Убран пустой source:{} из literal mode
Function:
- executor_type (poolmgr/newdeploy/container)
- function_timeout, idle_timeout
- min_scale, max_scale для ExecutionStrategy
Все 21 тест пройден. Обратная совместимость проверена.
Документация: doc/AUDIT_PROVIDER_VS_FISSION_2026-06-03.md
This commit is contained in:
@@ -24,13 +24,15 @@ type EnvironmentResource struct {
|
||||
}
|
||||
|
||||
type environmentResourceModel struct {
|
||||
ID types.String `tfsdk:"id"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Image types.String `tfsdk:"image"`
|
||||
Version types.Int64 `tfsdk:"version"`
|
||||
PoolSize types.Int64 `tfsdk:"poolsize"`
|
||||
Namespace types.String `tfsdk:"namespace"`
|
||||
UID types.String `tfsdk:"uid"`
|
||||
ID types.String `tfsdk:"id"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Image types.String `tfsdk:"image"`
|
||||
Version types.Int64 `tfsdk:"version"`
|
||||
PoolSize types.Int64 `tfsdk:"poolsize"`
|
||||
BuilderImage types.String `tfsdk:"builder_image"`
|
||||
BuilderCommand types.String `tfsdk:"builder_command"`
|
||||
Namespace types.String `tfsdk:"namespace"`
|
||||
UID types.String `tfsdk:"uid"`
|
||||
}
|
||||
|
||||
func NewEnvironmentResource() resource.Resource {
|
||||
@@ -68,6 +70,14 @@ func (r *EnvironmentResource) Schema(_ context.Context, _ resource.SchemaRequest
|
||||
Default: int64default.StaticInt64(3),
|
||||
Description: "Размер пула pre-warmed контейнеров.",
|
||||
},
|
||||
"builder_image": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "Builder image для Environment (например ghcr.io/fission/go-builder). Нужен для языков с build step (Go и др.).",
|
||||
},
|
||||
"builder_command": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "Команда сборки в builder контейнере (например 'build').",
|
||||
},
|
||||
"namespace": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
@@ -216,6 +226,26 @@ func (r *EnvironmentResource) ImportState(ctx context.Context, req resource.Impo
|
||||
|
||||
// environmentToUnstructured преобразует Terraform model в Kubernetes CRD payload.
|
||||
func environmentToUnstructured(model environmentResourceModel, namespace string) *unstructured.Unstructured {
|
||||
spec := map[string]interface{}{
|
||||
"version": model.Version.ValueInt64(),
|
||||
"runtime": map[string]interface{}{
|
||||
"image": model.Image.ValueString(),
|
||||
},
|
||||
"poolsize": model.PoolSize.ValueInt64(),
|
||||
}
|
||||
|
||||
builderImage := model.BuilderImage.ValueString()
|
||||
if builderImage != "" {
|
||||
builder := map[string]interface{}{
|
||||
"image": builderImage,
|
||||
}
|
||||
builderCmd := model.BuilderCommand.ValueString()
|
||||
if builderCmd != "" {
|
||||
builder["command"] = builderCmd
|
||||
}
|
||||
spec["builder"] = builder
|
||||
}
|
||||
|
||||
return &unstructured.Unstructured{Object: map[string]interface{}{
|
||||
"apiVersion": "fission.io/v1",
|
||||
"kind": "Environment",
|
||||
@@ -223,13 +253,7 @@ func environmentToUnstructured(model environmentResourceModel, namespace string)
|
||||
"name": model.Name.ValueString(),
|
||||
"namespace": namespace,
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"version": model.Version.ValueInt64(),
|
||||
"runtime": map[string]interface{}{
|
||||
"image": model.Image.ValueString(),
|
||||
},
|
||||
"poolsize": model.PoolSize.ValueInt64(),
|
||||
},
|
||||
"spec": spec,
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -238,6 +262,8 @@ func unstructuredToEnvironmentModel(environmentObject *unstructured.Unstructured
|
||||
imageValue, _, _ := unstructured.NestedString(environmentObject.Object, "spec", "runtime", "image")
|
||||
versionValue, _, _ := unstructured.NestedInt64(environmentObject.Object, "spec", "version")
|
||||
poolsizeValue, _, _ := unstructured.NestedInt64(environmentObject.Object, "spec", "poolsize")
|
||||
builderImage, _, _ := unstructured.NestedString(environmentObject.Object, "spec", "builder", "image")
|
||||
builderCommand, _, _ := unstructured.NestedString(environmentObject.Object, "spec", "builder", "command")
|
||||
|
||||
state := base
|
||||
state.Name = types.StringValue(environmentObject.GetName())
|
||||
@@ -254,6 +280,12 @@ func unstructuredToEnvironmentModel(environmentObject *unstructured.Unstructured
|
||||
if poolsizeValue != 0 {
|
||||
state.PoolSize = types.Int64Value(poolsizeValue)
|
||||
}
|
||||
if builderImage != "" {
|
||||
state.BuilderImage = types.StringValue(builderImage)
|
||||
}
|
||||
if builderCommand != "" {
|
||||
state.BuilderCommand = types.StringValue(builderCommand)
|
||||
}
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user