Skip to content

Commit

Permalink
add stemcellmetadata package
Browse files Browse the repository at this point in the history
refactor: move stemcell metadata loading to a separate package
refactor: improve error message in stemcellmetadata.SlugParts
  • Loading branch information
crhntr committed Dec 13, 2023
1 parent cc059fc commit 8fcc80d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion main/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/cloudfoundry/bosh-agent/app"
"github.com/cloudfoundry/bosh-agent/releasetarball"
"github.com/cloudfoundry/bosh-agent/settings/directories"
"github.com/cloudfoundry/bosh-agent/stemcellmetadata"
)

func compileTarball(command string, args []string) {
Expand All @@ -22,7 +23,7 @@ func compileTarball(command string, args []string) {
log.Fatal(err)
}

stemcellOS, stemcellName, stemcellVersion, err := readStemcellSlug()
stemcellOS, stemcellName, stemcellVersion, err := stemcellmetadata.SlugParts()
if err != nil {
log.Fatal(err)
}
Expand Down
11 changes: 0 additions & 11 deletions main/stemcell.go

This file was deleted.

10 changes: 10 additions & 0 deletions stemcellmetadata/slug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !linux

package stemcellmetadata

import "log"

func SlugParts() (_ string, _ string, _ string, _ error) {
log.Fatal("func readStemcellSlug (in package stemcellmetadata) is not implemented for GOOS != linux")
return
}
4 changes: 2 additions & 2 deletions main/stemcell_linux.go → stemcellmetadata/slug_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package stemcellmetadata

import (
"bufio"
Expand All @@ -10,7 +10,7 @@ import (
"strings"
)

func readStemcellSlug() (string, string, string, error) {
func SlugParts() (string, string, string, error) {
stemcellVersionBuf, err := os.ReadFile("/var/vcap/bosh/etc/stemcell_version")
if err != nil {
return "", "", "", err
Expand Down

0 comments on commit 8fcc80d

Please sign in to comment.