mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
save IAM export assets relative at a folder prefix (#15355)
This commit is contained in:
parent
2fddcc6a11
commit
7560fb6f9a
@ -1543,6 +1543,7 @@ const (
|
|||||||
groupPolicyMappingsFile = "group_mappings.json"
|
groupPolicyMappingsFile = "group_mappings.json"
|
||||||
stsUserPolicyMappingsFile = "stsuser_mappings.json"
|
stsUserPolicyMappingsFile = "stsuser_mappings.json"
|
||||||
stsGroupPolicyMappingsFile = "stsgroup_mappings.json"
|
stsGroupPolicyMappingsFile = "stsgroup_mappings.json"
|
||||||
|
iamAssetsDir = "iam-assets"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExportIAMHandler - exports all iam info as a zipped file
|
// ExportIAMHandler - exports all iam info as a zipped file
|
||||||
@ -1594,8 +1595,9 @@ func (a adminAPIHandlers) ExportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
stsUserPolicyMappingsFile,
|
stsUserPolicyMappingsFile,
|
||||||
stsGroupPolicyMappingsFile,
|
stsGroupPolicyMappingsFile,
|
||||||
}
|
}
|
||||||
for _, iamFile := range iamFiles {
|
for _, f := range iamFiles {
|
||||||
switch iamFile {
|
iamFile := pathJoin(iamAssetsDir, f)
|
||||||
|
switch f {
|
||||||
case allPoliciesFile:
|
case allPoliciesFile:
|
||||||
allPolicies, err := globalIAMSys.ListPolicies(ctx, "")
|
allPolicies, err := globalIAMSys.ListPolicies(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1821,7 +1823,8 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
// import policies first
|
// import policies first
|
||||||
{
|
{
|
||||||
f, err := zr.Open(allPoliciesFile)
|
|
||||||
|
f, err := zr.Open(pathJoin(iamAssetsDir, allPoliciesFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -1856,7 +1859,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import users
|
// import users
|
||||||
{
|
{
|
||||||
f, err := zr.Open(allUsersFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, allUsersFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -1933,7 +1936,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import groups
|
// import groups
|
||||||
{
|
{
|
||||||
f, err := zr.Open(allGroupsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, allGroupsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -1971,7 +1974,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import service accounts
|
// import service accounts
|
||||||
{
|
{
|
||||||
f, err := zr.Open(allSvcAcctsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, allSvcAcctsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -2067,7 +2070,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import user policy mappings
|
// import user policy mappings
|
||||||
{
|
{
|
||||||
f, err := zr.Open(userPolicyMappingsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, userPolicyMappingsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -2106,7 +2109,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import group policy mappings
|
// import group policy mappings
|
||||||
{
|
{
|
||||||
f, err := zr.Open(groupPolicyMappingsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, groupPolicyMappingsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -2135,7 +2138,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import sts user policy mappings
|
// import sts user policy mappings
|
||||||
{
|
{
|
||||||
f, err := zr.Open(stsUserPolicyMappingsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, stsUserPolicyMappingsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
@ -2174,7 +2177,7 @@ func (a adminAPIHandlers) ImportIAM(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// import sts group policy mappings
|
// import sts group policy mappings
|
||||||
{
|
{
|
||||||
f, err := zr.Open(stsGroupPolicyMappingsFile)
|
f, err := zr.Open(pathJoin(iamAssetsDir, stsGroupPolicyMappingsFile))
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case errors.Is(err, os.ErrNotExist):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
|
Loading…
Reference in New Issue
Block a user