@@ -11,12 +11,20 @@ import (
1111 "os/exec"
1212 "os/user"
1313 "path/filepath"
14+
15+ concatenate "github.com/paulvollmer/go-concatenate"
1416)
1517
1618// Configuration : represent .soos.json structure
1719type Configuration struct {
1820 ImageName string
1921 ExposePorts []string
22+ HashFiles []string
23+ }
24+
25+ // DefaultConfig : base for .soos.json
26+ var DefaultConfig = Configuration {
27+ HashFiles : []string {"package.json" },
2028}
2129
2230func getConfig () Configuration {
@@ -27,18 +35,24 @@ func getConfig() Configuration {
2735 if err != nil {
2836 fmt .Println ("error:" , err )
2937 }
38+
39+ if len (configuration .HashFiles ) == 0 {
40+ configuration .HashFiles = DefaultConfig .HashFiles
41+ }
42+
3043 return configuration
3144}
3245
33- func tokenizer () string {
34- f , err := os .Open ("package.json" )
46+ func tokenizer (hashFiles []string ) string {
47+
48+ data , err := concatenate .FilesToBytes ("\n " , hashFiles ... )
49+
3550 if err != nil {
3651 log .Fatal (err )
3752 }
38- defer f .Close ()
3953
4054 h := sha1 .New ()
41- if _ , err := io .Copy (h , f ); err != nil {
55+ if _ , err := io .Copy (h , bytes . NewReader ( data ) ); err != nil {
4256 log .Fatal (err )
4357 }
4458
@@ -202,8 +216,9 @@ func pushImage(imageNameWithTag string) {
202216func main () {
203217 fmt .Printf ("<*> Soos start\n " )
204218
205- imageReference := tokenizer ()
206- fmt .Printf ("<-> Generated image name is %s\n " , imageReference )
219+ hashFiles := getConfig ().HashFiles
220+ imageReference := tokenizer (hashFiles )
221+ fmt .Printf ("<-> Generated image name is %s based on %s\n " , imageReference , hashFiles )
207222
208223 fmt .Printf ("<-> Verifying/Generating Dockerfile presence..." )
209224 genDockerfile ()
0 commit comments