mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Use -dot- subdomain notation in MapReduce console links
appspot.com is not provisioned with a multi-level wildcard SSL certificate, so URLs of the form https://service.projectid.appspot.com/path need to be rewritten as https://service-dot-projectid.appspot.com/path (and same for version names). This is a follow-up to [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231418795
This commit is contained in:
parent
6e0b8f2cfd
commit
3812c2ceda
7 changed files with 85 additions and 6 deletions
|
@ -18,11 +18,18 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.appengine.api.modules.ModulesService;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** A wrapper for {@link ModulesService} that provides a saner API. */
|
||||
public class AppEngineServiceUtilsImpl implements AppEngineServiceUtils {
|
||||
|
||||
private static final Pattern APPSPOT_HOSTNAME_PATTERN =
|
||||
Pattern.compile("^(.*)\\.appspot\\.com$");
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final ModulesService modulesService;
|
||||
|
||||
@Inject
|
||||
|
@ -56,4 +63,14 @@ public class AppEngineServiceUtilsImpl implements AppEngineServiceUtils {
|
|||
checkArgument(numInstances > 0, "Number of instances must be greater than 0");
|
||||
modulesService.setNumInstances(service, version, numInstances);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToSingleSubdomain(String hostname) {
|
||||
Matcher matcher = APPSPOT_HOSTNAME_PATTERN.matcher(hostname);
|
||||
if (!matcher.matches()) {
|
||||
logger.atWarning().log("Skipping conversion because hostname can't be parsed: %s", hostname);
|
||||
return hostname;
|
||||
}
|
||||
return matcher.group(1).replace(".", "-dot-") + ".appspot.com";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue