use of com.amihaiemil.eoyaml.Yaml in project artipie by artipie.
the class DockerProxyTest method shouldFailBuildFromBadConfig.
@ParameterizedTest
@MethodSource("badConfigs")
void shouldFailBuildFromBadConfig(final String yaml) throws Exception {
final Slice slice = dockerProxy(yaml);
Assertions.assertThrows(RuntimeException.class, () -> slice.response(new RequestLine(RqMethod.GET, "/").toString(), Headers.EMPTY, Flowable.empty()).send((status, headers, body) -> CompletableFuture.allOf()).toCompletableFuture().join());
}
use of com.amihaiemil.eoyaml.Yaml in project artipie by artipie.
the class UsersFromStorageYaml method removeUserRecord.
/**
* Removes user record from credentials.yaml.
* @param username User name to remove
* @param yaml Credentials mapping
* @return YamlMappingBuilder without removed user
*/
private static YamlMappingBuilder removeUserRecord(final String username, final YamlMapping yaml) {
YamlMappingBuilder result = Yaml.createYamlMappingBuilder();
final YamlMapping credentials = yaml.yamlMapping(UsersFromStorageYaml.CREDENTIALS);
final List<YamlNode> keep = credentials.keys().stream().filter(node -> !node.asScalar().value().equals(username)).collect(Collectors.toList());
for (final YamlNode node : keep) {
result = result.add(node, credentials.value(node));
}
return result;
}
use of com.amihaiemil.eoyaml.Yaml in project front by artipie.
the class YamlUsers method remove.
@Override
public void remove(final String uid) {
if (this.users().map(yaml -> yaml.yamlMapping(uid) != null).orElse(false)) {
YamlMappingBuilder builder = Yaml.createYamlMappingBuilder();
final YamlMapping users = this.users().get();
for (final YamlNode node : users.keys()) {
final String val = node.asScalar().value();
if (!uid.equals(val)) {
builder = builder.add(val, users.yamlMapping(val));
}
}
this.blsto.save(this.key, Yaml.createYamlMappingBuilder().add(ArtipieYaml.NODE_CREDENTIALS, builder.build()).build().toString().getBytes(StandardCharsets.UTF_8));
return;
}
throw new NotFoundException(String.format("User %s does not exist", uid));
}
use of com.amihaiemil.eoyaml.Yaml in project artipie by artipie.
the class RepoPermissionsFromStorage method copyRepoSection.
/**
* Copy `repo` section without permissions from existing yaml setting.
* @param mapping Repo section mapping
* @return Setting without permissions
*/
private static YamlMappingBuilder copyRepoSection(final YamlMapping mapping) {
YamlMappingBuilder res = Yaml.createYamlMappingBuilder();
final List<YamlNode> keep = mapping.keys().stream().filter(node -> !new SetOf<>(RepoPermissionsFromStorage.PERMS, RepoPermissionsFromStorage.INCLUDE_PATTERNS).contains(node.asScalar().value())).collect(Collectors.toList());
for (final YamlNode node : keep) {
res = res.add(node, mapping.value(node));
}
return res;
}
Aggregations