本文整理汇总了Java中com.netflix.frigga.Names类的典型用法代码示例。如果您正苦于以下问题:Java Names类的具体用法?Java Names怎么用?Java Names使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Names类属于com.netflix.frigga包,在下文中一共展示了Names类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasPermission
import com.netflix.frigga.Names; //导入依赖的package包/类
@Override
public boolean hasPermission(Authentication authentication,
Serializable resourceName,
String resourceType,
Object authorization) {
if (!Boolean.valueOf(fiatEnabled)) {
return true;
}
if (resourceName == null || resourceType == null || authorization == null) {
log.debug("Permission denied due to null argument. resourceName={}, resourceType={}, " +
"authorization={}", resourceName, resourceType, authorization);
return false;
}
ResourceType r = ResourceType.parse(resourceType);
Authorization a = null;
// Service accounts don't have read/write authorizations.
if (r != ResourceType.SERVICE_ACCOUNT) {
a = Authorization.valueOf(authorization.toString());
}
if (r == ResourceType.APPLICATION) {
val parsedName = Names.parseName(resourceName.toString()).getApp();
if (StringUtils.isNotEmpty(parsedName)) {
resourceName = parsedName;
}
}
UserPermission.View permission = getPermission(getUsername(authentication));
return permissionContains(permission, resourceName.toString(), r, a);
}
示例2: getLoadBalancerDescription
import com.netflix.frigga.Names; //导入依赖的package包/类
default Map<String, Object> getLoadBalancerDescription(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) {
ServiceSettings settings = runtimeSettings.getServiceSettings(getService());
int port = settings.getPort();
String accountName = details.getAccount().getName();
KubernetesLoadBalancerDescription description = new KubernetesLoadBalancerDescription();
String namespace = getNamespace(settings);
String name = getServiceName();
Names parsedName = Names.parseName(name);
description.setApp(parsedName.getApp());
description.setStack(parsedName.getStack());
description.setDetail(parsedName.getDetail());
description.setName(name);
description.setNamespace(namespace);
description.setAccount(accountName);
KubernetesNamedServicePort servicePort = new KubernetesNamedServicePort();
servicePort.setPort(port);
servicePort.setTargetPort(port);
servicePort.setName("http");
servicePort.setProtocol("TCP");
KubernetesNamedServicePort monitoringPort = new KubernetesNamedServicePort();
monitoringPort.setPort(8008);
monitoringPort.setTargetPort(8008);
monitoringPort.setName("monitoring");
monitoringPort.setProtocol("TCP");
List<KubernetesNamedServicePort> servicePorts = new ArrayList<>();
servicePorts.add(servicePort);
servicePorts.add(monitoringPort);
description.setPorts(servicePorts);
return getObjectMapper().convertValue(description, new TypeReference<Map<String, Object>>() { });
}
示例3: instanceInfoTags
import com.netflix.frigga.Names; //导入依赖的package包/类
@Bean
public AtlasTagProvider instanceInfoTags() {
return () -> {
Map<String, String> tags = new HashMap<>();
tags.put("appName", instanceInfo.getAppName());
tags.put("cluster", Names.parseName(instanceInfo.getASGName()).getCluster());
return tags;
};
}
示例4: getServerGroupDescription
import com.netflix.frigga.Names; //导入依赖的package包/类
default Map<String, Object> getServerGroupDescription(
AccountDeploymentDetails<KubernetesAccount> details,
SpinnakerRuntimeSettings runtimeSettings,
List<ConfigSource> configSources) {
DeployKubernetesAtomicOperationDescription description = new DeployKubernetesAtomicOperationDescription();
SpinnakerMonitoringDaemonService monitoringService = getMonitoringDaemonService();
ServiceSettings settings = runtimeSettings.getServiceSettings(getService());
DeploymentEnvironment deploymentEnvironment = details
.getDeploymentConfiguration()
.getDeploymentEnvironment();
String accountName = details.getAccount().getName();
String namespace = getNamespace(settings);
String name = getServiceName();
Names parsedName = Names.parseName(name);
description.setNamespace(namespace);
description.setAccount(accountName);
description.setApplication(parsedName.getApp());
description.setStack(parsedName.getStack());
description.setFreeFormDetails(parsedName.getDetail());
List<KubernetesVolumeSource> volumeSources = new ArrayList<>();
for (ConfigSource configSource : configSources) {
KubernetesVolumeSource volumeSource = new KubernetesVolumeSource();
volumeSource.setName(configSource.getId());
volumeSource.setType(KubernetesVolumeSourceType.Secret);
KubernetesSecretVolumeSource secretVolumeSource = new KubernetesSecretVolumeSource();
secretVolumeSource.setSecretName(configSource.getId());
volumeSource.setSecret(secretVolumeSource);
volumeSources.add(volumeSource);
}
description.setVolumeSources(volumeSources);
List<String> loadBalancers = new ArrayList<>();
loadBalancers.add(name);
description.setLoadBalancers(loadBalancers);
List<KubernetesContainerDescription> containers = new ArrayList<>();
ServiceSettings serviceSettings = runtimeSettings.getServiceSettings(getService());
KubernetesContainerDescription container = buildContainer(name, serviceSettings, configSources, deploymentEnvironment, description);
containers.add(container);
ServiceSettings monitoringSettings = runtimeSettings.getServiceSettings(monitoringService);
if (monitoringSettings.getEnabled() && serviceSettings.getMonitored()) {
serviceSettings = runtimeSettings.getServiceSettings(monitoringService);
container = buildContainer(monitoringService.getServiceName(), serviceSettings, configSources, deploymentEnvironment, description);
containers.add(container);
}
description.setContainers(containers);
return getObjectMapper().convertValue(description, new TypeReference<Map<String, Object>>() { });
}
示例5: getRunningServiceDetails
import com.netflix.frigga.Names; //导入依赖的package包/类
@Override
default RunningServiceDetails getRunningServiceDetails(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) {
ServiceSettings settings = runtimeSettings.getServiceSettings(getService());
RunningServiceDetails res = new RunningServiceDetails();
KubernetesClient client = KubernetesProviderUtils.getClient(details);
String name = getServiceName();
String namespace = getNamespace(settings);
RunningServiceDetails.LoadBalancer lb = new RunningServiceDetails.LoadBalancer();
lb.setExists(client.services().inNamespace(namespace).withName(name).get() != null);
res.setLoadBalancer(lb);
List<Pod> pods = client.pods().inNamespace(namespace).withLabel("load-balancer-" + name, "true").list().getItems();
pods.addAll(client.pods().inNamespace(namespace).withLabel("load-balancer-" + name, "false").list().getItems());
Map<Integer, List<Instance>> instances = res.getInstances();
for (Pod pod : pods) {
String podName = pod.getMetadata().getName();
String serverGroupName = podName.substring(0, podName.lastIndexOf("-"));
Names parsedName = Names.parseName(serverGroupName);
Integer version = parsedName.getSequence();
if (version == null) {
throw new IllegalStateException("Server group for service " + getServiceName() + " has unknown sequence (" + serverGroupName + ")");
}
String location = pod.getMetadata().getNamespace();
String id = pod.getMetadata().getName();
Instance instance = new Instance().setId(id).setLocation(location);
List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses();
if (!containerStatuses.isEmpty() && containerStatuses.stream().allMatch(ContainerStatus::getReady)) {
instance.setHealthy(true);
}
if (!containerStatuses.isEmpty() && containerStatuses.stream().allMatch(s -> s.getState().getRunning() != null && s.getState().getTerminated() == null)) {
instance.setRunning(true);
}
List<Instance> knownInstances = instances.getOrDefault(version, new ArrayList<>());
knownInstances.add(instance);
instances.put(version, knownInstances);
}
List<ReplicaSet> replicaSets = client.extensions().replicaSets().inNamespace(settings.getLocation()).list().getItems();
for (ReplicaSet rs : replicaSets) {
String rsName = rs.getMetadata().getName();
Names parsedRsName = Names.parseName(rsName);
if (!parsedRsName.getCluster().equals(getServiceName())) {
continue;
}
instances.computeIfAbsent(parsedRsName.getSequence(), i -> new ArrayList<>());
}
return res;
}
示例6: getServerGroupDescription
import com.netflix.frigga.Names; //导入依赖的package包/类
@Override
default Map<String, Object> getServerGroupDescription(AccountDeploymentDetails<GoogleAccount> details, SpinnakerRuntimeSettings runtimeSettings, List<ConfigSource> configSources) {
GoogleAccount account = details.getAccount();
RunningServiceDetails runningServiceDetails = getRunningServiceDetails(details, runtimeSettings);
Integer version = runningServiceDetails.getLatestEnabledVersion();
if (version == null) {
version = 0;
} else {
version++;
}
Names name = Names.parseName(getServiceName());
String app = name.getApp();
String stack = name.getStack();
String detail = name.getDetail();
String network = GoogleProviderUtils.getNetworkName();
Map<String, String> metadata = getMetadata(details, runtimeSettings, configSources, version).stream()
.reduce(new HashMap<String, String>(),
(h1, item) -> {
h1.put(item.getKey(), item.getValue());
return h1;
},
(h1, h2) -> {
h1.putAll(h2);
return h1;
}
);
String serviceAccountEmail = GoogleProviderUtils.defaultServiceAccount(details);
List<String> scopes = getScopes();
String accountName = account.getName();
Map<String, Object> deployDescription = new HashMap<>();
deployDescription.put("application", app);
deployDescription.put("stack", stack);
deployDescription.put("freeFormDetails", detail);
deployDescription.put("network", network);
deployDescription.put("instanceMetadata", metadata);
deployDescription.put("serviceAccountEmail", serviceAccountEmail);
deployDescription.put("authScopes", scopes);
deployDescription.put("accountName", accountName);
deployDescription.put("account", accountName);
return deployDescription;
/* TODO(lwander): Google's credential class cannot be serialized as-is, making this type of construction impossible
BasicGoogleDeployDescription deployDescription = new BasicGoogleDeployDescription();
deployDescription.setApplication(app);
deployDescription.setStack(stack);
deployDescription.setFreeFormDetails(detail);
deployDescription.setNetwork(network);
deployDescription.setInstanceMetadata(metadata);
deployDescription.setServiceAccountEmail(serviceAccountEmail);
deployDescription.setAuthScopes(scopes);
// Google's credentials constructor prevents us from neatly creating a deploy description with only a name supplied
String jsonKey = null;
if (!StringUtils.isEmpty(account.getJsonPath())) {
try {
jsonKey = IOUtils.toString(new FileInputStream(account.getJsonPath()));
} catch (IOException e) {
throw new RuntimeException("Unvalidated json path found during deployment: " + e.getMessage(), e);
}
}
deployDescription.setCredentials(new GoogleNamedAccountCredentials.Builder()
.name(account.getName())
.jsonKey(jsonKey)
.project(account.getProject())
.build()
);
return new ObjectMapper().convertValue(deployDescription, new TypeReference<Map<String, Object>>() { });
*/
}