Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtopjian/craft
A Go library to help provision resources on a system
https://github.com/jtopjian/craft
Last synced: 4 days ago
JSON representation
A Go library to help provision resources on a system
- Host: GitHub
- URL: https://github.com/jtopjian/craft
- Owner: jtopjian
- License: mit
- Created: 2017-07-24T01:35:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-24T01:42:33.000Z (over 7 years ago)
- Last Synced: 2023-03-23T03:01:21.738Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Craft
Craft is a library to help provision resources -- such as users, groups, and packages -- on a system.
While it's possible to use this library as-is, it's better suited as an underlying component to a more user-friendly tool.
This library is in very early stages and will likely have major changes.
## Development
This library is not vendored, so you will have to download dependent packages manually for now:
```shell
$ go get -u ./...
```## Usage
If you really want to try using this, here's an example:
```go
package mainimport (
"fmt""github.com/jtopjian/craft/client"
"github.com/jtopjian/craft/resources/aptpkg"
"github.com/sirupsen/logrus"
)func main() {
logger := logrus.New()
logger.SetLevel(logrus.DebugLevel)c := client.Client{
Logger: logger,
}createOpts := aptpkg.CreateOpts{
Name: "sl",
}err := aptpkg.Create(c, createOpts)
if err != nil {
panic(err)
}exists, err := aptpkg.Exists(c, "sl")
if err != nil {
panic(err)
}fmt.Printf("Package sl exists: %t\n", exists)
pkg, err := aptpkg.Read(c, "sl")
if err != nil {
panic(err)
}fmt.Printf("Package sl: %#v\n", pkg)
err = aptpkg.Delete(c, "sl")
if err != nil {
panic(err)
}
}
```Which will yield the following output:
```
DEBU[0000] Installing package
DEBU[0000] Package Create Options: aptpkg.CreateOpts{Name:"sl", Version:""}
DEBU[0005] Checking if package sl exists
DEBU[0005] Reading package sl
Package sl exists: true
DEBU[0005] Reading package sl
Package sl: aptpkg.AptPkg{Name:"sl", Version:"3.03-17build1", LatestVersion:"3.03-17build1"}
DEBU[0005] Deleting package sl
```