Skip to content

Best way to control whether a query is "skipped" or produces a "pass / fail" #553

Closed Answered by arlimus
scottford-io asked this question in Q&A
Discussion options

You must be logged in to vote

Hiya! We can avoid that if-condition if we use a slightly different check: all can for example check if all entries in a block satisfy a condition. If the block is empty, all entries will automatically satisfy the condition.

Looking at your current code:

terraform.resources
  .where( nameLabel  == "google_compute_instance") {
    blocks.where( type == "network_interface") { 
      blocks
        .where( type == "access_config")
        .all( arguments.values.length != 0 ) 
    }
  }

Now it says: (1) blocks (2) where the type is access_config should (3) all have non-empty arguments.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by scottford-io
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants