@@ -29,6 +29,7 @@ import (
2929 "strings"
3030 "time"
3131
32+ "github.com/kitops-ml/kitops/pkg/output"
3233 modelspecv1 "github.com/modelpack/model-spec/specs-go/v1"
3334 "github.com/opencontainers/go-digest"
3435 "go.yaml.in/yaml/v3"
@@ -140,16 +141,17 @@ type (
140141 }
141142)
142143
143- func (kf * KitFile ) LoadModel (kitfileContent io.ReadCloser ) error {
144+ func (kf * KitFile ) LoadModel (kitfileContent io.ReadCloser ) ( err error ) {
144145 decoder := yaml .NewDecoder (kitfileContent )
145146 decoder .KnownFields (true )
146147 if err := decoder .Decode (kf ); err != nil {
147148 return err
148149 }
149- if err := kf .Validate (); err != nil {
150- return err
150+ warnings , err := kf .Validate ()
151+ for _ , warning := range warnings {
152+ output .Logln (output .LogLevelWarn , warning )
151153 }
152- return nil
154+ return err
153155}
154156
155157func (kf * KitFile ) MarshalToJSON () ([]byte , error ) {
@@ -171,15 +173,16 @@ func (kf *KitFile) MarshalToYAML() ([]byte, error) {
171173 return buf .Bytes (), nil
172174}
173175
174- func (kf * KitFile ) Validate () error {
176+ func (kf * KitFile ) Validate () (warnings []string , err error ) {
177+ if kf .ManifestVersion != "1.0.0" {
178+ warnings = append (warnings , fmt .Sprintf ("Unrecognized manifestVersion %s: treating Kitfile as 1.0.0" , kf .ManifestVersion ))
179+ }
180+
175181 var errs []string
176182 addErr := func (format string , a ... any ) {
177183 s := fmt .Sprintf (format , a ... )
178184 errs = append (errs , fmt .Sprintf (" * %s" , s ))
179185 }
180- if kf .ManifestVersion != "1.0.0" {
181- addErr ("invalid manifestVersion: expect 1.0.0 but got %s" , kf .ManifestVersion )
182- }
183186
184187 // Map of paths to the component that uses them; used to detect duplicate paths
185188 paths := map [string ][]string {}
@@ -287,10 +290,10 @@ func (kf *KitFile) Validate() error {
287290 if len (errs ) > 0 {
288291 // Iterating through the paths map is random; sort to get a consistent message
289292 slices .Sort (errs )
290- return fmt .Errorf ("errors while validating Kitfile: \n %s" , strings .Join (errs , "\n " ))
293+ return warnings , fmt .Errorf ("errors while validating Kitfile: \n %s" , strings .Join (errs , "\n " ))
291294 }
292295
293- return nil
296+ return warnings , nil
294297}
295298
296299func (kf * KitFile ) ToModelPackConfig (diffIDs []digest.Digest ) modelspecv1.Model {
0 commit comments