ribbybibby / ssl_exporter

Exports Prometheus metrics for TLS certificates
Apache License 2.0
504 stars 95 forks source link

Is the go.mod file broken? #91

Closed jamesalbert closed 2 years ago

jamesalbert commented 2 years ago

Noticed:

$ go list -m -versions github.com/ribbybibby/ssl_exporter
github.com/ribbybibby/ssl_exporter v0.1.0 v0.2.0 v0.3.0 v0.4.0 v0.5.0 v0.6.0 v1.0.0-rc.0 v1.0.0-test-tag v1.0.0-test-tag2 v1.0.0 v1.0.1

which is a bit behind recent releases. Without knowing too much about why this would happen, this SO answer suggests the go.mod file might be invalid, but I'm not sure. Is there any more info on this?

jamesalbert commented 2 years ago

also, when trying to get the latest version directly, I get:

$ go get github.com/ribbybibby/ssl_exporter@master
github.com/ribbybibby/ssl_exporter imports
        github.com/ribbybibby/ssl_exporter/prober imports
        k8s.io/client-go/kubernetes: cannot find module providing package k8s.io/client-go/kubernetes
github.com/ribbybibby/ssl_exporter imports
        github.com/ribbybibby/ssl_exporter/prober imports
        k8s.io/client-go/plugin/pkg/client/auth/oidc: cannot find module providing package k8s.io/client-go/plugin/pkg/client/auth/oidc
github.com/ribbybibby/ssl_exporter imports
        github.com/ribbybibby/ssl_exporter/prober imports
        k8s.io/client-go/tools/clientcmd: cannot find module providing package k8s.io/client-go/tools/clientcmd
go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.
jamesalbert commented 2 years ago

for additional context, I was able to import this package by forking this repo and regenerating the go.mod file. Granted, I'm a go noob these days, so take what I did with a grain of salt. It looks like it added packages that weren't there originally

ribbybibby commented 2 years ago

Hi @jamesalbert. I think this is down to the fact that I bumped from v1 to v2 without amending the module path: https://go.dev/doc/modules/release-workflow. I must admit I was unaware of this requirement at the time.

That being said, this project is not intended to be imported by anyone, so I don't see it as a huge problem.

jamesalbert commented 2 years ago

Nice @ribbybibby glad to hear that's the case. I was scratching my head at that for a bit :smile:

I actually have an open pull request to include this project into grafana/agent: https://github.com/grafana/agent/pull/1692

That PR is currently pointed to my fork and I was really hoping to point it back to yours once this was resolved. Would really like to use this exporter in our grafana stack.

jamesalbert commented 2 years ago

@ribbybibby when I regenerated go.mod, I didn't notice any module path change, but whatever it did, it allowed me to pull the most recent version. If I rename all those module path references back to their original, would you accept this as a pr: https://github.com/ribbybibby/ssl_exporter/compare/master...jamesalbert:master

or maybe there's other stuff you wanted to add? I'm not sure

ribbybibby commented 2 years ago

I've made the module path change and cut a new version. Can you try importing with:

require github.com/ribbybibby/ssl_exporter/v2 v2.4.1

This seems to work for me.

jamesalbert commented 2 years ago

Thanks for updating that! ~There seems to be one more point of contention (at least integrating it into that project). I think it's here: https://github.com/ribbybibby/ssl_exporter/blob/master/go.mod#L14~

~k8s.io/client-go@1.5.2 (different from the rest of the k8s.io dependencies at 0.24.0) seems to break version requirements. I'm getting a lot of~

~I noticed my fork brought it back down to 0.24.0 and is the version the target repo is pointed at. Is there any way we can pin it back down?~

Oh, this may have been my fault actually. I just needed this:

replace (
    k8s.io/api => k8s.io/api v0.24.0
    k8s.io/apimachinery => k8s.io/apimachinery v0.24.0
    k8s.io/client-go => k8s.io/client-go v0.24.0
)

It seems to be working now. You rock man, thanks writing this awesome exporter btw 😎