Warn users running an old proxy version
As we approach https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/872, we should add a warning message on startup for users who are running a version older than latest.
In terms of implementation, probably the simplest thing to do is add a text file into our GCS bucket that holds release binaries. As part of publishing new versions, we could update this text file.
We could write the text file right after this line:
https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/d0036fe229c9902c0fb2305dcaf9bb1e05b5f2cb/.kokoro/release_artifacts.sh#L46.
Another idea. We could just query the bucket, looking for the latest version with something like this:
package main
import (
"context"
"fmt"
"strings"
"cloud.google.com/go/storage"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
panic(err)
}
bkt := client.Bucket("cloudsql-proxy")
var versions []string
it := bkt.Objects(ctx, nil)
for {
attrs, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
panic(err)
}
res := strings.Split(attrs.Name, "/")
if len(res) != 2 {
// malformed object key; skip it
continue
}
version := res[0]
if strings.HasSuffix(version, "-dev") {
continue
}
versions = append(versions, version)
}
fmt.Println(versions[len(versions)-1])
}
Closing this out as infeasible. We'll add a log message to v1 when we're ready. Otherwise, v2 won't have this feature.