Skip to content

Commit b965a76

Browse files
committed
Merge branch 'ping' of https://github.com/dormanze/mc into ping
* 'ping' of https://github.com/dormanze/mc: (44 commits) mv:support set tag and checksum (minio#5133) ping: support ping a specified node and remove duplicate port printing (minio#5132) feat: add `--storage-class` option to `mc put` subcommand (minio#5228) mirror and cp support set the maximum number of threads (minio#5220) Some paths like url2Stat will send resource with backslashes on windows (minio#5226) Include ARN in "replicate list" output (minio#5215) Update build version (minio#5218) fix: add checks for nil HTTP in admin-trace matches func (minio#5216) remove fips 'mc' container Dockerfile Fix deletion of previously sync'd buckets and objects during mc-mirror (minio#5205) Add STATUS column to batch job list table output (minio#5202) fix: remove check if lock config exists before set (minio#5203) removing config cmd (minio#5201) fix: support chained mirror properly for delete propagation minio#4558 (minio#5197) Change support profile defaults (minio#5198) Explicitly set file permissions for admin-cluster-{bucket,iam}-export… (minio#5194) Add support for catalog batch job type (minio#5150) Add `idp openid accesskey` commands (minio#5182) feat: add deletemarker info for batch status (minio#5191) mirror: skip status message from excluded buckets (minio#5190) ...
2 parents 45dd67f + f72d75d commit b965a76

File tree

88 files changed

+1650
-800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1650
-800
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ mc
1414
mc.RELEASE*
1515
mc.gz
1616
.DS_Store
17-
.vscode/
17+
.vscode/
18+
.bin/

.golangci.yml

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
1+
version: "2"
12
linters:
2-
disable-all: true
3+
default: none
34
enable:
4-
- typecheck
5-
- goimports
6-
- misspell
7-
- staticcheck
5+
- gomodguard
86
- govet
9-
- revive
107
- ineffassign
11-
- gomodguard
12-
- gofmt
8+
- misspell
9+
- revive
10+
- staticcheck
1311
- unused
12+
settings:
13+
misspell:
14+
locale: US
15+
exclusions:
16+
generated: lax
17+
rules:
18+
- path: (.+)\.go$
19+
text: instead of using struct literal
20+
- path: (.+)\.go$
21+
text: should have a package comment
22+
- path: (.+)\.go$
23+
text: error strings should not be capitalized or end with punctuation or a newline
24+
- path: (.+)\.go$
25+
text: error strings should not end with punctuation or newlines
26+
- path: (.+)\.go$
27+
text: error strings should not be capitalized
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
32+
formatters:
33+
enable:
34+
- gofmt
1435
- gofumpt
15-
16-
linters-settings:
17-
golint:
18-
min-confidence: 0
19-
20-
misspell:
21-
locale: US
22-
23-
# Choose whether or not to use the extra rules that are disabled
24-
# by default
25-
extra-rules: false
26-
27-
issues:
28-
exclude-use-default: false
29-
exclude:
30-
- instead of using struct literal
31-
- should have a package comment
32-
- error strings should not be capitalized or end with punctuation or a newline
36+
- goimports
37+
exclusions:
38+
generated: lax
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$

Dockerfile.release.fips

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmd/admin-accesskey-info.go

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
package cmd
1919

2020
import (
21+
"strings"
22+
"time"
23+
24+
"github.com/charmbracelet/lipgloss"
25+
humanize "github.com/dustin/go-humanize"
2126
"github.com/minio/cli"
27+
json "github.com/minio/colorjson"
28+
"github.com/minio/madmin-go/v3"
29+
"github.com/minio/mc/pkg/probe"
2230
)
2331

2432
var adminAccesskeyInfoCmd = cli.Command{
@@ -45,6 +53,150 @@ EXAMPLES:
4553
`,
4654
}
4755

56+
type accesskeyMessage struct {
57+
op string
58+
Status string `json:"status"`
59+
AccessKey string `json:"accessKey"`
60+
SecretKey string `json:"secretKey,omitempty"`
61+
STS bool `json:"sts,omitempty"`
62+
ParentUser string `json:"parentUser,omitempty"`
63+
AccountStatus string `json:"accountStatus,omitempty"`
64+
ImpliedPolicy bool `json:"impliedPolicy,omitempty"`
65+
Policy json.RawMessage `json:"policy,omitempty"`
66+
Name string `json:"name,omitempty"`
67+
Description string `json:"description,omitempty"`
68+
Expiration *time.Time `json:"expiration,omitempty"`
69+
Provider string `json:"provider,omitempty"`
70+
ProviderInfo providerInfo `json:"providerInfo,omitempty"`
71+
}
72+
73+
func (m accesskeyMessage) String() string {
74+
labelStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#04B575")) // green
75+
o := strings.Builder{}
76+
switch m.op {
77+
case "info":
78+
expirationStr := "NONE"
79+
if m.Expiration != nil && !m.Expiration.IsZero() && !m.Expiration.Equal(timeSentinel) {
80+
expirationStr = humanize.Time(*m.Expiration)
81+
}
82+
policyStr := "embedded"
83+
if m.ImpliedPolicy {
84+
policyStr = "implied"
85+
}
86+
statusStr := "enabled"
87+
if m.AccountStatus == "off" {
88+
statusStr = "disabled"
89+
}
90+
stsStr := "false"
91+
if m.STS {
92+
stsStr = "true"
93+
}
94+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Access Key:"), m.AccessKey))
95+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Parent User:"), m.ParentUser))
96+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Status:"), statusStr))
97+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Policy:"), policyStr))
98+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Name:"), m.Name))
99+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Description:"), m.Description))
100+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Expiration:"), expirationStr))
101+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("STS:"), stsStr))
102+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Provider:"), m.Provider))
103+
if m.ProviderInfo != nil {
104+
o.WriteString(iFmt(0, "%s\n", labelStyle.Render("Provider Specific Info:")))
105+
o.WriteString(m.ProviderInfo.String())
106+
}
107+
case "create":
108+
expirationStr := "NONE"
109+
if m.Expiration != nil && !m.Expiration.IsZero() && !m.Expiration.Equal(timeSentinel) {
110+
expirationStr = m.Expiration.String()
111+
}
112+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Access Key:"), m.AccessKey))
113+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Secret Key:"), m.SecretKey))
114+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Expiration:"), expirationStr))
115+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Name:"), m.Name))
116+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Description:"), m.Description))
117+
case "remove":
118+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully removed access key `%s`.", m.AccessKey)))
119+
case "edit":
120+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully edited access key `%s`.", m.AccessKey)))
121+
case "enable":
122+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully enabled access key `%s`.", m.AccessKey)))
123+
case "disable":
124+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully disabled access key `%s`.", m.AccessKey)))
125+
}
126+
return o.String()
127+
}
128+
129+
func (m accesskeyMessage) JSON() string {
130+
m.Status = "success"
131+
jsonMessageBytes, e := json.MarshalIndent(m, "", " ")
132+
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
133+
134+
return string(jsonMessageBytes)
135+
}
136+
137+
type providerInfo interface {
138+
String() string
139+
}
140+
48141
func mainAdminAccesskeyInfo(ctx *cli.Context) error {
49142
return commonAccesskeyInfo(ctx)
50143
}
144+
145+
func commonAccesskeyInfo(ctx *cli.Context) error {
146+
if len(ctx.Args()) < 2 {
147+
showCommandHelpAndExit(ctx, 1) // last argument is exit code
148+
}
149+
150+
args := ctx.Args()
151+
aliasedURL := args.Get(0)
152+
accessKeys := args.Tail()
153+
154+
// Create a new MinIO Admin Client
155+
client, err := newAdminClient(aliasedURL)
156+
fatalIf(err, "Unable to initialize admin connection.")
157+
158+
for _, accessKey := range accessKeys {
159+
// Assume service account by default
160+
res, e := client.InfoAccessKey(globalContext, accessKey)
161+
fatalIf(probe.NewError(e), "Unable to get info for access key.")
162+
m := accesskeyMessage{
163+
op: "info",
164+
AccessKey: accessKey,
165+
ParentUser: res.ParentUser,
166+
AccountStatus: res.AccountStatus,
167+
ImpliedPolicy: res.ImpliedPolicy,
168+
Policy: json.RawMessage(res.Policy),
169+
Name: res.Name,
170+
Description: res.Description,
171+
Expiration: nilExpiry(res.Expiration),
172+
Provider: res.UserProvider,
173+
}
174+
175+
switch res.UserProvider {
176+
case madmin.LDAPProvider:
177+
info := res.LDAPSpecificInfo
178+
m.ProviderInfo = ldapAccessKeyInfo{
179+
Username: info.Username,
180+
}
181+
case madmin.OpenIDProvider:
182+
info := res.OpenIDSpecificInfo
183+
m.ProviderInfo = openIDAccessKeyInfo{
184+
ConfigName: info.ConfigName,
185+
UserID: info.UserID,
186+
UserIDClaim: info.UserIDClaim,
187+
DisplayName: info.DisplayName,
188+
DisplayNameClaim: info.DisplayNameClaim,
189+
}
190+
}
191+
printMsg(m)
192+
}
193+
194+
return nil
195+
}
196+
197+
func nilExpiry(expiry *time.Time) *time.Time {
198+
if expiry != nil && expiry.Equal(timeSentinel) {
199+
return nil
200+
}
201+
return expiry
202+
}

0 commit comments

Comments
 (0)