Skip to content

Commit

Permalink
Support --airgap in unregister command (minio#4441)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjalshireesh authored Jan 18, 2023
1 parent 6e97f16 commit 58f9fec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
19 changes: 12 additions & 7 deletions cmd/license-unregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var licenseUnregisterCmd = cli.Command{
Action: mainLicenseUnregister,
Before: setGlobalsFromContext,
Hidden: true,
Flags: supportGlobalFlags,
Flags: append(supportGlobalFlags, subnetCommonFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
Expand Down Expand Up @@ -83,14 +83,19 @@ func mainLicenseUnregister(ctx *cli.Context) error {
checkLicenseUnregisterSyntax(ctx)

aliasedURL := ctx.Args().Get(0)
alias, _ := initSubnetConnectivity(ctx, aliasedURL, false)
alias, apiKey := initSubnetConnectivity(ctx, aliasedURL, false)
if len(apiKey) == 0 {
// api key not passed as flag. Check that the cluster is registered.
apiKey = validateClusterRegistered(alias, true)
}

apiKey, e := getSubnetAPIKey(alias)
fatalIf(probe.NewError(e), "Error in fetching SUBNET API Key:")
if !globalAirgapped {
info := getAdminInfo(aliasedURL)
e := unregisterClusterFromSubnet(alias, info.DeploymentID, apiKey)
fatalIf(probe.NewError(e), "Could not unregister cluster from SUBNET:")
}

info := getAdminInfo(aliasedURL)
e = unregisterClusterFromSubnet(alias, info.DeploymentID, apiKey)
fatalIf(probe.NewError(e), "Could not unregister cluster from SUBNET:")
removeSubnetAuthConfig(alias)

printMsg(licUnregisterMessage{Status: "success", Alias: alias})
return nil
Expand Down
8 changes: 1 addition & 7 deletions cmd/subnet-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,7 @@ func unregisterClusterFromSubnet(alias string, depID string, apiKey string) erro
}

_, e = subnetPostReq(regURL, nil, headers)
if e != nil {
return e
}

removeSubnetAuthConfig(alias)

return nil
return e
}

// validateAndSaveLic - validates the given license in minio config
Expand Down

0 comments on commit 58f9fec

Please sign in to comment.