@@ -45,11 +45,12 @@ var OCICmd = &cobra.Command{
4545 os .Exit (1 )
4646 }
4747
48- env , err := ProcessPlatformAndConfig (platform , args [0 ])
48+ env , p , err := ProcessPlatformAndConfig (platform , args [0 ])
4949 if err != nil {
5050 fmt .Println (styles .ErrorStyle .Render ("error: " , err .Error ()))
5151 os .Exit (1 )
5252 }
53+ platform = p
5354
5455 sc , fh , err := binit .GetBSFInitializers ()
5556 if err != nil {
@@ -180,31 +181,31 @@ func findPlatform(platform string) (string, string) {
180181}
181182
182183// ProcessPlatformAndConfig processes the platform and config file
183- func ProcessPlatformAndConfig (platform string , envName string ) (hcl2nix.OCIArtifact , error ) {
184- if platform == "" {
185- tos , tarch := findPlatform (platform )
186- platform = tos + "/" + tarch
184+ func ProcessPlatformAndConfig (plat string , envName string ) (hcl2nix.OCIArtifact , string , error ) {
185+ if plat == "" {
186+ tos , tarch := findPlatform (plat )
187+ plat = tos + "/" + tarch
187188 }
188189
189190 pfound := false
190191 for _ , sp := range supportedPlatforms {
191- if strings .Contains (platform , sp ) {
192+ if strings .Contains (plat , sp ) {
192193 pfound = true
193194 break
194195 }
195196 }
196197 if ! pfound {
197- return hcl2nix.OCIArtifact {}, fmt .Errorf ("Platform %s is not supported. Supported platforms are %s" , platform , strings .Join (supportedPlatforms , ", " ))
198+ return hcl2nix.OCIArtifact {}, "" , fmt .Errorf ("Platform %s is not supported. Supported platforms are %s" , platform , strings .Join (supportedPlatforms , ", " ))
198199 }
199200 data , err := os .ReadFile ("bsf.hcl" )
200201 if err != nil {
201- return hcl2nix.OCIArtifact {}, fmt .Errorf ("error: %s" , err .Error ())
202+ return hcl2nix.OCIArtifact {}, "" , fmt .Errorf ("error: %s" , err .Error ())
202203 }
203204
204205 var dstErr bytes.Buffer
205206 conf , err := hcl2nix .ReadConfig (data , & dstErr )
206207 if err != nil {
207- return hcl2nix.OCIArtifact {}, fmt .Errorf (dstErr .String ())
208+ return hcl2nix.OCIArtifact {}, "" , fmt .Errorf (dstErr .String ())
208209 }
209210
210211 envNames := make ([]string , 0 , len (conf .OCIArtifact ))
@@ -213,7 +214,7 @@ func ProcessPlatformAndConfig(platform string, envName string) (hcl2nix.OCIArtif
213214 for _ , ec := range conf .OCIArtifact {
214215 errStr := ec .Validate (conf )
215216 if errStr != nil {
216- return hcl2nix.OCIArtifact {}, fmt .Errorf ("Config for export block %s is invalid\n Error: %s" , ec .Name , * errStr )
217+ return hcl2nix.OCIArtifact {}, "" , fmt .Errorf ("Config for export block %s is invalid\n Error: %s" , ec .Name , * errStr )
217218 }
218219
219220 if ec .Environment == envName {
@@ -225,10 +226,10 @@ func ProcessPlatformAndConfig(platform string, envName string) (hcl2nix.OCIArtif
225226 }
226227
227228 if ! found {
228- return hcl2nix.OCIArtifact {}, fmt .Errorf ("error: No such environment found. Valid oci environment that can be built are: %s" , strings .Join (envNames , ", " ))
229+ return hcl2nix.OCIArtifact {}, "" , fmt .Errorf ("error: No such environment found. Valid oci environment that can be built are: %s" , strings .Join (envNames , ", " ))
229230 }
230231
231- return env , nil
232+ return env , plat , nil
232233}
233234
234235func genOCIAttrName (env , platform string ) string {
0 commit comments