Skip to content

Commit

Permalink
Get eolinf from csv
Browse files Browse the repository at this point in the history
  • Loading branch information
chaspy committed Feb 7, 2021
1 parent e41912c commit 4ec3db3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rds"
"github.com/jszwec/csvutil"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
Expand All @@ -20,6 +22,11 @@ type RDSInfo struct {
Engine string
EngineVersion string
}
type EOLInfo struct {
Engine string
EOLEngineVersion string
EOLDate string
}

var (
//nolint:gochecknoglobals
Expand All @@ -34,6 +41,13 @@ var (
)

func main() {
eolinfo, err := readEOLInfoCSV()
if err != nil {
log.Fatal(err)
}

fmt.Println(eolinfo)

interval, err := getInterval()
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -199,3 +213,18 @@ func getRDSInstances() ([]RDSInfo, error) {

return RDSInfos, nil
}

func readEOLInfoCSV() ([]EOLInfo, error) {
var eolInfos []EOLInfo

csv, err := ioutil.ReadFile("eolinfo.csv")
if err != nil {
return []EOLInfo{}, fmt.Errorf("failed to read CSV file: %w", err)
}

if err := csvutil.Unmarshal(csv, &eolInfos); err != nil {
return []EOLInfo{}, fmt.Errorf("failed to unmarshal: %w", err)
}

return eolInfos, nil
}

0 comments on commit 4ec3db3

Please sign in to comment.