Skip to content

Commit

Permalink
feat(cmd/k8s/create_oidc_user): Add util to simple create OIDC user i…
Browse files Browse the repository at this point in the history
…n kubeconfig (for kubelogin)
  • Loading branch information
ondrejsika committed Jun 28, 2023
1 parent 2fd0394 commit 05c3394
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import (
_ "github.com/sikalabs/slu/cmd/ip"
_ "github.com/sikalabs/slu/cmd/ip_local"
_ "github.com/sikalabs/slu/cmd/k8s"
_ "github.com/sikalabs/slu/cmd/k8s/create_oidc_user"
_ "github.com/sikalabs/slu/cmd/k8s/delete_ns"
_ "github.com/sikalabs/slu/cmd/k8s/delete_pods"
_ "github.com/sikalabs/slu/cmd/k8s/get"
Expand Down
64 changes: 64 additions & 0 deletions cmd/k8s/create_oidc_user/create_oidc_user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package create_oidc_user

import (
k8s_cmd "github.com/sikalabs/slu/cmd/k8s"
"github.com/sikalabs/slu/utils/k8s_oidc_utils"

"github.com/spf13/cobra"
)

var FlagName string
var FlagIssuerUrl string
var FlagClientId string
var FlagClientSecret string
var FlagDry bool

var Cmd = &cobra.Command{
Use: "create-oidc-user",
Short: "Create OIDC User for kubelogin",
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
k8s_oidc_utils.CreateOidcUser(
FlagName, FlagIssuerUrl,
FlagClientId, FlagClientSecret,
FlagDry,
)
},
}

func init() {
k8s_cmd.Cmd.AddCommand(Cmd)
Cmd.Flags().StringVar(
&FlagName,
"name",
"",
"Name of user in kubeconfig",
)
Cmd.MarkFlagRequired("name")
Cmd.Flags().StringVar(
&FlagIssuerUrl,
"issuer-url",
"",
"OIDC Issuer url (eg.: https://sso.sikalabs.com/realm/sikalabs)",
)
Cmd.MarkFlagRequired("issuer-url")
Cmd.Flags().StringVar(
&FlagClientId,
"client-id",
"",
"OIDC client-id",
)
Cmd.MarkFlagRequired("client-id")
Cmd.Flags().StringVar(
&FlagClientSecret,
"client-secret",
"",
"OIDC Client Secret",
)
Cmd.Flags().BoolVar(
&FlagDry,
"dry",
false,
"Dry run",
)
}

0 comments on commit 05c3394

Please sign in to comment.