fs

package
v0.0.0-...-6477f42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fs handle the fileSystem part of terraform-validator (Files and Directories)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSubFolderList

func GetSubFolderList(pathF string) []string

GetSubFolderList returns you the list of folders inside pathF

func ListTerraformFiles

func ListTerraformFiles(pathF string) []string

ListTerraformFiles get the terraform file list in the given pathF

Example
package main

import (
	"fmt"
	"github.com/thazelart/terraform-validator/internal/fs"
)

func main() {
	path := "../../testdata/ok_default_config"
	var fileList []string
	fileList = fs.ListTerraformFiles(path)
	fmt.Printf("%v", fileList)
}
Output:

Types

type File

type File struct {
	Path    string
	Content []byte
}

File is a simple structure to permit fs function overriding in others terraform-validator subpackages. It contains the file Path and it's content in []byte.

func NewFile

func NewFile(path string) File

NewFile create a new File from the given path

func (File) FileEqual

func (file File) FileEqual(file2 File) bool

FileEqual ensures that the two files have the same content

Example
package main

import (
	"fmt"

	"github.com/thazelart/terraform-validator/internal/fs"
)

func main() {
	file1 := fs.NewFile("my_file.txt")
	file2 := fs.NewFile("another_one.txt")

	result := file1.FileEqual(file2)

	fmt.Printf("It is %t to say that my files are equals !", result)
}
Output:

func (File) GetFilename

func (file File) GetFilename() string

GetFilename return you the filename instead of it's full path

type Folder

type Folder struct {
	Path    string
	Content []File
}

Folder is a simple structure to permit fs function overriding in others terraform-validator subpackages

func NewTerraformFolder

func NewTerraformFolder(pathF string) Folder

NewTerraformFolder return you a Folder var that contains all the Terraform files in the given pathF

Example
package main

import (
	"fmt"
	"github.com/thazelart/terraform-validator/internal/fs"
)

func main() {
	path := "../../testdata/ok_default_config"
	folder := fs.NewTerraformFolder(path)

	fmt.Printf("%+v", folder)
}
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL