Skip to content

Commit 5dfdde6

Browse files
authored
feat: add kubelogin binary support for Kubernetes OpenID Connect authentication (#74)
This pull request adds support for the `kubelogin` binary (a kubectl plugin for Kubernetes OpenID Connect authentication) to the project. The changes include updating documentation, importing the new binary, registering it in the main command, and implementing the binary logic. **New binary integration:** * Added a new `kubelogin` binary implementation in `pkg/binaries/kubelogin/kubelogin.go`, including logic for downloading, extracting version, and handling binary options. * Registered the `kubelogin` binary in the main application by importing it in `cmd/b/main.go` and adding it to the list of managed binaries. [[1]](diffhunk://#diff-9220de3f3af10d1a2eb38298eefa2c9cc92852596770de03bc85dbbb6d136f9fR21) [[2]](diffhunk://#diff-9220de3f3af10d1a2eb38298eefa2c9cc92852596770de03bc85dbbb6d136f9fR62) **Documentation update:** * Updated `README.md` to include `kubelogin` in the list of available binaries, with a link to its GitHub repository and a brief description.
1 parent 86f192e commit 5dfdde6

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Have a look at [pkg/binaries](./pkg/binaries/) for prepackaged binaries.
148148
- [k9s](https://github.com/derailed/k9s) - Kubernetes CLI to manage your clusters
149149
- [kind](https://github.com/kubernetes-sigs/kind) - Kubernetes IN Docker
150150
- [kubectl](https://github.com/kubernetes/kubectl) - Kubernetes CLI to manage your clusters
151+
- [kubelogin - int128](https://github.com/int128/kubelogin) - kubectl plugin for Kubernetes OpenID Connect authentication (kubectl oidc-login)
151152
- [kubeseal](https://github.com/bitnami-labs/sealed-secrets) - A Kubernetes controller and tool for one-way encrypted Secrets
152153
- [kustomize](https://github.com/kubernetes-sigs/kustomize) - Kubernetes native configuration management
153154
- [mkcert](https://github.com/FiloSottile/mkcert) - Create locally-trusted development certificates

cmd/b/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/fentas/b/pkg/binaries/k9s"
1919
"github.com/fentas/b/pkg/binaries/kind"
2020
"github.com/fentas/b/pkg/binaries/kubectl"
21+
"github.com/fentas/b/pkg/binaries/kubelogin"
2122
"github.com/fentas/b/pkg/binaries/kubeseal"
2223
"github.com/fentas/b/pkg/binaries/kustomize"
2324
"github.com/fentas/b/pkg/binaries/mkcert"
@@ -58,6 +59,7 @@ func main() {
5859
k9s.Binary(o),
5960
kind.Binary(o),
6061
kubectl.Binary(o),
62+
kubelogin.Binary(o),
6163
kubeseal.Binary(o),
6264
kustomize.Binary(o),
6365
mkcert.Binary(o),
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package kubelogin
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"runtime"
7+
"strings"
8+
9+
"github.com/fentas/b/pkg/binaries"
10+
"github.com/fentas/b/pkg/binary"
11+
)
12+
13+
func Binary(options *binaries.BinaryOptions) *binary.Binary {
14+
if options == nil {
15+
options = &binaries.BinaryOptions{
16+
Context: context.Background(),
17+
}
18+
}
19+
return &binary.Binary{
20+
Context: options.Context,
21+
Envs: options.Envs,
22+
Tracker: options.Tracker,
23+
Version: options.Version,
24+
Name: "kubelogin",
25+
GitHubRepo: "int128/kubelogin",
26+
URLF: func(b *binary.Binary) (string, error) {
27+
return fmt.Sprintf(
28+
"https://github.com/%s/releases/download/%s/kubelogin_%s_%s.zip",
29+
b.GitHubRepo,
30+
b.Version,
31+
runtime.GOOS,
32+
runtime.GOARCH,
33+
), nil
34+
},
35+
VersionF: binary.GithubLatest,
36+
IsZip: true,
37+
VersionLocalF: func(b *binary.Binary) (string, error) {
38+
s, err := b.Exec("--version")
39+
if err != nil {
40+
return "", err
41+
}
42+
v := strings.Split(s, " ")
43+
return v[len(v)-1], nil
44+
},
45+
}
46+
}

0 commit comments

Comments
 (0)