blob: 842405e68f93a09dde6a9bf47786c2bc6b0c9754 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.model.VespaModel;
import java.util.logging.Logger;
/**
* Validator to check that only infrastructure tenant can use non-default application-type
*
* @author mortent
*/
public class InfrastructureDeploymentValidator extends Validator {
private static final Logger log = Logger.getLogger(InfrastructureDeploymentValidator.class.getName());
@Override
public void validate(VespaModel model, DeployState deployState) {
// Allow the internally defined tenant owning all infrastructure applications
if (ApplicationId.global().tenant().equals(model.applicationPackage().getApplicationId().tenant())) return;
ConfigModelContext.ApplicationType applicationType = model.getAdmin().getApplicationType();
if (applicationType != ConfigModelContext.ApplicationType.DEFAULT) {
log.warning("Tenant %s is not allowed to use application type %s".formatted(model.applicationPackage().getApplicationId().toFullString(), applicationType));
throw new IllegalArgumentException("Tenant is not allowed to override application type");
}
}
}
|