Repository: score-spec/score-compose
Pull request #221 (2024-12-13 16:46:05)

Changes made for provisoners flag
Initially the provisioners flag doesnt support local file and stdin. But now local and stdin added


rabelmervin: Hello @mathieu-benoit @astromechza I have signed the commits and DCO is passed successfully :) Is there anything i can help you with ?
7h3-3mp7y-m4n: hey, @rabelmervin  can you also update the test case over here https://github.com/score-spec/score-compose/blob/main/internal/command/init_test.go#L79 
Can you also add the test case for your function? 
rabelmervin: Hi @7h3-3mp7y-m4n I can add the test functions and I'll remove that irrelevant files 👍
rabelmervin: Hi @mathieu-benoit and @astromechza Now the Test is passed. I'll commit the changes 
![Screenshot (12)](https://github.com/user-attachments/assets/8327462c-0fb3-4509-aa75-da3d90d3e521)


astromechza: @rabelmervin Thanks! can you address the remaining comments on the diff, including this one for score-go? https://github.com/score-spec/score-compose/pull/221/files#r1904017231
rabelmervin: Bonjour @mathieu-benoit @astromechza I made changes ! I have Moved the `GetStdinFile` functionality to uriget.go present in score-go as part of `GetFile`   https://github.com/score-spec/score-go/pull/85 
7h3-3mp7y-m4n: I have proposed some changes to your `score-go` [PR](https://github.com/score-spec/score-go/pull/85)
Please wait for @astromechza  or @mathieu-benoit to review it, Thanks!
astromechza: @rabelmervin your score-go PR is now released under https://github.com/score-spec/score-go/releases/tag/v1.9.2 and can be imported here :)
mathieu-benoit: Hi @rabelmervin, while we were reviewing the projects status in preparation of KubeCon, we were wondering if you could continue on this one? Thanks again for your contributions!
rabelmervin: Ohh ! I forgot this, Sure I'll complete this  @mathieu-benoit 

Patch:
diff --git a/go.mod b/go.mod
index 106ade9..f6dcedb 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/compose-spec/compose-go/v2 v2.4.8
 	github.com/mitchellh/mapstructure v1.5.0
 	github.com/olekukonko/tablewriter v0.0.5
-	github.com/score-spec/score-go v1.9.3
+	github.com/score-spec/score-go v1.9.5
 	github.com/spf13/cobra v1.9.1
 	github.com/spf13/pflag v1.0.6
 	github.com/stretchr/testify v1.10.0
@@ -51,4 +51,4 @@ require (
 	golang.org/x/sys v0.31.0 // indirect
 	gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
 	oras.land/oras-go/v2 v2.5.0 // indirect
-)
+)
\ No newline at end of file
diff --git a/go.sum b/go.sum
index 0ee8685..1fb99b3 100644
--- a/go.sum
+++ b/go.sum
@@ -61,8 +61,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
-github.com/score-spec/score-go v1.9.3 h1:YZ1M5MCn/FI6nQNI0RUC0l8tgSwceOg+P7YvvNUyaNE=
-github.com/score-spec/score-go v1.9.3/go.mod h1:FTajUIhA1MyQeYtuTwVVisf+oqf+tV0V44g54hnnpMo=
+github.com/score-spec/score-go v1.9.5 h1:BkZCCf0s4YVYWR6WL4D57P5PT9XxVmfWpNw/rC01750=
+github.com/score-spec/score-go v1.9.5/go.mod h1:hbWRzCHVEyxZP2UhD2nkhTEMRFZZob/uczCnUDl0enI=
 github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
 github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
 github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
diff --git a/internal/command/default.provisioners.yaml b/internal/command/default.provisioners.yaml
index af97a96..a304553 100644
--- a/internal/command/default.provisioners.yaml
+++ b/internal/command/default.provisioners.yaml
@@ -886,7 +886,6 @@
   volumes: |
     {{ .Init.sk }}-data:
       driver: local
-  # Create an services with the database itself
   services: |
     {{ .Init.sk }}:
       image: mcr.microsoft.com/mssql/server:latest
diff --git a/internal/command/init.go b/internal/command/init.go
index 2e7e218..53e5b2d 100644
--- a/internal/command/init.go
+++ b/internal/command/init.go
@@ -203,7 +203,15 @@ the new provisioners will take precedence.
 				if err != nil {
 					return fmt.Errorf("failed to load provisioner %d: %w", i+1, err)
 				}
-				if err := loader.SaveProvisionerToDirectory(sd.Path, vi, data); err != nil {
+
+				var saveFilename string
+				if vi == "-" {
+					saveFilename = "from-stdin.provisioners.yaml"
+				} else {
+					saveFilename = vi
+				}
+
+				if err := loader.SaveProvisionerToDirectory(sd.Path, saveFilename, data); err != nil {
 					return fmt.Errorf("failed to save provisioner %d: %w", i+1, err)
 				}
 			}
@@ -230,7 +238,9 @@ func init() {
 		"- HTTPS       : https://host/file\n"+
 		"- Git (SSH)   : git-ssh://git@host/repo.git/file\n"+
 		"- Git (HTTPS) : git-https://host/repo.git/file\n"+
-		"- OCI         : oci://[registry/][namespace/]repository[:tag|@digest][#file]")
+		"- OCI         : oci://[registry/][namespace/]repository[:tag|@digest][#file]\n"+
+		"- Local File  : /path/to/local/file\n"+
+		"- Stdin       : - (read from standard input)")
 
 	rootCmd.AddCommand(initCmd)
 }


Test patch:
diff --git a/internal/command/init_test.go b/internal/command/init_test.go
index 7571921..b23adf4 100644
--- a/internal/command/init_test.go
+++ b/internal/command/init_test.go
@@ -76,6 +76,8 @@ Flags:
                                    - Git (SSH)   : git-ssh://git@host/repo.git/file
                                    - Git (HTTPS) : git-https://host/repo.git/file
                                    - OCI         : oci://[registry/][namespace/]repository[:tag|@digest][#file]
+                                   - Local File  : /path/to/local/file
+                                   - Stdin       : - (read from standard input)
 
 Global Flags:
       --quiet           Mute any logging output