From eb48a6b4f5c58897f91e86dbd5f98ee77c250b3d Mon Sep 17 00:00:00 2001 From: Harsh Kapse Date: Thu, 13 Aug 2026 15:02:39 +0530 Subject: [PATCH] feat(treesitter): add yaml rules and testdata --- internal/treesitter/parser_test.go | 11 + internal/treesitter/yaml/rules.yml | 41 + .../expected.json | 171 ++ .../metadata.json | 6 + .../new.yaml | 31 + .../old.yaml | 33 + .../expected.json | 885 ++++++++++ .../metadata.json | 6 + .../new.yaml | 193 +++ .../old.yaml | 203 +++ .../expected.json | 778 +++++++++ .../metadata.json | 6 + .../new.yaml | 175 ++ .../old.yaml | 176 ++ .../expected.json | 177 ++ .../metadata.json | 6 + .../new.yaml | 27 + .../old.yaml | 20 + .../expected.json | 157 ++ .../metadata.json | 6 + .../yaml_k8s_examples_javaweb_scalar/new.yaml | 25 + .../yaml_k8s_examples_javaweb_scalar/old.yaml | 24 + .../expected.json | 742 +++++++++ .../metadata.json | 6 + .../new.yaml | 12 + .../old.yaml | 9 + .../expected.json | 689 ++++++++ .../metadata.json | 6 + .../new.yaml | 72 + .../old.yaml | 69 + .../expected.json | 296 ++++ .../metadata.json | 6 + .../new.yaml | 52 + .../old.yaml | 65 + .../expected.json | 239 +++ .../metadata.json | 6 + .../new.yaml | 41 + .../old.yaml | 39 + .../expected.json | 239 +++ .../metadata.json | 6 + .../new.yaml | 41 + .../old.yaml | 39 + .../expected.json | 681 ++++++++ .../metadata.json | 6 + .../new.yaml | 40 + .../old.yaml | 40 + .../expected.json | 567 +++++++ .../metadata.json | 6 + .../new.yaml | 122 ++ .../old.yaml | 118 ++ .../expected.json | 1446 +++++++++++++++++ .../metadata.json | 6 + .../new.yaml | 108 ++ .../old.yaml | 107 ++ .../expected.json | 530 ++++++ .../metadata.json | 6 + .../new.yaml | 68 + .../old.yaml | 69 + .../expected.json | 495 ++++++ .../metadata.json | 6 + .../new.yaml | 114 ++ .../old.yaml | 107 ++ 62 files changed, 10473 insertions(+) create mode 100644 internal/treesitter/yaml/rules.yml create mode 100644 tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_flower_scalar_controller/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_flower_scalar_controller/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_flower_scalar_controller/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_flower_scalar_controller/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_javaweb_scalar/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_javaweb_scalar/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_javaweb_scalar/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_javaweb_scalar/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_persistentvolume_nfs/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_persistentvolume_nfs/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_persistentvolume_nfs/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_persistentvolume_nfs/old.yaml create mode 100644 tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/expected.json create mode 100644 tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/metadata.json create mode 100644 tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/new.yaml create mode 100644 tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/old.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_container/expected.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_container/metadata.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_container/new.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_container/old.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_limits/expected.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_limits/metadata.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_limits/new.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_limits/old.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_resources/expected.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_resources/metadata.json create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_resources/new.yaml create mode 100644 tests/testdata/yaml_microservices_cartservice_scalar_resources/old.yaml create mode 100644 tests/testdata/yaml_microservices_kustomization_scalar/expected.json create mode 100644 tests/testdata/yaml_microservices_kustomization_scalar/metadata.json create mode 100644 tests/testdata/yaml_microservices_kustomization_scalar/new.yaml create mode 100644 tests/testdata/yaml_microservices_kustomization_scalar/old.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_build_artifacts/expected.json create mode 100644 tests/testdata/yaml_microservices_skaffold_build_artifacts/metadata.json create mode 100644 tests/testdata/yaml_microservices_skaffold_build_artifacts/new.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_build_artifacts/old.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_pipeline_refactor/expected.json create mode 100644 tests/testdata/yaml_microservices_skaffold_pipeline_refactor/metadata.json create mode 100644 tests/testdata/yaml_microservices_skaffold_pipeline_refactor/new.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_pipeline_refactor/old.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_port_forward/expected.json create mode 100644 tests/testdata/yaml_microservices_skaffold_port_forward/metadata.json create mode 100644 tests/testdata/yaml_microservices_skaffold_port_forward/new.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_port_forward/old.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/expected.json create mode 100644 tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/metadata.json create mode 100644 tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/new.yaml create mode 100644 tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/old.yaml diff --git a/internal/treesitter/parser_test.go b/internal/treesitter/parser_test.go index beb5745..5600469 100644 --- a/internal/treesitter/parser_test.go +++ b/internal/treesitter/parser_test.go @@ -252,6 +252,17 @@ int main() { std::cout << "Hello C++\n"; return 0; }`) } }) + t.Run("valid yaml source", func(t *testing.T) { + src := []byte("name: diffmantic\nversion: 1.0\nservices:\n - web\n - db\n") + ast, err := Parse(src, "config.yaml") + if err != nil { + t.Fatalf("Parse(): unexpected error: %v", err) + } + if ast == nil { + t.Error("Parse(): expected non-nil AST root") + } + }) + t.Run("unknown extension", func(t *testing.T) { src := []byte(`some text`) ast, err := Parse(src, "main.xyz") diff --git a/internal/treesitter/yaml/rules.yml b/internal/treesitter/yaml/rules.yml new file mode 100644 index 0000000..3a26538 --- /dev/null +++ b/internal/treesitter/yaml/rules.yml @@ -0,0 +1,41 @@ +flattened: + - string_scalar + - double_quote_scalar + - single_quote_scalar + - plain_scalar + - comment + +ignored: + - ":" + - "-" + - "{" + - "}" + - "[" + - "]" + - "," + - "?" + +scaffolding: + - stream + - document + - block_node + - block_mapping + - block_mapping_pair + - block_sequence + - block_sequence_item + - flow_mapping + - flow_sequence + +unordered: + - block_mapping + - flow_mapping + +identifiers: + - tag + - anchor_name + - alias_name + +pairs: + - block_mapping_pair + - flow_pair + diff --git a/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/expected.json b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/expected.json new file mode 100644 index 0000000..0e307ed --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/expected.json @@ -0,0 +1,171 @@ +{ + "version": "v1", + "actions": [ + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 6, + 1, + 0, + 2 + ], + "type": "block_sequence_item", + "start_byte": 519, + "end_byte": 568 + }, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": -1 + }, + { + "left_line": 29, + "right_line": -1 + }, + { + "left_line": 30, + "right_line": 28 + }, + { + "left_line": 31, + "right_line": 29 + }, + { + "left_line": 32, + "right_line": 30 + }, + { + "left_line": 33, + "right_line": 31 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/metadata.json b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/metadata.json new file mode 100644 index 0000000..c6b015f --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "unknown", + "description": "Update cassandra deployment spec", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/new.yaml b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/new.yaml new file mode 100644 index 0000000..5240899 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/new.yaml @@ -0,0 +1,31 @@ +apiVersion: v1beta3 +kind: Pod +metadata: + labels: + name: cassandra + name: cassandra +spec: + containers: + - args: + - /run.sh + resources: + limits: + cpu: "1" + image: gcr.io/google_containers/cassandra:v3 + name: cassandra + ports: + - name: cql + containerPort: 9042 + - name: thrift + containerPort: 9160 + volumeMounts: + - name: data + mountPath: /cassandra_data + env: + - name: MAX_HEAP_SIZE + value: 512M + - name: HEAP_NEWSIZE + value: 100M + volumes: + - name: data + emptyDir: {} diff --git a/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/old.yaml b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/old.yaml new file mode 100644 index 0000000..f921db6 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/old.yaml @@ -0,0 +1,33 @@ +apiVersion: v1beta3 +kind: Pod +metadata: + labels: + name: cassandra + name: cassandra +spec: + containers: + - args: + - /run.sh + resources: + limits: + cpu: "1" + image: gcr.io/google_containers/cassandra:v3 + name: cassandra + ports: + - name: cql + containerPort: 9042 + - name: thrift + containerPort: 9160 + volumeMounts: + - name: data + mountPath: /cassandra_data + env: + - name: MAX_HEAP_SIZE + value: 512M + - name: HEAP_NEWSIZE + value: 100M + - name: KUBERNETES_API_PROTOCOL + value: http + volumes: + - name: data + emptyDir: {} diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/expected.json b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/expected.json new file mode 100644 index 0000000..2dc1ca5 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/expected.json @@ -0,0 +1,885 @@ +{ + "version": "v1", + "actions": [ + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 3, + 1, + 0, + 3, + 1, + 0, + 2, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 9 + ], + "type": "block_mapping_pair", + "start_byte": 5051, + "end_byte": 5177 + }, + "subtree": true + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 3, + 1, + 0, + 3, + 1, + 0, + 2, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 10 + ], + "type": "block_mapping_pair", + "start_byte": 5186, + "end_byte": 5313 + }, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": 40, + "right_line": 40 + }, + { + "left_line": 41, + "right_line": 41 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": 46 + }, + { + "left_line": 47, + "right_line": 47 + }, + { + "left_line": 48, + "right_line": 48 + }, + { + "left_line": 49, + "right_line": 49 + }, + { + "left_line": 50, + "right_line": 50 + }, + { + "left_line": 51, + "right_line": 51 + }, + { + "left_line": 52, + "right_line": 52 + }, + { + "left_line": 53, + "right_line": 53 + }, + { + "left_line": 54, + "right_line": 54 + }, + { + "left_line": 55, + "right_line": 55 + }, + { + "left_line": 56, + "right_line": 56 + }, + { + "left_line": 57, + "right_line": 57 + }, + { + "left_line": 58, + "right_line": 58 + }, + { + "left_line": 59, + "right_line": 59 + }, + { + "left_line": 60, + "right_line": 60 + }, + { + "left_line": 61, + "right_line": 61 + }, + { + "left_line": 62, + "right_line": 62 + }, + { + "left_line": 63, + "right_line": 63 + }, + { + "left_line": 64, + "right_line": 64 + }, + { + "left_line": 65, + "right_line": 65 + }, + { + "left_line": 66, + "right_line": 66 + }, + { + "left_line": 67, + "right_line": 67 + }, + { + "left_line": 68, + "right_line": 68 + }, + { + "left_line": 69, + "right_line": 69 + }, + { + "left_line": 70, + "right_line": 70 + }, + { + "left_line": 71, + "right_line": 71 + }, + { + "left_line": 72, + "right_line": 72 + }, + { + "left_line": 73, + "right_line": 73 + }, + { + "left_line": 74, + "right_line": 74 + }, + { + "left_line": 75, + "right_line": 75 + }, + { + "left_line": 76, + "right_line": 76 + }, + { + "left_line": 77, + "right_line": 77 + }, + { + "left_line": 78, + "right_line": 78 + }, + { + "left_line": 79, + "right_line": 79 + }, + { + "left_line": 80, + "right_line": 80 + }, + { + "left_line": 81, + "right_line": 81 + }, + { + "left_line": 82, + "right_line": 82 + }, + { + "left_line": 83, + "right_line": 83 + }, + { + "left_line": 84, + "right_line": 84 + }, + { + "left_line": 85, + "right_line": 85 + }, + { + "left_line": 86, + "right_line": 86 + }, + { + "left_line": 87, + "right_line": 87 + }, + { + "left_line": 88, + "right_line": 88 + }, + { + "left_line": 89, + "right_line": 89 + }, + { + "left_line": 90, + "right_line": 90 + }, + { + "left_line": 91, + "right_line": 91 + }, + { + "left_line": 92, + "right_line": 92 + }, + { + "left_line": 93, + "right_line": 93 + }, + { + "left_line": 94, + "right_line": 94 + }, + { + "left_line": 95, + "right_line": 95 + }, + { + "left_line": 96, + "right_line": 96 + }, + { + "left_line": 97, + "right_line": 97 + }, + { + "left_line": 98, + "right_line": 98 + }, + { + "left_line": 99, + "right_line": 99 + }, + { + "left_line": 100, + "right_line": 100 + }, + { + "left_line": 101, + "right_line": 101 + }, + { + "left_line": 102, + "right_line": 102 + }, + { + "left_line": 103, + "right_line": 103 + }, + { + "left_line": 104, + "right_line": 104 + }, + { + "left_line": 105, + "right_line": 105 + }, + { + "left_line": 106, + "right_line": 106 + }, + { + "left_line": 107, + "right_line": 107 + }, + { + "left_line": 108, + "right_line": 108 + }, + { + "left_line": 109, + "right_line": 109 + }, + { + "left_line": 110, + "right_line": 110 + }, + { + "left_line": 111, + "right_line": 111 + }, + { + "left_line": 112, + "right_line": 112 + }, + { + "left_line": 113, + "right_line": 113 + }, + { + "left_line": 114, + "right_line": 114 + }, + { + "left_line": 115, + "right_line": 115 + }, + { + "left_line": 116, + "right_line": 116 + }, + { + "left_line": 117, + "right_line": 117 + }, + { + "left_line": 118, + "right_line": 118 + }, + { + "left_line": 119, + "right_line": 119 + }, + { + "left_line": 120, + "right_line": 120 + }, + { + "left_line": 121, + "right_line": 121 + }, + { + "left_line": 122, + "right_line": 122 + }, + { + "left_line": 123, + "right_line": 123 + }, + { + "left_line": 124, + "right_line": 124 + }, + { + "left_line": 125, + "right_line": 125 + }, + { + "left_line": 126, + "right_line": 126 + }, + { + "left_line": 127, + "right_line": 127 + }, + { + "left_line": 128, + "right_line": 128 + }, + { + "left_line": 129, + "right_line": 129 + }, + { + "left_line": 130, + "right_line": 130 + }, + { + "left_line": 131, + "right_line": 131 + }, + { + "left_line": 132, + "right_line": 132 + }, + { + "left_line": 133, + "right_line": 133 + }, + { + "left_line": 134, + "right_line": 134 + }, + { + "left_line": 135, + "right_line": 135 + }, + { + "left_line": 136, + "right_line": 136 + }, + { + "left_line": 137, + "right_line": 137 + }, + { + "left_line": 138, + "right_line": 138 + }, + { + "left_line": 139, + "right_line": 139 + }, + { + "left_line": 140, + "right_line": 140 + }, + { + "left_line": 141, + "right_line": 141 + }, + { + "left_line": 142, + "right_line": 142 + }, + { + "left_line": 143, + "right_line": 143 + }, + { + "left_line": 144, + "right_line": 144 + }, + { + "left_line": 145, + "right_line": 145 + }, + { + "left_line": 146, + "right_line": 146 + }, + { + "left_line": 147, + "right_line": 147 + }, + { + "left_line": 148, + "right_line": 148 + }, + { + "left_line": 149, + "right_line": -1 + }, + { + "left_line": 150, + "right_line": -1 + }, + { + "left_line": 151, + "right_line": -1 + }, + { + "left_line": 152, + "right_line": -1 + }, + { + "left_line": 153, + "right_line": -1 + }, + { + "left_line": 154, + "right_line": -1 + }, + { + "left_line": 155, + "right_line": -1 + }, + { + "left_line": 156, + "right_line": -1 + }, + { + "left_line": 157, + "right_line": -1 + }, + { + "left_line": 158, + "right_line": -1 + }, + { + "left_line": 159, + "right_line": 149 + }, + { + "left_line": 160, + "right_line": 150 + }, + { + "left_line": 161, + "right_line": 151 + }, + { + "left_line": 162, + "right_line": 152 + }, + { + "left_line": 163, + "right_line": 153 + }, + { + "left_line": 164, + "right_line": 154 + }, + { + "left_line": 165, + "right_line": 155 + }, + { + "left_line": 166, + "right_line": 156 + }, + { + "left_line": 167, + "right_line": 157 + }, + { + "left_line": 168, + "right_line": 158 + }, + { + "left_line": 169, + "right_line": 159 + }, + { + "left_line": 170, + "right_line": 160 + }, + { + "left_line": 171, + "right_line": 161 + }, + { + "left_line": 172, + "right_line": 162 + }, + { + "left_line": 173, + "right_line": 163 + }, + { + "left_line": 174, + "right_line": 164 + }, + { + "left_line": 175, + "right_line": 165 + }, + { + "left_line": 176, + "right_line": 166 + }, + { + "left_line": 177, + "right_line": 167 + }, + { + "left_line": 178, + "right_line": 168 + }, + { + "left_line": 179, + "right_line": 169 + }, + { + "left_line": 180, + "right_line": 170 + }, + { + "left_line": 181, + "right_line": 171 + }, + { + "left_line": 182, + "right_line": 172 + }, + { + "left_line": 183, + "right_line": 173 + }, + { + "left_line": 184, + "right_line": 174 + }, + { + "left_line": 185, + "right_line": 175 + }, + { + "left_line": 186, + "right_line": 176 + }, + { + "left_line": 187, + "right_line": 177 + }, + { + "left_line": 188, + "right_line": 178 + }, + { + "left_line": 189, + "right_line": 179 + }, + { + "left_line": 190, + "right_line": 180 + }, + { + "left_line": 191, + "right_line": 181 + }, + { + "left_line": 192, + "right_line": 182 + }, + { + "left_line": 193, + "right_line": 183 + }, + { + "left_line": 194, + "right_line": 184 + }, + { + "left_line": 195, + "right_line": 185 + }, + { + "left_line": 196, + "right_line": 186 + }, + { + "left_line": 197, + "right_line": 187 + }, + { + "left_line": 198, + "right_line": 188 + }, + { + "left_line": 199, + "right_line": 189 + }, + { + "left_line": 200, + "right_line": 190 + }, + { + "left_line": 201, + "right_line": 191 + }, + { + "left_line": 202, + "right_line": 192 + }, + { + "left_line": 203, + "right_line": 193 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/metadata.json b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/metadata.json new file mode 100644 index 0000000..bddef24 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "unknown", + "description": "Update cockroachdb spec", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/new.yaml b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/new.yaml new file mode 100644 index 0000000..739d771 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/new.yaml @@ -0,0 +1,193 @@ +apiVersion: v1 +kind: Service +metadata: + # This service is meant to be used by clients of the database. It exposes a ClusterIP that will + # automatically load balance connections to the different database pods. + name: cockroachdb-public + labels: + app: cockroachdb +spec: + ports: + # The main port, served by gRPC, serves Postgres-flavor SQL, internode + # traffic and the cli. + - port: 26257 + targetPort: 26257 + name: grpc + # The secondary port serves the UI as well as health and debug endpoints. + - port: 8080 + targetPort: 8080 + name: http + selector: + app: cockroachdb +--- +apiVersion: v1 +kind: Service +metadata: + # This service only exists to create DNS entries for each pod in the stateful + # set such that they can resolve each other's IP addresses. It does not + # create a load-balanced ClusterIP and should not be used directly by clients + # in most circumstances. + name: cockroachdb + labels: + app: cockroachdb + annotations: + # This is needed to make the peer-finder work properly and to help avoid + # edge cases where instance 0 comes up after losing its data and needs to + # decide whether it should create a new cluster or try to join an existing + # one. If it creates a new cluster when it should have joined an existing + # one, we'd end up with two separate clusters listening at the same service + # endpoint, which would be very bad. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + # Enable automatic monitoring of all instances when Prometheus is running in the cluster. + prometheus.io/scrape: "true" + prometheus.io/path: "_status/vars" + prometheus.io/port: "8080" +spec: + ports: + - port: 26257 + targetPort: 26257 + name: grpc + - port: 8080 + targetPort: 8080 + name: http + clusterIP: None + selector: + app: cockroachdb +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: cockroachdb-budget + labels: + app: cockroachdb +spec: + selector: + matchLabels: + app: cockroachdb + minAvailable: 67% +--- +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: cockroachdb +spec: + serviceName: "cockroachdb" + replicas: 3 + template: + metadata: + labels: + app: cockroachdb + annotations: + scheduler.alpha.kubernetes.io/affinity: > + { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [{ + "weight": 100, + "labelSelector": { + "matchExpressions": [{ + "key": "app", + "operator": "In", + "values": ["cockroachdb"] + }] + }, + "topologyKey": "kubernetes.io/hostname" + }] + } + } + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + pod.alpha.kubernetes.io/init-containers: '[ + { + "name": "bootstrap", + "image": "cockroachdb/cockroach-k8s-init:0.1", + "imagePullPolicy": "IfNotPresent", + "args": [ + "-on-start=/on-start.sh", + "-service=cockroachdb" + ], + "env": [ + { + "name": "POD_NAMESPACE", + "valueFrom": { + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + } + } + } + ], + "volumeMounts": [ + { + "name": "datadir", + "mountPath": "/cockroach/cockroach-data" + } + ] + } + ]' + spec: + containers: + - name: cockroachdb + # Runs the master branch. Not recommended for production, but since + # CockroachDB is in Beta, you don't want to run it in production + # anyway. See + # https://hub.docker.com/r/cockroachdb/cockroach/tags/ + # if you prefer to run a beta release. + image: cockroachdb/cockroach + imagePullPolicy: IfNotPresent + ports: + - containerPort: 26257 + name: grpc + - containerPort: 8080 + name: http + volumeMounts: + - name: datadir + mountPath: /cockroach/cockroach-data + command: + - "/bin/bash" + - "-ecx" + - | + # The use of qualified `hostname -f` is crucial: + # Other nodes aren't able to look up the unqualified hostname. + CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0") + # We only want to initialize a new cluster (by omitting the join flag) + # if we're sure that we're the first node (i.e. index 0) and that + # there aren't any other nodes running as part of the cluster that + # this is supposed to be a part of (which indicates that a cluster + # already exists and we should make sure not to create a new one). + # It's fine to run without --join on a restart if there aren't any + # other nodes. + if [ ! "$(hostname)" == "cockroachdb-0" ] || \ + [ -e "/cockroach/cockroach-data/cluster_exists_marker" ] + then + # We don't join cockroachdb in order to avoid a node attempting + # to join itself, which currently doesn't work + # (https://github.com/cockroachdb/cockroach/issues/9625). + CRARGS+=("--join" "cockroachdb-public") + fi + exec /cockroach/cockroach ${CRARGS[*]} + # No pre-stop hook is required, a SIGTERM plus some time is all that's + # needed for graceful shutdown of a node. + terminationGracePeriodSeconds: 60 + volumes: + - name: datadir + persistentVolumeClaim: + claimName: datadir + volumeClaimTemplates: + - metadata: + name: datadir + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/old.yaml b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/old.yaml new file mode 100644 index 0000000..8115c6d --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_spec_update/old.yaml @@ -0,0 +1,203 @@ +apiVersion: v1 +kind: Service +metadata: + # This service is meant to be used by clients of the database. It exposes a ClusterIP that will + # automatically load balance connections to the different database pods. + name: cockroachdb-public + labels: + app: cockroachdb +spec: + ports: + # The main port, served by gRPC, serves Postgres-flavor SQL, internode + # traffic and the cli. + - port: 26257 + targetPort: 26257 + name: grpc + # The secondary port serves the UI as well as health and debug endpoints. + - port: 8080 + targetPort: 8080 + name: http + selector: + app: cockroachdb +--- +apiVersion: v1 +kind: Service +metadata: + # This service only exists to create DNS entries for each pod in the stateful + # set such that they can resolve each other's IP addresses. It does not + # create a load-balanced ClusterIP and should not be used directly by clients + # in most circumstances. + name: cockroachdb + labels: + app: cockroachdb + annotations: + # This is needed to make the peer-finder work properly and to help avoid + # edge cases where instance 0 comes up after losing its data and needs to + # decide whether it should create a new cluster or try to join an existing + # one. If it creates a new cluster when it should have joined an existing + # one, we'd end up with two separate clusters listening at the same service + # endpoint, which would be very bad. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + # Enable automatic monitoring of all instances when Prometheus is running in the cluster. + prometheus.io/scrape: "true" + prometheus.io/path: "_status/vars" + prometheus.io/port: "8080" +spec: + ports: + - port: 26257 + targetPort: 26257 + name: grpc + - port: 8080 + targetPort: 8080 + name: http + clusterIP: None + selector: + app: cockroachdb +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: cockroachdb-budget + labels: + app: cockroachdb +spec: + selector: + matchLabels: + app: cockroachdb + minAvailable: 67% +--- +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: cockroachdb +spec: + serviceName: "cockroachdb" + replicas: 3 + template: + metadata: + labels: + app: cockroachdb + annotations: + scheduler.alpha.kubernetes.io/affinity: > + { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [{ + "weight": 100, + "labelSelector": { + "matchExpressions": [{ + "key": "app", + "operator": "In", + "values": ["cockroachdb"] + }] + }, + "topologyKey": "kubernetes.io/hostname" + }] + } + } + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + pod.alpha.kubernetes.io/init-containers: '[ + { + "name": "bootstrap", + "image": "cockroachdb/cockroach-k8s-init:0.1", + "imagePullPolicy": "IfNotPresent", + "args": [ + "-on-start=/on-start.sh", + "-service=cockroachdb" + ], + "env": [ + { + "name": "POD_NAMESPACE", + "valueFrom": { + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + } + } + } + ], + "volumeMounts": [ + { + "name": "datadir", + "mountPath": "/cockroach/cockroach-data" + } + ] + } + ]' + spec: + containers: + - name: cockroachdb + # Runs the master branch. Not recommended for production, but since + # CockroachDB is in Beta, you don't want to run it in production + # anyway. See + # https://hub.docker.com/r/cockroachdb/cockroach/tags/ + # if you prefer to run a beta release. + image: cockroachdb/cockroach + imagePullPolicy: IfNotPresent + ports: + - containerPort: 26257 + name: grpc + - containerPort: 8080 + name: http + livenessProbe: + httpGet: + path: /_admin/v1/health + port: http + initialDelaySeconds: 30 + readinessProbe: + httpGet: + path: /_admin/v1/health + port: http + initialDelaySeconds: 10 + volumeMounts: + - name: datadir + mountPath: /cockroach/cockroach-data + command: + - "/bin/bash" + - "-ecx" + - | + # The use of qualified `hostname -f` is crucial: + # Other nodes aren't able to look up the unqualified hostname. + CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0") + # We only want to initialize a new cluster (by omitting the join flag) + # if we're sure that we're the first node (i.e. index 0) and that + # there aren't any other nodes running as part of the cluster that + # this is supposed to be a part of (which indicates that a cluster + # already exists and we should make sure not to create a new one). + # It's fine to run without --join on a restart if there aren't any + # other nodes. + if [ ! "$(hostname)" == "cockroachdb-0" ] || \ + [ -e "/cockroach/cockroach-data/cluster_exists_marker" ] + then + # We don't join cockroachdb in order to avoid a node attempting + # to join itself, which currently doesn't work + # (https://github.com/cockroachdb/cockroach/issues/9625). + CRARGS+=("--join" "cockroachdb-public") + fi + exec /cockroach/cockroach ${CRARGS[*]} + # No pre-stop hook is required, a SIGTERM plus some time is all that's + # needed for graceful shutdown of a node. + terminationGracePeriodSeconds: 60 + volumes: + - name: datadir + persistentVolumeClaim: + claimName: datadir + volumeClaimTemplates: + - metadata: + name: datadir + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/expected.json b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/expected.json new file mode 100644 index 0000000..0e5810e --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/expected.json @@ -0,0 +1,778 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 1 + ], + "type": "document", + "start_byte": 596, + "end_byte": 1832 + }, + "parent": { + "tree": "after", + "path": null, + "type": "stream", + "start_byte": 0, + "end_byte": 6224 + }, + "position": 1, + "subtree": true + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 2 + ], + "type": "document", + "start_byte": 1833, + "end_byte": 2035 + }, + "parent": { + "tree": "after", + "path": null, + "type": "stream", + "start_byte": 0, + "end_byte": 6224 + }, + "position": 2, + "subtree": true + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 3 + ], + "type": "document", + "start_byte": 2036, + "end_byte": 6224 + }, + "parent": { + "tree": "after", + "path": null, + "type": "stream", + "start_byte": 0, + "end_byte": 6224 + }, + "position": 3, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": 40, + "right_line": 40 + }, + { + "left_line": 41, + "right_line": 41 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": 46 + }, + { + "left_line": 47, + "right_line": 47 + }, + { + "left_line": 48, + "right_line": 48 + }, + { + "left_line": 49, + "right_line": 49 + }, + { + "left_line": 50, + "right_line": 50 + }, + { + "left_line": 51, + "right_line": 51 + }, + { + "left_line": 52, + "right_line": 52 + }, + { + "left_line": 53, + "right_line": 53 + }, + { + "left_line": 54, + "right_line": 54 + }, + { + "left_line": 55, + "right_line": 55 + }, + { + "left_line": 56, + "right_line": 56 + }, + { + "left_line": 57, + "right_line": 57 + }, + { + "left_line": 58, + "right_line": 58 + }, + { + "left_line": 59, + "right_line": 59 + }, + { + "left_line": 60, + "right_line": 60 + }, + { + "left_line": 61, + "right_line": 61 + }, + { + "left_line": 62, + "right_line": 62 + }, + { + "left_line": 63, + "right_line": 63 + }, + { + "left_line": 64, + "right_line": 64 + }, + { + "left_line": 65, + "right_line": 65 + }, + { + "left_line": 66, + "right_line": 66 + }, + { + "left_line": 67, + "right_line": 67 + }, + { + "left_line": 68, + "right_line": 68 + }, + { + "left_line": 69, + "right_line": 69 + }, + { + "left_line": 70, + "right_line": 70 + }, + { + "left_line": 71, + "right_line": 71 + }, + { + "left_line": 72, + "right_line": 72 + }, + { + "left_line": 73, + "right_line": 73 + }, + { + "left_line": 74, + "right_line": 74 + }, + { + "left_line": 75, + "right_line": 75 + }, + { + "left_line": 76, + "right_line": 76 + }, + { + "left_line": 77, + "right_line": 77 + }, + { + "left_line": 78, + "right_line": 78 + }, + { + "left_line": 79, + "right_line": 79 + }, + { + "left_line": 80, + "right_line": 80 + }, + { + "left_line": 81, + "right_line": 81 + }, + { + "left_line": 82, + "right_line": 82 + }, + { + "left_line": 83, + "right_line": 83 + }, + { + "left_line": 84, + "right_line": 84 + }, + { + "left_line": 85, + "right_line": 85 + }, + { + "left_line": 86, + "right_line": 86 + }, + { + "left_line": 87, + "right_line": 87 + }, + { + "left_line": 88, + "right_line": 88 + }, + { + "left_line": 89, + "right_line": 89 + }, + { + "left_line": 90, + "right_line": 90 + }, + { + "left_line": 91, + "right_line": 91 + }, + { + "left_line": 92, + "right_line": 92 + }, + { + "left_line": 93, + "right_line": 93 + }, + { + "left_line": 94, + "right_line": 94 + }, + { + "left_line": 95, + "right_line": 95 + }, + { + "left_line": 96, + "right_line": 96 + }, + { + "left_line": 97, + "right_line": 97 + }, + { + "left_line": 98, + "right_line": 98 + }, + { + "left_line": 99, + "right_line": 99 + }, + { + "left_line": 100, + "right_line": 100 + }, + { + "left_line": 101, + "right_line": 101 + }, + { + "left_line": 102, + "right_line": 102 + }, + { + "left_line": 103, + "right_line": 103 + }, + { + "left_line": 104, + "right_line": 104 + }, + { + "left_line": 105, + "right_line": -1 + }, + { + "left_line": 106, + "right_line": 105 + }, + { + "left_line": 107, + "right_line": 106 + }, + { + "left_line": 108, + "right_line": 107 + }, + { + "left_line": 109, + "right_line": 108 + }, + { + "left_line": 110, + "right_line": 109 + }, + { + "left_line": 111, + "right_line": 110 + }, + { + "left_line": 112, + "right_line": 111 + }, + { + "left_line": 113, + "right_line": 112 + }, + { + "left_line": 114, + "right_line": 113 + }, + { + "left_line": 115, + "right_line": 114 + }, + { + "left_line": 116, + "right_line": 115 + }, + { + "left_line": 117, + "right_line": 116 + }, + { + "left_line": 118, + "right_line": 117 + }, + { + "left_line": 119, + "right_line": 118 + }, + { + "left_line": 120, + "right_line": 119 + }, + { + "left_line": 121, + "right_line": 120 + }, + { + "left_line": 122, + "right_line": 121 + }, + { + "left_line": 123, + "right_line": 122 + }, + { + "left_line": 124, + "right_line": 123 + }, + { + "left_line": 125, + "right_line": 124 + }, + { + "left_line": 126, + "right_line": 125 + }, + { + "left_line": 127, + "right_line": 126 + }, + { + "left_line": 128, + "right_line": 127 + }, + { + "left_line": 129, + "right_line": 128 + }, + { + "left_line": 130, + "right_line": 129 + }, + { + "left_line": 131, + "right_line": 130 + }, + { + "left_line": 132, + "right_line": 131 + }, + { + "left_line": 133, + "right_line": 132 + }, + { + "left_line": 134, + "right_line": 133 + }, + { + "left_line": 135, + "right_line": 134 + }, + { + "left_line": 136, + "right_line": 135 + }, + { + "left_line": 137, + "right_line": 136 + }, + { + "left_line": 138, + "right_line": 137 + }, + { + "left_line": 139, + "right_line": 138 + }, + { + "left_line": 140, + "right_line": 139 + }, + { + "left_line": 141, + "right_line": 140 + }, + { + "left_line": 142, + "right_line": 141 + }, + { + "left_line": 143, + "right_line": 142 + }, + { + "left_line": 144, + "right_line": 143 + }, + { + "left_line": 145, + "right_line": 144 + }, + { + "left_line": 146, + "right_line": 145 + }, + { + "left_line": 147, + "right_line": 146 + }, + { + "left_line": 148, + "right_line": 147 + }, + { + "left_line": 149, + "right_line": 148 + }, + { + "left_line": 150, + "right_line": 149 + }, + { + "left_line": 151, + "right_line": 150 + }, + { + "left_line": 152, + "right_line": 151 + }, + { + "left_line": 153, + "right_line": 152 + }, + { + "left_line": 154, + "right_line": 153 + }, + { + "left_line": 155, + "right_line": 154 + }, + { + "left_line": 156, + "right_line": 155 + }, + { + "left_line": 157, + "right_line": 156 + }, + { + "left_line": 158, + "right_line": 157 + }, + { + "left_line": 159, + "right_line": 158 + }, + { + "left_line": 160, + "right_line": 159 + }, + { + "left_line": 161, + "right_line": 160 + }, + { + "left_line": 162, + "right_line": 161 + }, + { + "left_line": 163, + "right_line": 162 + }, + { + "left_line": 164, + "right_line": 163 + }, + { + "left_line": 165, + "right_line": 164 + }, + { + "left_line": 166, + "right_line": 165 + }, + { + "left_line": 167, + "right_line": 166 + }, + { + "left_line": 168, + "right_line": 167 + }, + { + "left_line": 169, + "right_line": 168 + }, + { + "left_line": 170, + "right_line": 169 + }, + { + "left_line": 171, + "right_line": 170 + }, + { + "left_line": 172, + "right_line": 171 + }, + { + "left_line": 173, + "right_line": 172 + }, + { + "left_line": 174, + "right_line": 173 + }, + { + "left_line": 175, + "right_line": 174 + }, + { + "left_line": 176, + "right_line": 175 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/metadata.json b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/metadata.json new file mode 100644 index 0000000..6886231 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "a18e70cdf7d1e66581aa7b6e6507ddf498e22eae", + "description": "Update cockroachdb statefulset replica count", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/new.yaml b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/new.yaml new file mode 100644 index 0000000..d3c1d85 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/new.yaml @@ -0,0 +1,175 @@ +apiVersion: v1 +kind: Service +metadata: + # This service is meant to be used by clients of the database. It exposes a ClusterIP that will + # automatically load balance connections to the different database pods. + name: cockroachdb-public + labels: + app: cockroachdb +spec: + ports: + # The main port, served by gRPC, serves Postgres-flavor SQL, internode + # traffic and the cli. + - port: 26257 + targetPort: 26257 + name: grpc + # The secondary port serves the UI as well as health and debug endpoints. + - port: 8080 + targetPort: 8080 + name: http + selector: + app: cockroachdb +--- +apiVersion: v1 +kind: Service +metadata: + # This service only exists to create DNS entries for each pod in the stateful + # set such that they can resolve each other's IP addresses. It does not + # create a load-balanced ClusterIP and should not be used directly by clients + # in most circumstances. + name: cockroachdb + labels: + app: cockroachdb + annotations: + # This is needed to make the peer-finder work properly and to help avoid + # edge cases where instance 0 comes up after losing its data and needs to + # decide whether it should create a new cluster or try to join an existing + # one. If it creates a new cluster when it should have joined an existing + # one, we'd end up with two separate clusters listening at the same service + # endpoint, which would be very bad. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + # Enable automatic monitoring of all instances when Prometheus is running in the cluster. + prometheus.io/scrape: "true" + prometheus.io/path: "_status/vars" + prometheus.io/port: "8080" +spec: + ports: + - port: 26257 + targetPort: 26257 + name: grpc + - port: 8080 + targetPort: 8080 + name: http + clusterIP: None + selector: + app: cockroachdb +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: cockroachdb-budget + labels: + app: cockroachdb +spec: + selector: + matchLabels: + app: cockroachdb + minAvailable: 67% +--- +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: cockroachdb +spec: + serviceName: "cockroachdb" + replicas: 3 + template: + metadata: + labels: + app: cockroachdb + spec: + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + initContainers: + - name: bootstrap + image: cockroachdb/cockroach-k8s-init:0.1 + imagePullPolicy: IfNotPresent + args: + - "-on-start=/on-start.sh" + - "-service=cockroachdb" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumeMounts: + - name: datadir + mountPath: "/cockroach/cockroach-data" + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - cockroachdb + topologyKey: kubernetes.io/hostname + containers: + - name: cockroachdb + # Runs the master branch. Not recommended for production, but since + # CockroachDB is in Beta, you don't want to run it in production + # anyway. See + # https://hub.docker.com/r/cockroachdb/cockroach/tags/ + # if you prefer to run a beta release. + image: cockroachdb/cockroach + imagePullPolicy: IfNotPresent + ports: + - containerPort: 26257 + name: grpc + - containerPort: 8080 + name: http + volumeMounts: + - name: datadir + mountPath: /cockroach/cockroach-data + command: + - "/bin/bash" + - "-ecx" + - | + # The use of qualified `hostname -f` is crucial: + # Other nodes aren't able to look up the unqualified hostname. + CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0") + # We only want to initialize a new cluster (by omitting the join flag) + # if we're sure that we're the first node (i.e. index 0) and that + # there aren't any other nodes running as part of the cluster that + # this is supposed to be a part of (which indicates that a cluster + # already exists and we should make sure not to create a new one). + # It's fine to run without --join on a restart if there aren't any + # other nodes. + if [ ! "$(hostname)" == "cockroachdb-0" ] || \ + [ -e "/cockroach/cockroach-data/cluster_exists_marker" ] + then + # We don't join cockroachdb in order to avoid a node attempting + # to join itself, which currently doesn't work + # (https://github.com/cockroachdb/cockroach/issues/9625). + CRARGS+=("--join" "cockroachdb-public") + fi + exec /cockroach/cockroach ${CRARGS[*]} + # No pre-stop hook is required, a SIGTERM plus some time is all that's + # needed for graceful shutdown of a node. + terminationGracePeriodSeconds: 60 + volumes: + - name: datadir + persistentVolumeClaim: + claimName: datadir + volumeClaimTemplates: + - metadata: + name: datadir + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi diff --git a/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/old.yaml b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/old.yaml new file mode 100644 index 0000000..7bb06e7 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_cockroachdb_statefulset/old.yaml @@ -0,0 +1,176 @@ +apiVersion: v1 +kind: Service +metadata: + # This service is meant to be used by clients of the database. It exposes a ClusterIP that will + # automatically load balance connections to the different database pods. + name: cockroachdb-public + labels: + app: cockroachdb +spec: + ports: + # The main port, served by gRPC, serves Postgres-flavor SQL, internode + # traffic and the cli. + - port: 26257 + targetPort: 26257 + name: grpc + # The secondary port serves the UI as well as health and debug endpoints. + - port: 8080 + targetPort: 8080 + name: http + selector: + app: cockroachdb +--- +apiVersion: v1 +kind: Service +metadata: + # This service only exists to create DNS entries for each pod in the stateful + # set such that they can resolve each other's IP addresses. It does not + # create a load-balanced ClusterIP and should not be used directly by clients + # in most circumstances. + name: cockroachdb + labels: + app: cockroachdb + annotations: + # This is needed to make the peer-finder work properly and to help avoid + # edge cases where instance 0 comes up after losing its data and needs to + # decide whether it should create a new cluster or try to join an existing + # one. If it creates a new cluster when it should have joined an existing + # one, we'd end up with two separate clusters listening at the same service + # endpoint, which would be very bad. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + # Enable automatic monitoring of all instances when Prometheus is running in the cluster. + prometheus.io/scrape: "true" + prometheus.io/path: "_status/vars" + prometheus.io/port: "8080" +spec: + ports: + - port: 26257 + targetPort: 26257 + name: grpc + - port: 8080 + targetPort: 8080 + name: http + clusterIP: None + selector: + app: cockroachdb +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: cockroachdb-budget + labels: + app: cockroachdb +spec: + selector: + matchLabels: + app: cockroachdb + minAvailable: 67% +--- +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: cockroachdb +spec: + serviceName: "cockroachdb" + replicas: 3 + template: + metadata: + labels: + app: cockroachdb + spec: + # Init containers are run only once in the lifetime of a pod, before + # it's started up for the first time. It has to exit successfully + # before the pod's main containers are allowed to start. + # This particular init container does a DNS lookup for other pods in + # the set to help determine whether or not a cluster already exists. + # If any other pods exist, it creates a file in the cockroach-data + # directory to pass that information along to the primary container that + # has to decide what command-line flags to use when starting CockroachDB. + # This only matters when a pod's persistent volume is empty - if it has + # data from a previous execution, that data will always be used. + initContainers: + - name: bootstrap + image: cockroachdb/cockroach-k8s-init:0.1 + imagePullPolicy: IfNotPresent + args: + - "-on-start=/on-start.sh" + - "-service=cockroachdb" + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumeMounts: + - name: datadir + mountPath: "/cockroach/cockroach-data" + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpress: + - key: app + operator: In + values: + - cockroachdb + topologyKey: kubernetes.io/hostname + containers: + - name: cockroachdb + # Runs the master branch. Not recommended for production, but since + # CockroachDB is in Beta, you don't want to run it in production + # anyway. See + # https://hub.docker.com/r/cockroachdb/cockroach/tags/ + # if you prefer to run a beta release. + image: cockroachdb/cockroach + imagePullPolicy: IfNotPresent + ports: + - containerPort: 26257 + name: grpc + - containerPort: 8080 + name: http + volumeMounts: + - name: datadir + mountPath: /cockroach/cockroach-data + command: + - "/bin/bash" + - "-ecx" + - | + # The use of qualified `hostname -f` is crucial: + # Other nodes aren't able to look up the unqualified hostname. + CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0") + # We only want to initialize a new cluster (by omitting the join flag) + # if we're sure that we're the first node (i.e. index 0) and that + # there aren't any other nodes running as part of the cluster that + # this is supposed to be a part of (which indicates that a cluster + # already exists and we should make sure not to create a new one). + # It's fine to run without --join on a restart if there aren't any + # other nodes. + if [ ! "$(hostname)" == "cockroachdb-0" ] || \ + [ -e "/cockroach/cockroach-data/cluster_exists_marker" ] + then + # We don't join cockroachdb in order to avoid a node attempting + # to join itself, which currently doesn't work + # (https://github.com/cockroachdb/cockroach/issues/9625). + CRARGS+=("--join" "cockroachdb-public") + fi + exec /cockroach/cockroach ${CRARGS[*]} + # No pre-stop hook is required, a SIGTERM plus some time is all that's + # needed for graceful shutdown of a node. + terminationGracePeriodSeconds: 60 + volumes: + - name: datadir + persistentVolumeClaim: + claimName: datadir + volumeClaimTemplates: + - metadata: + name: datadir + annotations: + volume.alpha.kubernetes.io/storage-class: anything + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi diff --git a/tests/testdata/yaml_k8s_examples_flower_scalar_controller/expected.json b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/expected.json new file mode 100644 index 0000000..6991214 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/expected.json @@ -0,0 +1,177 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3 + ], + "type": "block_mapping_pair", + "start_byte": 367, + "end_byte": 589 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 256, + "end_byte": 589 + }, + "position": 3, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": -1, + "right_line": 20 + }, + { + "left_line": -1, + "right_line": 21 + }, + { + "left_line": -1, + "right_line": 22 + }, + { + "left_line": -1, + "right_line": 23 + }, + { + "left_line": -1, + "right_line": 24 + }, + { + "left_line": -1, + "right_line": 25 + }, + { + "left_line": -1, + "right_line": 26 + }, + { + "left_line": 20, + "right_line": 27 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_flower_scalar_controller/metadata.json b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/metadata.json new file mode 100644 index 0000000..d3f37aa --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "42a29fc41fb5d3d412ede7a0ab30769bf7f3011b", + "description": "Update flower controller spec template", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_flower_scalar_controller/new.yaml b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/new.yaml new file mode 100644 index 0000000..bf006e6 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/new.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + labels: + component: flower + name: flower-controller +spec: + replicas: 1 + template: + metadata: + labels: + app: taskQueue + component: flower + spec: + containers: + - image: endocode/flower + name: flower + resources: + limits: + cpu: 100m + livenessProbe: + httpGet: + # Path to probe; should be cheap, but representative of typical behavior + path: / + port: 80 + initialDelaySeconds: 30 + timeoutSeconds: 1 diff --git a/tests/testdata/yaml_k8s_examples_flower_scalar_controller/old.yaml b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/old.yaml new file mode 100644 index 0000000..0693508 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_flower_scalar_controller/old.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + labels: + component: flower + name: flower-controller +spec: + replicas: 1 + template: + metadata: + labels: + app: taskQueue + component: flower + spec: + containers: + - image: endocode/flower + name: flower + resources: + limits: + cpu: 100m diff --git a/tests/testdata/yaml_k8s_examples_javaweb_scalar/expected.json b/tests/testdata/yaml_k8s_examples_javaweb_scalar/expected.json new file mode 100644 index 0000000..294d179 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_javaweb_scalar/expected.json @@ -0,0 +1,157 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 128, + "end_byte": 172 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 81, + "end_byte": 245 + }, + "position": 2, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": -1, + "right_line": 8 + }, + { + "left_line": 8, + "right_line": 9 + }, + { + "left_line": 9, + "right_line": 10 + }, + { + "left_line": 10, + "right_line": 11 + }, + { + "left_line": 11, + "right_line": 12 + }, + { + "left_line": 12, + "right_line": 13 + }, + { + "left_line": 13, + "right_line": 14 + }, + { + "left_line": 14, + "right_line": 15 + }, + { + "left_line": 15, + "right_line": 16 + }, + { + "left_line": 16, + "right_line": 17 + }, + { + "left_line": 17, + "right_line": 18 + }, + { + "left_line": 18, + "right_line": 19 + }, + { + "left_line": 19, + "right_line": 20 + }, + { + "left_line": 20, + "right_line": 21 + }, + { + "left_line": 21, + "right_line": 22 + }, + { + "left_line": 22, + "right_line": 23 + }, + { + "left_line": 23, + "right_line": 24 + }, + { + "left_line": 24, + "right_line": 25 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_javaweb_scalar/metadata.json b/tests/testdata/yaml_k8s_examples_javaweb_scalar/metadata.json new file mode 100644 index 0000000..a0aeccc --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_javaweb_scalar/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "e3c0e941312d3b5c9c957d3223354dc91a746bf2", + "description": "Update javaweb pod replica count", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_javaweb_scalar/new.yaml b/tests/testdata/yaml_k8s_examples_javaweb_scalar/new.yaml new file mode 100644 index 0000000..776b2cd --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_javaweb_scalar/new.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Pod +metadata: + name: javaweb +spec: + initContainers: + - image: resouer/sample:v1 + name: war + command: ["sh", "-c", "cp /sample.war /app"] + volumeMounts: + - mountPath: /app + name: app-volume + containers: + - image: resouer/mytomcat:7.0 + name: tomcat + command: ["sh", "-c", "/root/apache-tomcat-7.0.42-v2/bin/start.sh"] + volumeMounts: + - mountPath: /root/apache-tomcat-7.0.42-v2/webapps + name: app-volume + ports: + - containerPort: 8080 + hostPort: 8001 + volumes: + - name: app-volume + emptyDir: {} diff --git a/tests/testdata/yaml_k8s_examples_javaweb_scalar/old.yaml b/tests/testdata/yaml_k8s_examples_javaweb_scalar/old.yaml new file mode 100644 index 0000000..578f291 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_javaweb_scalar/old.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Pod +metadata: + name: javaweb +spec: + initContainers: + - image: resouer/sample:v1 + name: war + volumeMounts: + - mountPath: /app + name: app-volume + containers: + - image: resouer/mytomcat:7.0 + name: tomcat + command: ["sh", "-c", "/root/apache-tomcat-7.0.42-v2/bin/start.sh"] + volumeMounts: + - mountPath: /root/apache-tomcat-7.0.42-v2/webapps + name: app-volume + ports: + - containerPort: 8080 + hostPort: 8001 + volumes: + - name: app-volume + emptyDir: {} diff --git a/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/expected.json b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/expected.json new file mode 100644 index 0000000..84c61ce --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/expected.json @@ -0,0 +1,742 @@ +{ + "version": "v1", + "actions": [ + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 74, + "end_byte": 82 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 76, + "end_byte": 102 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 74, + "end_byte": 152 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 76, + "dest_end_byte": 84 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 136, + "end_byte": 151 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 90, + "end_byte": 102 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 90, + "end_byte": 152 + }, + "old_position": 2, + "subtree": true, + "dest_start_byte": 90, + "dest_end_byte": 102 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 0, + "end_byte": 10 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 183 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 152 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 0, + "dest_end_byte": 19 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 1 + ], + "type": "block_mapping_pair", + "start_byte": 11, + "end_byte": 33 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 183 + }, + "position": 1, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 152 + }, + "old_position": 1, + "subtree": true, + "dest_start_byte": 20, + "dest_end_byte": 42, + "group_id": "group-1" + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 43, + "end_byte": 67 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 183 + }, + "position": 2 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 62, + "end_byte": 68 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 43, + "end_byte": 67 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 62, + "end_byte": 152 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 43, + "dest_end_byte": 51 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 0 + ], + "type": "flow_node", + "start_byte": 54, + "end_byte": 58 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3 + ], + "type": "block_mapping_pair", + "start_byte": 68, + "end_byte": 183 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3 + ], + "type": "block_mapping_pair", + "start_byte": 54, + "end_byte": 152 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 68, + "dest_end_byte": 72, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 34, + "end_byte": 53 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 55, + "end_byte": 67 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 0, + "end_byte": 152 + }, + "old_position": 2, + "subtree": true, + "dest_start_byte": 55, + "dest_end_byte": 67 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 90, + "end_byte": 96 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 1 + ], + "type": "block_mapping_pair", + "start_byte": 105, + "end_byte": 137 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 90, + "end_byte": 110 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 105, + "dest_end_byte": 116 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 0 + ], + "type": "flow_node", + "start_byte": 117, + "end_byte": 121 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 140, + "end_byte": 183 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1 + ], + "type": "block_mapping_pair", + "start_byte": 117, + "end_byte": 129 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 140, + "dest_end_byte": 143 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 1, + 1 + ], + "type": "block_node", + "start_byte": 122, + "end_byte": 137 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 1 + ], + "type": "block_mapping_pair", + "start_byte": 105, + "end_byte": 137 + }, + "position": 1, + "subtree": true + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 2, + 1 + ], + "type": "block_node", + "start_byte": 149, + "end_byte": 183 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 140, + "end_byte": 183 + }, + "position": 1, + "subtree": true + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1 + ], + "type": "block_node", + "start_byte": 62, + "end_byte": 152 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3 + ], + "type": "block_mapping_pair", + "start_byte": 54, + "end_byte": 152 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 1 + ], + "type": "flow_node", + "start_byte": 98, + "end_byte": 110 + }, + "subtree": true + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1 + ], + "type": "flow_node", + "start_byte": 123, + "end_byte": 129 + }, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": -1, + "right_line": 2 + }, + { + "left_line": 2, + "right_line": 3 + }, + { + "left_line": 3, + "right_line": -1 + }, + { + "left_line": 4, + "right_line": -1 + }, + { + "left_line": -1, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": -1 + }, + { + "left_line": 7, + "right_line": -1 + }, + { + "left_line": 8, + "right_line": 6 + }, + { + "left_line": -1, + "right_line": 7 + }, + { + "left_line": -1, + "right_line": 8 + }, + { + "left_line": -1, + "right_line": 9 + }, + { + "left_line": -1, + "right_line": 10 + }, + { + "left_line": -1, + "right_line": 11 + }, + { + "left_line": 9, + "right_line": 12 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/metadata.json b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/metadata.json new file mode 100644 index 0000000..f7f18f7 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "ce6b8d8c2dd4ce993b3c386db1dcf62f813ac1c0", + "description": "Update persistentvolume nfs example spec", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/new.yaml b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/new.yaml new file mode 100644 index 0000000..6e0f911 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/new.yaml @@ -0,0 +1,12 @@ +apiVersion: v1beta3 +kind: PersistentVolume +metadata: + name: pv0003 +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + nfs: + path: /tmp + server: 172.17.0.2 diff --git a/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/old.yaml b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/old.yaml new file mode 100644 index 0000000..50a9976 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_persistentvolume_nfs/old.yaml @@ -0,0 +1,9 @@ +id: pv0003 +kind: PersistentVolume +apiVersion: v1beta1 +spec: + source: + nfsMount: + server: "172.17.0.2" + path: "/tmp" + readOnly: false diff --git a/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/expected.json b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/expected.json new file mode 100644 index 0000000..cea63e4 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/expected.json @@ -0,0 +1,689 @@ +{ + "version": "v1", + "actions": [ + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 259, + "end_byte": 267 + }, + "parent": { + "tree": "after", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 259, + "end_byte": 2411 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 259, + "end_byte": 2356 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 259, + "dest_end_byte": 267 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 273, + "end_byte": 323 + }, + "parent": { + "tree": "after", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 273, + "end_byte": 2411 + }, + "position": 0, + "subtree": true + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 273, + "end_byte": 2356 + }, + "parent": { + "tree": "after", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 273, + "end_byte": 2411 + }, + "position": 1, + "old_parent": { + "tree": "before", + "path": [ + 1, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 273, + "end_byte": 2356 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 328, + "dest_end_byte": 2411 + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": -1 + }, + { + "left_line": 11, + "right_line": -1 + }, + { + "left_line": 12, + "right_line": -1 + }, + { + "left_line": 13, + "right_line": -1 + }, + { + "left_line": 14, + "right_line": -1 + }, + { + "left_line": 15, + "right_line": -1 + }, + { + "left_line": 16, + "right_line": -1 + }, + { + "left_line": 17, + "right_line": -1 + }, + { + "left_line": 18, + "right_line": -1 + }, + { + "left_line": 19, + "right_line": -1 + }, + { + "left_line": 20, + "right_line": -1 + }, + { + "left_line": 21, + "right_line": -1 + }, + { + "left_line": 22, + "right_line": -1 + }, + { + "left_line": 23, + "right_line": -1 + }, + { + "left_line": 24, + "right_line": -1 + }, + { + "left_line": 25, + "right_line": -1 + }, + { + "left_line": 26, + "right_line": -1 + }, + { + "left_line": 27, + "right_line": -1 + }, + { + "left_line": 28, + "right_line": -1 + }, + { + "left_line": 29, + "right_line": -1 + }, + { + "left_line": 30, + "right_line": -1 + }, + { + "left_line": 31, + "right_line": -1 + }, + { + "left_line": 32, + "right_line": -1 + }, + { + "left_line": 33, + "right_line": -1 + }, + { + "left_line": 34, + "right_line": -1 + }, + { + "left_line": 35, + "right_line": -1 + }, + { + "left_line": 36, + "right_line": -1 + }, + { + "left_line": 37, + "right_line": -1 + }, + { + "left_line": 38, + "right_line": -1 + }, + { + "left_line": 39, + "right_line": -1 + }, + { + "left_line": 40, + "right_line": -1 + }, + { + "left_line": 41, + "right_line": -1 + }, + { + "left_line": 42, + "right_line": -1 + }, + { + "left_line": 43, + "right_line": -1 + }, + { + "left_line": 44, + "right_line": -1 + }, + { + "left_line": 45, + "right_line": -1 + }, + { + "left_line": 46, + "right_line": -1 + }, + { + "left_line": 47, + "right_line": -1 + }, + { + "left_line": 48, + "right_line": -1 + }, + { + "left_line": 49, + "right_line": -1 + }, + { + "left_line": 50, + "right_line": -1 + }, + { + "left_line": 51, + "right_line": -1 + }, + { + "left_line": 52, + "right_line": -1 + }, + { + "left_line": 53, + "right_line": -1 + }, + { + "left_line": 54, + "right_line": -1 + }, + { + "left_line": 55, + "right_line": -1 + }, + { + "left_line": 56, + "right_line": -1 + }, + { + "left_line": 57, + "right_line": -1 + }, + { + "left_line": 58, + "right_line": -1 + }, + { + "left_line": 59, + "right_line": -1 + }, + { + "left_line": 60, + "right_line": -1 + }, + { + "left_line": 61, + "right_line": -1 + }, + { + "left_line": 62, + "right_line": -1 + }, + { + "left_line": 63, + "right_line": -1 + }, + { + "left_line": 64, + "right_line": -1 + }, + { + "left_line": 65, + "right_line": -1 + }, + { + "left_line": 66, + "right_line": -1 + }, + { + "left_line": 67, + "right_line": -1 + }, + { + "left_line": 68, + "right_line": -1 + }, + { + "left_line": -1, + "right_line": 10 + }, + { + "left_line": -1, + "right_line": 11 + }, + { + "left_line": -1, + "right_line": 12 + }, + { + "left_line": -1, + "right_line": 13 + }, + { + "left_line": -1, + "right_line": 14 + }, + { + "left_line": -1, + "right_line": 15 + }, + { + "left_line": -1, + "right_line": 16 + }, + { + "left_line": -1, + "right_line": 17 + }, + { + "left_line": -1, + "right_line": 18 + }, + { + "left_line": -1, + "right_line": 19 + }, + { + "left_line": -1, + "right_line": 20 + }, + { + "left_line": -1, + "right_line": 21 + }, + { + "left_line": -1, + "right_line": 22 + }, + { + "left_line": -1, + "right_line": 23 + }, + { + "left_line": -1, + "right_line": 24 + }, + { + "left_line": -1, + "right_line": 25 + }, + { + "left_line": -1, + "right_line": 26 + }, + { + "left_line": -1, + "right_line": 27 + }, + { + "left_line": -1, + "right_line": 28 + }, + { + "left_line": -1, + "right_line": 29 + }, + { + "left_line": -1, + "right_line": 30 + }, + { + "left_line": -1, + "right_line": 31 + }, + { + "left_line": -1, + "right_line": 32 + }, + { + "left_line": -1, + "right_line": 33 + }, + { + "left_line": -1, + "right_line": 34 + }, + { + "left_line": -1, + "right_line": 35 + }, + { + "left_line": -1, + "right_line": 36 + }, + { + "left_line": -1, + "right_line": 37 + }, + { + "left_line": -1, + "right_line": 38 + }, + { + "left_line": -1, + "right_line": 39 + }, + { + "left_line": -1, + "right_line": 40 + }, + { + "left_line": -1, + "right_line": 41 + }, + { + "left_line": -1, + "right_line": 42 + }, + { + "left_line": -1, + "right_line": 43 + }, + { + "left_line": -1, + "right_line": 44 + }, + { + "left_line": -1, + "right_line": 45 + }, + { + "left_line": -1, + "right_line": 46 + }, + { + "left_line": -1, + "right_line": 47 + }, + { + "left_line": -1, + "right_line": 48 + }, + { + "left_line": -1, + "right_line": 49 + }, + { + "left_line": -1, + "right_line": 50 + }, + { + "left_line": -1, + "right_line": 51 + }, + { + "left_line": -1, + "right_line": 52 + }, + { + "left_line": -1, + "right_line": 53 + }, + { + "left_line": -1, + "right_line": 54 + }, + { + "left_line": -1, + "right_line": 55 + }, + { + "left_line": -1, + "right_line": 56 + }, + { + "left_line": -1, + "right_line": 57 + }, + { + "left_line": -1, + "right_line": 58 + }, + { + "left_line": -1, + "right_line": 59 + }, + { + "left_line": -1, + "right_line": 60 + }, + { + "left_line": -1, + "right_line": 61 + }, + { + "left_line": -1, + "right_line": 62 + }, + { + "left_line": -1, + "right_line": 63 + }, + { + "left_line": -1, + "right_line": 64 + }, + { + "left_line": -1, + "right_line": 65 + }, + { + "left_line": -1, + "right_line": 66 + }, + { + "left_line": -1, + "right_line": 67 + }, + { + "left_line": -1, + "right_line": 68 + }, + { + "left_line": -1, + "right_line": 69 + }, + { + "left_line": -1, + "right_line": 70 + }, + { + "left_line": -1, + "right_line": 71 + }, + { + "left_line": 69, + "right_line": 72 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/metadata.json b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/metadata.json new file mode 100644 index 0000000..aacfd0e --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "kubernetes/examples", + "commit": "906564ac37d234cc18dc01b6a1e1e4a5c0c2076a", + "description": "Update sysdig daemonset container args", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/new.yaml b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/new.yaml new file mode 100644 index 0000000..9bdfb90 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/new.yaml @@ -0,0 +1,72 @@ +#Use this sysdig.yaml when Daemon Sets are enabled on Kubernetes (minimum version 1.1.1). Otherwise use the RC method. + +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: sysdig-agent + labels: + app: sysdig-agent +spec: + template: + metadata: + labels: + name: sysdig-agent + spec: + volumes: + - name: docker-sock + hostPath: + path: /var/run/docker.sock + - name: dev-vol + hostPath: + path: /dev + - name: proc-vol + hostPath: + path: /proc + - name: boot-vol + hostPath: + path: /boot + - name: modules-vol + hostPath: + path: /lib/modules + - name: usr-vol + hostPath: + path: /usr + hostNetwork: true + hostPID: true + containers: + - name: sysdig-agent + image: sysdig/agent + securityContext: + privileged: true + env: + - name: ACCESS_KEY #REQUIRED - replace with your Sysdig Cloud access key + value: 8312341g-5678-abcd-4a2b2c-33bcsd655 +# - name: TAGS #OPTIONAL +# value: linux:ubuntu,dept:dev,local:nyc +# - name: COLLECTOR #OPTIONAL - on-prem install only +# value: 192.168.183.200 +# - name: SECURE #OPTIONAL - on-prem install only +# value: false +# - name: CHECK_CERTIFICATE #OPTIONAL - on-prem install only +# value: false +# - name: ADDITIONAL_CONF #OPTIONAL pass additional parameters to the agent such as authentication example provided here +# value: "k8s_uri: https://myacct:mypass@localhost:4430\nk8s_ca_certificate: k8s-ca.crt\nk8s_ssl_verify_certificate: true" + volumeMounts: + - mountPath: /host/var/run/docker.sock + name: docker-sock + readOnly: false + - mountPath: /host/dev + name: dev-vol + readOnly: false + - mountPath: /host/proc + name: proc-vol + readOnly: true + - mountPath: /host/boot + name: boot-vol + readOnly: true + - mountPath: /host/lib/modules + name: modules-vol + readOnly: true + - mountPath: /host/usr + name: usr-vol + readOnly: true diff --git a/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/old.yaml b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/old.yaml new file mode 100644 index 0000000..20a7e18 --- /dev/null +++ b/tests/testdata/yaml_k8s_examples_sysdig_scalar_daemonset/old.yaml @@ -0,0 +1,69 @@ +#Use this sysdig.yaml when Daemon Sets are enabled on Kubernetes (minimum version 1.1.1). Otherwise use the RC method. + +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: sysdig-agent + labels: + app: sysdig-agent +spec: + template: + spec: + volumes: + - name: docker-sock + hostPath: + path: /var/run/docker.sock + - name: dev-vol + hostPath: + path: /dev + - name: proc-vol + hostPath: + path: /proc + - name: boot-vol + hostPath: + path: /boot + - name: modules-vol + hostPath: + path: /lib/modules + - name: usr-vol + hostPath: + path: /usr + hostNetwork: true + hostPID: true + containers: + - name: sysdig-agent + image: sysdig/agent + securityContext: + privileged: true + env: + - name: ACCESS_KEY #REQUIRED - replace with your Sysdig Cloud access key + value: 8312341g-5678-abcd-4a2b2c-33bcsd655 +# - name: TAGS #OPTIONAL +# value: linux:ubuntu,dept:dev,local:nyc +# - name: COLLECTOR #OPTIONAL - on-prem install only +# value: 192.168.183.200 +# - name: SECURE #OPTIONAL - on-prem install only +# value: false +# - name: CHECK_CERTIFICATE #OPTIONAL - on-prem install only +# value: false +# - name: ADDITIONAL_CONF #OPTIONAL pass additional parameters to the agent such as authentication example provided here +# value: "k8s_uri: https://myacct:mypass@localhost:4430\nk8s_ca_certificate: k8s-ca.crt\nk8s_ssl_verify_certificate: true" + volumeMounts: + - mountPath: /host/var/run/docker.sock + name: docker-sock + readOnly: false + - mountPath: /host/dev + name: dev-vol + readOnly: false + - mountPath: /host/proc + name: proc-vol + readOnly: true + - mountPath: /host/boot + name: boot-vol + readOnly: true + - mountPath: /host/lib/modules + name: modules-vol + readOnly: true + - mountPath: /host/usr + name: usr-vol + readOnly: true diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_container/expected.json b/tests/testdata/yaml_microservices_cartservice_scalar_container/expected.json new file mode 100644 index 0000000..0eb64e0 --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_container/expected.json @@ -0,0 +1,296 @@ +{ + "version": "v1", + "actions": [ + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 1 + ], + "type": "block_mapping_pair", + "start_byte": 204, + "end_byte": 629 + }, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": -1 + }, + { + "left_line": 12, + "right_line": -1 + }, + { + "left_line": 13, + "right_line": -1 + }, + { + "left_line": 14, + "right_line": -1 + }, + { + "left_line": 15, + "right_line": -1 + }, + { + "left_line": 16, + "right_line": -1 + }, + { + "left_line": 17, + "right_line": -1 + }, + { + "left_line": 18, + "right_line": -1 + }, + { + "left_line": 19, + "right_line": -1 + }, + { + "left_line": 20, + "right_line": -1 + }, + { + "left_line": 21, + "right_line": -1 + }, + { + "left_line": 22, + "right_line": -1 + }, + { + "left_line": 23, + "right_line": -1 + }, + { + "left_line": 24, + "right_line": 11 + }, + { + "left_line": 25, + "right_line": 12 + }, + { + "left_line": 26, + "right_line": 13 + }, + { + "left_line": 27, + "right_line": 14 + }, + { + "left_line": 28, + "right_line": 15 + }, + { + "left_line": 29, + "right_line": 16 + }, + { + "left_line": 30, + "right_line": 17 + }, + { + "left_line": 31, + "right_line": 18 + }, + { + "left_line": 32, + "right_line": 19 + }, + { + "left_line": 33, + "right_line": 20 + }, + { + "left_line": 34, + "right_line": 21 + }, + { + "left_line": 35, + "right_line": 22 + }, + { + "left_line": 36, + "right_line": 23 + }, + { + "left_line": 37, + "right_line": 24 + }, + { + "left_line": 38, + "right_line": 25 + }, + { + "left_line": 39, + "right_line": 26 + }, + { + "left_line": 40, + "right_line": 27 + }, + { + "left_line": 41, + "right_line": 28 + }, + { + "left_line": 42, + "right_line": 29 + }, + { + "left_line": 43, + "right_line": 30 + }, + { + "left_line": 44, + "right_line": 31 + }, + { + "left_line": 45, + "right_line": 32 + }, + { + "left_line": 46, + "right_line": 33 + }, + { + "left_line": 47, + "right_line": 34 + }, + { + "left_line": 48, + "right_line": 35 + }, + { + "left_line": 49, + "right_line": 36 + }, + { + "left_line": 50, + "right_line": 37 + }, + { + "left_line": 51, + "right_line": 38 + }, + { + "left_line": 52, + "right_line": 39 + }, + { + "left_line": 53, + "right_line": 40 + }, + { + "left_line": 54, + "right_line": 41 + }, + { + "left_line": 55, + "right_line": 42 + }, + { + "left_line": 56, + "right_line": 43 + }, + { + "left_line": 57, + "right_line": 44 + }, + { + "left_line": 58, + "right_line": 45 + }, + { + "left_line": 59, + "right_line": 46 + }, + { + "left_line": 60, + "right_line": 47 + }, + { + "left_line": 61, + "right_line": 48 + }, + { + "left_line": 62, + "right_line": 49 + }, + { + "left_line": 63, + "right_line": 50 + }, + { + "left_line": 64, + "right_line": 51 + }, + { + "left_line": 65, + "right_line": 52 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_container/metadata.json b/tests/testdata/yaml_microservices_cartservice_scalar_container/metadata.json new file mode 100644 index 0000000..93e3d22 --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_container/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "0be5e7b1e265941a9d933d001665455990705e8b", + "description": "Update cartservice container specification", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_container/new.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_container/new.yaml new file mode 100644 index 0000000..54bc11f --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_container/new.yaml @@ -0,0 +1,52 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + terminationGracePeriodSeconds: 5 + containers: + - name: server + image: gcr.io/istio-next/cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: PORT + value: "7070" + - name: LISTEN_ADDR + value: "0.0.0.0" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 15 + exec: + command: ["/cartservice_probe"] + livenessProbe: + initialDelaySeconds: 15 + periodSeconds: 10 + exec: + command: ["/cartservice_probe"] +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - name: grpc + port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_container/old.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_container/old.yaml new file mode 100644 index 0000000..031f4e7 --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_container/old.yaml @@ -0,0 +1,65 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + terminationGracePeriodSeconds: 5 + initContainers: + - name: wait-redis + image: redis:alpine + command: ['sh', '-c', 'set -x; + until timeout -t 5 redis-cli -h "${REDIS_HOST}" -p "${REDIS_PORT}" ping; do + echo "waiting for redis at ${REDIS_HOST}:${REDIS_PORT}..."; + sleep 2; + done;'] + env: + - name: REDIS_HOST + value: "redis-cart" + - name: REDIS_PORT + value: "6379" + containers: + - name: server + image: gcr.io/istio-next/cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: PORT + value: "7070" + - name: LISTEN_ADDR + value: "0.0.0.0" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 5 + exec: + command: ["/cartservice_probe"] + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 10 + exec: + command: ["/cartservice_probe"] +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - name: grpc + port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_limits/expected.json b/tests/testdata/yaml_microservices_cartservice_scalar_limits/expected.json new file mode 100644 index 0000000..b47037f --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_limits/expected.json @@ -0,0 +1,239 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 0, + 2 + ], + "type": "block_sequence_item", + "start_byte": 411, + "end_byte": 465 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 291, + "end_byte": 465 + }, + "position": 2, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": -1, + "right_line": 20 + }, + { + "left_line": -1, + "right_line": 21 + }, + { + "left_line": 20, + "right_line": 22 + }, + { + "left_line": 21, + "right_line": 23 + }, + { + "left_line": 22, + "right_line": 24 + }, + { + "left_line": 23, + "right_line": 25 + }, + { + "left_line": 24, + "right_line": 26 + }, + { + "left_line": 25, + "right_line": 27 + }, + { + "left_line": 26, + "right_line": 28 + }, + { + "left_line": 27, + "right_line": 29 + }, + { + "left_line": 28, + "right_line": 30 + }, + { + "left_line": 29, + "right_line": 31 + }, + { + "left_line": 30, + "right_line": 32 + }, + { + "left_line": 31, + "right_line": 33 + }, + { + "left_line": 32, + "right_line": 34 + }, + { + "left_line": 33, + "right_line": 35 + }, + { + "left_line": 34, + "right_line": 36 + }, + { + "left_line": 35, + "right_line": 37 + }, + { + "left_line": 36, + "right_line": 38 + }, + { + "left_line": 37, + "right_line": 39 + }, + { + "left_line": 38, + "right_line": 40 + }, + { + "left_line": 39, + "right_line": 41 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_limits/metadata.json b/tests/testdata/yaml_microservices_cartservice_scalar_limits/metadata.json new file mode 100644 index 0000000..7fdd7df --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_limits/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "7c83802b9e5fa663f4cd7924b8c94e13f80d5bb4", + "description": "Update cartservice memory limits", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_limits/new.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_limits/new.yaml new file mode 100644 index 0000000..d7200e5 --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_limits/new.yaml @@ -0,0 +1,41 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + containers: + - name: server + image: cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: CART_SERVICE_PORT + value: "7070" + - name: CART_SERVICE_ADDR + value: "127.0.0.1" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_limits/old.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_limits/old.yaml new file mode 100644 index 0000000..83cb82d --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_limits/old.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + containers: + - name: server + image: cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: CART_SERVICE_PORT + value: "7070" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_resources/expected.json b/tests/testdata/yaml_microservices_cartservice_scalar_resources/expected.json new file mode 100644 index 0000000..b47037f --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_resources/expected.json @@ -0,0 +1,239 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 0, + 2 + ], + "type": "block_sequence_item", + "start_byte": 411, + "end_byte": 465 + }, + "parent": { + "tree": "after", + "path": [ + 0, + 0, + 0, + 3, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 3, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 291, + "end_byte": 465 + }, + "position": 2, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": -1, + "right_line": 20 + }, + { + "left_line": -1, + "right_line": 21 + }, + { + "left_line": 20, + "right_line": 22 + }, + { + "left_line": 21, + "right_line": 23 + }, + { + "left_line": 22, + "right_line": 24 + }, + { + "left_line": 23, + "right_line": 25 + }, + { + "left_line": 24, + "right_line": 26 + }, + { + "left_line": 25, + "right_line": 27 + }, + { + "left_line": 26, + "right_line": 28 + }, + { + "left_line": 27, + "right_line": 29 + }, + { + "left_line": 28, + "right_line": 30 + }, + { + "left_line": 29, + "right_line": 31 + }, + { + "left_line": 30, + "right_line": 32 + }, + { + "left_line": 31, + "right_line": 33 + }, + { + "left_line": 32, + "right_line": 34 + }, + { + "left_line": 33, + "right_line": 35 + }, + { + "left_line": 34, + "right_line": 36 + }, + { + "left_line": 35, + "right_line": 37 + }, + { + "left_line": 36, + "right_line": 38 + }, + { + "left_line": 37, + "right_line": 39 + }, + { + "left_line": 38, + "right_line": 40 + }, + { + "left_line": 39, + "right_line": 41 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_resources/metadata.json b/tests/testdata/yaml_microservices_cartservice_scalar_resources/metadata.json new file mode 100644 index 0000000..3935b9b --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_resources/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "6040585996caab2494a2812a13be423608baf0c0", + "description": "Update cartservice resource requests", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_resources/new.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_resources/new.yaml new file mode 100644 index 0000000..d7200e5 --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_resources/new.yaml @@ -0,0 +1,41 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + containers: + - name: server + image: cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: CART_SERVICE_PORT + value: "7070" + - name: CART_SERVICE_ADDR + value: "127.0.0.1" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_cartservice_scalar_resources/old.yaml b/tests/testdata/yaml_microservices_cartservice_scalar_resources/old.yaml new file mode 100644 index 0000000..83cb82d --- /dev/null +++ b/tests/testdata/yaml_microservices_cartservice_scalar_resources/old.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: cartservice +spec: + template: + metadata: + labels: + app: cartservice + spec: + containers: + - name: server + image: cartservice + ports: + - containerPort: 7070 + env: + - name: REDIS_ADDR + value: "redis-cart:6379" + - name: CART_SERVICE_PORT + value: "7070" + resources: + requests: + cpu: 200m + memory: 64Mi + limits: + cpu: 300m + memory: 128Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: cartservice +spec: + type: ClusterIP + selector: + app: cartservice + ports: + - port: 7070 + targetPort: 7070 diff --git a/tests/testdata/yaml_microservices_kustomization_scalar/expected.json b/tests/testdata/yaml_microservices_kustomization_scalar/expected.json new file mode 100644 index 0000000..d871f9f --- /dev/null +++ b/tests/testdata/yaml_microservices_kustomization_scalar/expected.json @@ -0,0 +1,681 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0, + 12 + ], + "type": "comment", + "label": "# components:", + "start_byte": 1001, + "end_byte": 1014 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 12 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4 + ], + "type": "comment", + "label": "# - ../kustomize/components/cymbal-branding", + "start_byte": 1013, + "end_byte": 1056 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 13, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 4, + "dest_start_byte": 1015, + "dest_end_byte": 1058, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5 + ], + "type": "comment", + "label": "# - ../kustomize/components/google-cloud-operations", + "start_byte": 1057, + "end_byte": 1108 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 14, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 5, + "dest_start_byte": 1059, + "dest_end_byte": 1110, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 6 + ], + "type": "comment", + "label": "# - ../kustomize/components/memorystore", + "start_byte": 1109, + "end_byte": 1148 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 15, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 6, + "dest_start_byte": 1111, + "dest_end_byte": 1150, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 7 + ], + "type": "comment", + "label": "# - ../kustomize/components/network-policies", + "start_byte": 1149, + "end_byte": 1193 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 16, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 7, + "dest_start_byte": 1151, + "dest_end_byte": 1195, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 8 + ], + "type": "comment", + "label": "# - ../kustomize/components/service-accounts", + "start_byte": 1194, + "end_byte": 1238 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 17, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 8, + "dest_start_byte": 1196, + "dest_end_byte": 1240, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 9 + ], + "type": "comment", + "label": "# - ../kustomize/components/spanner", + "start_byte": 1239, + "end_byte": 1274 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 18, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 9, + "dest_start_byte": 1241, + "dest_end_byte": 1276, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 10 + ], + "type": "comment", + "label": "# - ../kustomize/components/container-images-tag", + "start_byte": 1275, + "end_byte": 1323 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 19, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 10, + "dest_start_byte": 1277, + "dest_end_byte": 1325, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 11 + ], + "type": "comment", + "label": "# - ../kustomize/components/container-images-tag-suffix", + "start_byte": 1324, + "end_byte": 1379 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 20, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 11, + "dest_start_byte": 1326, + "dest_end_byte": 1381, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 12 + ], + "type": "comment", + "label": "# - ../kustomize/components/container-images-registry", + "start_byte": 1380, + "end_byte": 1433 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 21, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 12, + "dest_start_byte": 1382, + "dest_end_byte": 1435, + "group_id": "group-1" + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 13 + ], + "type": "comment", + "label": "# - ../kustomize/components/native-grpc-health-check", + "start_byte": 1434, + "end_byte": 1486 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 2, + 1, + 0 + ], + "type": "block_sequence", + "start_byte": 652, + "end_byte": 1489 + }, + "position": 22, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 1486 + }, + "old_position": 13, + "dest_start_byte": 1436, + "dest_end_byte": 1488, + "group_id": "group-1" + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 3 + ], + "type": "block_mapping_pair", + "start_byte": 1001, + "end_byte": 1012 + }, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": -1, + "right_line": 40 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_kustomization_scalar/metadata.json b/tests/testdata/yaml_microservices_kustomization_scalar/metadata.json new file mode 100644 index 0000000..6a709c4 --- /dev/null +++ b/tests/testdata/yaml_microservices_kustomization_scalar/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "58b6cd21c3f050d064598575d3df6c525a7ceaea", + "description": "Update kustomization scalar config", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_kustomization_scalar/new.yaml b/tests/testdata/yaml_microservices_kustomization_scalar/new.yaml new file mode 100644 index 0000000..56779ce --- /dev/null +++ b/tests/testdata/yaml_microservices_kustomization_scalar/new.yaml @@ -0,0 +1,40 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - adservice.yaml + - cartservice.yaml + - checkoutservice.yaml + - currencyservice.yaml + - emailservice.yaml + - frontend.yaml +# - loadgenerator.yaml # During development, the loadgenerator module inside skaffold.yaml will be used. + - paymentservice.yaml + - productcatalogservice.yaml + - recommendationservice.yaml + - redis.yaml + - shippingservice.yaml +# components: +# - ../kustomize/components/cymbal-branding +# - ../kustomize/components/google-cloud-operations +# - ../kustomize/components/memorystore +# - ../kustomize/components/network-policies +# - ../kustomize/components/service-accounts +# - ../kustomize/components/spanner +# - ../kustomize/components/container-images-tag +# - ../kustomize/components/container-images-tag-suffix +# - ../kustomize/components/container-images-registry +# - ../kustomize/components/native-grpc-health-check diff --git a/tests/testdata/yaml_microservices_kustomization_scalar/old.yaml b/tests/testdata/yaml_microservices_kustomization_scalar/old.yaml new file mode 100644 index 0000000..b42f88c --- /dev/null +++ b/tests/testdata/yaml_microservices_kustomization_scalar/old.yaml @@ -0,0 +1,40 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - adservice.yaml + - cartservice.yaml + - checkoutservice.yaml + - currencyservice.yaml + - emailservice.yaml + - frontend.yaml +# - loadgenerator.yaml # During development, the loadgenerator module inside skaffold.yaml will be used. + - paymentservice.yaml + - productcatalogservice.yaml + - recommendationservice.yaml + - redis.yaml + - shippingservice.yaml +components: +# - ../kustomize/components/cymbal-branding +# - ../kustomize/components/google-cloud-operations +# - ../kustomize/components/memorystore +# - ../kustomize/components/network-policies +# - ../kustomize/components/service-accounts +# - ../kustomize/components/spanner +# - ../kustomize/components/container-images-tag +# - ../kustomize/components/container-images-tag-suffix +# - ../kustomize/components/container-images-registry +# - ../kustomize/components/native-grpc-health-check \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_build_artifacts/expected.json b/tests/testdata/yaml_microservices_skaffold_build_artifacts/expected.json new file mode 100644 index 0000000..31d08f4 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_build_artifacts/expected.json @@ -0,0 +1,567 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 4, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3028, + "end_byte": 3069 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 4, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 3028, + "end_byte": 3192 + }, + "position": 0, + "subtree": true + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 4, + 1, + 0, + 2 + ], + "type": "block_mapping_pair", + "start_byte": 3141, + "end_byte": 3192 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 4, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 3028, + "end_byte": 3192 + }, + "position": 2, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": 40, + "right_line": 40 + }, + { + "left_line": 41, + "right_line": 41 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": 46 + }, + { + "left_line": 47, + "right_line": 47 + }, + { + "left_line": 48, + "right_line": 48 + }, + { + "left_line": 49, + "right_line": 49 + }, + { + "left_line": 50, + "right_line": 50 + }, + { + "left_line": 51, + "right_line": 51 + }, + { + "left_line": 52, + "right_line": 52 + }, + { + "left_line": 53, + "right_line": 53 + }, + { + "left_line": 54, + "right_line": 54 + }, + { + "left_line": 55, + "right_line": 55 + }, + { + "left_line": 56, + "right_line": 56 + }, + { + "left_line": 57, + "right_line": 57 + }, + { + "left_line": 58, + "right_line": 58 + }, + { + "left_line": 59, + "right_line": 59 + }, + { + "left_line": 60, + "right_line": 60 + }, + { + "left_line": 61, + "right_line": 61 + }, + { + "left_line": 62, + "right_line": 62 + }, + { + "left_line": 63, + "right_line": 63 + }, + { + "left_line": 64, + "right_line": 64 + }, + { + "left_line": 65, + "right_line": 65 + }, + { + "left_line": 66, + "right_line": 66 + }, + { + "left_line": 67, + "right_line": 67 + }, + { + "left_line": 68, + "right_line": 68 + }, + { + "left_line": 69, + "right_line": 69 + }, + { + "left_line": 70, + "right_line": 70 + }, + { + "left_line": 71, + "right_line": 71 + }, + { + "left_line": 72, + "right_line": 72 + }, + { + "left_line": 73, + "right_line": 73 + }, + { + "left_line": 74, + "right_line": 74 + }, + { + "left_line": 75, + "right_line": 75 + }, + { + "left_line": 76, + "right_line": 76 + }, + { + "left_line": 77, + "right_line": 77 + }, + { + "left_line": 78, + "right_line": 78 + }, + { + "left_line": 79, + "right_line": 79 + }, + { + "left_line": 80, + "right_line": 80 + }, + { + "left_line": 81, + "right_line": 81 + }, + { + "left_line": 82, + "right_line": 82 + }, + { + "left_line": 83, + "right_line": 83 + }, + { + "left_line": 84, + "right_line": 84 + }, + { + "left_line": 85, + "right_line": 85 + }, + { + "left_line": 86, + "right_line": 86 + }, + { + "left_line": 87, + "right_line": 87 + }, + { + "left_line": 88, + "right_line": 88 + }, + { + "left_line": 89, + "right_line": 89 + }, + { + "left_line": 90, + "right_line": 90 + }, + { + "left_line": 91, + "right_line": 91 + }, + { + "left_line": 92, + "right_line": 92 + }, + { + "left_line": 93, + "right_line": 93 + }, + { + "left_line": 94, + "right_line": 94 + }, + { + "left_line": 95, + "right_line": 95 + }, + { + "left_line": 96, + "right_line": 96 + }, + { + "left_line": 97, + "right_line": 97 + }, + { + "left_line": 98, + "right_line": 98 + }, + { + "left_line": 99, + "right_line": 99 + }, + { + "left_line": 100, + "right_line": 100 + }, + { + "left_line": 101, + "right_line": 101 + }, + { + "left_line": 102, + "right_line": 102 + }, + { + "left_line": -1, + "right_line": 103 + }, + { + "left_line": 103, + "right_line": 104 + }, + { + "left_line": 104, + "right_line": 105 + }, + { + "left_line": 105, + "right_line": 106 + }, + { + "left_line": -1, + "right_line": 107 + }, + { + "left_line": -1, + "right_line": 108 + }, + { + "left_line": -1, + "right_line": 109 + }, + { + "left_line": 106, + "right_line": 110 + }, + { + "left_line": 107, + "right_line": 111 + }, + { + "left_line": 108, + "right_line": 112 + }, + { + "left_line": 109, + "right_line": 113 + }, + { + "left_line": 110, + "right_line": 114 + }, + { + "left_line": 111, + "right_line": 115 + }, + { + "left_line": 112, + "right_line": 116 + }, + { + "left_line": 113, + "right_line": 117 + }, + { + "left_line": 114, + "right_line": 118 + }, + { + "left_line": 115, + "right_line": 119 + }, + { + "left_line": 116, + "right_line": 120 + }, + { + "left_line": 117, + "right_line": 121 + }, + { + "left_line": 118, + "right_line": 122 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_build_artifacts/metadata.json b/tests/testdata/yaml_microservices_skaffold_build_artifacts/metadata.json new file mode 100644 index 0000000..dab3cc4 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_build_artifacts/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "79be00aea1877384fe26ea5fa843dc610a8d6a9d", + "description": "Update skaffold build artifacts pipeline", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_build_artifacts/new.yaml b/tests/testdata/yaml_microservices_skaffold_build_artifacts/new.yaml new file mode 100644 index 0000000..9a13f5f --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_build_artifacts/new.yaml @@ -0,0 +1,122 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v3 +kind: Config +metadata: + name: app +build: + platforms: ["linux/amd64", "linux/arm64"] + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shoppingassistantservice + context: src/shoppingassistantservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useDockerCLI: true + useBuildkit: true +manifests: + kustomize: + paths: + - kubernetes-manifests +deploy: + kubectl: {} +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug +# The "network-policies" profile is not used by default. +# You can use it in isolation or in combination with other profiles: +# skaffold run -p network-policies, debug +- name: network-policies + patches: + - op: add + path: /manifests/kustomize/paths/1 + value: kustomize/components/network-policies +--- +apiVersion: skaffold/v3 +kind: Config +metadata: + name: loadgenerator +requires: +- configs: + - app +build: + platforms: ["linux/amd64", "linux/arm64"] + artifacts: + - image: loadgenerator + context: src/loadgenerator + local: + useDockerCLI: true + useBuildkit: true +manifests: + rawYaml: + - ./kubernetes-manifests/loadgenerator.yaml +deploy: + kubectl: {} +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s diff --git a/tests/testdata/yaml_microservices_skaffold_build_artifacts/old.yaml b/tests/testdata/yaml_microservices_skaffold_build_artifacts/old.yaml new file mode 100644 index 0000000..2d5a1c3 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_build_artifacts/old.yaml @@ -0,0 +1,118 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v3 +kind: Config +metadata: + name: app +build: + platforms: ["linux/amd64", "linux/arm64"] + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shoppingassistantservice + context: src/shoppingassistantservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useDockerCLI: true + useBuildkit: true +manifests: + kustomize: + paths: + - kubernetes-manifests +deploy: + kubectl: {} +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug +# The "network-policies" profile is not used by default. +# You can use it in isolation or in combination with other profiles: +# skaffold run -p network-policies, debug +- name: network-policies + patches: + - op: add + path: /manifests/kustomize/paths/1 + value: kustomize/components/network-policies +--- +apiVersion: skaffold/v3 +kind: Config +metadata: + name: loadgenerator +requires: +- configs: + - app +build: + artifacts: + - image: loadgenerator + context: src/loadgenerator +manifests: + rawYaml: + - ./kubernetes-manifests/loadgenerator.yaml +deploy: + kubectl: {} +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s diff --git a/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/expected.json b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/expected.json new file mode 100644 index 0000000..20fc489 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/expected.json @@ -0,0 +1,1446 @@ +{ + "version": "v1", + "actions": [ + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 1576, + "end_byte": 2130 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 576, + "end_byte": 2934 + }, + "position": 4, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 1576, + "end_byte": 2130 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 1560, + "dest_end_byte": 2090 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 5, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3157, + "end_byte": 3229 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2939, + "end_byte": 3202 + }, + "position": 5, + "old_parent": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 3157, + "end_byte": 3229 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 3113, + "dest_end_byte": 3180 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1 + ], + "type": "block_node", + "start_byte": 2101, + "end_byte": 2462 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5 + ], + "type": "block_mapping_pair", + "start_byte": 2091, + "end_byte": 2462 + }, + "position": 1 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 6, + 1 + ], + "type": "block_node", + "start_byte": 3191, + "end_byte": 3202 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 6 + ], + "type": "block_mapping_pair", + "start_byte": 3181, + "end_byte": 3202 + }, + "position": 1, + "subtree": true + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 1 + ], + "type": "comment", + "label": "# \"gcb\" profile allows building and pushing the images", + "start_byte": 2113, + "end_byte": 2167 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 1 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 2 + ], + "type": "comment", + "label": "# on Google Container Builder without requiring docker", + "start_byte": 2168, + "end_byte": 2222 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 2 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 3 + ], + "type": "comment", + "label": "# installed on the developer machine. However, note that", + "start_byte": 2223, + "end_byte": 2279 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 3 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 4 + ], + "type": "comment", + "label": "# since GCB does not cache the builds, each build will", + "start_byte": 2280, + "end_byte": 2334 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 4 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 5 + ], + "type": "comment", + "label": "# start from scratch and therefore take a long time.", + "start_byte": 2335, + "end_byte": 2387 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 5 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 6 + ], + "type": "comment", + "label": "#", + "start_byte": 2388, + "end_byte": 2389 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 6 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 7 + ], + "type": "comment", + "label": "# This is not used by default. To use it, run:", + "start_byte": 2390, + "end_byte": 2436 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 7 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 8 + ], + "type": "comment", + "label": "# skaffold run -p gcb", + "start_byte": 2437, + "end_byte": 2462 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2101, + "end_byte": 2462 + }, + "position": 8 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 0, + 1 + ], + "type": "flow_node", + "start_byte": 2110, + "end_byte": 2112 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 2101, + "end_byte": 2112 + }, + "position": 2, + "subtree": true + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0 + ], + "type": "plain_scalar", + "start_byte": 3066, + "end_byte": 3069 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 5, + 1, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 2101, + "end_byte": 2108 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 3066, + "end_byte": 3069 + }, + "old_position": 0, + "dest_start_byte": 2101, + "dest_end_byte": 2108 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3020, + "end_byte": 3036 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 3020, + "end_byte": 3036 + }, + "position": 0 + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 3056, + "end_byte": 3063 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3020, + "end_byte": 3036 + }, + "position": 0, + "old_parent": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3056, + "end_byte": 3070 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 3020, + "dest_end_byte": 3027 + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 1 + ], + "type": "block_node", + "start_byte": 3031, + "end_byte": 3036 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 3020, + "end_byte": 3036 + }, + "position": 1, + "subtree": true + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 3, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0 + ], + "type": "flow_node", + "start_byte": 3066, + "end_byte": 3069 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 1576, + "end_byte": 2130 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 1 + ], + "type": "block_node", + "start_byte": 1576, + "end_byte": 2130 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 1 + ], + "type": "comment", + "label": "# \"gcb\" profile allows building and pushing the images", + "start_byte": 2141, + "end_byte": 2195 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 2 + ], + "type": "comment", + "label": "# on Google Container Builder without requiring docker", + "start_byte": 2196, + "end_byte": 2250 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 3 + ], + "type": "comment", + "label": "# installed on the developer machine. However, note that", + "start_byte": 2251, + "end_byte": 2307 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 4 + ], + "type": "comment", + "label": "# since GCB does not cache the builds, each build will", + "start_byte": 2308, + "end_byte": 2362 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 5 + ], + "type": "comment", + "label": "# start from scratch and therefore take a long time.", + "start_byte": 2363, + "end_byte": 2415 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 6 + ], + "type": "comment", + "label": "#", + "start_byte": 2416, + "end_byte": 2417 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 7 + ], + "type": "comment", + "label": "# This is not used by default. To use it, run:", + "start_byte": 2418, + "end_byte": 2464 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 5, + 8 + ], + "type": "comment", + "label": "# skaffold run -p gcb", + "start_byte": 2465, + "end_byte": 2490 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 5, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 3157, + "end_byte": 3229 + } + }, + { + "action": "delete", + "node": { + "tree": "before", + "path": [ + 14, + 1, + 0, + 5, + 1 + ], + "type": "block_node", + "start_byte": 3157, + "end_byte": 3229 + } + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": 40, + "right_line": 40 + }, + { + "left_line": 41, + "right_line": 41 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": 46 + }, + { + "left_line": 47, + "right_line": 47 + }, + { + "left_line": 48, + "right_line": 48 + }, + { + "left_line": 49, + "right_line": 49 + }, + { + "left_line": -1, + "right_line": 50 + }, + { + "left_line": -1, + "right_line": 51 + }, + { + "left_line": -1, + "right_line": 52 + }, + { + "left_line": -1, + "right_line": 53 + }, + { + "left_line": -1, + "right_line": 54 + }, + { + "left_line": -1, + "right_line": 55 + }, + { + "left_line": -1, + "right_line": 56 + }, + { + "left_line": -1, + "right_line": 57 + }, + { + "left_line": -1, + "right_line": 58 + }, + { + "left_line": -1, + "right_line": 59 + }, + { + "left_line": -1, + "right_line": 60 + }, + { + "left_line": -1, + "right_line": 61 + }, + { + "left_line": -1, + "right_line": 62 + }, + { + "left_line": 50, + "right_line": 63 + }, + { + "left_line": 51, + "right_line": -1 + }, + { + "left_line": 52, + "right_line": -1 + }, + { + "left_line": 53, + "right_line": -1 + }, + { + "left_line": 54, + "right_line": -1 + }, + { + "left_line": 55, + "right_line": -1 + }, + { + "left_line": 56, + "right_line": -1 + }, + { + "left_line": 57, + "right_line": -1 + }, + { + "left_line": 58, + "right_line": -1 + }, + { + "left_line": 59, + "right_line": -1 + }, + { + "left_line": 60, + "right_line": -1 + }, + { + "left_line": 61, + "right_line": -1 + }, + { + "left_line": 62, + "right_line": -1 + }, + { + "left_line": 63, + "right_line": -1 + }, + { + "left_line": -1, + "right_line": 64 + }, + { + "left_line": -1, + "right_line": 65 + }, + { + "left_line": -1, + "right_line": 66 + }, + { + "left_line": -1, + "right_line": 67 + }, + { + "left_line": -1, + "right_line": 68 + }, + { + "left_line": -1, + "right_line": 69 + }, + { + "left_line": -1, + "right_line": 70 + }, + { + "left_line": -1, + "right_line": 71 + }, + { + "left_line": -1, + "right_line": 72 + }, + { + "left_line": 64, + "right_line": 73 + }, + { + "left_line": 65, + "right_line": -1 + }, + { + "left_line": 66, + "right_line": -1 + }, + { + "left_line": 67, + "right_line": -1 + }, + { + "left_line": 68, + "right_line": -1 + }, + { + "left_line": 69, + "right_line": -1 + }, + { + "left_line": 70, + "right_line": -1 + }, + { + "left_line": 71, + "right_line": -1 + }, + { + "left_line": 72, + "right_line": -1 + }, + { + "left_line": 73, + "right_line": 74 + }, + { + "left_line": 74, + "right_line": 75 + }, + { + "left_line": 75, + "right_line": 76 + }, + { + "left_line": 76, + "right_line": 77 + }, + { + "left_line": 77, + "right_line": 78 + }, + { + "left_line": 78, + "right_line": 79 + }, + { + "left_line": 79, + "right_line": 80 + }, + { + "left_line": 80, + "right_line": 81 + }, + { + "left_line": 81, + "right_line": 82 + }, + { + "left_line": 82, + "right_line": 83 + }, + { + "left_line": 83, + "right_line": 84 + }, + { + "left_line": 84, + "right_line": 85 + }, + { + "left_line": 85, + "right_line": 86 + }, + { + "left_line": 86, + "right_line": 87 + }, + { + "left_line": 87, + "right_line": 88 + }, + { + "left_line": 88, + "right_line": 89 + }, + { + "left_line": 89, + "right_line": 90 + }, + { + "left_line": 90, + "right_line": -1 + }, + { + "left_line": 91, + "right_line": 91 + }, + { + "left_line": 92, + "right_line": -1 + }, + { + "left_line": 93, + "right_line": 92 + }, + { + "left_line": 94, + "right_line": 93 + }, + { + "left_line": 95, + "right_line": 94 + }, + { + "left_line": 96, + "right_line": 95 + }, + { + "left_line": 97, + "right_line": 96 + }, + { + "left_line": 98, + "right_line": -1 + }, + { + "left_line": -1, + "right_line": 97 + }, + { + "left_line": -1, + "right_line": 98 + }, + { + "left_line": 99, + "right_line": 99 + }, + { + "left_line": 100, + "right_line": 100 + }, + { + "left_line": 101, + "right_line": 101 + }, + { + "left_line": 102, + "right_line": 102 + }, + { + "left_line": -1, + "right_line": 103 + }, + { + "left_line": -1, + "right_line": 104 + }, + { + "left_line": -1, + "right_line": 105 + }, + { + "left_line": 103, + "right_line": 106 + }, + { + "left_line": 104, + "right_line": -1 + }, + { + "left_line": 105, + "right_line": -1 + }, + { + "left_line": 106, + "right_line": -1 + }, + { + "left_line": 107, + "right_line": 107 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/metadata.json b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/metadata.json new file mode 100644 index 0000000..a0bbe5d --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "6e55d976e1b9721c2546941b07d66eaf005bb875", + "description": "Refactor skaffold pipeline services", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/new.yaml b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/new.yaml new file mode 100644 index 0000000..7ba8be5 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/new.yaml @@ -0,0 +1,108 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v3 +kind: Config +metadata: + name: app +build: + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useBuildkit: false +manifests: + rawYaml: + - ./kubernetes-manifests/adservice.yaml + - ./kubernetes-manifests/cartservice.yaml + - ./kubernetes-manifests/checkoutservice.yaml + - ./kubernetes-manifests/currencyservice.yaml + - ./kubernetes-manifests/emailservice.yaml + - ./kubernetes-manifests/frontend.yaml + - ./kubernetes-manifests/paymentservice.yaml + - ./kubernetes-manifests/productcatalogservice.yaml + - ./kubernetes-manifests/recommendationservice.yaml + - ./kubernetes-manifests/redis.yaml + - ./kubernetes-manifests/shippingservice.yaml +deploy: + kubectl: {} +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug +--- +apiVersion: skaffold/v3 +kind: Config +metadata: + name: loadgenerator +requires: +- configs: + - app +build: + artifacts: + - image: loadgenerator + context: src/loadgenerator +manifests: + rawYaml: + - ./kubernetes-manifests/loadgenerator.yaml +deploy: + kubectl: {} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/old.yaml b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/old.yaml new file mode 100644 index 0000000..6f95064 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_pipeline_refactor/old.yaml @@ -0,0 +1,107 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v2beta18 +kind: Config +metadata: + name: app +build: + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useBuildkit: false +deploy: + kubectl: + manifests: + - ./kubernetes-manifests/adservice.yaml + - ./kubernetes-manifests/cartservice.yaml + - ./kubernetes-manifests/checkoutservice.yaml + - ./kubernetes-manifests/currencyservice.yaml + - ./kubernetes-manifests/emailservice.yaml + - ./kubernetes-manifests/frontend.yaml + - ./kubernetes-manifests/paymentservice.yaml + - ./kubernetes-manifests/productcatalogservice.yaml + - ./kubernetes-manifests/recommendationservice.yaml + - ./kubernetes-manifests/redis.yaml + - ./kubernetes-manifests/shippingservice.yaml +profiles: +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug + +--- + +apiVersion: skaffold/v2beta18 +kind: Config +metadata: + name: loadgenerator +requires: + - configs: [app] +build: + artifacts: + - image: loadgenerator + context: src/loadgenerator +deploy: + kubectl: + manifests: + - ./kubernetes-manifests/loadgenerator.yaml diff --git a/tests/testdata/yaml_microservices_skaffold_port_forward/expected.json b/tests/testdata/yaml_microservices_skaffold_port_forward/expected.json new file mode 100644 index 0000000..fcf1033 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_port_forward/expected.json @@ -0,0 +1,530 @@ +{ + "version": "v1", + "actions": [ + { + "action": "update", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 1 + ], + "type": "comment", + "label": "# \"travis-ci\" profile is used to build the images without", + "start_byte": 1793, + "end_byte": 1850 + }, + "old_value": "# \"travis-ci\" profile is used to build the images without", + "new_value": "# \"travis-ci\" profile is used to build the images withou", + "dest_node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 4, + 1 + ], + "type": "comment", + "label": "# \"travis-ci\" profile is used to build the images withou", + "start_byte": 1785, + "end_byte": 1841 + } + }, + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 4, + 3, + 0, + 1, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 2269, + "end_byte": 2278 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 4, + 3, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 2269, + "end_byte": 2406 + }, + "position": 0, + "subtree": true + }, + { + "action": "move", + "node": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 3, + 0, + 1, + 0, + 0, + 0 + ], + "type": "block_mapping_pair", + "start_byte": 2306, + "end_byte": 2315 + }, + "parent": { + "tree": "after", + "path": [ + 13, + 0, + 0, + 4, + 3, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2316, + "end_byte": 2406 + }, + "position": 3, + "old_parent": { + "tree": "before", + "path": [ + 13, + 0, + 0, + 4, + 3, + 0, + 1, + 0, + 0 + ], + "type": "block_mapping", + "start_byte": 2306, + "end_byte": 2435 + }, + "old_position": 0, + "subtree": true, + "dest_start_byte": 2391, + "dest_end_byte": 2405 + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": -1, + "right_line": 17 + }, + { + "left_line": -1, + "right_line": 18 + }, + { + "left_line": -1, + "right_line": 19 + }, + { + "left_line": -1, + "right_line": 20 + }, + { + "left_line": -1, + "right_line": 21 + }, + { + "left_line": -1, + "right_line": 22 + }, + { + "left_line": -1, + "right_line": 23 + }, + { + "left_line": -1, + "right_line": 24 + }, + { + "left_line": -1, + "right_line": 25 + }, + { + "left_line": -1, + "right_line": 26 + }, + { + "left_line": -1, + "right_line": 27 + }, + { + "left_line": -1, + "right_line": 28 + }, + { + "left_line": -1, + "right_line": 29 + }, + { + "left_line": -1, + "right_line": 30 + }, + { + "left_line": -1, + "right_line": 31 + }, + { + "left_line": -1, + "right_line": 32 + }, + { + "left_line": -1, + "right_line": 33 + }, + { + "left_line": -1, + "right_line": 34 + }, + { + "left_line": -1, + "right_line": 35 + }, + { + "left_line": -1, + "right_line": 36 + }, + { + "left_line": -1, + "right_line": 37 + }, + { + "left_line": -1, + "right_line": 38 + }, + { + "left_line": -1, + "right_line": 39 + }, + { + "left_line": 17, + "right_line": 40 + }, + { + "left_line": 18, + "right_line": 41 + }, + { + "left_line": 19, + "right_line": -1 + }, + { + "left_line": 20, + "right_line": -1 + }, + { + "left_line": 21, + "right_line": -1 + }, + { + "left_line": 22, + "right_line": -1 + }, + { + "left_line": 23, + "right_line": -1 + }, + { + "left_line": 24, + "right_line": -1 + }, + { + "left_line": 25, + "right_line": -1 + }, + { + "left_line": 26, + "right_line": -1 + }, + { + "left_line": 27, + "right_line": -1 + }, + { + "left_line": 28, + "right_line": -1 + }, + { + "left_line": 29, + "right_line": -1 + }, + { + "left_line": 30, + "right_line": -1 + }, + { + "left_line": 31, + "right_line": -1 + }, + { + "left_line": 32, + "right_line": -1 + }, + { + "left_line": 33, + "right_line": -1 + }, + { + "left_line": 34, + "right_line": -1 + }, + { + "left_line": 35, + "right_line": -1 + }, + { + "left_line": 36, + "right_line": -1 + }, + { + "left_line": 37, + "right_line": -1 + }, + { + "left_line": 38, + "right_line": -1 + }, + { + "left_line": 39, + "right_line": -1 + }, + { + "left_line": 40, + "right_line": -1 + }, + { + "left_line": 41, + "right_line": -1 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": -1 + }, + { + "left_line": 47, + "right_line": -1 + }, + { + "left_line": 48, + "right_line": 46 + }, + { + "left_line": 49, + "right_line": 47 + }, + { + "left_line": 50, + "right_line": 48 + }, + { + "left_line": 51, + "right_line": 49 + }, + { + "left_line": 52, + "right_line": 50 + }, + { + "left_line": 53, + "right_line": 51 + }, + { + "left_line": 54, + "right_line": 52 + }, + { + "left_line": 55, + "right_line": 53 + }, + { + "left_line": 56, + "right_line": 54 + }, + { + "left_line": 57, + "right_line": 55 + }, + { + "left_line": 58, + "right_line": 56 + }, + { + "left_line": 59, + "right_line": 57 + }, + { + "left_line": 60, + "right_line": 58 + }, + { + "left_line": 61, + "right_line": 59 + }, + { + "left_line": 62, + "right_line": 60 + }, + { + "left_line": 63, + "right_line": -1 + }, + { + "left_line": -1, + "right_line": 61 + }, + { + "left_line": 64, + "right_line": 62 + }, + { + "left_line": 65, + "right_line": 63 + }, + { + "left_line": 66, + "right_line": -1 + }, + { + "left_line": 67, + "right_line": 64 + }, + { + "left_line": -1, + "right_line": 65 + }, + { + "left_line": 68, + "right_line": 66 + }, + { + "left_line": -1, + "right_line": 67 + }, + { + "left_line": 69, + "right_line": 68 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_port_forward/metadata.json b/tests/testdata/yaml_microservices_skaffold_port_forward/metadata.json new file mode 100644 index 0000000..d72fc73 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_port_forward/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "c6b825f846a58cf46b3eddcab1de0d392d0aa88a", + "description": "Update skaffold port forward options", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_port_forward/new.yaml b/tests/testdata/yaml_microservices_skaffold_port_forward/new.yaml new file mode 100644 index 0000000..ffa25c2 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_port_forward/new.yaml @@ -0,0 +1,68 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/microservices-demo-app/emailservice + workspace: src/emailservice + - imageName: gcr.io/microservices-demo-app/productcatalogservice + workspace: src/productcatalogservice + - imageName: gcr.io/microservices-demo-app/recommendationservice + workspace: src/recommendationservice + - imageName: gcr.io/microservices-demo-app/shippingservice + workspace: src/shippingservice + - imageName: gcr.io/microservices-demo-app/checkoutservice + workspace: src/checkoutservice + - imageName: gcr.io/microservices-demo-app/paymentservice + workspace: src/paymentservice + - imageName: gcr.io/microservices-demo-app/currencyservice + workspace: src/currencyservice + - imageName: gcr.io/microservices-demo-app/cartservice + workspace: src/cartservice + - imageName: gcr.io/microservices-demo-app/frontend + workspace: src/frontend + - imageName: gcr.io/microservices-demo-app/loadgenerator + workspace: src/loadgenerator + - imageName: gcr.io/microservices-demo-app/adservice + workspace: src/adservice + tagPolicy: + gitCommit: {} +deploy: + kubectl: + manifests: + - ./kubernetes-manifests/**.yaml +profiles: +# "travis-ci" profile is used to build the images withou +# pushing them. +- name: travis-ci + build: + local: + skipPush: true +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +- name: gcb + build: + googleCloudBuild: + projectId: "" + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s diff --git a/tests/testdata/yaml_microservices_skaffold_port_forward/old.yaml b/tests/testdata/yaml_microservices_skaffold_port_forward/old.yaml new file mode 100644 index 0000000..9bf9d46 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_port_forward/old.yaml @@ -0,0 +1,69 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v1alpha2 +kind: Config +build: + tagPolicy: + gitCommit: {} + artifacts: + - imageName: gcr.io/microservices-demo-app/emailservice + workspace: src/emailservice + - imageName: gcr.io/microservices-demo-app/productcatalogservice + workspace: src/productcatalogservice + - imageName: gcr.io/microservices-demo-app/recommendationservice + workspace: src/recommendationservice + - imageName: gcr.io/microservices-demo-app/shippingservice + workspace: src/shippingservice + - imageName: gcr.io/microservices-demo-app/checkoutservice + workspace: src/checkoutservice + - imageName: gcr.io/microservices-demo-app/paymentservice + workspace: src/paymentservice + - imageName: gcr.io/microservices-demo-app/currencyservice + workspace: src/currencyservice + - imageName: gcr.io/microservices-demo-app/cartservice + workspace: src/cartservice + - imageName: gcr.io/microservices-demo-app/frontend + workspace: src/frontend + - imageName: gcr.io/microservices-demo-app/loadgenerator + workspace: src/loadgenerator + - imageName: gcr.io/microservices-demo-app/adservice + workspace: src/adservice +deploy: + kubectl: + manifests: + - ./kubernetes-manifests/**.yaml + + +profiles: + # "travis-ci" profile is used to build the images without + # pushing them. + - name: travis-ci + build: + local: + skipPush: true + # "gcb" profile allows building and pushing the images + # on Google Container Builder without requiring docker + # installed on the developer machine. However, note that + # since GCB does not cache the builds, each build will + # start from scratch and therefore take a long time. + # + # This is not used by default. To use it, run: + # skaffold run -p gcb + - name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: "N1_HIGHCPU_32" + timeout: 4000s diff --git a/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/expected.json b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/expected.json new file mode 100644 index 0000000..e2fe730 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/expected.json @@ -0,0 +1,495 @@ +{ + "version": "v1", + "actions": [ + { + "action": "insert", + "node": { + "tree": "after", + "path": [ + 14, + 1, + 0, + 7 + ], + "type": "block_mapping_pair", + "start_byte": 3041, + "end_byte": 3170 + }, + "parent": { + "tree": "after", + "path": [ + 14, + 1, + 0 + ], + "type": "block_mapping", + "start_byte": 2777, + "end_byte": 3170 + }, + "position": 7, + "subtree": true + } + ], + "line_alignment": [ + { + "left_line": 0, + "right_line": 0 + }, + { + "left_line": 1, + "right_line": 1 + }, + { + "left_line": 2, + "right_line": 2 + }, + { + "left_line": 3, + "right_line": 3 + }, + { + "left_line": 4, + "right_line": 4 + }, + { + "left_line": 5, + "right_line": 5 + }, + { + "left_line": 6, + "right_line": 6 + }, + { + "left_line": 7, + "right_line": 7 + }, + { + "left_line": 8, + "right_line": 8 + }, + { + "left_line": 9, + "right_line": 9 + }, + { + "left_line": 10, + "right_line": 10 + }, + { + "left_line": 11, + "right_line": 11 + }, + { + "left_line": 12, + "right_line": 12 + }, + { + "left_line": 13, + "right_line": 13 + }, + { + "left_line": 14, + "right_line": 14 + }, + { + "left_line": 15, + "right_line": 15 + }, + { + "left_line": 16, + "right_line": 16 + }, + { + "left_line": 17, + "right_line": 17 + }, + { + "left_line": 18, + "right_line": 18 + }, + { + "left_line": 19, + "right_line": 19 + }, + { + "left_line": 20, + "right_line": 20 + }, + { + "left_line": 21, + "right_line": 21 + }, + { + "left_line": 22, + "right_line": 22 + }, + { + "left_line": 23, + "right_line": 23 + }, + { + "left_line": 24, + "right_line": 24 + }, + { + "left_line": 25, + "right_line": 25 + }, + { + "left_line": 26, + "right_line": 26 + }, + { + "left_line": 27, + "right_line": 27 + }, + { + "left_line": 28, + "right_line": 28 + }, + { + "left_line": 29, + "right_line": 29 + }, + { + "left_line": 30, + "right_line": 30 + }, + { + "left_line": 31, + "right_line": 31 + }, + { + "left_line": 32, + "right_line": 32 + }, + { + "left_line": 33, + "right_line": 33 + }, + { + "left_line": 34, + "right_line": 34 + }, + { + "left_line": 35, + "right_line": 35 + }, + { + "left_line": 36, + "right_line": 36 + }, + { + "left_line": 37, + "right_line": 37 + }, + { + "left_line": 38, + "right_line": 38 + }, + { + "left_line": 39, + "right_line": 39 + }, + { + "left_line": 40, + "right_line": 40 + }, + { + "left_line": 41, + "right_line": 41 + }, + { + "left_line": 42, + "right_line": 42 + }, + { + "left_line": 43, + "right_line": 43 + }, + { + "left_line": 44, + "right_line": 44 + }, + { + "left_line": 45, + "right_line": 45 + }, + { + "left_line": 46, + "right_line": 46 + }, + { + "left_line": 47, + "right_line": 47 + }, + { + "left_line": 48, + "right_line": 48 + }, + { + "left_line": 49, + "right_line": 49 + }, + { + "left_line": 50, + "right_line": 50 + }, + { + "left_line": 51, + "right_line": 51 + }, + { + "left_line": 52, + "right_line": 52 + }, + { + "left_line": 53, + "right_line": 53 + }, + { + "left_line": 54, + "right_line": 54 + }, + { + "left_line": 55, + "right_line": 55 + }, + { + "left_line": 56, + "right_line": 56 + }, + { + "left_line": 57, + "right_line": 57 + }, + { + "left_line": 58, + "right_line": 58 + }, + { + "left_line": 59, + "right_line": 59 + }, + { + "left_line": 60, + "right_line": 60 + }, + { + "left_line": 61, + "right_line": 61 + }, + { + "left_line": 62, + "right_line": 62 + }, + { + "left_line": 63, + "right_line": 63 + }, + { + "left_line": 64, + "right_line": 64 + }, + { + "left_line": 65, + "right_line": 65 + }, + { + "left_line": 66, + "right_line": 66 + }, + { + "left_line": 67, + "right_line": 67 + }, + { + "left_line": 68, + "right_line": 68 + }, + { + "left_line": 69, + "right_line": 69 + }, + { + "left_line": 70, + "right_line": 70 + }, + { + "left_line": 71, + "right_line": 71 + }, + { + "left_line": 72, + "right_line": 72 + }, + { + "left_line": 73, + "right_line": 73 + }, + { + "left_line": 74, + "right_line": 74 + }, + { + "left_line": 75, + "right_line": 75 + }, + { + "left_line": 76, + "right_line": 76 + }, + { + "left_line": 77, + "right_line": 77 + }, + { + "left_line": 78, + "right_line": 78 + }, + { + "left_line": 79, + "right_line": 79 + }, + { + "left_line": 80, + "right_line": 80 + }, + { + "left_line": 81, + "right_line": 81 + }, + { + "left_line": 82, + "right_line": 82 + }, + { + "left_line": 83, + "right_line": 83 + }, + { + "left_line": 84, + "right_line": 84 + }, + { + "left_line": 85, + "right_line": 85 + }, + { + "left_line": 86, + "right_line": 86 + }, + { + "left_line": 87, + "right_line": 87 + }, + { + "left_line": 88, + "right_line": 88 + }, + { + "left_line": 89, + "right_line": 89 + }, + { + "left_line": 90, + "right_line": 90 + }, + { + "left_line": 91, + "right_line": 91 + }, + { + "left_line": 92, + "right_line": 92 + }, + { + "left_line": 93, + "right_line": 93 + }, + { + "left_line": 94, + "right_line": 94 + }, + { + "left_line": 95, + "right_line": 95 + }, + { + "left_line": 96, + "right_line": 96 + }, + { + "left_line": 97, + "right_line": 97 + }, + { + "left_line": 98, + "right_line": 98 + }, + { + "left_line": 99, + "right_line": 99 + }, + { + "left_line": 100, + "right_line": 100 + }, + { + "left_line": 101, + "right_line": 101 + }, + { + "left_line": 102, + "right_line": 102 + }, + { + "left_line": 103, + "right_line": 103 + }, + { + "left_line": 104, + "right_line": 104 + }, + { + "left_line": 105, + "right_line": 105 + }, + { + "left_line": 106, + "right_line": 106 + }, + { + "left_line": -1, + "right_line": 107 + }, + { + "left_line": -1, + "right_line": 108 + }, + { + "left_line": -1, + "right_line": 109 + }, + { + "left_line": -1, + "right_line": 110 + }, + { + "left_line": -1, + "right_line": 111 + }, + { + "left_line": -1, + "right_line": 112 + }, + { + "left_line": -1, + "right_line": 113 + }, + { + "left_line": 107, + "right_line": 114 + } + ] +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/metadata.json b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/metadata.json new file mode 100644 index 0000000..3b3590b --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/metadata.json @@ -0,0 +1,6 @@ +{ + "repository": "GoogleCloudPlatform/microservices-demo", + "commit": "7be0cd19a855b59e86dccdeaa0338012df82e483", + "description": "Update skaffold deployment manifests", + "language": "yaml" +} \ No newline at end of file diff --git a/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/new.yaml b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/new.yaml new file mode 100644 index 0000000..7bb3b06 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/new.yaml @@ -0,0 +1,114 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v3 +kind: Config +metadata: + name: app +build: + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useBuildkit: false +manifests: + kustomize: + paths: + - kubernetes-manifests +deploy: + kubectl: {} +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug +# The "network-policies" profile is not used by default. +# You can use it in isolation or in combination with other profiles: +# skaffold run -p network-policies, debug +- name: network-policies + patches: + - op: add + path: /manifests/kustomize/paths/1 + value: kustomize/components/network-policies +--- +apiVersion: skaffold/v3 +kind: Config +metadata: + name: loadgenerator +requires: +- configs: + - app +build: + artifacts: + - image: loadgenerator + context: src/loadgenerator +manifests: + rawYaml: + - ./kubernetes-manifests/loadgenerator.yaml +deploy: + kubectl: {} +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s diff --git a/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/old.yaml b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/old.yaml new file mode 100644 index 0000000..dc43650 --- /dev/null +++ b/tests/testdata/yaml_microservices_skaffold_scalar_deploy_manifests/old.yaml @@ -0,0 +1,107 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: skaffold/v3 +kind: Config +metadata: + name: app +build: + artifacts: + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://skaffold.dev/docs/concepts/#image-repository-handling + - image: emailservice + context: src/emailservice + - image: productcatalogservice + context: src/productcatalogservice + - image: recommendationservice + context: src/recommendationservice + - image: shippingservice + context: src/shippingservice + - image: checkoutservice + context: src/checkoutservice + - image: paymentservice + context: src/paymentservice + - image: currencyservice + context: src/currencyservice + - image: cartservice + context: src/cartservice/src + docker: + dockerfile: Dockerfile + - image: frontend + context: src/frontend + - image: adservice + context: src/adservice + tagPolicy: + gitCommit: {} + local: + useBuildkit: false +manifests: + kustomize: + paths: + - kubernetes-manifests +deploy: + kubectl: {} +# "gcb" profile allows building and pushing the images +# on Google Container Builder without requiring docker +# installed on the developer machine. However, note that +# since GCB does not cache the builds, each build will +# start from scratch and therefore take a long time. +# +# This is not used by default. To use it, run: +# skaffold run -p gcb +profiles: +- name: gcb + build: + googleCloudBuild: + diskSizeGb: 300 + machineType: N1_HIGHCPU_32 + timeout: 4000s +# "debug" profile replaces the default Dockerfile in cartservice with Dockerfile.debug, +# which enables debugging via skaffold. +# +# This profile is used by default when running skaffold debug. +- name: debug + activation: + - command: debug + patches: + - op: replace + path: /build/artifacts/7/docker/dockerfile + value: Dockerfile.debug +# The "network-policies" profile is not used by default. +# You can use it in isolation or in combination with other profiles: +# skaffold run -p network-policies, debug +- name: network-policies + patches: + - op: add + path: /manifests/kustomize/paths/1 + value: kustomize/components/network-policies +--- +apiVersion: skaffold/v3 +kind: Config +metadata: + name: loadgenerator +requires: +- configs: + - app +build: + artifacts: + - image: loadgenerator + context: src/loadgenerator +manifests: + rawYaml: + - ./kubernetes-manifests/loadgenerator.yaml +deploy: + kubectl: {}