Implement version handling in check
This commit is contained in:
parent
75bd20c775
commit
99eef916b4
1 changed files with 11 additions and 2 deletions
|
@ -147,8 +147,10 @@ func (r *Resource) Check() error {
|
||||||
return fmt.Errorf("could not parse input from Concourse: %w", err)
|
return fmt.Errorf("could not parse input from Concourse: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var inputDate time.Time
|
||||||
|
|
||||||
if len(input.Version.Date) > 0 {
|
if len(input.Version.Date) > 0 {
|
||||||
_, err = parseISODate(input.Version.Date)
|
inputDate, err = parseISODate(input.Version.Date)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not interpret version from Concourse as date: %w", err)
|
return fmt.Errorf("could not interpret version from Concourse as date: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,14 @@ func (r *Resource) Check() error {
|
||||||
for _, item := range dsaData.Items {
|
for _, item := range dsaData.Items {
|
||||||
parts := strings.SplitN(item.Title, " ", 2)
|
parts := strings.SplitN(item.Title, " ", 2)
|
||||||
|
|
||||||
dates.addVersion(Version{Date: item.Date, DSANumber: parts[0]})
|
versionDate, err := parseISODate(item.Date)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not interpret date from RDF feed as date: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if inputDate.IsZero() || inputDate.Before(versionDate) {
|
||||||
|
dates.addVersion(Version{Date: item.Date, DSANumber: parts[0]})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(dates)
|
sort.Sort(dates)
|
||||||
|
|
Loading…
Reference in a new issue