engine: resources: Add reversible API and file resource
This adds the first reversible resource (file) and the necessary engine API hooks to make it all work. This allows a special "reversed" resource to be added to the subsequent graph in the stream when an earlier version "disappears". This disappearance can happen if it was previously in an if statement that then becomes false. It might be wise to combine the use of this meta parameter with the use of the `realize` meta parameter to ensure that your reversed resource actually runs at least once, if there's a chance that it might be gone for a while. This patch also adds a new test harness for testing resources. It doesn't test the "live" aspect of resources, as it doesn't run Watch, but it was designed to ensure CheckApply works as intended, and it runs very quickly with a simplified timeline of happenings.
This commit is contained in:
@@ -16,6 +16,13 @@ function run-test()
|
||||
|
||||
GO_VERSION=($(go version))
|
||||
|
||||
function typos() {
|
||||
if grep -i 'reversable' "$1"; then # the word is "reversible"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function simplify-gocase() {
|
||||
if grep 'case _ = <-' "$1"; then
|
||||
return 1 # 'case _ = <- can be simplified to: case <-'
|
||||
@@ -106,6 +113,7 @@ for file in `find . -maxdepth 9 -type f -name '*.go' -not -path './old/*' -not -
|
||||
# continue
|
||||
#fi
|
||||
run-test grep 'log.Print' "$file" | grep '\\n"' && fail_test 'no newline needed in log.Print*()' # no \n needed in log.Printf or log.Println
|
||||
run-test typos "$file"
|
||||
run-test simplify-gocase "$file"
|
||||
run-test token-coloncheck "$file"
|
||||
run-test naked-error "$file"
|
||||
|
||||
Reference in New Issue
Block a user