@@ -39,23 +39,19 @@ func (tc *tasConfigManager) LoadAndValidate(ctx context.Context,
3939 version int ,
4040 path string ,
4141 eventType core.EventType ,
42- licenseTier core.Tier ) (interface {}, error ) {
43- if version < global .NewTASVersion {
44- return tc .loadAndValidateV1 (ctx , path , eventType , licenseTier )
45- }
46- return tc .loadAndValidateV2 (ctx , path , eventType , licenseTier )
47- }
48-
49- func (tc * tasConfigManager ) loadAndValidateV1 (ctx context.Context ,
50- filePath string ,
51- eventType core.EventType ,
52- licenseTier core.Tier ) (* core.TASConfig , error ) {
53- yamlFile , err := os .ReadFile (filePath )
42+ licenseTier core.Tier , tasFilePathInRepo string ) (interface {}, error ) {
43+ yamlFile , err := os .ReadFile (path )
5444 if err != nil {
55- tc .logger .Errorf ("Error while reading file %s, error %v" , filePath , err )
56- return nil , errs .New (fmt .Sprintf ("Error while reading configuration file at path: %s" , filePath ))
45+ if errors .Is (err , os .ErrNotExist ) {
46+ return nil , errs .New (fmt .Sprintf ("Configuration file not found at path: %s" , tasFilePathInRepo ))
47+ }
48+ tc .logger .Errorf ("Error while reading file, error %v" , err )
49+ return nil , errs .New (fmt .Sprintf ("Error while reading configuration file at path: %s" , tasFilePathInRepo ))
5750 }
58- return tc .validateYMLV1 (ctx , yamlFile , eventType , licenseTier , filePath )
51+ if version < global .NewTASVersion {
52+ return tc .validateYMLV1 (ctx , yamlFile , eventType , licenseTier , tasFilePathInRepo )
53+ }
54+ return tc .validateYMLV2 (ctx , yamlFile , eventType , licenseTier , tasFilePathInRepo )
5955}
6056
6157func (tc * tasConfigManager ) validateYMLV1 (ctx context.Context ,
@@ -170,21 +166,6 @@ func (tc *tasConfigManager) GetVersion(path string) (int, error) {
170166 return versionYml , nil
171167}
172168
173- func (tc * tasConfigManager ) loadAndValidateV2 (ctx context.Context ,
174- yamlFilePath string ,
175- eventType core.EventType ,
176- licenseTier core.Tier ) (* core.TASConfigV2 , error ) {
177- yamlFile , err := os .ReadFile (yamlFilePath )
178- if err != nil {
179- if errors .Is (err , os .ErrNotExist ) {
180- return nil , errs .New (fmt .Sprintf ("Configuration file not found at path: %s" , yamlFilePath ))
181- }
182- tc .logger .Errorf ("Error while reading file, error %v" , err )
183- return nil , errs .New (fmt .Sprintf ("Error while reading configuration file at path: %s" , yamlFilePath ))
184- }
185- return tc .validateYMLV2 (ctx , yamlFile , eventType , licenseTier , yamlFilePath )
186- }
187-
188169func (tc * tasConfigManager ) GetTasConfigFilePath (payload * core.Payload ) (string , error ) {
189170 // load tas yaml file
190171 filePath , err := utils .GetTASFilePath (payload .TasFileName )
0 commit comments