Documentation ¶
Overview ¶
Example (TestWithDirectory) ¶
rl, err := ResourceListFromDirectory("testdata/resources/input", "testdata/resources/input/fn-config.yaml") if err != nil { // check error } // Do something with the ResourceList // Create a temporary directory and write the resources back as files. tempDir, err := ioutil.TempDir("", "kyaml-fn-sdk-*") err = ResourceListToDirectory(rl, tempDir) if err != nil { // check error } // Read the resources again from disk as a ResourceList. rlActual, err := ResourceListFromDirectory(tempDir, "") if err != nil { // check error } actualYaml, err := rlActual.ToYAML() if err != nil { // check error } rlExpected, err := ResourceListFromDirectory("testdata/resources/expected", "") if err != nil { // check error } expectedYaml, err := rlExpected.ToYAML() if err != nil { // check error } // Compare expectedYaml and actualYaml. The 2 directories are identical if // they can produce the same ResourceLists. if string(expectedYaml) != string(actualYaml) { // do something }
Output:
Example (TestWithResourceList) ¶
rl, err := ResourceListFromFile("testdata/resourcelist.yaml") if err != nil { // check error } // do something with the ResourceList actualYaml, err := rl.ToYAML() if err != nil { // check error } rlExpected, err := ResourceListFromFile("testdata/expected_resourcelist.yaml") if err != nil { // check error } expectedYaml, err := rlExpected.ToYAML() if err != nil { // check error } // Compare expectedYaml and actualYaml if string(expectedYaml) != string(actualYaml) { // do something }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResourceListFromDirectory ¶
func ResourceListFromDirectory(dir string, fnConfigFile string) (*fnsdk.ResourceList, error)
ResourceListFromDirectory reads yaml files from dir and functionConfig file, and then assemble them as a fnsdk.ResourceList.
func ResourceListFromFile ¶
func ResourceListFromFile(path string) (*fnsdk.ResourceList, error)
ResourceListFromFile reads a yaml file and converts it to a fnsdk.ResourceList.
func ResourceListToDirectory ¶
func ResourceListToDirectory(rl *fnsdk.ResourceList, dir string) error
ResourceListToDirectory write ResourceList.items to yaml files according to the path annotation (https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md#internalconfigkubernetesiopath).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.