@opensoha/contracts 0.1.25 → 0.1.26

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.
Files changed (81) hide show
  1. package/COMPATIBILITY.md +24 -0
  2. package/README.md +1 -1
  3. package/agent/environment/export.go +1 -0
  4. package/agent/environment/protocol_test.go +1 -1
  5. package/agent/guest/protocol_test.go +2 -2
  6. package/compat/json-schema-ecosystem-0.1.0.json +1 -1
  7. package/compat/openapi-loose-boundaries-0.1.0.json +1 -1
  8. package/delivery/document.schema.json +127 -9
  9. package/examples/relations_compat_test.go +18 -0
  10. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-build-template.json +30 -0
  11. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-deployment-template.json +30 -0
  12. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-workflow-template.json +27 -0
  13. package/fixtures/openapi/DeliveryDocument/valid/migration-build-template.json +31 -0
  14. package/fixtures/openapi/DeliveryDocument/valid/migration-deployment-template.json +31 -0
  15. package/fixtures/openapi/DeliveryDocument/valid/migration-workflow-template.json +28 -0
  16. package/fixtures/openapi/DeliveryPlanInput/invalid/manual-plan.json +7 -0
  17. package/fixtures/openapi/DeliveryPlanInput/valid/manual-plan.json +6 -0
  18. package/fixtures/openapi/DeliveryTargetInput/invalid/candidate-on-runtime-deploy.json +9 -0
  19. package/fixtures/openapi/DeliveryTargetInput/invalid/config-update-missing-service.json +7 -0
  20. package/fixtures/openapi/DeliveryTargetInput/valid/template-configuration-only.json +8 -0
  21. package/fixtures/openapi/DeliveryTargetInput/valid/template-configuration-without-runtime-environment.json +1 -0
  22. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/invalid/source-with-spec.json +33 -0
  23. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/invalid/source-without-uid.json +29 -0
  24. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/valid/stable-source.json +30 -0
  25. package/fixtures/openapi/KubernetesPod/invalid/pod-uid.json +9 -0
  26. package/fixtures/openapi/KubernetesPod/valid/pod-uid.json +9 -0
  27. package/fixtures/openapi/KubernetesPodDetail/invalid/pod-uid.json +6 -0
  28. package/fixtures/openapi/KubernetesPodDetail/valid/pod-uid.json +6 -0
  29. package/fixtures/openapi/KubernetesServiceImportRequest/invalid/empty-source-uid.json +48 -0
  30. package/fixtures/openapi/KubernetesServiceImportRequest/valid/pinned-workloads-and-cr.json +48 -0
  31. package/fixtures/openapi/ManifestExecutionTaskPayload/invalid/initialization.json +7 -0
  32. package/fixtures/openapi/ManifestExecutionTaskPayload/valid/initialization.json +7 -0
  33. package/fixtures/openapi/ManifestRootResource/invalid/root.json +1 -0
  34. package/fixtures/openapi/ManifestRootResource/valid/root.json +1 -0
  35. package/fixtures/openapi/ResourceRelationConfig/invalid/executable-rule.json +17 -0
  36. package/fixtures/openapi/ResourceRelationConfig/valid/unknown-kind.json +13 -0
  37. package/fixtures/openapi/ServiceDeploymentTemplateInput/invalid/migration-missing-guide-valid-yaml.json +38 -0
  38. package/fixtures/openapi/ServiceDeploymentTemplateInput/valid/migration-valid-yaml.json +39 -0
  39. package/fixtures/openapi/TemplateMigrationAssessment/invalid/initialization.json +9 -0
  40. package/fixtures/openapi/TemplateMigrationAssessment/valid/initialization.json +9 -0
  41. package/fixtures/openapi/TemplateMigrationPolicy/invalid/blank-guide.json +5 -0
  42. package/fixtures/openapi/TemplateMigrationPolicy/invalid/missing-guide.json +4 -0
  43. package/fixtures/openapi/TemplateMigrationPolicy/invalid/unknown-escape-hatch.json +6 -0
  44. package/fixtures/openapi/TemplateMigrationPolicy/valid/legacy-safe.json +4 -0
  45. package/fixtures/openapi/TemplateMigrationPolicy/valid/ordered-data-change.json +5 -0
  46. package/fixtures/openapi/TemplateUpdateBatchInput/invalid/duplicate-candidates.json +11 -0
  47. package/fixtures/openapi/TemplateUpdateBatchInput/invalid/empty-identities.json +10 -0
  48. package/fixtures/openapi/TemplateUpdateBatchInput/valid/staged-adoption.json +10 -0
  49. package/fixtures/openapi/TemplateUpdatePolicyInput/invalid/unknown-mode.json +8 -0
  50. package/fixtures/openapi/TemplateUpdatePolicyInput/valid/explicit-automatic.json +8 -0
  51. package/fixtures/openapi/TemplateUpdatePreviewInput/invalid/empty-identities.json +10 -0
  52. package/fixtures/openapi/TemplateUpdatePreviewInput/invalid/empty-targets.json +6 -0
  53. package/fixtures/openapi/TemplateUpdatePreviewInput/valid/cross-version-manual.json +14 -0
  54. package/gen/go/sohaapi/client.go +1 -1
  55. package/gen/go/sohaapi/client_test.go +2 -2
  56. package/gen/go/sohaapi/import_source_compat_test.go +12 -0
  57. package/gen/go/sohaapi/types.go +945 -159
  58. package/gen/ts/sohaapi/index.ts +746 -4
  59. package/go.mod +2 -2
  60. package/helmrelease/delivery.go +4 -1
  61. package/helmrelease/initialization.go +10 -0
  62. package/helmrelease/runtime/delivery.go +40 -10
  63. package/helmrelease/runtime/delivery_test.go +4 -0
  64. package/helmrelease/runtime/initialization.go +186 -0
  65. package/helmrelease/runtime/initialization_test.go +203 -0
  66. package/openapi/soha-api.json +2195 -55
  67. package/openapi/soha-api.yaml +349 -9
  68. package/openapi/spec_generated.go +3 -3
  69. package/openapi/spec_test.go +42 -0
  70. package/package.json +1 -1
  71. package/resource/models.go +2 -0
  72. package/resource/relations.go +225 -0
  73. package/resource/relations_test.go +47 -0
  74. package/resource/root_cr.go +38 -0
  75. package/resource/runtime/argocd_integration_test.go +1 -1
  76. package/resource/runtime/initialization.go +66 -0
  77. package/resource/runtime/initialization_test.go +80 -0
  78. package/resource/runtime/relations.go +161 -0
  79. package/resource/runtime/relations_test.go +100 -0
  80. package/resource/runtime/root_cr.go +79 -0
  81. package/resource/runtime/root_cr_test.go +118 -0
@@ -0,0 +1,48 @@
1
+ {
2
+ "clusterId": "cluster-prod",
3
+ "namespace": "payments",
4
+ "applicationKey": "payments",
5
+ "applicationName": "Payments",
6
+ "environmentKey": "prod",
7
+ "environmentName": "Production",
8
+ "ownershipMode": "observe_only",
9
+ "workloads": [
10
+ {
11
+ "workloadKind": "Deployment",
12
+ "workloadName": "deployment",
13
+ "expectedUid": "",
14
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
15
+ },
16
+ {
17
+ "workloadKind": "StatefulSet",
18
+ "workloadName": "statefulset",
19
+ "expectedUid": "uid-StatefulSet",
20
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
21
+ },
22
+ {
23
+ "workloadKind": "DaemonSet",
24
+ "workloadName": "daemonset",
25
+ "expectedUid": "uid-DaemonSet",
26
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
27
+ },
28
+ {
29
+ "workloadKind": "Job",
30
+ "workloadName": "job",
31
+ "expectedUid": "uid-Job",
32
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
33
+ },
34
+ {
35
+ "workloadKind": "CronJob",
36
+ "workloadName": "cronjob",
37
+ "expectedUid": "uid-CronJob",
38
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
39
+ },
40
+ {
41
+ "workloadKind": "CustomResource",
42
+ "workloadName": "customresource",
43
+ "expectedUid": "uid-CustomResource",
44
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
45
+ "crdName": "elasticsearches.elasticsearch.k8s.elastic.co"
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "clusterId": "cluster-prod",
3
+ "namespace": "payments",
4
+ "applicationKey": "payments",
5
+ "applicationName": "Payments",
6
+ "environmentKey": "prod",
7
+ "environmentName": "Production",
8
+ "ownershipMode": "observe_only",
9
+ "workloads": [
10
+ {
11
+ "workloadKind": "Deployment",
12
+ "workloadName": "deployment",
13
+ "expectedUid": "uid-Deployment",
14
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
15
+ },
16
+ {
17
+ "workloadKind": "StatefulSet",
18
+ "workloadName": "statefulset",
19
+ "expectedUid": "uid-StatefulSet",
20
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
21
+ },
22
+ {
23
+ "workloadKind": "DaemonSet",
24
+ "workloadName": "daemonset",
25
+ "expectedUid": "uid-DaemonSet",
26
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
27
+ },
28
+ {
29
+ "workloadKind": "Job",
30
+ "workloadName": "job",
31
+ "expectedUid": "uid-Job",
32
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
33
+ },
34
+ {
35
+ "workloadKind": "CronJob",
36
+ "workloadName": "cronjob",
37
+ "expectedUid": "uid-CronJob",
38
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
39
+ },
40
+ {
41
+ "workloadKind": "CustomResource",
42
+ "workloadName": "customresource",
43
+ "expectedUid": "uid-CustomResource",
44
+ "expectedSpecDigest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
45
+ "crdName": "elasticsearches.elasticsearch.k8s.elastic.co"
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "action": "preflight",
3
+ "packageId": "pkg",
4
+ "generation": 1,
5
+ "idempotencyKey": "initialization:plan:target",
6
+ "initializationPlanId": ""
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "action": "preflight",
3
+ "packageId": "pkg",
4
+ "generation": 1,
5
+ "idempotencyKey": "initialization:plan:target",
6
+ "initializationPlanId": "plan"
7
+ }
@@ -0,0 +1 @@
1
+ {"apiVersion":"unknown.example/v1","kind":"Database","namespace":"team","name":"db","uid":"","generation":0,"crdName":"databases.unknown.example"}
@@ -0,0 +1 @@
1
+ {"apiVersion": "unknown.example/v1", "kind": "Database", "namespace": "team", "name": "db", "uid": "uid-1", "generation": 2, "crdName": "databases.unknown.example", "targetId": "target", "deliveryPlanId": "plan"}
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": "v1",
3
+ "rootUid": "root",
4
+ "sources": [],
5
+ "rules": [
6
+ {
7
+ "id": "bad",
8
+ "type": "script",
9
+ "target": {
10
+ "apiVersion": "v1",
11
+ "resource": "pods",
12
+ "kind": "Pod",
13
+ "namespace": "team"
14
+ }
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "v1",
3
+ "rootUid": "root",
4
+ "sources": [
5
+ {
6
+ "apiVersion": "widgets.test/v1",
7
+ "resource": "widgets",
8
+ "kind": "Widget",
9
+ "namespace": "team"
10
+ }
11
+ ],
12
+ "rules": []
13
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "key": "http",
3
+ "name": "HTTP service",
4
+ "source": {
5
+ "renderer": "raw_yaml",
6
+ "files": [
7
+ {
8
+ "path": "deployment.yaml",
9
+ "content": "kind: Deployment\napiVersion: apps/v1\n"
10
+ }
11
+ ]
12
+ },
13
+ "parameterSchema": {
14
+ "type": "object",
15
+ "properties": {
16
+ "port": {
17
+ "type": "integer",
18
+ "minimum": 1,
19
+ "maximum": 65535
20
+ }
21
+ },
22
+ "required": [
23
+ "port"
24
+ ]
25
+ },
26
+ "defaults": {
27
+ "port": 8080
28
+ },
29
+ "health": {
30
+ "mode": "workload_ready",
31
+ "timeoutSeconds": 300
32
+ },
33
+ "enabled": true,
34
+ "migrationPolicy": {
35
+ "sequential": true,
36
+ "irreversible": false
37
+ }
38
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "key": "http",
3
+ "name": "HTTP service",
4
+ "source": {
5
+ "renderer": "raw_yaml",
6
+ "files": [
7
+ {
8
+ "path": "deployment.yaml",
9
+ "content": "kind: Deployment\napiVersion: apps/v1\n"
10
+ }
11
+ ]
12
+ },
13
+ "parameterSchema": {
14
+ "type": "object",
15
+ "properties": {
16
+ "port": {
17
+ "type": "integer",
18
+ "minimum": 1,
19
+ "maximum": 65535
20
+ }
21
+ },
22
+ "required": [
23
+ "port"
24
+ ]
25
+ },
26
+ "defaults": {
27
+ "port": 8080
28
+ },
29
+ "health": {
30
+ "mode": "workload_ready",
31
+ "timeoutSeconds": 300
32
+ },
33
+ "enabled": true,
34
+ "migrationPolicy": {
35
+ "sequential": true,
36
+ "irreversible": true,
37
+ "guide": "Backup, migrate in order, verify; forward repair only."
38
+ }
39
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "fromVersion": 0,
3
+ "toVersion": 3,
4
+ "blocked": false,
5
+ "requiresApproval": true,
6
+ "reason": "首次发布须先证明不存在并审批",
7
+ "steps": [],
8
+ "initialization": "force"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "fromVersion": 0,
3
+ "toVersion": 3,
4
+ "blocked": false,
5
+ "requiresApproval": true,
6
+ "reason": "首次发布须先证明不存在并审批",
7
+ "steps": [],
8
+ "initialization": true
9
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "sequential": false,
3
+ "irreversible": true,
4
+ "guide": " \n"
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "sequential": true,
3
+ "irreversible": false
4
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "sequential": true,
3
+ "irreversible": true,
4
+ "guide": "manual",
5
+ "force": true
6
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "sequential": false,
3
+ "irreversible": false
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "sequential": true,
3
+ "irreversible": true,
4
+ "guide": "先备份,再按相邻版本发布;完成业务检查后继续。"
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "previewDigest": "sha256:abc",
3
+ "candidateIds": [
4
+ "candidate-1",
5
+ "candidate-1"
6
+ ],
7
+ "waveSize": 2,
8
+ "stopOnFailure": true,
9
+ "acknowledgeHistoryGaps": false,
10
+ "idempotencyKey": "manual-1"
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "previewDigest": "",
3
+ "candidateIds": [
4
+ ""
5
+ ],
6
+ "waveSize": 2,
7
+ "stopOnFailure": true,
8
+ "acknowledgeHistoryGaps": false,
9
+ "idempotencyKey": ""
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "previewDigest": "sha256:abc",
3
+ "candidateIds": [
4
+ "candidate-1"
5
+ ],
6
+ "waveSize": 2,
7
+ "stopOnFailure": true,
8
+ "acknowledgeHistoryGaps": false,
9
+ "idempotencyKey": "manual-1"
10
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "kind": "deployment",
3
+ "templateId": "web-template",
4
+ "targetId": "binding-test",
5
+ "mode": "latest",
6
+ "paused": false,
7
+ "expectedVersion": 0
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "kind": "deployment",
3
+ "templateId": "web-template",
4
+ "targetId": "binding-test",
5
+ "mode": "automatic",
6
+ "paused": false,
7
+ "expectedVersion": 0
8
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "kind": "deployment",
3
+ "templateId": "",
4
+ "toVersion": 4,
5
+ "targets": [
6
+ {
7
+ "targetId": ""
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "kind": "deployment",
3
+ "templateId": "web-template",
4
+ "toVersion": 4,
5
+ "targets": []
6
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "kind": "deployment",
3
+ "templateId": "web-template",
4
+ "toVersion": 4,
5
+ "targets": [
6
+ {
7
+ "targetId": "binding-test",
8
+ "wave": 0,
9
+ "useNewDefaults": [
10
+ "replicas"
11
+ ]
12
+ }
13
+ ]
14
+ }
@@ -16,7 +16,7 @@ import (
16
16
  "time"
17
17
  )
18
18
 
19
- const defaultUserAgent = "opensoha-contracts/0.1.25"
19
+ const defaultUserAgent = "opensoha-contracts/0.1.26"
20
20
 
21
21
  type Client struct {
22
22
  BaseURL string
@@ -1622,7 +1622,7 @@ func TestCreateServiceAccountTokenEscapesPathPostsBodyAndDecodesData(t *testing.
1622
1622
  writeJSON(t, w, map[string]any{
1623
1623
  "data": map[string]any{
1624
1624
  "value": "soha_sat_secret",
1625
- "token": map[string]any{
1625
+ "token": map[string]any{ // #nosec G101 -- Synthetic token metadata in an httptest response, not a usable credential.
1626
1626
  "id": "sat-2",
1627
1627
  "serviceAccountId": "svc/1",
1628
1628
  "name": "deploy token",
@@ -1682,7 +1682,7 @@ func TestRotateServiceAccountTokenEscapesPathPostsBodyAndDecodesData(t *testing.
1682
1682
  writeJSON(t, w, map[string]any{
1683
1683
  "data": map[string]any{
1684
1684
  "value": "soha_sat_rotated",
1685
- "token": map[string]any{
1685
+ "token": map[string]any{ // #nosec G101 -- Synthetic token metadata in an httptest response, not a usable credential.
1686
1686
  "id": "sat-rotated",
1687
1687
  "serviceAccountId": "svc-1",
1688
1688
  "name": "rotated service token",
@@ -0,0 +1,12 @@
1
+ package sohaapi
2
+
3
+ import "testing"
4
+
5
+ func TestDeliveryServiceKindPublishedNamesRemainUsable(t *testing.T) {
6
+ values := []DeliveryDraftServiceServiceKind{ExternalService, HelmRelease, Job, KubernetesWorkload}
7
+ for _, value := range values {
8
+ if !value.Valid() {
9
+ t.Errorf("published service kind %q is invalid", value)
10
+ }
11
+ }
12
+ }