Skip to content

Commit af5eff6

Browse files
ahornacevladak
authored andcommitted
Fix terraform definitions regex
1 parent 1d90c1f commit af5eff6

File tree

3 files changed

+25
-2
lines changed
  • opengrok-indexer/src

3 files changed

+25
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Ctags.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ private void addTerraformSupport(List<String> command) {
455455
*/
456456
command.add("--kinddef-terraform=s,struct,Resource\\ names");
457457
command.add("--regex-terraform=" +
458-
"/[[:<:]]resource[[:space:]]*\"([[:alpha:]][-_[:alpha:]]*)\"[[:space:]]*" +
459-
"\"([[:alpha:]][-_[:alpha:]]*)\"[[:space:]]*\\{/" +
458+
"/^[[:space:]]*resource[[:space:]]*\\\"([[:alpha:]][-_[:alpha:]]*)\\\"[[:space:]]*" +
459+
"\\\"([[:alpha:]][-_[:alpha:]]*)\\\"[[:space:]]*\\{/" +
460460
"\\1.\\2/s/");
461461
}
462462

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/CtagsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.junit.jupiter.api.Test;
3131
import org.opengrok.indexer.util.TestRepository;
3232

33+
import static org.junit.jupiter.api.Assertions.assertAll;
3334
import static org.junit.jupiter.api.Assertions.assertEquals;
3435
import static org.junit.jupiter.api.Assertions.assertTrue;
3536

@@ -136,4 +137,13 @@ void bug19195() throws Exception {
136137
}
137138
assertEquals(names.length, count, "function count");
138139
}
140+
141+
@Test
142+
void testTfTags() throws Exception {
143+
var defs = getDefs("terraform/test.tf");
144+
assertAll(
145+
() -> assertEquals(1, defs.getTags().size()),
146+
() -> assertEquals("oci_core_vcn.test_vcn", defs.getTags().get(0).symbol)
147+
);
148+
}
139149
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "oci_core_vcn" "test_vcn" {
2+
#Required
3+
compartment_id = var.compartment_id
4+
5+
#Optional
6+
cidr_block = var.vcn_cidr_block
7+
cidr_blocks = var.vcn_cidr_blocks
8+
defined_tags = {"Operations.CostCenter"= "42"}
9+
display_name = var.vcn_display_name
10+
dns_label = var.vcn_dns_label
11+
freeform_tags = {"Department"= "Finance"}
12+
is_ipv6enabled = var.vcn_is_ipv6enabled
13+
}

0 commit comments

Comments
 (0)