-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/k8s/create_oidc_user): Add util to simple create OIDC user i…
…n kubeconfig (for kubelogin)
- Loading branch information
1 parent
2fd0394
commit 05c3394
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) | ||
} |