All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.artipie.helm.ChartYaml Maven / Gradle / Ivy

The newest version!
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2020 artipie.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.artipie.helm;

import io.reactivex.Single;
import java.util.Map;
import org.yaml.snakeyaml.Yaml;

/**
 * The Chart.yaml file.
 *
 * @since 0.2
 */
public class ChartYaml {

    /**
     * The Yaml.
     */
    private final Single> yaml;

    /**
     * Ctor.
     * @param yaml The yaml.
     */
    public ChartYaml(final String yaml) {
        this.yaml = Single.>fromCallable(() -> new Yaml().load(yaml)).cache();
    }

    /**
     * Obtain a name of the chart.
     * @return Name of the chart.
     */
    public String name() {
        return (String) this.field("name");
    }

    /**
     * Obtain a version of the chart.
     * @return Version of the chart.
     */
    public String version() {
        return (String) this.field("version");
    }

    /**
     * Return Chart.yaml fields.
     * @return The fields.
     */
    public Map fields() {
        return this.yaml.blockingGet();
    }

    /**
     * Obtain a field by name.
     * @param name The name of field to read.
     * @return A field the Yaml file.
     */
    private Object field(final String name) {
        return this.yaml.blockingGet().get(name);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy