summaryrefslogtreecommitdiff
path: root/scripts/timeouts.sh
blob: 52b0a12f15b9456af70c4638fbafc876928c8bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash

files=$(find ./azurerm -type f -name "*.go")
error=false

echo "==> Checking that Custom Timeouts are used..."

for f in $files; do
  if grep "ctx := meta." "$f" > /dev/null; then
    echo $f
    error=true
  fi
done

if $error; then
  echo ""
  echo "------------------------------------------------"
  echo ""
  echo "The files listed above must use a Wrapped StopContext to enable Custom Timeouts."
  echo "You can do this by changing:"
  echo ""
  echo "> ctx := meta.(*clients.Client).StopContext"
  echo ""
  echo "to"
  echo ""
  echo "> ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)"
  echo "> defer cancel()"
  echo ""
  echo "where 'ForCreate', 'ForCreateUpdate', 'ForDelete', 'ForRead' and 'ForUpdate' are available"
  echo ""
  echo "and then configuring Timeouts on the resource:"
  echo ""
  echo "> return &schema.Resource{"
  echo ">   ..."
  echo ">   Timeouts: &schema.ResourceTimeout{"
  echo ">     Create: schema.DefaultTimeout(30 * time.Minute),"
  echo ">     Read:   schema.DefaultTimeout(5 * time.Minute),"
  echo ">     Update: schema.DefaultTimeout(30 * time.Minute),"
  echo ">     Delete: schema.DefaultTimeout(30 * time.Minute),"
  echo ">   },"
  echo ">   ..."
  echo "> }"
  exit 1
fi

exit 0