@synopackageland/cli 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/build-spk/generator.js +3 -0
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +9 -2
- package/dist/error-registry.js +20 -0
- package/dist/init.d.ts +4 -0
- package/dist/init.js +20 -12
- package/dist/standalone/build.js +3 -1
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +1 -1
- package/dist/standalone/dsm-window.js +50 -10
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +2 -12
- package/dist/standalone/helper.js +8 -7
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +2 -0
- package/dist/standalone/inspect-spk.js +49 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +4 -1
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.js +9 -0
- package/dist/standalone/root-window.d.ts +4 -3
- package/dist/standalone/root-window.js +17 -5
- package/dist/standalone/spk.d.ts +4 -3
- package/dist/standalone/spk.js +20 -33
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/native-go/README.md +57 -1
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/go.mod +4 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
- package/dist/templates/native-go/backend/internal/api/server.go +4 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
- package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
- package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/ui/app.js +8 -1
- package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
- package/dist/templates/native-go-vue/README.md +115 -1
- package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/dist/templates/native-go-vue/frontend/package.json +1 -1
- package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
- package/package.json +3 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/native-go/README.md +57 -1
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/go.mod +4 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/registry.go +14 -4
- package/templates/native-go/backend/internal/api/server.go +4 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/routes.go +11 -0
- package/templates/native-go/backend/internal/app/routes_test.go +10 -5
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +226 -21
- package/templates/native-go/backend/internal/helper/control_test.go +10 -2
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
- package/templates/native-go/backend/internal/helper/status.go +74 -11
- package/templates/native-go/backend/internal/helper/status_test.go +83 -0
- package/templates/native-go/backend/internal/helper/supervision.go +28 -5
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/ui/app.js +8 -1
- package/templates/native-go-better-auth/node/build.mjs +2 -0
- package/templates/native-go-vue/README.md +115 -1
- package/templates/native-go-vue/frontend/DESIGN.md +1 -1
- package/templates/native-go-vue/frontend/package-lock.json +132 -229
- package/templates/native-go-vue/frontend/package.json +1 -1
- package/templates/native-go-vue/frontend/src/App.vue +33 -6
- package/templates/native-go-vue/frontend/src/context.ts +41 -2
- package/templates/native-go-vue/frontend/src/main.ts +4 -1
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +17 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -1
- package/templates/native-go-vue/frontend/vite.config.ts +6 -4
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"fmt"
|
|
7
|
+
"github.com/godbus/dbus/v5"
|
|
8
|
+
"os"
|
|
9
|
+
"os/exec"
|
|
10
|
+
"path/filepath"
|
|
11
|
+
"reflect"
|
|
12
|
+
"strings"
|
|
13
|
+
"sync"
|
|
14
|
+
"testing"
|
|
15
|
+
"time"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
func TestLinuxUnitRemovedRequiresFreshVerification(t *testing.T) {
|
|
19
|
+
b := testBinding()
|
|
20
|
+
g := newAdmission(b)
|
|
21
|
+
g.observe(b, 7, true, time.Now())
|
|
22
|
+
o := &unitObserver{unit: "pkgctl-root.service", path: systemdUnitPath("pkgctl-root.service"), owner: ":1.1", gate: g}
|
|
23
|
+
o.DeliverSignal("", "", &dbus.Signal{Sender: o.owner, Path: "/org/freedesktop/systemd1", Name: managerInterface + ".UnitRemoved", Body: []interface{}{o.unit, o.path}})
|
|
24
|
+
if g.allow(time.Now()) || g.reason() != "" {
|
|
25
|
+
t.Fatalf("must suspend admission without sticky fence: %s", g.reason())
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Opt-in, disposable root VM. Captures the actual systemd signal sequence and
|
|
30
|
+
// proves a daemon reload cannot alter this helper's durable epoch or identity.
|
|
31
|
+
func TestLinuxDaemonReloadPreservesHelperEpoch(t *testing.T) {
|
|
32
|
+
p := linuxFixture(t)
|
|
33
|
+
process := startVMHelper(t, p)
|
|
34
|
+
before, err := readRecord(p.StateDir, 0)
|
|
35
|
+
if err != nil {
|
|
36
|
+
t.Fatal(err)
|
|
37
|
+
}
|
|
38
|
+
child := supervisedPID(t, process.PID)
|
|
39
|
+
conn, err := dbus.ConnectSystemBus()
|
|
40
|
+
if err != nil {
|
|
41
|
+
t.Fatal(err)
|
|
42
|
+
}
|
|
43
|
+
defer conn.Close()
|
|
44
|
+
if err = conn.AddMatchSignal(dbus.WithMatchInterface(managerInterface)); err != nil {
|
|
45
|
+
t.Fatal(err)
|
|
46
|
+
}
|
|
47
|
+
events := make(chan *dbus.Signal, 1024)
|
|
48
|
+
conn.Signal(events)
|
|
49
|
+
if err = conn.Object(systemdName, "/org/freedesktop/systemd1").Call(managerInterface+".Subscribe", 0).Err; err != nil {
|
|
50
|
+
t.Fatal(err)
|
|
51
|
+
}
|
|
52
|
+
var signalMu sync.Mutex
|
|
53
|
+
var signals []string
|
|
54
|
+
done := make(chan struct{})
|
|
55
|
+
stopped := make(chan struct{})
|
|
56
|
+
go func() {
|
|
57
|
+
defer close(stopped)
|
|
58
|
+
for {
|
|
59
|
+
select {
|
|
60
|
+
case s := <-events:
|
|
61
|
+
if s.Name == managerInterface+".Reloading" || (len(s.Body) > 0 && s.Body[0] == "pkgctl-root.service") {
|
|
62
|
+
signalMu.Lock()
|
|
63
|
+
signals = append(signals, fmt.Sprintf("%s %s %v", time.Now().Format(time.RFC3339Nano), s.Name, s.Body))
|
|
64
|
+
signalMu.Unlock()
|
|
65
|
+
}
|
|
66
|
+
case <-done:
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}()
|
|
71
|
+
defer func() {
|
|
72
|
+
close(done)
|
|
73
|
+
<-stopped
|
|
74
|
+
signalMu.Lock()
|
|
75
|
+
defer signalMu.Unlock()
|
|
76
|
+
for _, s := range signals {
|
|
77
|
+
t.Log("systemd signal:", s)
|
|
78
|
+
}
|
|
79
|
+
}()
|
|
80
|
+
for n := 0; n < 3; n++ {
|
|
81
|
+
started := time.Now()
|
|
82
|
+
if out, err := exec.Command("systemctl", "daemon-reload").CombinedOutput(); err != nil {
|
|
83
|
+
t.Fatalf("reload: %s: %v", out, err)
|
|
84
|
+
}
|
|
85
|
+
time.Sleep(600 * time.Millisecond)
|
|
86
|
+
after, e := readRecord(p.StateDir, 0)
|
|
87
|
+
encoded, _ := json.Marshal(after)
|
|
88
|
+
t.Logf("reload trial=%d elapsed=%s lifecycle=%s", n+1, time.Since(started), encoded)
|
|
89
|
+
if e != nil || !reflect.DeepEqual(after, before) {
|
|
90
|
+
journal, _ := exec.Command("journalctl", "--no-pager", "-n", "30").CombinedOutput()
|
|
91
|
+
t.Fatalf("reload changed approval: lifecycle %+v -> %+v: %v; journal=%s", before.Lifecycle, after.Lifecycle, e, journal)
|
|
92
|
+
}
|
|
93
|
+
got, e := readProcess(p.RunDir, 0)
|
|
94
|
+
if e != nil || got != process || supervisedPID(t, process.PID) != child {
|
|
95
|
+
t.Fatalf("reload replaced helper: %+v: %v", got, e)
|
|
96
|
+
}
|
|
97
|
+
if state := p.Client.Status(context.Background()); state.State != "ready" {
|
|
98
|
+
t.Fatalf("health after reload: %+v", state)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
signalMu.Lock()
|
|
102
|
+
defer signalMu.Unlock()
|
|
103
|
+
seenTrue, seenFalse := false, false
|
|
104
|
+
for _, s := range signals {
|
|
105
|
+
seenTrue = seenTrue || strings.Contains(s, ".Reloading [true]")
|
|
106
|
+
seenFalse = seenFalse || strings.Contains(s, ".Reloading [false]")
|
|
107
|
+
}
|
|
108
|
+
if !seenTrue || !seenFalse {
|
|
109
|
+
t.Fatal("missing reload boundary signals")
|
|
110
|
+
}
|
|
111
|
+
t.Logf("reload preserved epoch=%s", before.Lifecycle.Epoch)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
func activeUnitValues(o *unitObserver) map[string]dbus.Variant {
|
|
115
|
+
return map[string]dbus.Variant{"Id": dbus.MakeVariant(o.unit), "LoadState": dbus.MakeVariant("loaded"), "ActiveState": dbus.MakeVariant("active"), "SubState": dbus.MakeVariant("exited"), "ActiveEnterTimestampMonotonic": dbus.MakeVariant(uint64(7)), "Job": dbus.MakeVariant([]interface{}{uint32(0), dbus.ObjectPath("/")}), "InvocationID": dbus.MakeVariant([]byte("1234567890123456"))}
|
|
116
|
+
}
|
|
117
|
+
func TestLinuxReloadRetainsStopRemoveRestartFences(t *testing.T) {
|
|
118
|
+
for _, kind := range []string{"unchanged", "stop", "restart", "job", "job-snapshot", "malformed-job", "zero-invocation", "invalidated", "owner", "disconnect", "load", "substate", "wrong-id", "timestamp", "invocation", "missing-invocation", "malformed-invocation", "malformed-reload", "foreign-reload", "other-removal"} {
|
|
119
|
+
t.Run(kind, func(t *testing.T) {
|
|
120
|
+
g := newAdmission(testBinding())
|
|
121
|
+
o := &unitObserver{unit: "pkgctl-root.service", path: systemdUnitPath("pkgctl-root.service"), owner: ":1.1", gate: g}
|
|
122
|
+
now := time.Now()
|
|
123
|
+
if err := o.observeValues(testBinding(), activeUnitValues(o), 0, now); err != nil {
|
|
124
|
+
t.Fatal(err)
|
|
125
|
+
}
|
|
126
|
+
send := func(name string, body []interface{}) {
|
|
127
|
+
o.DeliverSignal("", "", &dbus.Signal{Sender: o.owner, Path: "/org/freedesktop/systemd1", Name: managerInterface + "." + name, Body: body})
|
|
128
|
+
}
|
|
129
|
+
send("Reloading", []interface{}{true})
|
|
130
|
+
send("UnitRemoved", []interface{}{o.unit, o.path})
|
|
131
|
+
if g.allow(now) || g.fenced(now) {
|
|
132
|
+
t.Fatal("must suspend while reloading")
|
|
133
|
+
}
|
|
134
|
+
values := activeUnitValues(o)
|
|
135
|
+
want := false
|
|
136
|
+
switch kind {
|
|
137
|
+
case "unchanged":
|
|
138
|
+
want = true
|
|
139
|
+
case "stop", "restart":
|
|
140
|
+
o.DeliverSignal("", "", &dbus.Signal{Sender: o.owner, Path: o.path, Name: propertiesInterface + ".PropertiesChanged", Body: []interface{}{unitInterface, map[string]dbus.Variant{"ActiveState": dbus.MakeVariant("inactive")}, []string{}}})
|
|
141
|
+
if kind == "restart" {
|
|
142
|
+
values["ActiveEnterTimestampMonotonic"] = dbus.MakeVariant(uint64(8))
|
|
143
|
+
}
|
|
144
|
+
case "job":
|
|
145
|
+
send("JobNew", []interface{}{uint32(1), dbus.ObjectPath("/job/1"), o.unit})
|
|
146
|
+
case "job-snapshot":
|
|
147
|
+
values["Job"] = dbus.MakeVariant([]interface{}{uint32(9), dbus.ObjectPath("/job/9")})
|
|
148
|
+
case "malformed-job":
|
|
149
|
+
values["Job"] = dbus.MakeVariant("bad")
|
|
150
|
+
case "zero-invocation":
|
|
151
|
+
values["InvocationID"] = dbus.MakeVariant(make([]byte, 16))
|
|
152
|
+
case "invalidated":
|
|
153
|
+
o.DeliverSignal("", "", &dbus.Signal{Sender: o.owner, Path: o.path, Name: propertiesInterface + ".PropertiesChanged", Body: []interface{}{unitInterface, map[string]dbus.Variant{}, []string{"InvocationID"}}})
|
|
154
|
+
case "owner":
|
|
155
|
+
g.fence("bus-owner-changed")
|
|
156
|
+
case "disconnect":
|
|
157
|
+
o.Terminate()
|
|
158
|
+
case "load":
|
|
159
|
+
values["LoadState"] = dbus.MakeVariant("not-found")
|
|
160
|
+
case "substate":
|
|
161
|
+
values["SubState"] = dbus.MakeVariant("dead")
|
|
162
|
+
case "wrong-id":
|
|
163
|
+
values["Id"] = dbus.MakeVariant("pkgctl-other.service")
|
|
164
|
+
case "timestamp":
|
|
165
|
+
values["ActiveEnterTimestampMonotonic"] = dbus.MakeVariant(uint64(8))
|
|
166
|
+
case "invocation":
|
|
167
|
+
values["InvocationID"] = dbus.MakeVariant([]byte("6543210987654321"))
|
|
168
|
+
case "missing-invocation":
|
|
169
|
+
delete(values, "InvocationID")
|
|
170
|
+
case "malformed-invocation":
|
|
171
|
+
values["InvocationID"] = dbus.MakeVariant("wrong-type")
|
|
172
|
+
case "malformed-reload":
|
|
173
|
+
send("Reloading", []interface{}{"false"})
|
|
174
|
+
case "foreign-reload":
|
|
175
|
+
want = true
|
|
176
|
+
o.DeliverSignal("", "", &dbus.Signal{Sender: ":1.2", Path: "/org/freedesktop/systemd1", Name: managerInterface + ".Reloading", Body: []interface{}{false}})
|
|
177
|
+
if _, ready := g.unitProbe(now); ready {
|
|
178
|
+
t.Fatal("foreign sender ended reload")
|
|
179
|
+
}
|
|
180
|
+
case "other-removal":
|
|
181
|
+
want = true
|
|
182
|
+
send("UnitRemoved", []interface{}{"pkgctl-other.service", systemdUnitPath("pkgctl-other.service")})
|
|
183
|
+
}
|
|
184
|
+
send("Reloading", []interface{}{false})
|
|
185
|
+
serial, _ := g.unitProbe(now)
|
|
186
|
+
_ = o.observeValues(testBinding(), values, serial, now)
|
|
187
|
+
_ = o.observeValues(testBinding(), activeUnitValues(o), serial, now)
|
|
188
|
+
if g.allow(now) != want {
|
|
189
|
+
t.Fatalf("reload acceptance %s reason=%s", kind, g.reason())
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
func TestLinuxStopDuringDaemonReloadStillFences(t *testing.T) {
|
|
196
|
+
p := linuxFixture(t)
|
|
197
|
+
process := startVMHelper(t, p)
|
|
198
|
+
conn, err := dbus.ConnectSystemBus()
|
|
199
|
+
if err != nil {
|
|
200
|
+
t.Fatal(err)
|
|
201
|
+
}
|
|
202
|
+
defer conn.Close()
|
|
203
|
+
if err = conn.AddMatchSignal(dbus.WithMatchInterface(managerInterface), dbus.WithMatchMember("Reloading")); err != nil {
|
|
204
|
+
t.Fatal(err)
|
|
205
|
+
}
|
|
206
|
+
events := make(chan *dbus.Signal, 16)
|
|
207
|
+
conn.Signal(events)
|
|
208
|
+
if err = conn.Object(systemdName, "/org/freedesktop/systemd1").Call(managerInterface+".Subscribe", 0).Err; err != nil {
|
|
209
|
+
t.Fatal(err)
|
|
210
|
+
}
|
|
211
|
+
generators := "/etc/systemd/system-generators"
|
|
212
|
+
if err = os.MkdirAll(generators, 0755); err != nil {
|
|
213
|
+
t.Fatal(err)
|
|
214
|
+
}
|
|
215
|
+
generator := filepath.Join(generators, "m1h-slow-reload")
|
|
216
|
+
if err = os.WriteFile(generator, []byte("#!/bin/sh\nsleep 0.4\n"), 0755); err != nil {
|
|
217
|
+
t.Fatal(err)
|
|
218
|
+
}
|
|
219
|
+
defer os.Remove(generator)
|
|
220
|
+
reload := exec.Command("systemctl", "daemon-reload")
|
|
221
|
+
if err = reload.Start(); err != nil {
|
|
222
|
+
t.Fatal(err)
|
|
223
|
+
}
|
|
224
|
+
defer func() { _ = reload.Wait() }()
|
|
225
|
+
select {
|
|
226
|
+
case s := <-events:
|
|
227
|
+
if len(s.Body) != 1 || s.Body[0] != true {
|
|
228
|
+
t.Fatalf("reload did not start: %+v", s)
|
|
229
|
+
}
|
|
230
|
+
case <-time.After(2 * time.Second):
|
|
231
|
+
t.Fatal("missing Reloading(true)")
|
|
232
|
+
}
|
|
233
|
+
stop := exec.Command("systemctl", "stop", "pkgctl-root.service")
|
|
234
|
+
if err = stop.Run(); err != nil {
|
|
235
|
+
t.Fatal(err)
|
|
236
|
+
}
|
|
237
|
+
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
|
238
|
+
defer cancel()
|
|
239
|
+
if err = waitHealthy(ctx, func(context.Context) bool {
|
|
240
|
+
r, e := readRecord(p.StateDir, 0)
|
|
241
|
+
return e == nil && r.Lifecycle.Phase == "stopped" && r.Lifecycle.Completion != ""
|
|
242
|
+
}); err != nil {
|
|
243
|
+
t.Fatal("stop during reload failed to fence and complete", err)
|
|
244
|
+
}
|
|
245
|
+
record, err := readRecord(p.StateDir, 0)
|
|
246
|
+
if err != nil {
|
|
247
|
+
t.Fatal(err)
|
|
248
|
+
}
|
|
249
|
+
proof, err := completionRecord(p.Client, record)
|
|
250
|
+
if err != nil || proof.Process != process {
|
|
251
|
+
t.Fatal("wrong completion identity", err)
|
|
252
|
+
}
|
|
253
|
+
vmUnit(t, "start")
|
|
254
|
+
time.Sleep(300 * time.Millisecond)
|
|
255
|
+
after, err := readRecord(p.StateDir, 0)
|
|
256
|
+
if err != nil || !reflect.DeepEqual(after, record) {
|
|
257
|
+
t.Fatal("active snapshot erased sticky fence", err)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
func TestLinuxReloadQueryAndSubscriptionFailuresFence(t *testing.T) {
|
|
262
|
+
for _, kind := range []string{"query", "disconnect"} {
|
|
263
|
+
t.Run(kind, func(t *testing.T) {
|
|
264
|
+
p := linuxFixture(t)
|
|
265
|
+
o, err := openUnitObserver(context.Background(), p.Expected)
|
|
266
|
+
if err != nil {
|
|
267
|
+
t.Fatal(err)
|
|
268
|
+
}
|
|
269
|
+
defer o.conn.Close()
|
|
270
|
+
binding, values, err := o.snapshot(context.Background())
|
|
271
|
+
if err != nil {
|
|
272
|
+
t.Fatal(err)
|
|
273
|
+
}
|
|
274
|
+
o.gate.requestUnitCheck(true, time.Now())
|
|
275
|
+
o.gate.requestUnitCheck(false, time.Now())
|
|
276
|
+
if kind == "query" {
|
|
277
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
278
|
+
cancel()
|
|
279
|
+
if err = o.reconcile(ctx); err == nil {
|
|
280
|
+
t.Fatal("canceled query succeeded")
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
o.conn.Close()
|
|
284
|
+
}
|
|
285
|
+
t.Logf("query kind=%s fence reason=%s", kind, o.gate.reason())
|
|
286
|
+
if o.gate.allow(time.Now()) || !o.gate.fenced(time.Now()) {
|
|
287
|
+
t.Fatal("query/subscription failure resumed admission")
|
|
288
|
+
}
|
|
289
|
+
serial, _ := o.gate.unitProbe(time.Now())
|
|
290
|
+
_ = o.observeValues(binding, values, serial, time.Now())
|
|
291
|
+
if o.gate.allow(time.Now()) {
|
|
292
|
+
t.Fatal("active snapshot erased failure")
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// A query can straddle Reloading(true). Its response cannot revoke the epoch or
|
|
299
|
+
// resume admission after that boundary, even when it contains invalid values.
|
|
300
|
+
func TestLinuxReloadInvalidatedSnapshotCannotFence(t *testing.T) {
|
|
301
|
+
for _, kind := range []string{"inactive", "missing-invocation", "malformed-invocation", "missing-values"} {
|
|
302
|
+
for _, finished := range []bool{false, true} {
|
|
303
|
+
t.Run(fmt.Sprintf("%s/reloadFinished=%t", kind, finished), func(t *testing.T) {
|
|
304
|
+
now := time.Now()
|
|
305
|
+
g := newAdmission(testBinding())
|
|
306
|
+
o := &unitObserver{unit: "pkgctl-root.service", gate: g}
|
|
307
|
+
if err := o.observeValues(testBinding(), activeUnitValues(o), 0, now); err != nil {
|
|
308
|
+
t.Fatal(err)
|
|
309
|
+
}
|
|
310
|
+
old, _ := g.unitProbe(now)
|
|
311
|
+
g.requestUnitCheck(true, now)
|
|
312
|
+
if finished {
|
|
313
|
+
g.requestUnitCheck(false, now)
|
|
314
|
+
}
|
|
315
|
+
values := activeUnitValues(o)
|
|
316
|
+
switch kind {
|
|
317
|
+
case "inactive":
|
|
318
|
+
values["ActiveState"] = dbus.MakeVariant("inactive")
|
|
319
|
+
case "missing-invocation":
|
|
320
|
+
delete(values, "InvocationID")
|
|
321
|
+
case "malformed-invocation":
|
|
322
|
+
values["InvocationID"] = dbus.MakeVariant("bad")
|
|
323
|
+
case "missing-values":
|
|
324
|
+
values = map[string]dbus.Variant{}
|
|
325
|
+
}
|
|
326
|
+
if err := o.observeValues(testBinding(), values, old, now); err != nil || g.fenced(now) || g.allow(now) {
|
|
327
|
+
t.Fatalf("stale response fenced or resumed: err=%v reason=%s", err, g.reason())
|
|
328
|
+
}
|
|
329
|
+
if !finished {
|
|
330
|
+
g.requestUnitCheck(false, now)
|
|
331
|
+
}
|
|
332
|
+
serial, _ := g.unitProbe(now)
|
|
333
|
+
if err := o.observeValues(testBinding(), activeUnitValues(o), serial, now); err != nil || !g.allow(now) {
|
|
334
|
+
t.Fatalf("fresh verification failed: %v %s", err, g.reason())
|
|
335
|
+
}
|
|
336
|
+
g.fence("unit-stopped")
|
|
337
|
+
_ = o.observeValues(testBinding(), activeUnitValues(o), old, now)
|
|
338
|
+
if g.reason() != "unit-stopped" {
|
|
339
|
+
t.Fatal("stale reply cleared stop")
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
func TestLinuxReloadInvalidatedQueryCannotFence(t *testing.T) {
|
|
347
|
+
p := linuxFixture(t)
|
|
348
|
+
o, err := openUnitObserver(context.Background(), p.Expected)
|
|
349
|
+
if err != nil {
|
|
350
|
+
t.Fatal(err)
|
|
351
|
+
}
|
|
352
|
+
defer o.conn.Close()
|
|
353
|
+
binding, values, err := o.snapshot(context.Background())
|
|
354
|
+
if err != nil {
|
|
355
|
+
t.Fatal(err)
|
|
356
|
+
}
|
|
357
|
+
// Start a probe, then deliver the trusted reload edge before its reply/error.
|
|
358
|
+
err = o.reconcileSnapshot(context.Background(), func(context.Context) (Binding, map[string]dbus.Variant, error) {
|
|
359
|
+
o.gate.requestUnitCheck(true, time.Now())
|
|
360
|
+
ctx, cancel := context.WithCancel(context.Background())
|
|
361
|
+
cancel()
|
|
362
|
+
return o.snapshot(ctx)
|
|
363
|
+
})
|
|
364
|
+
if err != nil || o.gate.fenced(time.Now()) || o.gate.allow(time.Now()) {
|
|
365
|
+
t.Fatalf("stale query error fenced or resumed: %v %s", err, o.gate.reason())
|
|
366
|
+
}
|
|
367
|
+
o.gate.requestUnitCheck(false, time.Now())
|
|
368
|
+
serial, _ := o.gate.unitProbe(time.Now())
|
|
369
|
+
if err = o.observeValues(binding, values, serial, time.Now()); err != nil || !o.gate.allow(time.Now()) {
|
|
370
|
+
t.Fatalf("fresh check failed: %v %s", err, o.gate.reason())
|
|
371
|
+
}
|
|
372
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
"github.com/godbus/dbus/v5"
|
|
7
|
+
"os"
|
|
8
|
+
"os/exec"
|
|
9
|
+
"path/filepath"
|
|
10
|
+
"sync"
|
|
11
|
+
"testing"
|
|
12
|
+
"time"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
// Real manager signal/query sequence, no signal injection or product patch.
|
|
16
|
+
func TestLinuxObserverReloadSignalAndQuerySequence(t *testing.T) {
|
|
17
|
+
p := linuxFixture(t)
|
|
18
|
+
identity := startVMHelper(t, p)
|
|
19
|
+
childBefore := supervisedPID(t, identity.PID)
|
|
20
|
+
before, err := readRecord(p.StateDir, 0)
|
|
21
|
+
if err != nil {
|
|
22
|
+
t.Fatal(err)
|
|
23
|
+
}
|
|
24
|
+
unit := "pkgctl-root.service"
|
|
25
|
+
path := systemdUnitPath(unit)
|
|
26
|
+
var mu sync.Mutex
|
|
27
|
+
events := []observerEvent{}
|
|
28
|
+
started := make(chan struct{})
|
|
29
|
+
var once sync.Once
|
|
30
|
+
conn, err := dbus.ConnectSystemBus(dbus.WithIncomingInterceptor(func(m *dbus.Message) {
|
|
31
|
+
if m.Type != dbus.TypeSignal {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
iface, _ := m.Headers[dbus.FieldInterface].Value().(string)
|
|
35
|
+
member, _ := m.Headers[dbus.FieldMember].Value().(string)
|
|
36
|
+
sender, _ := m.Headers[dbus.FieldSender].Value().(string)
|
|
37
|
+
name := iface + "." + member
|
|
38
|
+
e := observerEvent{At: time.Now().UTC(), Kind: "signal", Signal: name, Sender: safeBusSender(sender), WireSerial: m.Serial()}
|
|
39
|
+
switch name {
|
|
40
|
+
case managerInterface + ".Reloading":
|
|
41
|
+
if len(m.Body) != 1 {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
value, ok := m.Body[0].(bool)
|
|
45
|
+
if !ok {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
if value {
|
|
49
|
+
e.Detail = "reload-start"
|
|
50
|
+
once.Do(func() { close(started) })
|
|
51
|
+
} else {
|
|
52
|
+
e.Detail = "reload-end"
|
|
53
|
+
}
|
|
54
|
+
case managerInterface + ".UnitRemoved", managerInterface + ".UnitNew":
|
|
55
|
+
if len(m.Body) < 1 || m.Body[0] != unit {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
case propertiesInterface + ".PropertiesChanged":
|
|
59
|
+
if m.Headers[dbus.FieldPath].Value() != path || len(m.Body) != 3 || m.Body[0] != unitInterface {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
e.Detail = "own-properties-changed"
|
|
63
|
+
// Only fixed monitored names, never values or unrecognized strings.
|
|
64
|
+
if invalid, ok := m.Body[2].([]string); ok {
|
|
65
|
+
for _, key := range invalid {
|
|
66
|
+
for _, fixed := range []string{"LoadState", "ActiveState", "SubState", "Job", "ActiveEnterTimestampMonotonic", "InvocationID"} {
|
|
67
|
+
if key == fixed {
|
|
68
|
+
e.Detail = "own-invalidated-" + fixed
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
mu.Lock()
|
|
77
|
+
defer mu.Unlock()
|
|
78
|
+
if len(events) < 64 {
|
|
79
|
+
events = append(events, e)
|
|
80
|
+
}
|
|
81
|
+
}))
|
|
82
|
+
if err != nil {
|
|
83
|
+
t.Fatal(err)
|
|
84
|
+
}
|
|
85
|
+
defer conn.Close()
|
|
86
|
+
if err = conn.AddMatchSignal(dbus.WithMatchInterface(managerInterface)); err != nil {
|
|
87
|
+
t.Fatal(err)
|
|
88
|
+
}
|
|
89
|
+
if err = conn.AddMatchSignal(dbus.WithMatchInterface(propertiesInterface), dbus.WithMatchObjectPath(path)); err != nil {
|
|
90
|
+
t.Fatal(err)
|
|
91
|
+
}
|
|
92
|
+
if err = conn.Object(systemdName, "/org/freedesktop/systemd1").Call(managerInterface+".Subscribe", 0).Err; err != nil {
|
|
93
|
+
t.Fatal(err)
|
|
94
|
+
}
|
|
95
|
+
var owner string
|
|
96
|
+
if err = conn.BusObject().Call("org.freedesktop.DBus.GetNameOwner", 0, systemdName).Store(&owner); err != nil {
|
|
97
|
+
t.Fatal(err)
|
|
98
|
+
}
|
|
99
|
+
dir := "/etc/systemd/system-generators"
|
|
100
|
+
if err = os.MkdirAll(dir, 0755); err != nil {
|
|
101
|
+
t.Fatal(err)
|
|
102
|
+
}
|
|
103
|
+
generator := filepath.Join(dir, "m1j-sequence-reload")
|
|
104
|
+
if err = os.WriteFile(generator, []byte("#!/bin/sh\nsleep 4\n"), 0755); err != nil {
|
|
105
|
+
t.Fatal(err)
|
|
106
|
+
}
|
|
107
|
+
defer os.Remove(generator)
|
|
108
|
+
reload := exec.Command("systemctl", "daemon-reload")
|
|
109
|
+
if err = reload.Start(); err != nil {
|
|
110
|
+
t.Fatal(err)
|
|
111
|
+
}
|
|
112
|
+
waited := make(chan error, 1)
|
|
113
|
+
go func() { waited <- reload.Wait() }()
|
|
114
|
+
select {
|
|
115
|
+
case <-started:
|
|
116
|
+
case <-time.After(3 * time.Second):
|
|
117
|
+
t.Fatal("missing true")
|
|
118
|
+
}
|
|
119
|
+
// Sample the public health envelope throughout the real 4s reload and
|
|
120
|
+
// post-edge validation. Preserve every sample; any failed/fenced is fatal.
|
|
121
|
+
stopSamples := make(chan struct{})
|
|
122
|
+
sampleDone := make(chan []State, 1)
|
|
123
|
+
go func() {
|
|
124
|
+
samples := []State{}
|
|
125
|
+
ticker := time.NewTicker(100 * time.Millisecond)
|
|
126
|
+
defer ticker.Stop()
|
|
127
|
+
for {
|
|
128
|
+
samples = append(samples, p.Client.Status(context.Background()))
|
|
129
|
+
select {
|
|
130
|
+
case <-stopSamples:
|
|
131
|
+
sampleDone <- samples
|
|
132
|
+
return
|
|
133
|
+
case <-ticker.C:
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}()
|
|
137
|
+
defer func() {
|
|
138
|
+
select {
|
|
139
|
+
case <-stopSamples:
|
|
140
|
+
default:
|
|
141
|
+
close(stopSamples)
|
|
142
|
+
}
|
|
143
|
+
}()
|
|
144
|
+
pendingCtx, pendingCancel := context.WithTimeout(context.Background(), time.Second)
|
|
145
|
+
var during State
|
|
146
|
+
err = waitHealthy(pendingCtx, func(context.Context) bool { during = p.Client.Status(pendingCtx); return during.State == "pending" })
|
|
147
|
+
pendingCancel()
|
|
148
|
+
if err != nil || during.Reason != "reload-revalidating" || during.Cleanup != "" {
|
|
149
|
+
t.Fatalf("reload did not report pending: %+v %v", during, err)
|
|
150
|
+
}
|
|
151
|
+
t.Logf("during reload API state=%s reason=%s cleanup=%s", during.State, during.Reason, during.Cleanup)
|
|
152
|
+
query := func(phase string) {
|
|
153
|
+
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
|
154
|
+
defer cancel()
|
|
155
|
+
begin := time.Now()
|
|
156
|
+
var err error
|
|
157
|
+
switch phase {
|
|
158
|
+
case "get-owner":
|
|
159
|
+
var name string
|
|
160
|
+
err = conn.BusObject().CallWithContext(ctx, "org.freedesktop.DBus.GetNameOwner", 0, systemdName).Store(&name)
|
|
161
|
+
case "get-unit":
|
|
162
|
+
var object dbus.ObjectPath
|
|
163
|
+
err = conn.Object(owner, "/org/freedesktop/systemd1").CallWithContext(ctx, managerInterface+".GetUnit", 0, unit).Store(&object)
|
|
164
|
+
case "get-all":
|
|
165
|
+
var values map[string]dbus.Variant
|
|
166
|
+
err = conn.Object(owner, path).CallWithContext(ctx, propertiesInterface+".GetAll", 0, unitInterface).Store(&values)
|
|
167
|
+
if err == nil {
|
|
168
|
+
_, invocationPresent := values["InvocationID"]
|
|
169
|
+
entered, ok := values["ActiveEnterTimestampMonotonic"].Value().(uint64)
|
|
170
|
+
t.Logf("GetAll supportedness InvocationID=%t sameEntered=%t", invocationPresent, ok && entered == before.Lifecycle.Binding.Entered)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
result := "ok"
|
|
174
|
+
if err != nil {
|
|
175
|
+
result = observerErrorClass(err)
|
|
176
|
+
}
|
|
177
|
+
t.Logf("real reload query phase=%s elapsed=%s result=%s", phase, time.Since(begin), result)
|
|
178
|
+
}
|
|
179
|
+
for _, phase := range []string{"get-owner", "get-unit", "get-all"} {
|
|
180
|
+
query(phase)
|
|
181
|
+
}
|
|
182
|
+
select {
|
|
183
|
+
case err := <-waited:
|
|
184
|
+
if err != nil {
|
|
185
|
+
t.Fatal(err)
|
|
186
|
+
}
|
|
187
|
+
case <-time.After(12 * time.Second):
|
|
188
|
+
t.Fatal("reload stuck")
|
|
189
|
+
}
|
|
190
|
+
time.Sleep(750 * time.Millisecond)
|
|
191
|
+
for _, phase := range []string{"get-owner", "get-unit", "get-all"} {
|
|
192
|
+
query(phase)
|
|
193
|
+
}
|
|
194
|
+
mu.Lock()
|
|
195
|
+
copyEvents := append([]observerEvent(nil), events...)
|
|
196
|
+
mu.Unlock()
|
|
197
|
+
b, _ := json.Marshal(copyEvents)
|
|
198
|
+
t.Logf("real reload signals=%s", b)
|
|
199
|
+
seenTrue, seenFalse := false, false
|
|
200
|
+
for _, e := range copyEvents {
|
|
201
|
+
seenTrue = seenTrue || e.Detail == "reload-start"
|
|
202
|
+
seenFalse = seenFalse || e.Detail == "reload-end"
|
|
203
|
+
}
|
|
204
|
+
if !seenTrue || !seenFalse {
|
|
205
|
+
t.Fatal("missing reload boundaries")
|
|
206
|
+
}
|
|
207
|
+
logObserverResult(t, p, before, identity, false, childBefore)
|
|
208
|
+
close(stopSamples)
|
|
209
|
+
samples := <-sampleDone
|
|
210
|
+
ready, pending := 0, 0
|
|
211
|
+
for _, sample := range samples {
|
|
212
|
+
switch sample.State {
|
|
213
|
+
case "ready":
|
|
214
|
+
ready++
|
|
215
|
+
case "pending":
|
|
216
|
+
pending++
|
|
217
|
+
if sample.Reason != "reload-revalidating" || sample.Cleanup != "" {
|
|
218
|
+
t.Fatalf("unsafe pending: %+v", sample)
|
|
219
|
+
}
|
|
220
|
+
default:
|
|
221
|
+
t.Fatalf("4s reload API sampled failure: %+v", sample)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if ready == 0 || pending == 0 {
|
|
225
|
+
t.Fatalf("missing health transition: ready=%d pending=%d", ready, pending)
|
|
226
|
+
}
|
|
227
|
+
t.Logf("4s reload API samples=%d ready=%d pending=%d failed=0", len(samples), ready, pending)
|
|
228
|
+
r, err := readRecord(p.StateDir, 0)
|
|
229
|
+
if err != nil || r.Lifecycle.Phase != "running" {
|
|
230
|
+
t.Fatalf("bounded reload retired helper: %+v %v", r, err)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
package helper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"strings"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Internal compiled gates; never filled from browser controls or environment.
|
|
9
|
+
// Stream writes require both the write opt-in and a separately proved publish
|
|
10
|
+
// primitive. Shipped adapters install none of these gates.
|
|
11
|
+
type writeGates struct{ Create, Stream, Publish bool }
|
|
12
|
+
|
|
13
|
+
func (g writeGates) allows(a Action) bool {
|
|
14
|
+
switch a {
|
|
15
|
+
case ActionCreate:
|
|
16
|
+
return g.Create
|
|
17
|
+
case ActionWriteStream:
|
|
18
|
+
return g.Create && g.Stream && g.Publish
|
|
19
|
+
case ActionPublish:
|
|
20
|
+
return g.Create && g.Publish
|
|
21
|
+
}
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type writeWork struct {
|
|
26
|
+
RootPath string `json:"rootPath"`
|
|
27
|
+
Action Action `json:"action"`
|
|
28
|
+
Segments []string `json:"segments"`
|
|
29
|
+
MaxBytes uint64 `json:"maxBytes"`
|
|
30
|
+
Staged bool `json:"staged"`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func (w writeWork) validate() Code {
|
|
34
|
+
if !strings.HasPrefix(w.RootPath, "/") || w.RootPath == "/" {
|
|
35
|
+
return ErrInvalid
|
|
36
|
+
}
|
|
37
|
+
if c := ValidateRelativeSegments(strings.Split(w.RootPath[1:], "/"), false); c != "" {
|
|
38
|
+
return c
|
|
39
|
+
}
|
|
40
|
+
if c := ValidateRelativeSegments(w.Segments, false); c != "" {
|
|
41
|
+
return c
|
|
42
|
+
}
|
|
43
|
+
ceiling := uint64(MaxBoundedBytes)
|
|
44
|
+
switch w.Action {
|
|
45
|
+
case ActionCreate:
|
|
46
|
+
if w.Staged {
|
|
47
|
+
return ErrInvalid
|
|
48
|
+
}
|
|
49
|
+
case ActionWriteStream:
|
|
50
|
+
if !w.Staged {
|
|
51
|
+
return ErrInvalid
|
|
52
|
+
}
|
|
53
|
+
ceiling = MaxTransferBytes
|
|
54
|
+
default:
|
|
55
|
+
return ErrUnsupported
|
|
56
|
+
}
|
|
57
|
+
if w.MaxBytes == 0 || w.MaxBytes > ceiling {
|
|
58
|
+
return ErrLimit
|
|
59
|
+
}
|
|
60
|
+
return ""
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Only the permanently dropped actor may implement these filesystem effects.
|
|
64
|
+
// Root reserves each chunk and commit under S3, but never opens user data.
|
|
65
|
+
type actorWriteTransfer interface {
|
|
66
|
+
WriteChunk(context.Context, []byte) (MutationReceipt, Code)
|
|
67
|
+
Commit(context.Context) (MutationReceipt, Code)
|
|
68
|
+
Receipt() MutationReceipt
|
|
69
|
+
Close()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type retiredWriteReceipt struct {
|
|
73
|
+
operation cohortOperation
|
|
74
|
+
receipt MutationReceipt
|
|
75
|
+
code Code
|
|
76
|
+
unknown bool
|
|
77
|
+
}
|