aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bommom.go24
-rw-r--r--core.go6
-rw-r--r--formats.go16
-rw-r--r--store.go40
4 files changed, 43 insertions, 43 deletions
diff --git a/bommom.go b/bommom.go
index 2573300..6b62bfa 100644
--- a/bommom.go
+++ b/bommom.go
@@ -77,7 +77,7 @@ func openBomStore() {
}
}
-func dumpOut(fname string, bs *BomStub, b *Bom) {
+func dumpOut(fname string, bs *BomMeta, b *Bom) {
var outFile io.Writer
if fname == "" {
outFile = os.Stdout
@@ -120,7 +120,7 @@ func dumpOut(fname string, bs *BomStub, b *Bom) {
}
-func loadIn(fname string) (bs *BomStub, b *Bom) {
+func loadIn(fname string) (bs *BomMeta, b *Bom) {
if inFormat == "" {
switch ext := path.Ext(fname); ext {
@@ -160,14 +160,14 @@ func loadIn(fname string) (bs *BomStub, b *Bom) {
func initCmd() {
openBomStore()
- bs, err := bomstore.GetStub(ShortName("common"), ShortName("gizmo"))
+ bs, err := bomstore.GetBomMeta(ShortName("common"), ShortName("gizmo"))
if err == nil {
- // dummy BomStub already exists?
+ // dummy BomMeta already exists?
return
}
b := makeTestBom()
b.Version = "v001"
- bs = &BomStub{Name: "gizmo",
+ bs = &BomMeta{Name: "gizmo",
Owner: "common",
Description: "fancy stuff",
HeadVersion: b.Version,
@@ -227,7 +227,7 @@ func loadCmd() {
bs, b := loadIn(inFname)
if inFormat == "csv" && bs == nil {
// TODO: from inname? if ShortName?
- bs = &BomStub{}
+ bs = &BomMeta{}
}
bs.Owner = userName
@@ -258,11 +258,11 @@ func convertCmd() {
}
if inFormat == "csv" && bs == nil {
// TODO: from inname? if ShortName?
- bs = &BomStub{Name: "untitled", Owner: anonUser.name}
+ bs = &BomMeta{Name: "untitled", Owner: anonUser.name}
}
if err := bs.Validate(); err != nil {
- log.Fatal("loaded bomstub not valid: " + err.Error())
+ log.Fatal("loaded bommeta not valid: " + err.Error())
}
if err := b.Validate(); err != nil {
log.Fatal("loaded bom not valid: " + err.Error())
@@ -274,7 +274,7 @@ func convertCmd() {
func listCmd() {
openBomStore()
- var bomStubs []BomStub
+ var bomMetas []BomMeta
var err error
if flag.NArg() > 2 {
log.Fatal("Error: too many arguments...")
@@ -284,18 +284,18 @@ func listCmd() {
if !isShortName(name) {
log.Fatal("Error: not a possible username: " + name)
}
- bomStubs, err = bomstore.ListBoms(ShortName(name))
+ bomMetas, err = bomstore.ListBoms(ShortName(name))
if err != nil {
log.Fatal(err)
}
} else {
// list all boms from all names
- bomStubs, err = bomstore.ListBoms("")
+ bomMetas, err = bomstore.ListBoms("")
if err != nil {
log.Fatal(err)
}
}
- for _, bs := range bomStubs {
+ for _, bs := range bomMetas {
fmt.Println(bs.Owner + "/" + bs.Name)
}
}
diff --git a/core.go b/core.go
index 0ae6da1..74a72b9 100644
--- a/core.go
+++ b/core.go
@@ -34,9 +34,9 @@ func (li *LineItem) Id() string {
}
// The main anchor of a BOM as a cohesive whole, with a name and permissions.
-// Multiple BOMs are associated with a single BomStub; the currently active one
+// Multiple BOMs are associated with a single BomMeta; the currently active one
// is the 'head'.
-type BomStub struct {
+type BomMeta struct {
Name string `json:"name"`
Owner string `json:"owner_name"`
Description string `json:"description"`
@@ -87,7 +87,7 @@ func (b *Bom) Validate() error {
return nil
}
-func (bs *BomStub) Validate() error {
+func (bs *BomMeta) Validate() error {
if !isShortName(bs.Name) {
return Error("name not a ShortName: \"" + bs.Name + "\"")
}
diff --git a/formats.go b/formats.go
index fb7f573..e24c0ae 100644
--- a/formats.go
+++ b/formats.go
@@ -1,6 +1,6 @@
package main
-// Bom/BomStub conversion/dump/load routines
+// Bom/BomMeta conversion/dump/load routines
import (
"encoding/csv"
@@ -14,7 +14,7 @@ import (
// --------------------- text (CLI only ) -----------------------
-func DumpBomAsText(bs *BomStub, b *Bom, out io.Writer) {
+func DumpBomAsText(bs *BomMeta, b *Bom, out io.Writer) {
fmt.Fprintln(out)
fmt.Fprintf(out, "%s (version %s, created %s)\n", bs.Name, b.Version, b.Created)
fmt.Fprintf(out, "Creator: %s\n", bs.Owner)
@@ -81,7 +81,7 @@ func LoadBomFromCSV(out io.Writer) (*Bom, error) {
// --------------------- JSON -----------------------
-func DumpBomAsJSON(bs *BomStub, b *Bom, out io.Writer) {
+func DumpBomAsJSON(bs *BomMeta, b *Bom, out io.Writer) {
obj := map[string]interface{}{
"bom_meta": bs,
@@ -94,9 +94,9 @@ func DumpBomAsJSON(bs *BomStub, b *Bom, out io.Writer) {
}
}
-func LoadBomFromJSON(input io.Reader) (*BomStub, *Bom, error) {
+func LoadBomFromJSON(input io.Reader) (*BomMeta, *Bom, error) {
- bs := &BomStub{}
+ bs := &BomMeta{}
b := &Bom{}
obj := map[string]interface{}{
@@ -120,7 +120,7 @@ func LoadBomFromJSON(input io.Reader) (*BomStub, *Bom, error) {
// --------------------- XML -----------------------
-func DumpBomAsXML(bs *BomStub, b *Bom, out io.Writer) {
+func DumpBomAsXML(bs *BomMeta, b *Bom, out io.Writer) {
enc := xml.NewEncoder(out)
if err := enc.Encode(bs); err != nil {
@@ -131,9 +131,9 @@ func DumpBomAsXML(bs *BomStub, b *Bom, out io.Writer) {
}
}
-func LoadBomFromXML(input io.Reader) (*BomStub, *Bom, error) {
+func LoadBomFromXML(input io.Reader) (*BomMeta, *Bom, error) {
- bs := BomStub{}
+ bs := BomMeta{}
b := Bom{}
enc := xml.NewDecoder(input)
diff --git a/store.go b/store.go
index 7cbf360..6187f78 100644
--- a/store.go
+++ b/store.go
@@ -9,11 +9,11 @@ import (
// TODO: who owns returned BOMs? Caller? need "free" methods?
type BomStore interface {
- GetStub(user, name ShortName) (*BomStub, error)
- GetHead(user, name ShortName) (*BomStub, *Bom, error)
+ GetBomMeta(user, name ShortName) (*BomMeta, error)
+ GetHead(user, name ShortName) (*BomMeta, *Bom, error)
GetBom(user, name, version ShortName) (*Bom, error)
- Persist(bs *BomStub, b *Bom, version ShortName) error
- ListBoms(user ShortName) ([]BomStub, error)
+ Persist(bs *BomMeta, b *Bom, version ShortName) error
+ ListBoms(user ShortName) ([]BomMeta, error)
}
// Basic BomStore backend using a directory structure of JSON files saved to
@@ -38,17 +38,17 @@ func OpenJSONFileBomStore(fpath string) (*JSONFileBomStore, error) {
return &JSONFileBomStore{Rootfpath: fpath}, nil
}
-func (jfbs *JSONFileBomStore) GetStub(user, name ShortName) (*BomStub, error) {
+func (jfbs *JSONFileBomStore) GetBomMeta(user, name ShortName) (*BomMeta, error) {
fpath := jfbs.Rootfpath + "/" + string(user) + "/" + string(name) + "/_meta.json"
- bs := BomStub{}
- if err := readJsonBomStub(fpath, &bs); err != nil {
+ bs := BomMeta{}
+ if err := readJsonBomMeta(fpath, &bs); err != nil {
return nil, err
}
return &bs, nil
}
-func (jfbs *JSONFileBomStore) GetHead(user, name ShortName) (*BomStub, *Bom, error) {
- bs, err := jfbs.GetStub(user, name)
+func (jfbs *JSONFileBomStore) GetHead(user, name ShortName) (*BomMeta, *Bom, error) {
+ bs, err := jfbs.GetBomMeta(user, name)
if err != nil {
return nil, nil, err
}
@@ -69,7 +69,7 @@ func (jfbs *JSONFileBomStore) GetBom(user, name, version ShortName) (*Bom, error
return &b, nil
}
-func (jfbs *JSONFileBomStore) ListBoms(user ShortName) ([]BomStub, error) {
+func (jfbs *JSONFileBomStore) ListBoms(user ShortName) ([]BomMeta, error) {
if user != "" {
return jfbs.listBomsForUser(user)
}
@@ -79,7 +79,7 @@ func (jfbs *JSONFileBomStore) ListBoms(user ShortName) ([]BomStub, error) {
log.Fatal(err)
}
defer rootDir.Close()
- bsList := []BomStub{}
+ bsList := []BomMeta{}
dirInfo, err := rootDir.Readdir(0)
for _, node := range dirInfo {
if !node.IsDir() || !isShortName(node.Name()) {
@@ -94,8 +94,8 @@ func (jfbs *JSONFileBomStore) ListBoms(user ShortName) ([]BomStub, error) {
return bsList, nil
}
-func (jfbs *JSONFileBomStore) listBomsForUser(user ShortName) ([]BomStub, error) {
- bsList := []BomStub{}
+func (jfbs *JSONFileBomStore) listBomsForUser(user ShortName) ([]BomMeta, error) {
+ bsList := []BomMeta{}
uDirPath := jfbs.Rootfpath + "/" + string(user)
uDir, err := os.Open(uDirPath)
if err != nil {
@@ -115,8 +115,8 @@ func (jfbs *JSONFileBomStore) listBomsForUser(user ShortName) ([]BomStub, error)
continue
}
fpath := jfbs.Rootfpath + "/" + string(user) + "/" + node.Name() + "/_meta.json"
- bs := BomStub{}
- if err := readJsonBomStub(fpath, &bs); err != nil {
+ bs := BomMeta{}
+ if err := readJsonBomMeta(fpath, &bs); err != nil {
if e, ok := err.(*os.PathError); ok && e.Err.Error() == "no such file or directory" {
// no _meta.json in there
continue
@@ -128,7 +128,7 @@ func (jfbs *JSONFileBomStore) listBomsForUser(user ShortName) ([]BomStub, error)
return bsList, nil
}
-func (jfbs *JSONFileBomStore) Persist(bs *BomStub, b *Bom, version ShortName) error {
+func (jfbs *JSONFileBomStore) Persist(bs *BomMeta, b *Bom, version ShortName) error {
if err := bs.Validate(); err != nil {
return err
@@ -144,7 +144,7 @@ func (jfbs *JSONFileBomStore) Persist(bs *BomStub, b *Bom, version ShortName) er
f.Close()
return Error("bom with same owner, name, and version already exists")
}
- if err := writeJsonBomStub(bs_fpath, bs); err != nil {
+ if err := writeJsonBomMeta(bs_fpath, bs); err != nil {
log.Fatal(err)
}
if err := writeJsonBom(b_fpath, b); err != nil {
@@ -153,7 +153,7 @@ func (jfbs *JSONFileBomStore) Persist(bs *BomStub, b *Bom, version ShortName) er
return nil
}
-func readJsonBomStub(fpath string, bs *BomStub) error {
+func readJsonBomMeta(fpath string, bs *BomMeta) error {
f, err := os.Open(path.Clean(fpath))
if err != nil {
return err
@@ -166,7 +166,7 @@ func readJsonBomStub(fpath string, bs *BomStub) error {
return nil
}
-func writeJsonBomStub(fpath string, bs *BomStub) error {
+func writeJsonBomMeta(fpath string, bs *BomMeta) error {
err := os.MkdirAll(path.Dir(fpath), os.ModePerm|os.ModeDir)
if err != nil && !os.IsExist(err) {
return err
@@ -196,7 +196,7 @@ func readJsonBom(fpath string, b *Bom) error {
return nil
}
-// Need to write the BomStub before writing the Bom
+// Need to write the BomMeta before writing the Bom
func writeJsonBom(fpath string, b *Bom) error {
f, err := os.Create(fpath)
if err != nil {