Documentation ¶
Index ¶
- func FindFiles(root, pattern string) ([]string, error)
- func GetKubeClient() (client.Client, error)
- func GitClone(script string, repo string) error
- func GitLog(filepath string) ([]byte, error)
- func GitPull(script string) ([]byte, error)
- func IndexSOP(indexer Indexer, sops map[string]string) error
- func NeedReIndex(config Config) error
- func RunIndex(index bool, config Config) error
- func ScanForFiles(path string, config Config) ([]MDFile, []ADFile, error)
- func ToBulkJSON(s []Sop) (map[string]string, error)
- type ADFile
- type Config
- type Dates
- type ElasticClient
- type Indexer
- type MDFile
- type Sop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFiles ¶
FindFiles takes a path to a directory and a pattern (in this case, the type of file) and looks through the entire directory and adds all the paths for the files that match the pattern into a slice of strings which it returns.
func GetKubeClient ¶
GetKubeClient creates a Kubernetes client which can be used to access the ConfigMap stored on the oc environment.
func GitClone ¶
GitClone performs a git clone of repo contained in the repo string. The script string containts the location of the shell script that performs the git clone.
func GitLog ¶
GitLog performs a git log of a file specified by the filepath string. It then returns the output of the command.
func GitPull ¶
GitPull performs a git pull of the repo. The script string contains the location of the shell script that performs the git pull. It will then return the output of the git pull to determine if the repo was actually updated or not.
func IndexSOP ¶
IndexSOP takes the map holding the SOPs and indexes them or updates the index that already exists.
func NeedReIndex ¶
NeedReIndex performs a git pull to determine if a re-indexing needs to occur. If the repo is already up to date, then it will do a RunIndex with false. If it's not, then it wil return RunIndex with true.
func RunIndex ¶
RunIndex performs the indexing. If the index bool is true, then this function will perform the indexing routine. If the bool is false, then it won't index. The Config object is used to get the elasticsearch url. Once it finishes the indexing routine, it will print out how much time it took to index the SOP documents.
func ScanForFiles ¶
ScanForFiles scans the ops-sop directory and finds files ending in .md or .asciidoc and then it will take all of those files and put them inside of a MDFile or ADFile object respectively. It also performs a GitLog to find authors and dates for files, and will grab other data from the files to put into the object.
func ToBulkJSON ¶
ToBulkJSON takes all the Sop objects and puts them into the map that will be used when calling IndexSOP after encoding the Sop into JSON. The name of the SOP will be the key and the json encoded sop as the value for the key-value pair.
Types ¶
type ADFile ¶
type ADFile struct { Path string Name string Content string Author []string CreationDate time.Time LastUpdated time.Time Tags []string Link string }
ADFile is the struct for a asciidoc file
type Config ¶
type Config struct { Time int ElasticURL string GitURL string RepoName string GitScript string RepoURL string }
Config struct holds all the important values used across the program.
type Dates ¶
Dates contains the creation date of the SOP document and the date it was last updated
func GetAuthorsAndDates ¶
GetAuthorsAndDates takes the slice of bytes (data) which contains the git log of a file and then goes through and finds all the unique authors of the file as well as the creation date and date the file was last updated and then returns that information.
type ElasticClient ¶
type ElasticClient struct {
// contains filtered or unexported fields
}
ElasticClient struct holds the elasticsearch client
func NewElasticClient ¶
func NewElasticClient(addresses []string, username, password string) (ElasticClient, error)
NewElasticClient creates a new elastic client which lets SOPs be indexed into the elasticsearch cluster.
func (*ElasticClient) CreateOrUpdateIndex ¶
func (ec *ElasticClient) CreateOrUpdateIndex(index, documentID, body string) error
CreateOrUpdateIndex will instantiate a request object and then perform the request. In this particular case, it will create or update each index for an SOP.
type MDFile ¶
type MDFile struct { Path string Name string Content string Author []string CreationDate time.Time LastUpdated time.Time Tags []string Link string }
MDFile is the struct for a markdown file
type Sop ¶
type Sop struct { Name string `json:"name"` Path string `json:"path"` Author []string `json:"author"` CreationDate time.Time `json:"creationDate"` LastUpdated time.Time `json:"lastUpdated"` Commit string `json:"commit"` Content string `json:"content"` Tags []string `json:"tags"` Link string `json:"links"` }
Sop struct contains all the information that will be in the index for the sop document