repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
minio/mc | cmd/config-migrate.go | migrateConfig | func migrateConfig() {
// Migrate config V1 to V101
migrateConfigV1ToV101()
// Migrate config V101 to V2
migrateConfigV101ToV2()
// Migrate config V2 to V3
migrateConfigV2ToV3()
// Migrate config V3 to V4
migrateConfigV3ToV4()
// Migrate config V4 to V5
migrateConfigV4ToV5()
// Migrate config V5 to V6
migra... | go | func migrateConfig() {
// Migrate config V1 to V101
migrateConfigV1ToV101()
// Migrate config V101 to V2
migrateConfigV101ToV2()
// Migrate config V2 to V3
migrateConfigV2ToV3()
// Migrate config V3 to V4
migrateConfigV3ToV4()
// Migrate config V4 to V5
migrateConfigV4ToV5()
// Migrate config V5 to V6
migra... | [
"func",
"migrateConfig",
"(",
")",
"{",
"// Migrate config V1 to V101",
"migrateConfigV1ToV101",
"(",
")",
"\n",
"// Migrate config V101 to V2",
"migrateConfigV101ToV2",
"(",
")",
"\n",
"// Migrate config V2 to V3",
"migrateConfigV2ToV3",
"(",
")",
"\n",
"// Migrate config V3... | // migrate config files from the any older version to the latest. | [
"migrate",
"config",
"files",
"from",
"the",
"any",
"older",
"version",
"to",
"the",
"latest",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L29-L48 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV1ToV101 | func migrateConfigV1ToV101() {
if !isMcConfigExists() {
return
}
mcCfgV1, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV1())
fatalIf(probe.NewError(e), "Unable to load config version `1`.")
// If loaded config version does not match 1.0.0, we do nothing.
if mcCfgV1.Version() != "1.0.0" {
return... | go | func migrateConfigV1ToV101() {
if !isMcConfigExists() {
return
}
mcCfgV1, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV1())
fatalIf(probe.NewError(e), "Unable to load config version `1`.")
// If loaded config version does not match 1.0.0, we do nothing.
if mcCfgV1.Version() != "1.0.0" {
return... | [
"func",
"migrateConfigV1ToV101",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"mcCfgV1",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV1",
"(",
")"... | // Migrate from config version 1.0 to 1.0.1. Populate example entries and save it back. | [
"Migrate",
"from",
"config",
"version",
"1",
".",
"0",
"to",
"1",
".",
"0",
".",
"1",
".",
"Populate",
"example",
"entries",
"and",
"save",
"it",
"back",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L51-L105 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV101ToV2 | func migrateConfigV101ToV2() {
if !isMcConfigExists() {
return
}
mcCfgV101, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV101())
fatalIf(probe.NewError(e), "Unable to load config version `1.0.1`.")
// update to newer version
if mcCfgV101.Version() != "1.0.1" {
return
}
cfgV2 := newConfigV2()... | go | func migrateConfigV101ToV2() {
if !isMcConfigExists() {
return
}
mcCfgV101, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV101())
fatalIf(probe.NewError(e), "Unable to load config version `1.0.1`.")
// update to newer version
if mcCfgV101.Version() != "1.0.1" {
return
}
cfgV2 := newConfigV2()... | [
"func",
"migrateConfigV101ToV2",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"mcCfgV101",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV101",
"(",
... | // Migrate from config `1.0.1` to `2`. Drop semantic versioning and move to integer versioning. No other changes. | [
"Migrate",
"from",
"config",
"1",
".",
"0",
".",
"1",
"to",
"2",
".",
"Drop",
"semantic",
"versioning",
"and",
"move",
"to",
"integer",
"versioning",
".",
"No",
"other",
"changes",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L108-L142 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV2ToV3 | func migrateConfigV2ToV3() {
if !isMcConfigExists() {
return
}
mcCfgV2, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV2())
fatalIf(probe.NewError(e), "Unable to load mc config V2.")
// update to newer version
if mcCfgV2.Version() != "2" {
return
}
cfgV3 := newConfigV3()
// Copy aliases.
... | go | func migrateConfigV2ToV3() {
if !isMcConfigExists() {
return
}
mcCfgV2, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV2())
fatalIf(probe.NewError(e), "Unable to load mc config V2.")
// update to newer version
if mcCfgV2.Version() != "2" {
return
}
cfgV3 := newConfigV3()
// Copy aliases.
... | [
"func",
"migrateConfigV2ToV3",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"mcCfgV2",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV2",
"(",
")"... | // Migrate from config `2` to `3`. Use `-` separated names for
// hostConfig using struct json tags. | [
"Migrate",
"from",
"config",
"2",
"to",
"3",
".",
"Use",
"-",
"separated",
"names",
"for",
"hostConfig",
"using",
"struct",
"json",
"tags",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L146-L182 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV3ToV4 | func migrateConfigV3ToV4() {
if !isMcConfigExists() {
return
}
mcCfgV3, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV3())
fatalIf(probe.NewError(e), "Unable to load mc config V2.")
// update to newer version
if mcCfgV3.Version() != "3" {
return
}
cfgV4 := newConfigV4()
for k, v := range mc... | go | func migrateConfigV3ToV4() {
if !isMcConfigExists() {
return
}
mcCfgV3, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV3())
fatalIf(probe.NewError(e), "Unable to load mc config V2.")
// update to newer version
if mcCfgV3.Version() != "3" {
return
}
cfgV4 := newConfigV4()
for k, v := range mc... | [
"func",
"migrateConfigV3ToV4",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"mcCfgV3",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV3",
"(",
")",
... | // Migrate from config version `3` to `4`. Introduce API Signature
// field in host config. Also Use JavaScript notation for field names. | [
"Migrate",
"from",
"config",
"version",
"3",
"to",
"4",
".",
"Introduce",
"API",
"Signature",
"field",
"in",
"host",
"config",
".",
"Also",
"Use",
"JavaScript",
"notation",
"for",
"field",
"names",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L186-L222 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV4ToV5 | func migrateConfigV4ToV5() {
if !isMcConfigExists() {
return
}
mcCfgV4, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV4())
fatalIf(probe.NewError(e), "Unable to load mc config V4.")
// update to newer version
if mcCfgV4.Version() != "4" {
return
}
cfgV5 := newConfigV5()
for k, v := range mc... | go | func migrateConfigV4ToV5() {
if !isMcConfigExists() {
return
}
mcCfgV4, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV4())
fatalIf(probe.NewError(e), "Unable to load mc config V4.")
// update to newer version
if mcCfgV4.Version() != "4" {
return
}
cfgV5 := newConfigV5()
for k, v := range mc... | [
"func",
"migrateConfigV4ToV5",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"mcCfgV4",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV4",
"(",
")",
... | // Migrate config version `4` to `5`. Rename hostConfigV4.Signature -> hostConfigV5.API. | [
"Migrate",
"config",
"version",
"4",
"to",
"5",
".",
"Rename",
"hostConfigV4",
".",
"Signature",
"-",
">",
"hostConfigV5",
".",
"API",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L225-L256 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV5ToV6 | func migrateConfigV5ToV6() {
if !isMcConfigExists() {
return
}
mcCfgV5, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV5())
fatalIf(probe.NewError(e), "Unable to load mc config V5.")
// update to newer version
if mcCfgV5.Version() != "5" {
return
}
cfgV6 := newConfigV6()
// Add new Google C... | go | func migrateConfigV5ToV6() {
if !isMcConfigExists() {
return
}
mcCfgV5, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV5())
fatalIf(probe.NewError(e), "Unable to load mc config V5.")
// update to newer version
if mcCfgV5.Version() != "5" {
return
}
cfgV6 := newConfigV6()
// Add new Google C... | [
"func",
"migrateConfigV5ToV6",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"mcCfgV5",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV5",
"(",
")",
... | // Migrate config version `5` to `6`. Add google cloud storage servers
// to host config. Also remove "." from s3 aws glob rule. | [
"Migrate",
"config",
"version",
"5",
"to",
"6",
".",
"Add",
"google",
"cloud",
"storage",
"servers",
"to",
"host",
"config",
".",
"Also",
"remove",
".",
"from",
"s3",
"aws",
"glob",
"rule",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L260-L322 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV6ToV7 | func migrateConfigV6ToV7() {
if !isMcConfigExists() {
return
}
mcCfgV6, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV6())
fatalIf(probe.NewError(e), "Unable to load mc config V6.")
if mcCfgV6.Version() != "6" {
return
}
cfgV7 := newConfigV7()
aliasIndex := 0
// old Aliases.
oldAliases :... | go | func migrateConfigV6ToV7() {
if !isMcConfigExists() {
return
}
mcCfgV6, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV6())
fatalIf(probe.NewError(e), "Unable to load mc config V6.")
if mcCfgV6.Version() != "6" {
return
}
cfgV7 := newConfigV7()
aliasIndex := 0
// old Aliases.
oldAliases :... | [
"func",
"migrateConfigV6ToV7",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"mcCfgV6",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV6",
"(",
")"... | // Migrate config version `6` to `7'. Remove alias map and introduce
// named Host config. Also no more glob match for host config entries. | [
"Migrate",
"config",
"version",
"6",
"to",
"7",
".",
"Remove",
"alias",
"map",
"and",
"introduce",
"named",
"Host",
"config",
".",
"Also",
"no",
"more",
"glob",
"match",
"for",
"host",
"config",
"entries",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L326-L401 | train |
minio/mc | cmd/config-migrate.go | migrateConfigV8ToV9 | func migrateConfigV8ToV9() {
if !isMcConfigExists() {
return
}
mcCfgV8, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV8())
fatalIf(probe.NewError(e), "Unable to load mc config V8.")
if mcCfgV8.Version() != "8" {
return
}
cfgV9 := newConfigV9()
isEmpty := true
// We dropped alias support in... | go | func migrateConfigV8ToV9() {
if !isMcConfigExists() {
return
}
mcCfgV8, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV8())
fatalIf(probe.NewError(e), "Unable to load mc config V8.")
if mcCfgV8.Version() != "8" {
return
}
cfgV9 := newConfigV9()
isEmpty := true
// We dropped alias support in... | [
"func",
"migrateConfigV8ToV9",
"(",
")",
"{",
"if",
"!",
"isMcConfigExists",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"mcCfgV8",
",",
"e",
":=",
"quick",
".",
"LoadConfig",
"(",
"mustGetMcConfigPath",
"(",
")",
",",
"nil",
",",
"newConfigV8",
"(",
")"... | // Migrate config version `8` to `9'. Add optional field virtual | [
"Migrate",
"config",
"version",
"8",
"to",
"9",
".",
"Add",
"optional",
"field",
"virtual"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-migrate.go#L443-L484 | train |
minio/mc | cmd/cp-main.go | String | func (c copyMessage) String() string {
return console.Colorize("Copy", fmt.Sprintf("`%s` -> `%s`", c.Source, c.Target))
} | go | func (c copyMessage) String() string {
return console.Colorize("Copy", fmt.Sprintf("`%s` -> `%s`", c.Source, c.Target))
} | [
"func",
"(",
"c",
"copyMessage",
")",
"String",
"(",
")",
"string",
"{",
"return",
"console",
".",
"Colorize",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"Source",
",",
"c",
".",
"Target",
")",
")",
"\n",
"}"
] | // String colorized copy message | [
"String",
"colorized",
"copy",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L139-L141 | train |
minio/mc | cmd/cp-main.go | JSON | func (c copyMessage) JSON() string {
c.Status = "success"
copyMessageBytes, e := json.MarshalIndent(c, "", " ")
fatalIf(probe.NewError(e), "Failed to marshal copy message.")
return string(copyMessageBytes)
} | go | func (c copyMessage) JSON() string {
c.Status = "success"
copyMessageBytes, e := json.MarshalIndent(c, "", " ")
fatalIf(probe.NewError(e), "Failed to marshal copy message.")
return string(copyMessageBytes)
} | [
"func",
"(",
"c",
"copyMessage",
")",
"JSON",
"(",
")",
"string",
"{",
"c",
".",
"Status",
"=",
"\"",
"\"",
"\n",
"copyMessageBytes",
",",
"e",
":=",
"json",
".",
"MarshalIndent",
"(",
"c",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fatalIf",
... | // JSON jsonified copy message | [
"JSON",
"jsonified",
"copy",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L144-L150 | train |
minio/mc | cmd/cp-main.go | String | func (c copyStatMessage) String() string {
speedBox := pb.Format(int64(c.Speed)).To(pb.U_BYTES).String()
if speedBox == "" {
speedBox = "0 MB"
} else {
speedBox = speedBox + "/s"
}
message := fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.Format(c.Total).To(pb.U_BYTES),
pb.Format(c.Transferred).To(p... | go | func (c copyStatMessage) String() string {
speedBox := pb.Format(int64(c.Speed)).To(pb.U_BYTES).String()
if speedBox == "" {
speedBox = "0 MB"
} else {
speedBox = speedBox + "/s"
}
message := fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.Format(c.Total).To(pb.U_BYTES),
pb.Format(c.Transferred).To(p... | [
"func",
"(",
"c",
"copyStatMessage",
")",
"String",
"(",
")",
"string",
"{",
"speedBox",
":=",
"pb",
".",
"Format",
"(",
"int64",
"(",
"c",
".",
"Speed",
")",
")",
".",
"To",
"(",
"pb",
".",
"U_BYTES",
")",
".",
"String",
"(",
")",
"\n",
"if",
... | // copyStatMessage copy accounting message | [
"copyStatMessage",
"copy",
"accounting",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L160-L170 | train |
minio/mc | cmd/cp-main.go | doCopy | func doCopy(ctx context.Context, cpURLs URLs, pg ProgressReader, encKeyDB map[string][]prefixSSEPair) URLs {
if cpURLs.Error != nil {
cpURLs.Error = cpURLs.Error.Trace()
return cpURLs
}
sourceAlias := cpURLs.SourceAlias
sourceURL := cpURLs.SourceContent.URL
targetAlias := cpURLs.TargetAlias
targetURL := cpUR... | go | func doCopy(ctx context.Context, cpURLs URLs, pg ProgressReader, encKeyDB map[string][]prefixSSEPair) URLs {
if cpURLs.Error != nil {
cpURLs.Error = cpURLs.Error.Trace()
return cpURLs
}
sourceAlias := cpURLs.SourceAlias
sourceURL := cpURLs.SourceContent.URL
targetAlias := cpURLs.TargetAlias
targetURL := cpUR... | [
"func",
"doCopy",
"(",
"ctx",
"context",
".",
"Context",
",",
"cpURLs",
"URLs",
",",
"pg",
"ProgressReader",
",",
"encKeyDB",
"map",
"[",
"string",
"]",
"[",
"]",
"prefixSSEPair",
")",
"URLs",
"{",
"if",
"cpURLs",
".",
"Error",
"!=",
"nil",
"{",
"cpURL... | // doCopy - Copy a singe file from source to destination | [
"doCopy",
"-",
"Copy",
"a",
"singe",
"file",
"from",
"source",
"to",
"destination"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L186-L212 | train |
minio/mc | cmd/cp-main.go | doCopyFake | func doCopyFake(cpURLs URLs, pg Progress) URLs {
if progressReader, ok := pg.(*progressBar); ok {
progressReader.ProgressBar.Add64(cpURLs.SourceContent.Size)
}
return cpURLs
} | go | func doCopyFake(cpURLs URLs, pg Progress) URLs {
if progressReader, ok := pg.(*progressBar); ok {
progressReader.ProgressBar.Add64(cpURLs.SourceContent.Size)
}
return cpURLs
} | [
"func",
"doCopyFake",
"(",
"cpURLs",
"URLs",
",",
"pg",
"Progress",
")",
"URLs",
"{",
"if",
"progressReader",
",",
"ok",
":=",
"pg",
".",
"(",
"*",
"progressBar",
")",
";",
"ok",
"{",
"progressReader",
".",
"ProgressBar",
".",
"Add64",
"(",
"cpURLs",
"... | // doCopyFake - Perform a fake copy to update the progress bar appropriately. | [
"doCopyFake",
"-",
"Perform",
"a",
"fake",
"copy",
"to",
"update",
"the",
"progress",
"bar",
"appropriately",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L215-L220 | train |
minio/mc | cmd/cp-main.go | doPrepareCopyURLs | func doPrepareCopyURLs(session *sessionV8, trapCh <-chan bool, cancelCopy context.CancelFunc) {
// Separate source and target. 'cp' can take only one target,
// but any number of sources.
sourceURLs := session.Header.CommandArgs[:len(session.Header.CommandArgs)-1]
targetURL := session.Header.CommandArgs[len(session... | go | func doPrepareCopyURLs(session *sessionV8, trapCh <-chan bool, cancelCopy context.CancelFunc) {
// Separate source and target. 'cp' can take only one target,
// but any number of sources.
sourceURLs := session.Header.CommandArgs[:len(session.Header.CommandArgs)-1]
targetURL := session.Header.CommandArgs[len(session... | [
"func",
"doPrepareCopyURLs",
"(",
"session",
"*",
"sessionV8",
",",
"trapCh",
"<-",
"chan",
"bool",
",",
"cancelCopy",
"context",
".",
"CancelFunc",
")",
"{",
"// Separate source and target. 'cp' can take only one target,",
"// but any number of sources.",
"sourceURLs",
":=... | // doPrepareCopyURLs scans the source URL and prepares a list of objects for copying. | [
"doPrepareCopyURLs",
"scans",
"the",
"source",
"URL",
"and",
"prepares",
"a",
"list",
"of",
"objects",
"for",
"copying",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L223-L307 | train |
minio/mc | cmd/cp-main.go | getMetaDataEntry | func getMetaDataEntry(metadataString string) (map[string]string, *probe.Error) {
metaDataMap := make(map[string]string)
for _, metaData := range strings.Split(metadataString, ",") {
metaDataEntry := strings.Split(metaData, "=")
if len(metaDataEntry) == 2 {
metaDataMap[metaDataEntry[0]] = metaDataEntry[1]
} e... | go | func getMetaDataEntry(metadataString string) (map[string]string, *probe.Error) {
metaDataMap := make(map[string]string)
for _, metaData := range strings.Split(metadataString, ",") {
metaDataEntry := strings.Split(metaData, "=")
if len(metaDataEntry) == 2 {
metaDataMap[metaDataEntry[0]] = metaDataEntry[1]
} e... | [
"func",
"getMetaDataEntry",
"(",
"metadataString",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"metaDataMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"_",
",",
... | // validate the passed metadataString and populate the map | [
"validate",
"the",
"passed",
"metadataString",
"and",
"populate",
"the",
"map"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L471-L482 | train |
minio/mc | cmd/cp-main.go | mainCopy | func mainCopy(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// Parse metadata.
userMetaMap := make(map[string]string)
if ctx.String("attr") != "" {
userMetaMap, err = getMetaDataEntry(ctx.String("attr"))
fatal... | go | func mainCopy(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// Parse metadata.
userMetaMap := make(map[string]string)
if ctx.String("attr") != "" {
userMetaMap, err = getMetaDataEntry(ctx.String("attr"))
fatal... | [
"func",
"mainCopy",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Parse encryption keys per command.",
"encKeyDB",
",",
"err",
":=",
"getEncKeys",
"(",
"ctx",
")",
"\n",
"fatalIf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n\n",
"// Parse metadata... | // mainCopy is the entry point for cp command. | [
"mainCopy",
"is",
"the",
"entry",
"point",
"for",
"cp",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/cp-main.go#L485-L535 | train |
minio/mc | cmd/pretty-record.go | newPrettyRecord | func newPrettyRecord(indent int, rows ...Row) PrettyRecord {
maxDescLen := 0
for _, r := range rows {
if len(r.desc) > maxDescLen {
maxDescLen = len(r.desc)
}
}
return PrettyRecord{
rows: rows,
indent: indent,
maxLen: maxDescLen,
}
} | go | func newPrettyRecord(indent int, rows ...Row) PrettyRecord {
maxDescLen := 0
for _, r := range rows {
if len(r.desc) > maxDescLen {
maxDescLen = len(r.desc)
}
}
return PrettyRecord{
rows: rows,
indent: indent,
maxLen: maxDescLen,
}
} | [
"func",
"newPrettyRecord",
"(",
"indent",
"int",
",",
"rows",
"...",
"Row",
")",
"PrettyRecord",
"{",
"maxDescLen",
":=",
"0",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"rows",
"{",
"if",
"len",
"(",
"r",
".",
"desc",
")",
">",
"maxDescLen",
"{",
... | // newPrettyRecord - creates a new pretty record | [
"newPrettyRecord",
"-",
"creates",
"a",
"new",
"pretty",
"record"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/pretty-record.go#L40-L52 | train |
minio/mc | cmd/pretty-record.go | buildRecord | func (t PrettyRecord) buildRecord(contents ...string) (line string) {
// totalRows is the minimum of the number of fields config
// and the number of contents elements.
totalRows := len(contents)
if len(t.rows) < totalRows {
totalRows = len(t.rows)
}
var format, separator string
// Format fields and construct... | go | func (t PrettyRecord) buildRecord(contents ...string) (line string) {
// totalRows is the minimum of the number of fields config
// and the number of contents elements.
totalRows := len(contents)
if len(t.rows) < totalRows {
totalRows = len(t.rows)
}
var format, separator string
// Format fields and construct... | [
"func",
"(",
"t",
"PrettyRecord",
")",
"buildRecord",
"(",
"contents",
"...",
"string",
")",
"(",
"line",
"string",
")",
"{",
"// totalRows is the minimum of the number of fields config",
"// and the number of contents elements.",
"totalRows",
":=",
"len",
"(",
"contents"... | // buildRecord - creates a string which represents a record table given
// some fields contents. | [
"buildRecord",
"-",
"creates",
"a",
"string",
"which",
"represents",
"a",
"record",
"table",
"given",
"some",
"fields",
"contents",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/pretty-record.go#L56-L80 | train |
minio/mc | cmd/admin-policy-add.go | checkAdminPolicyAddSyntax | func checkAdminPolicyAddSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 3 {
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
}
} | go | func checkAdminPolicyAddSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 3 {
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
}
} | [
"func",
"checkAdminPolicyAddSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"!=",
"3",
"{",
"cli",
".",
"ShowCommandHelpAndExit",
"(",
"ctx",
",",
"\"",
"\"",
",",
"1",
")",
"// last arg... | // checkAdminPolicyAddSyntax - validate all the passed arguments | [
"checkAdminPolicyAddSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-policy-add.go#L57-L61 | train |
minio/mc | cmd/admin-policy-add.go | mainAdminPolicyAdd | func mainAdminPolicyAdd(ctx *cli.Context) error {
checkAdminPolicyAddSyntax(ctx)
console.SetColor("PolicyMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
policy, e := ioutil.ReadFile(args.Get(2))
fatalIf(probe.NewError(e).Trace(args...), "Una... | go | func mainAdminPolicyAdd(ctx *cli.Context) error {
checkAdminPolicyAddSyntax(ctx)
console.SetColor("PolicyMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
policy, e := ioutil.ReadFile(args.Get(2))
fatalIf(probe.NewError(e).Trace(args...), "Una... | [
"func",
"mainAdminPolicyAdd",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"checkAdminPolicyAddSyntax",
"(",
"ctx",
")",
"\n\n",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",
"color",
".",
"New",
"(",
"color",
".",
"FgGreen",
")",
")",
... | // mainAdminPolicyAdd is the handle for "mc admin policy add" command. | [
"mainAdminPolicyAdd",
"is",
"the",
"handle",
"for",
"mc",
"admin",
"policy",
"add",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-policy-add.go#L99-L123 | train |
minio/mc | cmd/error.go | fatalIf | func fatalIf(err *probe.Error, msg string, data ...interface{}) {
if err == nil {
return
}
fatal(err, msg, data...)
} | go | func fatalIf(err *probe.Error, msg string, data ...interface{}) {
if err == nil {
return
}
fatal(err, msg, data...)
} | [
"func",
"fatalIf",
"(",
"err",
"*",
"probe",
".",
"Error",
",",
"msg",
"string",
",",
"data",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"fatal",
"(",
"err",
",",
"msg",
",",
"data",
"...",
... | // fatalIf wrapper function which takes error and selectively prints stack frames if available on debug | [
"fatalIf",
"wrapper",
"function",
"which",
"takes",
"error",
"and",
"selectively",
"prints",
"stack",
"frames",
"if",
"available",
"on",
"debug"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/error.go#L46-L51 | train |
minio/mc | cmd/error.go | errorIf | func errorIf(err *probe.Error, msg string, data ...interface{}) {
if err == nil {
return
}
if globalJSON {
errorMsg := errorMessage{
Message: fmt.Sprintf(msg, data...),
Type: "error",
Cause: causeMessage{
Message: err.ToGoError().Error(),
Error: err.ToGoError(),
},
SysInfo: err.SysInf... | go | func errorIf(err *probe.Error, msg string, data ...interface{}) {
if err == nil {
return
}
if globalJSON {
errorMsg := errorMessage{
Message: fmt.Sprintf(msg, data...),
Type: "error",
Cause: causeMessage{
Message: err.ToGoError().Error(),
Error: err.ToGoError(),
},
SysInfo: err.SysInf... | [
"func",
"errorIf",
"(",
"err",
"*",
"probe",
".",
"Error",
",",
"msg",
"string",
",",
"data",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"globalJSON",
"{",
"errorMsg",
":=",
"errorMessage",... | // errorIf synonymous with fatalIf but doesn't exit on error != nil | [
"errorIf",
"synonymous",
"with",
"fatalIf",
"but",
"doesn",
"t",
"exit",
"on",
"error",
"!",
"=",
"nil"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/error.go#L121-L157 | train |
minio/mc | pkg/colorjson/stream.go | MarshalJSON | func (m RawMessage) MarshalJSON() ([]byte, error) {
if m == nil {
return []byte("null"), nil
}
return m, nil
} | go | func (m RawMessage) MarshalJSON() ([]byte, error) {
if m == nil {
return []byte("null"), nil
}
return m, nil
} | [
"func",
"(",
"m",
"RawMessage",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"m",
"==",
"nil",
"{",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"m",
",",
"nil"... | // MarshalJSON returns m as the JSON encoding of m. | [
"MarshalJSON",
"returns",
"m",
"as",
"the",
"JSON",
"encoding",
"of",
"m",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/stream.go#L269-L274 | train |
minio/mc | pkg/colorjson/stream.go | tokenPrepareForDecode | func (dec *Decoder) tokenPrepareForDecode() error {
// Note: Not calling peek before switch, to avoid
// putting peek into the standard Decode path.
// peek is only called when using the Token API.
switch dec.tokenState {
case tokenArrayComma:
c, err := dec.peek()
if err != nil {
return err
}
if c != ',... | go | func (dec *Decoder) tokenPrepareForDecode() error {
// Note: Not calling peek before switch, to avoid
// putting peek into the standard Decode path.
// peek is only called when using the Token API.
switch dec.tokenState {
case tokenArrayComma:
c, err := dec.peek()
if err != nil {
return err
}
if c != ',... | [
"func",
"(",
"dec",
"*",
"Decoder",
")",
"tokenPrepareForDecode",
"(",
")",
"error",
"{",
"// Note: Not calling peek before switch, to avoid",
"// putting peek into the standard Decode path.",
"// peek is only called when using the Token API.",
"switch",
"dec",
".",
"tokenState",
... | // advance tokenstate from a separator state to a value state | [
"advance",
"tokenstate",
"from",
"a",
"separator",
"state",
"to",
"a",
"value",
"state"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/stream.go#L312-L339 | train |
minio/mc | pkg/colorjson/stream.go | More | func (dec *Decoder) More() bool {
c, err := dec.peek()
return err == nil && c != ']' && c != '}'
} | go | func (dec *Decoder) More() bool {
c, err := dec.peek()
return err == nil && c != ']' && c != '}'
} | [
"func",
"(",
"dec",
"*",
"Decoder",
")",
"More",
"(",
")",
"bool",
"{",
"c",
",",
"err",
":=",
"dec",
".",
"peek",
"(",
")",
"\n",
"return",
"err",
"==",
"nil",
"&&",
"c",
"!=",
"']'",
"&&",
"c",
"!=",
"'}'",
"\n",
"}"
] | // More reports whether there is another element in the
// current array or object being parsed. | [
"More",
"reports",
"whether",
"there",
"is",
"another",
"element",
"in",
"the",
"current",
"array",
"or",
"object",
"being",
"parsed",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/stream.go#L491-L494 | train |
minio/mc | pkg/probe/probe.go | GetSysInfo | func GetSysInfo() map[string]string {
host, err := os.Hostname()
if err != nil {
host = ""
}
memstats := &runtime.MemStats{}
runtime.ReadMemStats(memstats)
return map[string]string{
"host.name": host,
"host.os": runtime.GOOS,
"host.arch": runtime.GOARCH,
"host.lang": runtime.Versio... | go | func GetSysInfo() map[string]string {
host, err := os.Hostname()
if err != nil {
host = ""
}
memstats := &runtime.MemStats{}
runtime.ReadMemStats(memstats)
return map[string]string{
"host.name": host,
"host.os": runtime.GOOS,
"host.arch": runtime.GOARCH,
"host.lang": runtime.Versio... | [
"func",
"GetSysInfo",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"host",
",",
"err",
":=",
"os",
".",
"Hostname",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"host",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"memstats",
":=",
"&",
"runtime",
... | // GetSysInfo returns useful system statistics. | [
"GetSysInfo",
"returns",
"useful",
"system",
"statistics",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L61-L79 | train |
minio/mc | pkg/probe/probe.go | Trace | func (e *Error) Trace(fields ...string) *Error {
if e == nil {
return nil
}
e.lock.Lock()
defer e.lock.Unlock()
return e.trace(fields...)
} | go | func (e *Error) Trace(fields ...string) *Error {
if e == nil {
return nil
}
e.lock.Lock()
defer e.lock.Unlock()
return e.trace(fields...)
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Trace",
"(",
"fields",
"...",
"string",
")",
"*",
"Error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"e",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"lock",
"... | // Trace records the point at which it is invoked.
// Stack traces are important for debugging purposes. | [
"Trace",
"records",
"the",
"point",
"at",
"which",
"it",
"is",
"invoked",
".",
"Stack",
"traces",
"are",
"important",
"for",
"debugging",
"purposes",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L125-L134 | train |
minio/mc | pkg/probe/probe.go | trace | func (e *Error) trace(fields ...string) *Error {
if e == nil {
return nil
}
pc, file, line, _ := runtime.Caller(2)
function := runtime.FuncForPC(pc).Name()
_, function = filepath.Split(function)
file = strings.TrimPrefix(file, rootPath+string(os.PathSeparator)) // trims project's root path.
tp := TracePoint{}
... | go | func (e *Error) trace(fields ...string) *Error {
if e == nil {
return nil
}
pc, file, line, _ := runtime.Caller(2)
function := runtime.FuncForPC(pc).Name()
_, function = filepath.Split(function)
file = strings.TrimPrefix(file, rootPath+string(os.PathSeparator)) // trims project's root path.
tp := TracePoint{}
... | [
"func",
"(",
"e",
"*",
"Error",
")",
"trace",
"(",
"fields",
"...",
"string",
")",
"*",
"Error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"pc",
",",
"file",
",",
"line",
",",
"_",
":=",
"runtime",
".",
"Caller",
"(",
... | // trace records caller's caller. It is intended for probe's own
// internal use. Take a look at probe.NewError for example. | [
"trace",
"records",
"caller",
"s",
"caller",
".",
"It",
"is",
"intended",
"for",
"probe",
"s",
"own",
"internal",
"use",
".",
"Take",
"a",
"look",
"at",
"probe",
".",
"NewError",
"for",
"example",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L138-L154 | train |
minio/mc | pkg/probe/probe.go | Untrace | func (e *Error) Untrace() *Error {
if e == nil {
return nil
}
e.lock.Lock()
defer e.lock.Unlock()
l := len(e.CallTrace)
if l == 0 {
return nil
}
e.CallTrace = e.CallTrace[:l-1]
return e
} | go | func (e *Error) Untrace() *Error {
if e == nil {
return nil
}
e.lock.Lock()
defer e.lock.Unlock()
l := len(e.CallTrace)
if l == 0 {
return nil
}
e.CallTrace = e.CallTrace[:l-1]
return e
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Untrace",
"(",
")",
"*",
"Error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"e",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"lock",
".",
"Unlock",
"(",
")",
"... | // Untrace erases last known trace entry. | [
"Untrace",
"erases",
"last",
"known",
"trace",
"entry",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L157-L170 | train |
minio/mc | pkg/probe/probe.go | ToGoError | func (e *Error) ToGoError() error {
if e == nil || e.Cause == nil {
return nil
}
return e.Cause
} | go | func (e *Error) ToGoError() error {
if e == nil || e.Cause == nil {
return nil
}
return e.Cause
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"ToGoError",
"(",
")",
"error",
"{",
"if",
"e",
"==",
"nil",
"||",
"e",
".",
"Cause",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"e",
".",
"Cause",
"\n",
"}"
] | // ToGoError returns original error message. | [
"ToGoError",
"returns",
"original",
"error",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L173-L178 | train |
minio/mc | pkg/probe/probe.go | String | func (e *Error) String() string {
if e == nil || e.Cause == nil {
return "<nil>"
}
e.lock.RLock()
defer e.lock.RUnlock()
if e.Cause != nil {
str := e.Cause.Error()
callLen := len(e.CallTrace)
for i := callLen - 1; i >= 0; i-- {
if len(e.CallTrace[i].Env) > 0 {
str += fmt.Sprintf("\n (%d) %s:%d %s(.... | go | func (e *Error) String() string {
if e == nil || e.Cause == nil {
return "<nil>"
}
e.lock.RLock()
defer e.lock.RUnlock()
if e.Cause != nil {
str := e.Cause.Error()
callLen := len(e.CallTrace)
for i := callLen - 1; i >= 0; i-- {
if len(e.CallTrace[i].Env) > 0 {
str += fmt.Sprintf("\n (%d) %s:%d %s(.... | [
"func",
"(",
"e",
"*",
"Error",
")",
"String",
"(",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"||",
"e",
".",
"Cause",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"e",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
... | // String returns error message. | [
"String",
"returns",
"error",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/probe/probe.go#L181-L217 | train |
minio/mc | cmd/status.go | SetTotal | func (qs *QuietStatus) SetTotal(v int64) Status {
qs.accounter.Total = v
return qs
} | go | func (qs *QuietStatus) SetTotal(v int64) Status {
qs.accounter.Total = v
return qs
} | [
"func",
"(",
"qs",
"*",
"QuietStatus",
")",
"SetTotal",
"(",
"v",
"int64",
")",
"Status",
"{",
"qs",
".",
"accounter",
".",
"Total",
"=",
"v",
"\n",
"return",
"qs",
"\n",
"}"
] | // SetTotal sets the total of the progressbar, ignored for quietstatus | [
"SetTotal",
"sets",
"the",
"total",
"of",
"the",
"progressbar",
"ignored",
"for",
"quietstatus"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/status.go#L136-L139 | train |
minio/mc | cmd/status.go | Finish | func (qs *QuietStatus) Finish() {
console.Println(console.Colorize("Mirror", qs.accounter.Stat().String()))
} | go | func (qs *QuietStatus) Finish() {
console.Println(console.Colorize("Mirror", qs.accounter.Stat().String()))
} | [
"func",
"(",
"qs",
"*",
"QuietStatus",
")",
"Finish",
"(",
")",
"{",
"console",
".",
"Println",
"(",
"console",
".",
"Colorize",
"(",
"\"",
"\"",
",",
"qs",
".",
"accounter",
".",
"Stat",
"(",
")",
".",
"String",
"(",
")",
")",
")",
"\n",
"}"
] | // Finish displays the accounting summary | [
"Finish",
"displays",
"the",
"accounting",
"summary"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/status.go#L174-L176 | train |
minio/mc | cmd/status.go | SetTotal | func (ps *ProgressStatus) SetTotal(v int64) Status {
ps.progressBar.Total = v
return ps
} | go | func (ps *ProgressStatus) SetTotal(v int64) Status {
ps.progressBar.Total = v
return ps
} | [
"func",
"(",
"ps",
"*",
"ProgressStatus",
")",
"SetTotal",
"(",
"v",
"int64",
")",
"Status",
"{",
"ps",
".",
"progressBar",
".",
"Total",
"=",
"v",
"\n",
"return",
"ps",
"\n",
"}"
] | // SetTotal sets the total of the progressbar | [
"SetTotal",
"sets",
"the",
"total",
"of",
"the",
"progressbar"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/status.go#L221-L224 | train |
minio/mc | cmd/admin-profile-stop.go | mainAdminProfileStop | func mainAdminProfileStop(ctx *cli.Context) error {
// Check for command syntax
checkAdminProfileStopSyntax(ctx)
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
if err != nil {
fatalIf(err.Trace(ali... | go | func mainAdminProfileStop(ctx *cli.Context) error {
// Check for command syntax
checkAdminProfileStopSyntax(ctx)
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
if err != nil {
fatalIf(err.Trace(ali... | [
"func",
"mainAdminProfileStop",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Check for command syntax",
"checkAdminProfileStopSyntax",
"(",
"ctx",
")",
"\n\n",
"// Get the alias parameter from cli",
"args",
":=",
"ctx",
".",
"Args",
"(",
")",
"\n",... | // mainAdminProfileStop - the entry function of profile stop command | [
"mainAdminProfileStop",
"-",
"the",
"entry",
"function",
"of",
"profile",
"stop",
"command"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-profile-stop.go#L86-L133 | train |
minio/mc | pkg/colorjson/encode.go | MarshalIndent | func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
b, err := Marshal(v)
if err != nil {
return nil, err
}
if !isatty.IsTerminal(os.Stdout.Fd()) {
return b, err
}
var buf bytes.Buffer
err = Indent(&buf, b, prefix, indent)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} | go | func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
b, err := Marshal(v)
if err != nil {
return nil, err
}
if !isatty.IsTerminal(os.Stdout.Fd()) {
return b, err
}
var buf bytes.Buffer
err = Indent(&buf, b, prefix, indent)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} | [
"func",
"MarshalIndent",
"(",
"v",
"interface",
"{",
"}",
",",
"prefix",
",",
"indent",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"Marshal",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // MarshalIndent is like Marshal but applies Indent to format the output.
// Each JSON element in the output will begin on a new line beginning with prefix
// followed by one or more copies of indent according to the indentation nesting. | [
"MarshalIndent",
"is",
"like",
"Marshal",
"but",
"applies",
"Indent",
"to",
"format",
"the",
"output",
".",
"Each",
"JSON",
"element",
"in",
"the",
"output",
"will",
"begin",
"on",
"a",
"new",
"line",
"beginning",
"with",
"prefix",
"followed",
"by",
"one",
... | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/encode.go#L194-L208 | train |
minio/mc | pkg/colorjson/encode.go | newCondAddrEncoder | func newCondAddrEncoder(canAddrEnc, elseEnc encoderFunc) encoderFunc {
enc := &condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc}
return enc.encode
} | go | func newCondAddrEncoder(canAddrEnc, elseEnc encoderFunc) encoderFunc {
enc := &condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc}
return enc.encode
} | [
"func",
"newCondAddrEncoder",
"(",
"canAddrEnc",
",",
"elseEnc",
"encoderFunc",
")",
"encoderFunc",
"{",
"enc",
":=",
"&",
"condAddrEncoder",
"{",
"canAddrEnc",
":",
"canAddrEnc",
",",
"elseEnc",
":",
"elseEnc",
"}",
"\n",
"return",
"enc",
".",
"encode",
"\n",... | // newCondAddrEncoder returns an encoder that checks whether its value
// CanAddr and delegates to canAddrEnc if so, else to elseEnc. | [
"newCondAddrEncoder",
"returns",
"an",
"encoder",
"that",
"checks",
"whether",
"its",
"value",
"CanAddr",
"and",
"delegates",
"to",
"canAddrEnc",
"if",
"so",
"else",
"to",
"elseEnc",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/encode.go#L836-L839 | train |
minio/mc | cmd/admin-policy-remove.go | checkAdminPolicyRemoveSyntax | func checkAdminPolicyRemoveSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 2 {
cli.ShowCommandHelpAndExit(ctx, "remove", 1) // last argument is exit code
}
} | go | func checkAdminPolicyRemoveSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 2 {
cli.ShowCommandHelpAndExit(ctx, "remove", 1) // last argument is exit code
}
} | [
"func",
"checkAdminPolicyRemoveSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"!=",
"2",
"{",
"cli",
".",
"ShowCommandHelpAndExit",
"(",
"ctx",
",",
"\"",
"\"",
",",
"1",
")",
"// last ... | // checkAdminPolicyRemoveSyntax - validate all the passed arguments | [
"checkAdminPolicyRemoveSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-policy-remove.go#L51-L55 | train |
minio/mc | cmd/admin-policy-remove.go | mainAdminPolicyRemove | func mainAdminPolicyRemove(ctx *cli.Context) error {
checkAdminPolicyRemoveSyntax(ctx)
console.SetColor("PolicyMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fata... | go | func mainAdminPolicyRemove(ctx *cli.Context) error {
checkAdminPolicyRemoveSyntax(ctx)
console.SetColor("PolicyMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fata... | [
"func",
"mainAdminPolicyRemove",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"checkAdminPolicyRemoveSyntax",
"(",
"ctx",
")",
"\n\n",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",
"color",
".",
"New",
"(",
"color",
".",
"FgGreen",
")",
... | // mainAdminPolicyRemove is the handle for "mc admin policy remove" command. | [
"mainAdminPolicyRemove",
"is",
"the",
"handle",
"for",
"mc",
"admin",
"policy",
"remove",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-policy-remove.go#L58-L79 | train |
minio/mc | cmd/stat.go | parseStat | func parseStat(c *clientContent) statMessage {
content := statMessage{}
content.Date = c.Time.Local()
// guess file type.
content.Type = func() string {
if c.Type.IsDir() {
return "folder"
}
return "file"
}()
content.Size = c.Size
content.Key = getKey(c)
content.Metadata = c.Metadata
content.ETag = st... | go | func parseStat(c *clientContent) statMessage {
content := statMessage{}
content.Date = c.Time.Local()
// guess file type.
content.Type = func() string {
if c.Type.IsDir() {
return "folder"
}
return "file"
}()
content.Size = c.Size
content.Key = getKey(c)
content.Metadata = c.Metadata
content.ETag = st... | [
"func",
"parseStat",
"(",
"c",
"*",
"clientContent",
")",
"statMessage",
"{",
"content",
":=",
"statMessage",
"{",
"}",
"\n",
"content",
".",
"Date",
"=",
"c",
".",
"Time",
".",
"Local",
"(",
")",
"\n",
"// guess file type.",
"content",
".",
"Type",
"=",... | // parseStat parses client Content container into statMessage struct. | [
"parseStat",
"parses",
"client",
"Content",
"container",
"into",
"statMessage",
"struct",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/stat.go#L95-L113 | train |
minio/mc | cmd/stat.go | statURL | func statURL(targetURL string, isIncomplete, isRecursive bool, encKeyDB map[string][]prefixSSEPair) ([]*clientContent, *probe.Error) {
var stats []*clientContent
var clnt Client
clnt, err := newClient(targetURL)
if err != nil {
return nil, err
}
targetAlias, _, _ := mustExpandAlias(targetURL)
prefixPath := c... | go | func statURL(targetURL string, isIncomplete, isRecursive bool, encKeyDB map[string][]prefixSSEPair) ([]*clientContent, *probe.Error) {
var stats []*clientContent
var clnt Client
clnt, err := newClient(targetURL)
if err != nil {
return nil, err
}
targetAlias, _, _ := mustExpandAlias(targetURL)
prefixPath := c... | [
"func",
"statURL",
"(",
"targetURL",
"string",
",",
"isIncomplete",
",",
"isRecursive",
"bool",
",",
"encKeyDB",
"map",
"[",
"string",
"]",
"[",
"]",
"prefixSSEPair",
")",
"(",
"[",
"]",
"*",
"clientContent",
",",
"*",
"probe",
".",
"Error",
")",
"{",
... | // statURL - simple or recursive listing | [
"statURL",
"-",
"simple",
"or",
"recursive",
"listing"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/stat.go#L116-L176 | train |
minio/mc | cmd/share-list-main.go | checkShareListSyntax | func checkShareListSyntax(ctx *cli.Context) {
args := ctx.Args()
if !args.Present() || (args.First() != "upload" && args.First() != "download") {
cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code.
}
} | go | func checkShareListSyntax(ctx *cli.Context) {
args := ctx.Args()
if !args.Present() || (args.First() != "upload" && args.First() != "download") {
cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code.
}
} | [
"func",
"checkShareListSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"args",
":=",
"ctx",
".",
"Args",
"(",
")",
"\n",
"if",
"!",
"args",
".",
"Present",
"(",
")",
"||",
"(",
"args",
".",
"First",
"(",
")",
"!=",
"\"",
"\"",
"&&",
... | // validate command-line args. | [
"validate",
"command",
"-",
"line",
"args",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-list-main.go#L58-L63 | train |
minio/mc | cmd/share-list-main.go | doShareList | func doShareList(cmd string) *probe.Error {
if cmd != "upload" && cmd != "download" {
return probe.NewError(fmt.Errorf("Unknown argument `%s` passed", cmd))
}
// Fetch defaults.
uploadsFile := getShareUploadsFile()
downloadsFile := getShareDownloadsFile()
// Load previously saved upload-shares.
shareDB := ne... | go | func doShareList(cmd string) *probe.Error {
if cmd != "upload" && cmd != "download" {
return probe.NewError(fmt.Errorf("Unknown argument `%s` passed", cmd))
}
// Fetch defaults.
uploadsFile := getShareUploadsFile()
downloadsFile := getShareDownloadsFile()
// Load previously saved upload-shares.
shareDB := ne... | [
"func",
"doShareList",
"(",
"cmd",
"string",
")",
"*",
"probe",
".",
"Error",
"{",
"if",
"cmd",
"!=",
"\"",
"\"",
"&&",
"cmd",
"!=",
"\"",
"\"",
"{",
"return",
"probe",
".",
"NewError",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"cmd",
")",... | // doShareList list shared url's. | [
"doShareList",
"list",
"shared",
"url",
"s",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-list-main.go#L66-L102 | train |
minio/mc | cmd/share-list-main.go | mainShareList | func mainShareList(ctx *cli.Context) error {
// validate command-line args.
checkShareListSyntax(ctx)
// Additional command speific theme customization.
shareSetColor()
// Initialize share config folder.
initShareConfig()
// List shares.
fatalIf(doShareList(ctx.Args().First()).Trace(), "Unable to list previ... | go | func mainShareList(ctx *cli.Context) error {
// validate command-line args.
checkShareListSyntax(ctx)
// Additional command speific theme customization.
shareSetColor()
// Initialize share config folder.
initShareConfig()
// List shares.
fatalIf(doShareList(ctx.Args().First()).Trace(), "Unable to list previ... | [
"func",
"mainShareList",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// validate command-line args.",
"checkShareListSyntax",
"(",
"ctx",
")",
"\n\n",
"// Additional command speific theme customization.",
"shareSetColor",
"(",
")",
"\n\n",
"// Initialize s... | // main entry point for share list. | [
"main",
"entry",
"point",
"for",
"share",
"list",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-list-main.go#L105-L119 | train |
minio/mc | cmd/share-db-v1.go | newShareDBV1 | func newShareDBV1() *shareDBV1 {
s := &shareDBV1{
Version: "1",
}
s.Shares = make(map[string]shareEntryV1)
s.mutex = &sync.Mutex{}
return s
} | go | func newShareDBV1() *shareDBV1 {
s := &shareDBV1{
Version: "1",
}
s.Shares = make(map[string]shareEntryV1)
s.mutex = &sync.Mutex{}
return s
} | [
"func",
"newShareDBV1",
"(",
")",
"*",
"shareDBV1",
"{",
"s",
":=",
"&",
"shareDBV1",
"{",
"Version",
":",
"\"",
"\"",
",",
"}",
"\n",
"s",
".",
"Shares",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"shareEntryV1",
")",
"\n",
"s",
".",
"mutex",
... | // Instantiate a new uploads structure for persistence. | [
"Instantiate",
"a",
"new",
"uploads",
"structure",
"for",
"persistence",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-db-v1.go#L46-L53 | train |
minio/mc | cmd/share-db-v1.go | Set | func (s *shareDBV1) Set(objectURL string, shareURL string, expiry time.Duration, contentType string) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.Shares[shareURL] = shareEntryV1{
URL: objectURL,
Date: UTCNow(),
Expiry: expiry,
ContentType: contentType,
}
} | go | func (s *shareDBV1) Set(objectURL string, shareURL string, expiry time.Duration, contentType string) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.Shares[shareURL] = shareEntryV1{
URL: objectURL,
Date: UTCNow(),
Expiry: expiry,
ContentType: contentType,
}
} | [
"func",
"(",
"s",
"*",
"shareDBV1",
")",
"Set",
"(",
"objectURL",
"string",
",",
"shareURL",
"string",
",",
"expiry",
"time",
".",
"Duration",
",",
"contentType",
"string",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
... | // Set upload info for each share. | [
"Set",
"upload",
"info",
"for",
"each",
"share",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-db-v1.go#L56-L66 | train |
minio/mc | cmd/share-db-v1.go | Delete | func (s *shareDBV1) Delete(objectURL string) {
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.Shares, objectURL)
} | go | func (s *shareDBV1) Delete(objectURL string) {
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.Shares, objectURL)
} | [
"func",
"(",
"s",
"*",
"shareDBV1",
")",
"Delete",
"(",
"objectURL",
"string",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"s",
".",
"Shares",
",",
"objectU... | // Delete upload info if it exists. | [
"Delete",
"upload",
"info",
"if",
"it",
"exists",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-db-v1.go#L69-L74 | train |
minio/mc | cmd/share-db-v1.go | deleteAllExpired | func (s *shareDBV1) deleteAllExpired() {
for shareURL, share := range s.Shares {
if (share.Expiry - time.Since(share.Date)) <= 0 {
// Expired entry. Safe to drop.
delete(s.Shares, shareURL)
}
}
} | go | func (s *shareDBV1) deleteAllExpired() {
for shareURL, share := range s.Shares {
if (share.Expiry - time.Since(share.Date)) <= 0 {
// Expired entry. Safe to drop.
delete(s.Shares, shareURL)
}
}
} | [
"func",
"(",
"s",
"*",
"shareDBV1",
")",
"deleteAllExpired",
"(",
")",
"{",
"for",
"shareURL",
",",
"share",
":=",
"range",
"s",
".",
"Shares",
"{",
"if",
"(",
"share",
".",
"Expiry",
"-",
"time",
".",
"Since",
"(",
"share",
".",
"Date",
")",
")",
... | // Delete all expired uploads. | [
"Delete",
"all",
"expired",
"uploads",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-db-v1.go#L77-L84 | train |
minio/mc | cmd/share-db-v1.go | Load | func (s *shareDBV1) Load(filename string) *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
// Check if the db file exist.
if _, e := os.Stat(filename); e != nil {
return probe.NewError(e)
}
// Initialize and load using quick package.
qs, e := quick.NewConfig(newShareDBV1(), nil)
if e != nil {
return p... | go | func (s *shareDBV1) Load(filename string) *probe.Error {
s.mutex.Lock()
defer s.mutex.Unlock()
// Check if the db file exist.
if _, e := os.Stat(filename); e != nil {
return probe.NewError(e)
}
// Initialize and load using quick package.
qs, e := quick.NewConfig(newShareDBV1(), nil)
if e != nil {
return p... | [
"func",
"(",
"s",
"*",
"shareDBV1",
")",
"Load",
"(",
"filename",
"string",
")",
"*",
"probe",
".",
"Error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// Check if the db file ex... | // Load shareDB entries from disk. Any entries held in memory are reset. | [
"Load",
"shareDB",
"entries",
"from",
"disk",
".",
"Any",
"entries",
"held",
"in",
"memory",
"are",
"reset",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/share-db-v1.go#L87-L116 | train |
minio/mc | cmd/print.go | printMsg | func printMsg(msg message) {
if !globalJSON {
console.Println(msg.String())
} else {
console.Println(msg.JSON())
}
} | go | func printMsg(msg message) {
if !globalJSON {
console.Println(msg.String())
} else {
console.Println(msg.JSON())
}
} | [
"func",
"printMsg",
"(",
"msg",
"message",
")",
"{",
"if",
"!",
"globalJSON",
"{",
"console",
".",
"Println",
"(",
"msg",
".",
"String",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"console",
".",
"Println",
"(",
"msg",
".",
"JSON",
"(",
")",
")",
"\n... | // printMsg prints message string or JSON structure depending on the type of output console. | [
"printMsg",
"prints",
"message",
"string",
"or",
"JSON",
"structure",
"depending",
"on",
"the",
"type",
"of",
"output",
"console",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/print.go#L28-L34 | train |
minio/mc | cmd/admin-user-add.go | checkAdminUserAddSyntax | func checkAdminUserAddSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 4 {
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
}
} | go | func checkAdminUserAddSyntax(ctx *cli.Context) {
if len(ctx.Args()) != 4 {
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
}
} | [
"func",
"checkAdminUserAddSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"!=",
"4",
"{",
"cli",
".",
"ShowCommandHelpAndExit",
"(",
"ctx",
",",
"\"",
"\"",
",",
"1",
")",
"// last argum... | // checkAdminUserAddSyntax - validate all the passed arguments | [
"checkAdminUserAddSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-user-add.go#L54-L58 | train |
minio/mc | cmd/admin-user-add.go | mainAdminUserAdd | func mainAdminUserAdd(ctx *cli.Context) error {
checkAdminUserAddSyntax(ctx)
console.SetColor("UserMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fatalIf(err, "Ca... | go | func mainAdminUserAdd(ctx *cli.Context) error {
checkAdminUserAddSyntax(ctx)
console.SetColor("UserMessage", color.New(color.FgGreen))
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
fatalIf(err, "Ca... | [
"func",
"mainAdminUserAdd",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"checkAdminUserAddSyntax",
"(",
"ctx",
")",
"\n\n",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",
"color",
".",
"New",
"(",
"color",
".",
"FgGreen",
")",
")",
"\... | // mainAdminUserAdd is the handle for "mc admin user add" command. | [
"mainAdminUserAdd",
"is",
"the",
"handle",
"for",
"mc",
"admin",
"user",
"add",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-user-add.go#L106-L131 | train |
minio/mc | cmd/admin-config-set.go | checkAdminConfigSetSyntax | func checkAdminConfigSetSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
cli.ShowCommandHelpAndExit(ctx, "set", 1) // last argument is exit code
}
} | go | func checkAdminConfigSetSyntax(ctx *cli.Context) {
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
cli.ShowCommandHelpAndExit(ctx, "set", 1) // last argument is exit code
}
} | [
"func",
"checkAdminConfigSetSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"==",
"0",
"||",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
">",
"2",
"{",
"cli",
".",
"ShowCommandHel... | // checkAdminConfigSetSyntax - validate all the passed arguments | [
"checkAdminConfigSetSyntax",
"-",
"validate",
"all",
"the",
"passed",
"arguments"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-config-set.go#L86-L90 | train |
minio/mc | cmd/admin-config-set.go | mainAdminConfigSet | func mainAdminConfigSet(ctx *cli.Context) error {
// Check command arguments
checkAdminConfigSetSyntax(ctx)
// Set color preference of command outputs
console.SetColor("SetConfigSuccess", color.New(color.FgGreen, color.Bold))
console.SetColor("SetConfigFailure", color.New(color.FgRed, color.Bold))
// Get the a... | go | func mainAdminConfigSet(ctx *cli.Context) error {
// Check command arguments
checkAdminConfigSetSyntax(ctx)
// Set color preference of command outputs
console.SetColor("SetConfigSuccess", color.New(color.FgGreen, color.Bold))
console.SetColor("SetConfigFailure", color.New(color.FgRed, color.Bold))
// Get the a... | [
"func",
"mainAdminConfigSet",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Check command arguments",
"checkAdminConfigSetSyntax",
"(",
"ctx",
")",
"\n\n",
"// Set color preference of command outputs",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",... | // main config set function | [
"main",
"config",
"set",
"function"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-config-set.go#L93-L119 | train |
minio/mc | cmd/utils.go | newRandomID | func newRandomID(n int) string {
rand.Seed(UTCNow().UnixNano())
sid := make([]rune, n)
for i := range sid {
sid[i] = letters[rand.Intn(len(letters))]
}
return string(sid)
} | go | func newRandomID(n int) string {
rand.Seed(UTCNow().UnixNano())
sid := make([]rune, n)
for i := range sid {
sid[i] = letters[rand.Intn(len(letters))]
}
return string(sid)
} | [
"func",
"newRandomID",
"(",
"n",
"int",
")",
"string",
"{",
"rand",
".",
"Seed",
"(",
"UTCNow",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
"\n",
"sid",
":=",
"make",
"(",
"[",
"]",
"rune",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"range",
"sid",
... | // newRandomID generates a random id of regular lower case and uppercase english characters. | [
"newRandomID",
"generates",
"a",
"random",
"id",
"of",
"regular",
"lower",
"case",
"and",
"uppercase",
"english",
"characters",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L70-L77 | train |
minio/mc | cmd/utils.go | dumpTLSCertificates | func dumpTLSCertificates(t *tls.ConnectionState) {
for _, cert := range t.PeerCertificates {
console.Debugln("TLS Certificate found: ")
if len(cert.Issuer.Country) > 0 {
console.Debugln(" >> Country: " + cert.Issuer.Country[0])
}
if len(cert.Issuer.Organization) > 0 {
console.Debugln(" >> Organization: "... | go | func dumpTLSCertificates(t *tls.ConnectionState) {
for _, cert := range t.PeerCertificates {
console.Debugln("TLS Certificate found: ")
if len(cert.Issuer.Country) > 0 {
console.Debugln(" >> Country: " + cert.Issuer.Country[0])
}
if len(cert.Issuer.Organization) > 0 {
console.Debugln(" >> Organization: "... | [
"func",
"dumpTLSCertificates",
"(",
"t",
"*",
"tls",
".",
"ConnectionState",
")",
"{",
"for",
"_",
",",
"cert",
":=",
"range",
"t",
".",
"PeerCertificates",
"{",
"console",
".",
"Debugln",
"(",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"cert",
".",
"I... | // dumpTlsCertificates prints some fields of the certificates received from the server.
// Fields will be inspected by the user, so they must be conscise and useful | [
"dumpTlsCertificates",
"prints",
"some",
"fields",
"of",
"the",
"certificates",
"received",
"from",
"the",
"server",
".",
"Fields",
"will",
"be",
"inspected",
"by",
"the",
"user",
"so",
"they",
"must",
"be",
"conscise",
"and",
"useful"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L99-L110 | train |
minio/mc | cmd/utils.go | splitStr | func splitStr(path, sep string, n int) []string {
splits := strings.SplitN(path, sep, n)
// Add empty strings if we found elements less than nr
for i := n - len(splits); i > 0; i-- {
splits = append(splits, "")
}
return splits
} | go | func splitStr(path, sep string, n int) []string {
splits := strings.SplitN(path, sep, n)
// Add empty strings if we found elements less than nr
for i := n - len(splits); i > 0; i-- {
splits = append(splits, "")
}
return splits
} | [
"func",
"splitStr",
"(",
"path",
",",
"sep",
"string",
",",
"n",
"int",
")",
"[",
"]",
"string",
"{",
"splits",
":=",
"strings",
".",
"SplitN",
"(",
"path",
",",
"sep",
",",
"n",
")",
"\n",
"// Add empty strings if we found elements less than nr",
"for",
"... | // splitStr splits a string into n parts, empty strings are added
// if we are not able to reach n elements | [
"splitStr",
"splits",
"a",
"string",
"into",
"n",
"parts",
"empty",
"strings",
"are",
"added",
"if",
"we",
"are",
"not",
"able",
"to",
"reach",
"n",
"elements"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L119-L126 | train |
minio/mc | cmd/utils.go | newS3Config | func newS3Config(urlStr string, hostCfg *hostConfigV9) *Config {
// We have a valid alias and hostConfig. We populate the
// credentials from the match found in the config file.
s3Config := new(Config)
s3Config.AppName = "mc"
s3Config.AppVersion = Version
s3Config.AppComments = []string{os.Args[0], runtime.GOOS,... | go | func newS3Config(urlStr string, hostCfg *hostConfigV9) *Config {
// We have a valid alias and hostConfig. We populate the
// credentials from the match found in the config file.
s3Config := new(Config)
s3Config.AppName = "mc"
s3Config.AppVersion = Version
s3Config.AppComments = []string{os.Args[0], runtime.GOOS,... | [
"func",
"newS3Config",
"(",
"urlStr",
"string",
",",
"hostCfg",
"*",
"hostConfigV9",
")",
"*",
"Config",
"{",
"// We have a valid alias and hostConfig. We populate the",
"// credentials from the match found in the config file.",
"s3Config",
":=",
"new",
"(",
"Config",
")",
... | // newS3Config simply creates a new Config struct using the passed
// parameters. | [
"newS3Config",
"simply",
"creates",
"a",
"new",
"Config",
"struct",
"using",
"the",
"passed",
"parameters",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L130-L149 | train |
minio/mc | cmd/utils.go | lineTrunc | func lineTrunc(content string, maxLen int) string {
runes := []rune(content)
rlen := len(runes)
if rlen <= maxLen {
return content
}
halfLen := maxLen / 2
fstPart := string(runes[0:halfLen])
sndPart := string(runes[rlen-halfLen:])
return fstPart + "…" + sndPart
} | go | func lineTrunc(content string, maxLen int) string {
runes := []rune(content)
rlen := len(runes)
if rlen <= maxLen {
return content
}
halfLen := maxLen / 2
fstPart := string(runes[0:halfLen])
sndPart := string(runes[rlen-halfLen:])
return fstPart + "…" + sndPart
} | [
"func",
"lineTrunc",
"(",
"content",
"string",
",",
"maxLen",
"int",
")",
"string",
"{",
"runes",
":=",
"[",
"]",
"rune",
"(",
"content",
")",
"\n",
"rlen",
":=",
"len",
"(",
"runes",
")",
"\n",
"if",
"rlen",
"<=",
"maxLen",
"{",
"return",
"content",... | // lineTrunc - truncates a string to the given maximum length by
// adding ellipsis in the middle | [
"lineTrunc",
"-",
"truncates",
"a",
"string",
"to",
"the",
"given",
"maximum",
"length",
"by",
"adding",
"ellipsis",
"in",
"the",
"middle"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L153-L163 | train |
minio/mc | cmd/utils.go | isOlder | func isOlder(ti time.Time, olderRef string) bool {
objectAge := UTCNow().Sub(ti)
var e error
var olderThan time.Duration
if olderRef != "" {
olderThan, e = ioutils.ParseDurationTime(olderRef)
fatalIf(probe.NewError(e), "Unable to parse olderThan=`"+olderRef+"`.")
}
return objectAge < olderThan
} | go | func isOlder(ti time.Time, olderRef string) bool {
objectAge := UTCNow().Sub(ti)
var e error
var olderThan time.Duration
if olderRef != "" {
olderThan, e = ioutils.ParseDurationTime(olderRef)
fatalIf(probe.NewError(e), "Unable to parse olderThan=`"+olderRef+"`.")
}
return objectAge < olderThan
} | [
"func",
"isOlder",
"(",
"ti",
"time",
".",
"Time",
",",
"olderRef",
"string",
")",
"bool",
"{",
"objectAge",
":=",
"UTCNow",
"(",
")",
".",
"Sub",
"(",
"ti",
")",
"\n",
"var",
"e",
"error",
"\n",
"var",
"olderThan",
"time",
".",
"Duration",
"\n",
"... | // isOlder returns true if the passed object is older than olderRef | [
"isOlder",
"returns",
"true",
"if",
"the",
"passed",
"object",
"is",
"older",
"than",
"olderRef"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L166-L175 | train |
minio/mc | cmd/utils.go | isNewer | func isNewer(ti time.Time, newerRef string) bool {
objectAge := UTCNow().Sub(ti)
var e error
var newerThan time.Duration
if newerRef != "" {
newerThan, e = ioutils.ParseDurationTime(newerRef)
fatalIf(probe.NewError(e), "Unable to parse newerThan=`"+newerRef+"`.")
}
return objectAge >= newerThan
} | go | func isNewer(ti time.Time, newerRef string) bool {
objectAge := UTCNow().Sub(ti)
var e error
var newerThan time.Duration
if newerRef != "" {
newerThan, e = ioutils.ParseDurationTime(newerRef)
fatalIf(probe.NewError(e), "Unable to parse newerThan=`"+newerRef+"`.")
}
return objectAge >= newerThan
} | [
"func",
"isNewer",
"(",
"ti",
"time",
".",
"Time",
",",
"newerRef",
"string",
")",
"bool",
"{",
"objectAge",
":=",
"UTCNow",
"(",
")",
".",
"Sub",
"(",
"ti",
")",
"\n",
"var",
"e",
"error",
"\n",
"var",
"newerThan",
"time",
".",
"Duration",
"\n",
"... | // isNewer returns true if the passed object is newer than newerRef | [
"isNewer",
"returns",
"true",
"if",
"the",
"passed",
"object",
"is",
"newer",
"than",
"newerRef"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L178-L187 | train |
minio/mc | cmd/utils.go | getLookupType | func getLookupType(l string) minio.BucketLookupType {
l = strings.ToLower(l)
switch l {
case "dns":
return minio.BucketLookupDNS
case "path":
return minio.BucketLookupPath
}
return minio.BucketLookupAuto
} | go | func getLookupType(l string) minio.BucketLookupType {
l = strings.ToLower(l)
switch l {
case "dns":
return minio.BucketLookupDNS
case "path":
return minio.BucketLookupPath
}
return minio.BucketLookupAuto
} | [
"func",
"getLookupType",
"(",
"l",
"string",
")",
"minio",
".",
"BucketLookupType",
"{",
"l",
"=",
"strings",
".",
"ToLower",
"(",
"l",
")",
"\n",
"switch",
"l",
"{",
"case",
"\"",
"\"",
":",
"return",
"minio",
".",
"BucketLookupDNS",
"\n",
"case",
"\"... | // getLookupType returns the minio.BucketLookupType for lookup
// option entered on the command line | [
"getLookupType",
"returns",
"the",
"minio",
".",
"BucketLookupType",
"for",
"lookup",
"option",
"entered",
"on",
"the",
"command",
"line"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L191-L200 | train |
minio/mc | cmd/utils.go | parseAndValidateEncryptionKeys | func parseAndValidateEncryptionKeys(sseKeys string, sse string) (encMap map[string][]prefixSSEPair, err *probe.Error) {
encMap, err = parseEncryptionKeys(sseKeys)
if err != nil {
return nil, err
}
if sse != "" {
for _, prefix := range strings.Split(sse, ",") {
alias, _ := url2Alias(prefix)
encMap[alias] =... | go | func parseAndValidateEncryptionKeys(sseKeys string, sse string) (encMap map[string][]prefixSSEPair, err *probe.Error) {
encMap, err = parseEncryptionKeys(sseKeys)
if err != nil {
return nil, err
}
if sse != "" {
for _, prefix := range strings.Split(sse, ",") {
alias, _ := url2Alias(prefix)
encMap[alias] =... | [
"func",
"parseAndValidateEncryptionKeys",
"(",
"sseKeys",
"string",
",",
"sse",
"string",
")",
"(",
"encMap",
"map",
"[",
"string",
"]",
"[",
"]",
"prefixSSEPair",
",",
"err",
"*",
"probe",
".",
"Error",
")",
"{",
"encMap",
",",
"err",
"=",
"parseEncryptio... | // parse and validate encryption keys entered on command line | [
"parse",
"and",
"validate",
"encryption",
"keys",
"entered",
"on",
"command",
"line"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L209-L231 | train |
minio/mc | cmd/utils.go | getSSE | func getSSE(resource string, encKeys []prefixSSEPair) encrypt.ServerSide {
for _, k := range encKeys {
if strings.HasPrefix(resource, k.Prefix) {
return k.SSE
}
}
return nil
} | go | func getSSE(resource string, encKeys []prefixSSEPair) encrypt.ServerSide {
for _, k := range encKeys {
if strings.HasPrefix(resource, k.Prefix) {
return k.SSE
}
}
return nil
} | [
"func",
"getSSE",
"(",
"resource",
"string",
",",
"encKeys",
"[",
"]",
"prefixSSEPair",
")",
"encrypt",
".",
"ServerSide",
"{",
"for",
"_",
",",
"k",
":=",
"range",
"encKeys",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"resource",
",",
"k",
".",
"Pre... | // get SSE Key if object prefix matches with given resource. | [
"get",
"SSE",
"Key",
"if",
"object",
"prefix",
"matches",
"with",
"given",
"resource",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/utils.go#L295-L302 | train |
minio/mc | cmd/config.go | getMcConfigDir | func getMcConfigDir() (string, *probe.Error) {
if mcCustomConfigDir != "" {
return mcCustomConfigDir, nil
}
homeDir, e := homedir.Dir()
if e != nil {
return "", probe.NewError(e)
}
var configDir string
// For windows the path is slightly different
if runtime.GOOS == "windows" {
configDir = filepath.Join(h... | go | func getMcConfigDir() (string, *probe.Error) {
if mcCustomConfigDir != "" {
return mcCustomConfigDir, nil
}
homeDir, e := homedir.Dir()
if e != nil {
return "", probe.NewError(e)
}
var configDir string
// For windows the path is slightly different
if runtime.GOOS == "windows" {
configDir = filepath.Join(h... | [
"func",
"getMcConfigDir",
"(",
")",
"(",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"if",
"mcCustomConfigDir",
"!=",
"\"",
"\"",
"{",
"return",
"mcCustomConfigDir",
",",
"nil",
"\n",
"}",
"\n",
"homeDir",
",",
"e",
":=",
"homedir",
".",
"Dir"... | // getMcConfigDir - construct MinIO Client config folder. | [
"getMcConfigDir",
"-",
"construct",
"MinIO",
"Client",
"config",
"folder",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L41-L57 | train |
minio/mc | cmd/config.go | mustGetMcConfigDir | func mustGetMcConfigDir() (configDir string) {
configDir, err := getMcConfigDir()
fatalIf(err.Trace(), "Unable to get mcConfigDir.")
return configDir
} | go | func mustGetMcConfigDir() (configDir string) {
configDir, err := getMcConfigDir()
fatalIf(err.Trace(), "Unable to get mcConfigDir.")
return configDir
} | [
"func",
"mustGetMcConfigDir",
"(",
")",
"(",
"configDir",
"string",
")",
"{",
"configDir",
",",
"err",
":=",
"getMcConfigDir",
"(",
")",
"\n",
"fatalIf",
"(",
"err",
".",
"Trace",
"(",
")",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"configDir",
"\n",
"}"... | // mustGetMcConfigDir - construct MinIO Client config folder or fail | [
"mustGetMcConfigDir",
"-",
"construct",
"MinIO",
"Client",
"config",
"folder",
"or",
"fail"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L60-L65 | train |
minio/mc | cmd/config.go | createMcConfigDir | func createMcConfigDir() *probe.Error {
p, err := getMcConfigDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | go | func createMcConfigDir() *probe.Error {
p, err := getMcConfigDir()
if err != nil {
return err.Trace()
}
if e := os.MkdirAll(p, 0700); e != nil {
return probe.NewError(e)
}
return nil
} | [
"func",
"createMcConfigDir",
"(",
")",
"*",
"probe",
".",
"Error",
"{",
"p",
",",
"err",
":=",
"getMcConfigDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Trace",
"(",
")",
"\n",
"}",
"\n",
"if",
"e",
":=",
"os",
".",
... | // createMcConfigDir - create MinIO Client config folder | [
"createMcConfigDir",
"-",
"create",
"MinIO",
"Client",
"config",
"folder"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L68-L77 | train |
minio/mc | cmd/config.go | getMcConfigPath | func getMcConfigPath() (string, *probe.Error) {
if mcCustomConfigDir != "" {
return filepath.Join(mcCustomConfigDir, globalMCConfigFile), nil
}
dir, err := getMcConfigDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(dir, globalMCConfigFile), nil
} | go | func getMcConfigPath() (string, *probe.Error) {
if mcCustomConfigDir != "" {
return filepath.Join(mcCustomConfigDir, globalMCConfigFile), nil
}
dir, err := getMcConfigDir()
if err != nil {
return "", err.Trace()
}
return filepath.Join(dir, globalMCConfigFile), nil
} | [
"func",
"getMcConfigPath",
"(",
")",
"(",
"string",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"if",
"mcCustomConfigDir",
"!=",
"\"",
"\"",
"{",
"return",
"filepath",
".",
"Join",
"(",
"mcCustomConfigDir",
",",
"globalMCConfigFile",
")",
",",
"nil",
"\n",
... | // getMcConfigPath - construct MinIO Client configuration path | [
"getMcConfigPath",
"-",
"construct",
"MinIO",
"Client",
"configuration",
"path"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L80-L89 | train |
minio/mc | cmd/config.go | loadMcConfigFactory | func loadMcConfigFactory() func() (*configV9, *probe.Error) {
// Load once and cache in a closure.
cfgCache, err := loadConfigV9()
// loadMcConfig - reads configuration file and returns config.
return func() (*configV9, *probe.Error) {
return cfgCache, err
}
} | go | func loadMcConfigFactory() func() (*configV9, *probe.Error) {
// Load once and cache in a closure.
cfgCache, err := loadConfigV9()
// loadMcConfig - reads configuration file and returns config.
return func() (*configV9, *probe.Error) {
return cfgCache, err
}
} | [
"func",
"loadMcConfigFactory",
"(",
")",
"func",
"(",
")",
"(",
"*",
"configV9",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"// Load once and cache in a closure.",
"cfgCache",
",",
"err",
":=",
"loadConfigV9",
"(",
")",
"\n\n",
"// loadMcConfig - reads configurati... | // loadMcConfigCached - returns loadMcConfig with a closure for config cache. | [
"loadMcConfigCached",
"-",
"returns",
"loadMcConfig",
"with",
"a",
"closure",
"for",
"config",
"cache",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L107-L115 | train |
minio/mc | cmd/config.go | saveMcConfig | func saveMcConfig(config *configV9) *probe.Error {
if config == nil {
return errInvalidArgument().Trace()
}
err := createMcConfigDir()
if err != nil {
return err.Trace(mustGetMcConfigDir())
}
// Save the config.
if err := saveConfigV9(config); err != nil {
return err.Trace(mustGetMcConfigPath())
}
// ... | go | func saveMcConfig(config *configV9) *probe.Error {
if config == nil {
return errInvalidArgument().Trace()
}
err := createMcConfigDir()
if err != nil {
return err.Trace(mustGetMcConfigDir())
}
// Save the config.
if err := saveConfigV9(config); err != nil {
return err.Trace(mustGetMcConfigPath())
}
// ... | [
"func",
"saveMcConfig",
"(",
"config",
"*",
"configV9",
")",
"*",
"probe",
".",
"Error",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"errInvalidArgument",
"(",
")",
".",
"Trace",
"(",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"createMcConfigDir",
"(",
... | // saveMcConfig - saves configuration file and returns error if any. | [
"saveMcConfig",
"-",
"saves",
"configuration",
"file",
"and",
"returns",
"error",
"if",
"any",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L121-L139 | train |
minio/mc | cmd/config.go | isMcConfigExists | func isMcConfigExists() bool {
configFile, err := getMcConfigPath()
if err != nil {
return false
}
if _, e := os.Stat(configFile); e != nil {
return false
}
return true
} | go | func isMcConfigExists() bool {
configFile, err := getMcConfigPath()
if err != nil {
return false
}
if _, e := os.Stat(configFile); e != nil {
return false
}
return true
} | [
"func",
"isMcConfigExists",
"(",
")",
"bool",
"{",
"configFile",
",",
"err",
":=",
"getMcConfigPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"_",
",",
"e",
":=",
"os",
".",
"Stat",
"(",
"configFile",
... | // isMcConfigExists returns err if config doesn't exist. | [
"isMcConfigExists",
"returns",
"err",
"if",
"config",
"doesn",
"t",
"exist",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L142-L151 | train |
minio/mc | cmd/config.go | getHostConfig | func getHostConfig(alias string) (*hostConfigV9, *probe.Error) {
mcCfg, err := loadMcConfig()
if err != nil {
return nil, err.Trace(alias)
}
// if host is exact return quickly.
if _, ok := mcCfg.Hosts[alias]; ok {
hostCfg := mcCfg.Hosts[alias]
return &hostCfg, nil
}
// return error if cannot be matched.
... | go | func getHostConfig(alias string) (*hostConfigV9, *probe.Error) {
mcCfg, err := loadMcConfig()
if err != nil {
return nil, err.Trace(alias)
}
// if host is exact return quickly.
if _, ok := mcCfg.Hosts[alias]; ok {
hostCfg := mcCfg.Hosts[alias]
return &hostCfg, nil
}
// return error if cannot be matched.
... | [
"func",
"getHostConfig",
"(",
"alias",
"string",
")",
"(",
"*",
"hostConfigV9",
",",
"*",
"probe",
".",
"Error",
")",
"{",
"mcCfg",
",",
"err",
":=",
"loadMcConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
".",
"... | // getHostConfig retrieves host specific configuration such as access keys, signature type. | [
"getHostConfig",
"retrieves",
"host",
"specific",
"configuration",
"such",
"as",
"access",
"keys",
"signature",
"type",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L159-L173 | train |
minio/mc | cmd/config.go | mustGetHostConfig | func mustGetHostConfig(alias string) *hostConfigV9 {
hostCfg, _ := getHostConfig(alias)
// If alias is not found,
// look for it in the environment variable.
if hostCfg == nil {
if envConfig, ok := os.LookupEnv(mcEnvHostPrefix + alias); ok {
hostCfg, _ = expandAliasFromEnv(envConfig)
}
}
if hostCfg == nil ... | go | func mustGetHostConfig(alias string) *hostConfigV9 {
hostCfg, _ := getHostConfig(alias)
// If alias is not found,
// look for it in the environment variable.
if hostCfg == nil {
if envConfig, ok := os.LookupEnv(mcEnvHostPrefix + alias); ok {
hostCfg, _ = expandAliasFromEnv(envConfig)
}
}
if hostCfg == nil ... | [
"func",
"mustGetHostConfig",
"(",
"alias",
"string",
")",
"*",
"hostConfigV9",
"{",
"hostCfg",
",",
"_",
":=",
"getHostConfig",
"(",
"alias",
")",
"\n",
"// If alias is not found,",
"// look for it in the environment variable.",
"if",
"hostCfg",
"==",
"nil",
"{",
"i... | // mustGetHostConfig retrieves host specific configuration such as access keys, signature type. | [
"mustGetHostConfig",
"retrieves",
"host",
"specific",
"configuration",
"such",
"as",
"access",
"keys",
"signature",
"type",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L176-L192 | train |
minio/mc | cmd/config.go | expandAlias | func expandAlias(aliasedURL string) (alias string, urlStr string, hostCfg *hostConfigV9, err *probe.Error) {
// Extract alias from the URL.
alias, path := url2Alias(aliasedURL)
var envConfig string
var ok bool
if envConfig, ok = os.LookupEnv(mcEnvHostPrefix + alias); !ok {
envConfig, ok = os.LookupEnv(mcEnvHos... | go | func expandAlias(aliasedURL string) (alias string, urlStr string, hostCfg *hostConfigV9, err *probe.Error) {
// Extract alias from the URL.
alias, path := url2Alias(aliasedURL)
var envConfig string
var ok bool
if envConfig, ok = os.LookupEnv(mcEnvHostPrefix + alias); !ok {
envConfig, ok = os.LookupEnv(mcEnvHos... | [
"func",
"expandAlias",
"(",
"aliasedURL",
"string",
")",
"(",
"alias",
"string",
",",
"urlStr",
"string",
",",
"hostCfg",
"*",
"hostConfigV9",
",",
"err",
"*",
"probe",
".",
"Error",
")",
"{",
"// Extract alias from the URL.",
"alias",
",",
"path",
":=",
"ur... | // expandAlias expands aliased URL if any match is found, returns as is otherwise. | [
"expandAlias",
"expands",
"aliased",
"URL",
"if",
"any",
"match",
"is",
"found",
"returns",
"as",
"is",
"otherwise",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L281-L308 | train |
minio/mc | cmd/config.go | mustExpandAlias | func mustExpandAlias(aliasedURL string) (alias string, urlStr string, hostCfg *hostConfigV9) {
alias, urlStr, hostCfg, _ = expandAlias(aliasedURL)
return alias, urlStr, hostCfg
} | go | func mustExpandAlias(aliasedURL string) (alias string, urlStr string, hostCfg *hostConfigV9) {
alias, urlStr, hostCfg, _ = expandAlias(aliasedURL)
return alias, urlStr, hostCfg
} | [
"func",
"mustExpandAlias",
"(",
"aliasedURL",
"string",
")",
"(",
"alias",
"string",
",",
"urlStr",
"string",
",",
"hostCfg",
"*",
"hostConfigV9",
")",
"{",
"alias",
",",
"urlStr",
",",
"hostCfg",
",",
"_",
"=",
"expandAlias",
"(",
"aliasedURL",
")",
"\n",... | // mustExpandAlias expands aliased URL if any match is found, returns as is otherwise. | [
"mustExpandAlias",
"expands",
"aliased",
"URL",
"if",
"any",
"match",
"is",
"found",
"returns",
"as",
"is",
"otherwise",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config.go#L311-L314 | train |
minio/mc | cmd/config-fix.go | newBrokenConfigV3 | func newBrokenConfigV3() *brokenConfigV3 {
conf := new(brokenConfigV3)
conf.Version = "3"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]brokenHostConfigV3)
return conf
} | go | func newBrokenConfigV3() *brokenConfigV3 {
conf := new(brokenConfigV3)
conf.Version = "3"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]brokenHostConfigV3)
return conf
} | [
"func",
"newBrokenConfigV3",
"(",
")",
"*",
"brokenConfigV3",
"{",
"conf",
":=",
"new",
"(",
"brokenConfigV3",
")",
"\n",
"conf",
".",
"Version",
"=",
"\"",
"\"",
"\n",
"conf",
".",
"Aliases",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",... | // newConfigV3 - get new config broken version 3. | [
"newConfigV3",
"-",
"get",
"new",
"config",
"broken",
"version",
"3",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-fix.go#L55-L61 | train |
minio/mc | cmd/config-old.go | newConfigV3 | func newConfigV3() *configV3 {
conf := new(configV3)
conf.Version = "3"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV3)
return conf
} | go | func newConfigV3() *configV3 {
conf := new(configV3)
conf.Version = "3"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV3)
return conf
} | [
"func",
"newConfigV3",
"(",
")",
"*",
"configV3",
"{",
"conf",
":=",
"new",
"(",
"configV3",
")",
"\n",
"conf",
".",
"Version",
"=",
"\"",
"\"",
"\n",
"conf",
".",
"Aliases",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"conf",... | // newConfigV3 - get new config version 3. | [
"newConfigV3",
"-",
"get",
"new",
"config",
"version",
"3",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-old.go#L91-L97 | train |
minio/mc | cmd/config-old.go | newConfigV6 | func newConfigV6() *configV6 {
conf := new(configV6)
conf.Version = "6"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV6)
return conf
} | go | func newConfigV6() *configV6 {
conf := new(configV6)
conf.Version = "6"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV6)
return conf
} | [
"func",
"newConfigV6",
"(",
")",
"*",
"configV6",
"{",
"conf",
":=",
"new",
"(",
"configV6",
")",
"\n",
"conf",
".",
"Version",
"=",
"\"",
"\"",
"\n",
"conf",
".",
"Aliases",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"conf",... | // newConfigV6 - new config version '6'. | [
"newConfigV6",
"-",
"new",
"config",
"version",
"6",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-old.go#L155-L161 | train |
minio/mc | cmd/config-old.go | newConfigV7 | func newConfigV7() *configV7 {
cfg := new(configV7)
cfg.Version = "7"
cfg.Hosts = make(map[string]hostConfigV7)
return cfg
} | go | func newConfigV7() *configV7 {
cfg := new(configV7)
cfg.Version = "7"
cfg.Hosts = make(map[string]hostConfigV7)
return cfg
} | [
"func",
"newConfigV7",
"(",
")",
"*",
"configV7",
"{",
"cfg",
":=",
"new",
"(",
"configV7",
")",
"\n",
"cfg",
".",
"Version",
"=",
"\"",
"\"",
"\n",
"cfg",
".",
"Hosts",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"hostConfigV7",
")",
"\n",
"retur... | // newConfigV7 - new config version '7'. | [
"newConfigV7",
"-",
"new",
"config",
"version",
"7",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-old.go#L179-L184 | train |
minio/mc | cmd/config-old.go | newConfigV8 | func newConfigV8() *configV8 {
cfg := new(configV8)
cfg.Version = globalMCConfigVersion
cfg.Hosts = make(map[string]hostConfigV8)
return cfg
} | go | func newConfigV8() *configV8 {
cfg := new(configV8)
cfg.Version = globalMCConfigVersion
cfg.Hosts = make(map[string]hostConfigV8)
return cfg
} | [
"func",
"newConfigV8",
"(",
")",
"*",
"configV8",
"{",
"cfg",
":=",
"new",
"(",
"configV8",
")",
"\n",
"cfg",
".",
"Version",
"=",
"globalMCConfigVersion",
"\n",
"cfg",
".",
"Hosts",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"hostConfigV8",
")",
"\n... | // newConfigV8 - new config version. | [
"newConfigV8",
"-",
"new",
"config",
"version",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-old.go#L258-L263 | train |
minio/mc | cmd/config-host-remove.go | checkConfigHostRemoveSyntax | func checkConfigHostRemoveSyntax(ctx *cli.Context) {
args := ctx.Args()
if len(ctx.Args()) != 1 {
fatalIf(errInvalidArgument().Trace(args...),
"Incorrect number of arguments for remove host command.")
}
if !isValidAlias(args.Get(0)) {
fatalIf(errDummy().Trace(args.Get(0)),
"Invalid alias `"+args.Get(0)+... | go | func checkConfigHostRemoveSyntax(ctx *cli.Context) {
args := ctx.Args()
if len(ctx.Args()) != 1 {
fatalIf(errInvalidArgument().Trace(args...),
"Incorrect number of arguments for remove host command.")
}
if !isValidAlias(args.Get(0)) {
fatalIf(errDummy().Trace(args.Get(0)),
"Invalid alias `"+args.Get(0)+... | [
"func",
"checkConfigHostRemoveSyntax",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"args",
":=",
"ctx",
".",
"Args",
"(",
")",
"\n\n",
"if",
"len",
"(",
"ctx",
".",
"Args",
"(",
")",
")",
"!=",
"1",
"{",
"fatalIf",
"(",
"errInvalidArgument",
"(... | // checkConfigHostRemoveSyntax - verifies input arguments to 'config host remove'. | [
"checkConfigHostRemoveSyntax",
"-",
"verifies",
"input",
"arguments",
"to",
"config",
"host",
"remove",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-remove.go#L50-L62 | train |
minio/mc | cmd/config-host-remove.go | mainConfigHostRemove | func mainConfigHostRemove(ctx *cli.Context) error {
checkConfigHostRemoveSyntax(ctx)
console.SetColor("HostMessage", color.New(color.FgGreen))
args := ctx.Args()
alias := args.Get(0)
removeHost(alias) // Remove a host.
return nil
} | go | func mainConfigHostRemove(ctx *cli.Context) error {
checkConfigHostRemoveSyntax(ctx)
console.SetColor("HostMessage", color.New(color.FgGreen))
args := ctx.Args()
alias := args.Get(0)
removeHost(alias) // Remove a host.
return nil
} | [
"func",
"mainConfigHostRemove",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"checkConfigHostRemoveSyntax",
"(",
"ctx",
")",
"\n\n",
"console",
".",
"SetColor",
"(",
"\"",
"\"",
",",
"color",
".",
"New",
"(",
"color",
".",
"FgGreen",
")",
"... | // mainConfigHost is the handle for "mc config host rm" command. | [
"mainConfigHost",
"is",
"the",
"handle",
"for",
"mc",
"config",
"host",
"rm",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-remove.go#L65-L74 | train |
minio/mc | cmd/config-host-remove.go | removeHost | func removeHost(alias string) {
conf, err := loadMcConfig()
fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config version `"+globalMCConfigVersion+"`.")
// Remove host.
delete(conf.Hosts, alias)
err = saveMcConfig(conf)
fatalIf(err.Trace(alias), "Unable to save deleted hosts in config version `"+glob... | go | func removeHost(alias string) {
conf, err := loadMcConfig()
fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config version `"+globalMCConfigVersion+"`.")
// Remove host.
delete(conf.Hosts, alias)
err = saveMcConfig(conf)
fatalIf(err.Trace(alias), "Unable to save deleted hosts in config version `"+glob... | [
"func",
"removeHost",
"(",
"alias",
"string",
")",
"{",
"conf",
",",
"err",
":=",
"loadMcConfig",
"(",
")",
"\n",
"fatalIf",
"(",
"err",
".",
"Trace",
"(",
"globalMCConfigVersion",
")",
",",
"\"",
"\"",
"+",
"globalMCConfigVersion",
"+",
"\"",
"\"",
")",... | // removeHost - removes a host. | [
"removeHost",
"-",
"removes",
"a",
"host",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host-remove.go#L77-L88 | train |
minio/mc | cmd/config-host.go | mainConfigHost | func mainConfigHost(ctx *cli.Context) error {
cli.ShowCommandHelp(ctx, ctx.Args().First())
return nil
// Sub-commands like "remove", "list" have their own main.
} | go | func mainConfigHost(ctx *cli.Context) error {
cli.ShowCommandHelp(ctx, ctx.Args().First())
return nil
// Sub-commands like "remove", "list" have their own main.
} | [
"func",
"mainConfigHost",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cli",
".",
"ShowCommandHelp",
"(",
"ctx",
",",
"ctx",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
")",
"\n",
"return",
"nil",
"\n",
"// Sub-commands like \"remove\",... | // mainConfigHost is the handle for "mc config host" command. | [
"mainConfigHost",
"is",
"the",
"handle",
"for",
"mc",
"config",
"host",
"command",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host.go#L41-L45 | train |
minio/mc | cmd/config-host.go | String | func (h hostMessage) String() string {
switch h.op {
case "list":
// Create a new pretty table with cols configuration
t := newPrettyRecord(2,
Row{"Alias", "Alias"},
Row{"URL", "URL"},
Row{"AccessKey", "AccessKey"},
Row{"SecretKey", "SecretKey"},
Row{"API", "API"},
Row{"Lookup", "Lookup"},
)
... | go | func (h hostMessage) String() string {
switch h.op {
case "list":
// Create a new pretty table with cols configuration
t := newPrettyRecord(2,
Row{"Alias", "Alias"},
Row{"URL", "URL"},
Row{"AccessKey", "AccessKey"},
Row{"SecretKey", "SecretKey"},
Row{"API", "API"},
Row{"Lookup", "Lookup"},
)
... | [
"func",
"(",
"h",
"hostMessage",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"h",
".",
"op",
"{",
"case",
"\"",
"\"",
":",
"// Create a new pretty table with cols configuration",
"t",
":=",
"newPrettyRecord",
"(",
"2",
",",
"Row",
"{",
"\"",
"\"",
",... | // Print the config information of one alias, when prettyPrint flag
// is activated, fields contents are cut and '...' will be added to
// show a pretty table of all aliases configurations | [
"Print",
"the",
"config",
"information",
"of",
"one",
"alias",
"when",
"prettyPrint",
"flag",
"is",
"activated",
"fields",
"contents",
"are",
"cut",
"and",
"...",
"will",
"be",
"added",
"to",
"show",
"a",
"pretty",
"table",
"of",
"all",
"aliases",
"configura... | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host.go#L63-L83 | train |
minio/mc | cmd/config-host.go | JSON | func (h hostMessage) JSON() string {
h.Status = "success"
jsonMessageBytes, e := json.MarshalIndent(h, "", " ")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
return string(jsonMessageBytes)
} | go | func (h hostMessage) JSON() string {
h.Status = "success"
jsonMessageBytes, e := json.MarshalIndent(h, "", " ")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
return string(jsonMessageBytes)
} | [
"func",
"(",
"h",
"hostMessage",
")",
"JSON",
"(",
")",
"string",
"{",
"h",
".",
"Status",
"=",
"\"",
"\"",
"\n",
"jsonMessageBytes",
",",
"e",
":=",
"json",
".",
"MarshalIndent",
"(",
"h",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fatalIf",
... | // JSON jsonified host message | [
"JSON",
"jsonified",
"host",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/config-host.go#L86-L92 | train |
minio/mc | cmd/find.go | regexMatch | func regexMatch(pattern, path string) bool {
matched, e := regexp.MatchString(pattern, path)
errorIf(probe.NewError(e).Trace(pattern), "Unable to regex match with input pattern.")
return matched
} | go | func regexMatch(pattern, path string) bool {
matched, e := regexp.MatchString(pattern, path)
errorIf(probe.NewError(e).Trace(pattern), "Unable to regex match with input pattern.")
return matched
} | [
"func",
"regexMatch",
"(",
"pattern",
",",
"path",
"string",
")",
"bool",
"{",
"matched",
",",
"e",
":=",
"regexp",
".",
"MatchString",
"(",
"pattern",
",",
"path",
")",
"\n",
"errorIf",
"(",
"probe",
".",
"NewError",
"(",
"e",
")",
".",
"Trace",
"("... | // regexMatch reports whether path matches the regex pattern. | [
"regexMatch",
"reports",
"whether",
"path",
"matches",
"the",
"regex",
"pattern",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/find.go#L95-L99 | train |
minio/mc | cmd/find.go | execFind | func execFind(command string) {
commandArgs := strings.Split(command, " ")
cmd := exec.Command(commandArgs[0], commandArgs[1:]...)
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
console.Print(console.Colorize("FindExecErr", stderr.String()... | go | func execFind(command string) {
commandArgs := strings.Split(command, " ")
cmd := exec.Command(commandArgs[0], commandArgs[1:]...)
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
console.Print(console.Colorize("FindExecErr", stderr.String()... | [
"func",
"execFind",
"(",
"command",
"string",
")",
"{",
"commandArgs",
":=",
"strings",
".",
"Split",
"(",
"command",
",",
"\"",
"\"",
")",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"commandArgs",
"[",
"0",
"]",
",",
"commandArgs",
"[",
"1",
... | // execFind executes the input command line, additionally formats input
// for the command line in accordance with subsititution arguments. | [
"execFind",
"executes",
"the",
"input",
"command",
"line",
"additionally",
"formats",
"input",
"for",
"the",
"command",
"line",
"in",
"accordance",
"with",
"subsititution",
"arguments",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/find.go#L115-L129 | train |
minio/mc | cmd/find.go | doFind | func doFind(ctx *findContext) error {
// If watch is enabled we will wait on the prefix perpetually
// for all I/O events until canceled by user, if watch is not enabled
// following defer is a no-op.
defer watchFind(ctx)
var prevKeyName string
// iterate over all content which is within the given directory
fo... | go | func doFind(ctx *findContext) error {
// If watch is enabled we will wait on the prefix perpetually
// for all I/O events until canceled by user, if watch is not enabled
// following defer is a no-op.
defer watchFind(ctx)
var prevKeyName string
// iterate over all content which is within the given directory
fo... | [
"func",
"doFind",
"(",
"ctx",
"*",
"findContext",
")",
"error",
"{",
"// If watch is enabled we will wait on the prefix perpetually",
"// for all I/O events until canceled by user, if watch is not enabled",
"// following defer is a no-op.",
"defer",
"watchFind",
"(",
"ctx",
")",
"\... | // doFind - find is main function body which interprets and executes
// all the input parameters. | [
"doFind",
"-",
"find",
"is",
"main",
"function",
"body",
"which",
"interprets",
"and",
"executes",
"all",
"the",
"input",
"parameters",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/find.go#L244-L306 | train |
minio/mc | cmd/find.go | matchFind | func matchFind(ctx *findContext, fileContent contentMessage) (match bool) {
match = true
prefixPath := ctx.targetURL
// Add separator only if targetURL doesn't already have separator.
if !strings.HasPrefix(prefixPath, string(ctx.clnt.GetURL().Separator)) {
prefixPath = ctx.targetURL + string(ctx.clnt.GetURL().Sep... | go | func matchFind(ctx *findContext, fileContent contentMessage) (match bool) {
match = true
prefixPath := ctx.targetURL
// Add separator only if targetURL doesn't already have separator.
if !strings.HasPrefix(prefixPath, string(ctx.clnt.GetURL().Separator)) {
prefixPath = ctx.targetURL + string(ctx.clnt.GetURL().Sep... | [
"func",
"matchFind",
"(",
"ctx",
"*",
"findContext",
",",
"fileContent",
"contentMessage",
")",
"(",
"match",
"bool",
")",
"{",
"match",
"=",
"true",
"\n",
"prefixPath",
":=",
"ctx",
".",
"targetURL",
"\n",
"// Add separator only if targetURL doesn't already have se... | // matchFind matches whether fileContent matches appropriately with standard
// "pattern matching" flags requested by the user, such as "name", "path", "regex" ..etc. | [
"matchFind",
"matches",
"whether",
"fileContent",
"matches",
"appropriately",
"with",
"standard",
"pattern",
"matching",
"flags",
"requested",
"by",
"the",
"user",
"such",
"as",
"name",
"path",
"regex",
"..",
"etc",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/find.go#L377-L412 | train |
minio/mc | pkg/hookreader/hookreader.go | Read | func (hr *hookReader) Read(b []byte) (n int, err error) {
n, err = hr.source.Read(b)
if err != nil && err != io.EOF {
return n, err
}
// Progress the hook with the total read bytes from the source.
if _, herr := hr.hook.Read(b[:n]); herr != nil {
if herr != io.EOF {
return n, herr
}
}
return n, err
} | go | func (hr *hookReader) Read(b []byte) (n int, err error) {
n, err = hr.source.Read(b)
if err != nil && err != io.EOF {
return n, err
}
// Progress the hook with the total read bytes from the source.
if _, herr := hr.hook.Read(b[:n]); herr != nil {
if herr != io.EOF {
return n, herr
}
}
return n, err
} | [
"func",
"(",
"hr",
"*",
"hookReader",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"n",
",",
"err",
"=",
"hr",
".",
"source",
".",
"Read",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",... | // Read implements io.Reader. Always reads from the source, the return
// value 'n' number of bytes are reported through the hook. Returns
// error for all non io.EOF conditions. | [
"Read",
"implements",
"io",
".",
"Reader",
".",
"Always",
"reads",
"from",
"the",
"source",
"the",
"return",
"value",
"n",
"number",
"of",
"bytes",
"are",
"reported",
"through",
"the",
"hook",
".",
"Returns",
"error",
"for",
"all",
"non",
"io",
".",
"EOF... | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/hookreader/hookreader.go#L53-L65 | train |
minio/mc | pkg/hookreader/hookreader.go | NewHook | func NewHook(source, hook io.Reader) io.Reader {
if hook == nil {
return source
}
return &hookReader{source, hook}
} | go | func NewHook(source, hook io.Reader) io.Reader {
if hook == nil {
return source
}
return &hookReader{source, hook}
} | [
"func",
"NewHook",
"(",
"source",
",",
"hook",
"io",
".",
"Reader",
")",
"io",
".",
"Reader",
"{",
"if",
"hook",
"==",
"nil",
"{",
"return",
"source",
"\n",
"}",
"\n",
"return",
"&",
"hookReader",
"{",
"source",
",",
"hook",
"}",
"\n",
"}"
] | // NewHook returns a io.Reader which implements hookReader that
// reports the data read from the source to the hook. | [
"NewHook",
"returns",
"a",
"io",
".",
"Reader",
"which",
"implements",
"hookReader",
"that",
"reports",
"the",
"data",
"read",
"from",
"the",
"source",
"to",
"the",
"hook",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/hookreader/hookreader.go#L69-L74 | train |
minio/mc | cmd/admin-heal.go | JSON | func (s stopHealMessage) JSON() string {
stopHealJSONBytes, e := json.MarshalIndent(s, "", " ")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
return string(stopHealJSONBytes)
} | go | func (s stopHealMessage) JSON() string {
stopHealJSONBytes, e := json.MarshalIndent(s, "", " ")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
return string(stopHealJSONBytes)
} | [
"func",
"(",
"s",
"stopHealMessage",
")",
"JSON",
"(",
")",
"string",
"{",
"stopHealJSONBytes",
",",
"e",
":=",
"json",
".",
"MarshalIndent",
"(",
"s",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fatalIf",
"(",
"probe",
".",
"NewError",
"(",
"e",
... | // JSON jsonified stop heal message. | [
"JSON",
"jsonified",
"stop",
"heal",
"message",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-heal.go#L129-L134 | train |
minio/mc | cmd/admin-heal.go | mainAdminHeal | func mainAdminHeal(ctx *cli.Context) error {
// Check for command syntax
checkAdminHealSyntax(ctx)
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
console.SetColor("Heal", color.New(color.FgGreen, color.Bold))
console.SetColor("HealUpdateUI", color.New(color.FgYellow, color.Bo... | go | func mainAdminHeal(ctx *cli.Context) error {
// Check for command syntax
checkAdminHealSyntax(ctx)
// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)
console.SetColor("Heal", color.New(color.FgGreen, color.Bold))
console.SetColor("HealUpdateUI", color.New(color.FgYellow, color.Bo... | [
"func",
"mainAdminHeal",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Check for command syntax",
"checkAdminHealSyntax",
"(",
"ctx",
")",
"\n\n",
"// Get the alias parameter from cli",
"args",
":=",
"ctx",
".",
"Args",
"(",
")",
"\n",
"aliasedURL... | // mainAdminHeal - the entry function of heal command | [
"mainAdminHeal",
"-",
"the",
"entry",
"function",
"of",
"heal",
"command"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/admin-heal.go#L145-L212 | train |
minio/mc | cmd/diff-main.go | String | func (d diffMessage) String() string {
msg := ""
switch d.Diff {
case differInFirst:
msg = console.Colorize("DiffOnlyInFirst", "< "+d.FirstURL)
case differInSecond:
msg = console.Colorize("DiffOnlyInSecond", "> "+d.SecondURL)
case differInType:
msg = console.Colorize("DiffType", "! "+d.SecondURL)
case diffe... | go | func (d diffMessage) String() string {
msg := ""
switch d.Diff {
case differInFirst:
msg = console.Colorize("DiffOnlyInFirst", "< "+d.FirstURL)
case differInSecond:
msg = console.Colorize("DiffOnlyInSecond", "> "+d.SecondURL)
case differInType:
msg = console.Colorize("DiffType", "! "+d.SecondURL)
case diffe... | [
"func",
"(",
"d",
"diffMessage",
")",
"String",
"(",
")",
"string",
"{",
"msg",
":=",
"\"",
"\"",
"\n",
"switch",
"d",
".",
"Diff",
"{",
"case",
"differInFirst",
":",
"msg",
"=",
"console",
".",
"Colorize",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
... | // String colorized diff message | [
"String",
"colorized",
"diff",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/diff-main.go#L81-L100 | train |
minio/mc | cmd/diff-main.go | JSON | func (d diffMessage) JSON() string {
d.Status = "success"
diffJSONBytes, e := json.MarshalIndent(d, "", " ")
fatalIf(probe.NewError(e),
"Unable to marshal diff message `"+d.FirstURL+"`, `"+d.SecondURL+"` and `"+string(d.Diff)+"`.")
return string(diffJSONBytes)
} | go | func (d diffMessage) JSON() string {
d.Status = "success"
diffJSONBytes, e := json.MarshalIndent(d, "", " ")
fatalIf(probe.NewError(e),
"Unable to marshal diff message `"+d.FirstURL+"`, `"+d.SecondURL+"` and `"+string(d.Diff)+"`.")
return string(diffJSONBytes)
} | [
"func",
"(",
"d",
"diffMessage",
")",
"JSON",
"(",
")",
"string",
"{",
"d",
".",
"Status",
"=",
"\"",
"\"",
"\n",
"diffJSONBytes",
",",
"e",
":=",
"json",
".",
"MarshalIndent",
"(",
"d",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fatalIf",
"("... | // JSON jsonified diff message | [
"JSON",
"jsonified",
"diff",
"message"
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/diff-main.go#L103-L109 | train |
minio/mc | cmd/diff-main.go | doDiffMain | func doDiffMain(firstURL, secondURL string) error {
// Source and targets are always directories
sourceSeparator := string(newClientURL(firstURL).Separator)
if !strings.HasSuffix(firstURL, sourceSeparator) {
firstURL = firstURL + sourceSeparator
}
targetSeparator := string(newClientURL(secondURL).Separator)
if ... | go | func doDiffMain(firstURL, secondURL string) error {
// Source and targets are always directories
sourceSeparator := string(newClientURL(firstURL).Separator)
if !strings.HasSuffix(firstURL, sourceSeparator) {
firstURL = firstURL + sourceSeparator
}
targetSeparator := string(newClientURL(secondURL).Separator)
if ... | [
"func",
"doDiffMain",
"(",
"firstURL",
",",
"secondURL",
"string",
")",
"error",
"{",
"// Source and targets are always directories",
"sourceSeparator",
":=",
"string",
"(",
"newClientURL",
"(",
"firstURL",
")",
".",
"Separator",
")",
"\n",
"if",
"!",
"strings",
"... | // doDiffMain runs the diff. | [
"doDiffMain",
"runs",
"the",
"diff",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/diff-main.go#L150-L188 | train |
minio/mc | cmd/diff-main.go | mainDiff | func mainDiff(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// check 'diff' cli arguments.
checkDiffSyntax(ctx, encKeyDB)
// Additional command specific theme customization.
console.SetColor("DiffMessage", color... | go | func mainDiff(ctx *cli.Context) error {
// Parse encryption keys per command.
encKeyDB, err := getEncKeys(ctx)
fatalIf(err, "Unable to parse encryption keys.")
// check 'diff' cli arguments.
checkDiffSyntax(ctx, encKeyDB)
// Additional command specific theme customization.
console.SetColor("DiffMessage", color... | [
"func",
"mainDiff",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"// Parse encryption keys per command.",
"encKeyDB",
",",
"err",
":=",
"getEncKeys",
"(",
"ctx",
")",
"\n",
"fatalIf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n\n",
"// check 'diff' c... | // mainDiff main for 'diff'. | [
"mainDiff",
"main",
"for",
"diff",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/cmd/diff-main.go#L191-L212 | train |
minio/mc | pkg/colorjson/decode.go | isValidNumber | func isValidNumber(s string) bool {
// This function implements the JSON numbers grammar.
// See https://tools.ietf.org/html/rfc7159#section-6
// and https://json.org/number.gif
if s == "" {
return false
}
// Optional -
if s[0] == '-' {
s = s[1:]
if s == "" {
return false
}
}
// Digits
switch {
... | go | func isValidNumber(s string) bool {
// This function implements the JSON numbers grammar.
// See https://tools.ietf.org/html/rfc7159#section-6
// and https://json.org/number.gif
if s == "" {
return false
}
// Optional -
if s[0] == '-' {
s = s[1:]
if s == "" {
return false
}
}
// Digits
switch {
... | [
"func",
"isValidNumber",
"(",
"s",
"string",
")",
"bool",
"{",
"// This function implements the JSON numbers grammar.",
"// See https://tools.ietf.org/html/rfc7159#section-6",
"// and https://json.org/number.gif",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}"... | // isValidNumber reports whether s is a valid JSON number literal. | [
"isValidNumber",
"reports",
"whether",
"s",
"is",
"a",
"valid",
"JSON",
"number",
"literal",
"."
] | f0f156aca82e451c80b05d5be8eb01a04fee29dd | https://github.com/minio/mc/blob/f0f156aca82e451c80b05d5be8eb01a04fee29dd/pkg/colorjson/decode.go#L216-L273 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.