(cache *Cache, tailnet string)
| 103 | } |
| 104 | |
| 105 | func test(cache *Cache, tailnet string) func(context.Context, []string) error { |
| 106 | return func(ctx context.Context, args []string) error { |
| 107 | controlEtag, err := getACLETag(ctx, tailnet) |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | localEtag, err := sumFile(*policyFname) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | if cache.PrevETag == "" { |
| 118 | log.Println("no previous etag found, assuming the latest control etag") |
| 119 | cache.PrevETag = controlEtag |
| 120 | } |
| 121 | |
| 122 | log.Printf("control: %s", controlEtag) |
| 123 | log.Printf("local: %s", localEtag) |
| 124 | log.Printf("cache: %s", cache.PrevETag) |
| 125 | |
| 126 | if controlEtag == localEtag { |
| 127 | log.Println("no updates found, doing nothing") |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | if cache.PrevETag != controlEtag { |
| 132 | if err := modifiedExternallyError(); err != nil { |
| 133 | if *failOnManualEdits { |
| 134 | return err |
| 135 | } else { |
| 136 | fmt.Println(err) |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if err := testNewACLs(ctx, tailnet, *policyFname); err != nil { |
| 142 | return err |
| 143 | } |
| 144 | return nil |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func getChecksums(cache *Cache, tailnet string) func(context.Context, []string) error { |
| 149 | return func(ctx context.Context, args []string) error { |
searching dependent graphs…