Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add __file__ and __dir__ attributes to resource properties for file l…
…inters
- Loading branch information
Larry Hitchon
committed
Jul 23, 2018
1 parent
8a59f38
commit f0592ea
Showing
6 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package linter | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestKubernetesSpecialVariables(t *testing.T) { | ||
loader := KubernetesResourceLoader{} | ||
filename := "./testdata/resources/pod.yml" | ||
loaded, err := loader.Load(filename) | ||
assert.Nil(t, err, "Expecting Load to not return an error") | ||
for _, resource := range loaded.Resources { | ||
properties := resource.Properties.(map[string]interface{}) | ||
assert.Equal(t, filename, properties["__file__"]) | ||
assert.Equal(t, filepath.Dir(filename), properties["__dir__"]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx | ||
namespace: web | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.7.9 | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters