configmanage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Copyright © 2022 Scott Hawkins <scott@echoboomer.net>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package configmanage instantiates functions to manage configuration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateStateFileIfNotExists

func CreateStateFileIfNotExists()

CreateStateFileIfNotExists populates an empty state file when one does not exist

func DeleteFile

func DeleteFile(credentials Credentials, file FileSpecification)

DeleteFile removes a file from a managed resource

func DeleteFromState

func DeleteFromState(data map[string]ManagedResource) ([]map[string]ManagedResource, error)

DeleteFromState removes a resource from the state file

func Deploy

func Deploy()

func InstallPackage

func InstallPackage(credentials Credentials, pkg PackageSpecification)

InstallPackage installs a package on a managed resource

func Propose

func Propose()

Propose determines what changes need to be made and clearly describes them

func ReadFromState

func ReadFromState() []map[string]ManagedResource

ReadFromState parses objects stored in the state file

func ReadOneFromState

func ReadOneFromState(resource string) map[string]ManagedResource

ReadOneFromState parses a single object stored in the state file

func RemovePackage

func RemovePackage(credentials Credentials, pkg PackageSpecification)

RemovePackage removes a package from a managed resource

func RunOnRemoteHost

func RunOnRemoteHost(credentials Credentials, command string) (string, error)

RunOnRemoteHost allows execution of a command on a host via an ssh shell - useful for managing resources on remote hosts

func UpdateFileMode

func UpdateFileMode(credentials Credentials, file FileSpecification)

UpdateFileMode updates a file's permissions

func UploadFileViaSFTP

func UploadFileViaSFTP(credentials Credentials, file FileSpecification) error

UploadFileViaSFTP leverages sftp to place a file onto a host

func Validate

func Validate()

Validate parses fields in a configuration file and returns whether or not the file structure is valid

func WriteToState

func WriteToState(data map[string]ManagedResource)

WriteToState formats a resource to be written to state on creation, update, or removal

Types

type Credentials

type Credentials struct {
	Hostname string
	Username string
	Password string
}

type FileResourceDiff

type FileResourceDiff struct {
	Operation    string
	Target       string
	UpdateValue  interface{}
	FileResource FileSpecification
}

func GetFileDiffs

func GetFileDiffs(credentials Credentials, files []FileSpecification, fromState ManagedResource) []FileResourceDiff

GetFileDiffs processes a slice of FileSpecification and determines changes for resources that already have state entries

type FileSpecification

type FileSpecification struct {
	Name string `yaml:"name" json:"name"`
	Path string `yaml:"path" json:"path"`
	Mode string `yaml:"mode" json:"mode"`
}

type ManagedResource

type ManagedResource struct {
	Host     string                 `yaml:"host" json:"host"`
	Password string                 `yaml:"password" json:"password"`
	Files    []FileSpecification    `yaml:"files" json:"files"`
	Packages []PackageSpecification `yaml:"packages" json:"packages"`
	Command  []string               `yaml:"command" json:"command"`
}

type PackageResourceDiff

type PackageResourceDiff struct {
	Operation       string
	PackageResource PackageSpecification
}

func GetPackageDiffs

func GetPackageDiffs(credentials Credentials, pkgs []PackageSpecification, fromState ManagedResource) []PackageResourceDiff

GetPackageDiffs iterates through requested packages on a managed resource and shows and returns any diffs

type PackageSpecification

type PackageSpecification struct {
	Package string `yaml:"package" json:"package"`
	Version string `yaml:"version" json:"version"`
}

Jump to

Keyboard shortcuts

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