Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/treesitter/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
41 changes: 41 additions & 0 deletions internal/treesitter/yaml/rules.yml
Original file line number Diff line number Diff line change
@@ -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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"repository": "kubernetes/examples",
"commit": "unknown",
"description": "Update cassandra deployment spec",
"language": "yaml"
}
31 changes: 31 additions & 0 deletions tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/new.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
33 changes: 33 additions & 0 deletions tests/testdata/yaml_k8s_examples_cassandra_scalar_replica/old.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
Loading
Loading