@ -59,6 +59,7 @@ const (
type tenantFlags struct {
type tenantFlags struct {
namespaces [ ] string
namespaces [ ] string
clusterRole string
clusterRole string
account string
}
}
var tenantArgs tenantFlags
var tenantArgs tenantFlags
@ -66,6 +67,7 @@ var tenantArgs tenantFlags
func init ( ) {
func init ( ) {
createTenantCmd . Flags ( ) . StringSliceVar ( & tenantArgs . namespaces , "with-namespace" , nil , "namespace belonging to this tenant" )
createTenantCmd . Flags ( ) . StringSliceVar ( & tenantArgs . namespaces , "with-namespace" , nil , "namespace belonging to this tenant" )
createTenantCmd . Flags ( ) . StringVar ( & tenantArgs . clusterRole , "cluster-role" , "cluster-admin" , "cluster role of the tenant role binding" )
createTenantCmd . Flags ( ) . StringVar ( & tenantArgs . clusterRole , "cluster-role" , "cluster-admin" , "cluster role of the tenant role binding" )
createTenantCmd . Flags ( ) . StringVar ( & tenantArgs . account , "with-service-account" , "" , "service account belonging to this tenant" )
createCmd . AddCommand ( createTenantCmd )
createCmd . AddCommand ( createTenantCmd )
}
}
@ -107,9 +109,17 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
}
}
namespaces = append ( namespaces , namespace )
namespaces = append ( namespaces , namespace )
accountName := tenant
if tenantArgs . account != "" {
accountName = tenantArgs . account
}
if err := validation . IsQualifiedName ( accountName ) ; len ( err ) > 0 {
return fmt . Errorf ( "invalid service-account name '%s': %v" , accountName , err )
}
account := corev1 . ServiceAccount {
account := corev1 . ServiceAccount {
ObjectMeta : metav1 . ObjectMeta {
ObjectMeta : metav1 . ObjectMeta {
Name : tenant ,
Name : accou ntName ,
Namespace : ns ,
Namespace : ns ,
Labels : objLabels ,
Labels : objLabels ,
} ,
} ,
@ -131,7 +141,7 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
} ,
} ,
{
{
Kind : "ServiceAccount" ,
Kind : "ServiceAccount" ,
Name : ten ant,
Name : accou ntName ,
Namespace : ns ,
Namespace : ns ,
} ,
} ,
} ,
} ,