Documentation ¶
Overview ¶
Copyright © 2023 Iggy <iggy@theiggy.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Package laws - Laws describe the state of the system ¶
Package laws - Laws describe the state of the system
Index ¶
- func ParseFiles(path string) ([]*gograph.Vertex[*LawNode], error)
- type AbsentMount
- type Container
- type FileChange
- type FileInsert
- type FileLink
- type FileTemplate
- type Group
- type HealthCheckOpts
- type Law
- type LawNode
- type Laws3
- type LogOpts
- type Mount
- type Package
- type PackageRepo
- type RetryOpts
- type Root
- type SSHKey
- type Script
- type Service
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFiles ¶
ParseFiles - parse a file or directory of yaml files to get the laws This is a total pain... either I screw myself on the logic by making everything a struct or I screw myself on the parsing by using maps and interfaces
Types ¶
type AbsentMount ¶
type AbsentMount struct { // Name string Spec string MountPoint string `yaml:"mount_point"` Type string Options string Freq int64 Pass int64 // CommonFields Name string Before []string After []string }
func (*AbsentMount) Ensure ¶
func (m *AbsentMount) Ensure(pretend bool) error
func (*AbsentMount) Exists ¶
func (m *AbsentMount) Exists() (bool, error)
func (*AbsentMount) UnmarshalYAML ¶
func (m *AbsentMount) UnmarshalYAML(value *yaml.Node) error
type Container ¶
type Container struct { // Name string Image string Running bool Volumes map[string]string Environment map[string]string Labels map[string]string LogDriver string Hostname string Network string // bridge|none|container:<name|id>|host|<network-name|network-id> HealthCheck HealthCheckOpts Privileged bool PublishAll bool Publish map[string]string RestartPolicy string // no|on-failure[:max-retries]|always|unless-stopped // CommonFields Name string Before []string After []string }
Container - This is a struct for the container
func (*Container) UnmarshalYAML ¶
UnmarshalYAML - This fills in default values if they aren't specified
type FileChange ¶
type FileChange struct { Search string `yaml:"search"` // line to search for Replace string `yaml:"replace,omitempty"` // line to replace with Done string `yaml:"done"` If []string // should probably convert this into some template logic // contains filtered or unexported fields }
func (*FileChange) UnmarshalYAML ¶
func (f *FileChange) UnmarshalYAML(value *yaml.Node) error
type FileInsert ¶
type FileInsert struct { // Name string // MakeDir bool `yaml:"make_dir"` // make the parent dir AfterLine string BeforeLine string LineNum int64 Text string // contains filtered or unexported fields }
func (*FileInsert) Ensure ¶
func (f *FileInsert) Ensure(pretend bool) error
func (*FileInsert) UnmarshalYAML ¶
func (f *FileInsert) UnmarshalYAML(value *yaml.Node) error
type FileLink ¶
type FileLink struct { Target string `yaml:"target"` // the target of the link Symbolic bool `yaml:"symbolic"` // contains filtered or unexported fields }
func (*FileLink) UnmarshalYAML ¶
type FileTemplate ¶
type FileTemplate struct { // Name string // file path // MakeDir bool `yaml:"make_dir"` // make the parent dir // User string // user/uid owner of the file // Group string // group/gid owner of the file // Mode fs.FileMode // file mode TODO maybe default to 400? Text string // text template TemplatePath string // path to a file to use instead of Text (unimpl) // contains filtered or unexported fields }
func (*FileTemplate) Ensure ¶
func (f *FileTemplate) Ensure(pretend bool) error
Ensure ensures that the file exists with the correct contents
func (*FileTemplate) UnmarshalYAML ¶
func (f *FileTemplate) UnmarshalYAML(value *yaml.Node) error
type Group ¶
type Group struct { // Name string GID uint64 System bool // CommonFields Name string Before []string After []string }
Group - a group the system should have
type HealthCheckOpts ¶
type HealthCheckOpts struct { Enabled bool Command string Interval string Retries int StartPeriod string Timeout string }
HealthCheckOpts - This is a struct for the healthcheck options
type LawNode ¶
dep graph node that represents each law parsed from the laws yaml files i.e. each one represents a user, group, file, etc
type Laws3 ¶
type Laws3 struct { Users struct { Present []*User } Groups struct { Present []*Group } Packages struct { Installed []*Package } PackageRepos struct { Present []*PackageRepo } `yaml:"package_repos"` Containers struct { // FIXME revisit this naming Running []*Container } Scripts struct { Run []*Script } Files struct { Templates []*FileTemplate Inserts []*FileInsert Changes []*FileChange Links []*FileLink } Mounts struct { Exists []*Mount Absent []*AbsentMount } Services struct { Enabled []*Service } SSH struct { AuthorizedKeys []*SSHKey `yaml:"authorized_keys"` } `yaml:"ssh"` }
Laws - describe the state of the system TODO should really just turn this into a list of `Law`
type Laws struct { Users []User Groups []Group Packages []Package PackageRepos []PackageRepo Containers []Container Scripts []Script Files FileTemplate Mounts []Mount Services []Service }
type Laws2 map[string]interface{}
type LogOpts ¶
type LogOpts struct { Driver string // none|json-file|syslog|journald|gelf|fluentd|awslogs|splunk Opt map[string]string }
LogOpts - This is a struct for the log options
type Mount ¶
type Mount struct { // Name string Spec string MountPoint string `yaml:"mount_point"` Type string Options string Freq int64 Pass int64 Present bool // CommonFields Name string Before []string After []string }
Mount is a mount point
func (*Mount) Ensure ¶
Ensure - ensure mount is setup TODO should probably mark fstab as managed by govern
func (*Mount) UnmarshalYAML ¶
UnmarshalYAML implements the Unmarshaler interface
type Package ¶
type Package struct { // Name string Version string `yaml:",omitempty"` Installed bool `yaml:",omitempty"` // whether the package should be installed or removed // CommonFields Name string Before []string After []string }
Package - package info
func (*Package) IsInstalled ¶
IsInstalled - check if a package is installed true/false whether a package is installed err = nil if we know what distro we are on
func (*Package) UnmarshalYAML ¶
UnmarshalYAML - This fills in default values if they aren't specified
type PackageRepo ¶
type PackageRepo struct { // Name string Key string `yaml:"key"` // (gpg|etc) key to fetch and load into the system store Contents string // the repo URL usually // CommonFields Name string // unique identifier, not used in the actual repo Before []string After []string }
PackageRepo describes a package repository
func (*PackageRepo) Ensure ¶
func (r *PackageRepo) Ensure(pretend bool) error
func (*PackageRepo) UnmarshalYAML ¶
func (r *PackageRepo) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements the Unmarshaler interface
type RetryOpts ¶
type RetryOpts struct { Attempts uint // how many times to try to apply the law Until bool // ??? copied from Salt, probably not necessary Interval uint // how long to wait between tries Splay uint // how much variance to add to the interval, useful for thundering herd type scenarios }
RetryOpts - retry options
type Script ¶
type Script struct { // Name string Shell string Script string Env []string Args []string WorkingDir string Creates []string RunAs string // CommonFields Name string Before []string After []string }
Script is a script to run
func (*Script) UnmarshalYAML ¶
UnmarshalYAML implements the Unmarshaler interface.
type Service ¶
type Service struct { // Name string State string `yaml:",omitempty"` Persistent bool `yaml:",omitempty"` RunLevel string `yaml:",omitempty"` // CommonFields Name string Before []string After []string }
Service - package info
func (*Service) CurrentState ¶
CurrentState - get current state of service
func (*Service) Ensure ¶
FIXME changing the runlevel doesn't update the service Ensure - ensure service is in desired state
func (*Service) UnmarshalYAML ¶
type User ¶
type User struct { // Name string “ // the user's name UID uint64 `yaml:",omitempty"` // the user's UID, uint64 matches GID uint64 `yaml:",omitempty"` // The primary group ID Fullname string `` // part of the GECOS string Password string `` // the encrypted password HomeDir string `` // the user's $HOME Shell string `` // the system shell System bool `` // whether this is a system user or not Exists bool `` // Whether the user should exist on the system or not ExtraGroups []string `` // required extra group names OptionalGroups []string `yaml:"optional_groups"` // if these groups exist already, add the user to them, otherwise ignore // CommonFields //`yaml:",inline"` // CommonFields `yaml:"commonfields,inline"` // fields that are supported for everything, mostly dep related Name string Before []string After []string }
User - a user the system should have
func (*User) GetPassword ¶
GetPassword - Get the password for the user Common internet wisdom says I should be talking to pam, but Alpine doesn't use pam
func (*User) UnmarshalYAML ¶
UnmarshalYAML - This fills in default values if they aren't specified