Skip to content

Отдельные классы Relation #4

@ildar-ceo

Description

@ildar-ceo

Для некоторых Relation сделать возможность создания отдельных классов

class YamlFile extends Relation
{
	/**
	 * Before save item
	 */
	Dict onBeforeSave(Dict d)
	{
		if (this.isNew())
		{
			this.set("gmtime_created", DateTime::now());
		}
		this.set("gmtime_updated", DateTime::now());
		return d;
	}
	
	
	/**
	 * Compose yaml file
	 */
	async void compose()
	{
		/* Save file */
		await this.saveFile();
		
		string file_path = "/data/yaml/" ~ this.get("stack_name") ~ "/" ~ this.get("file_name");
		string result = await DockerApi::compose(file_path, this.get("stack_name"));
		
		return result;
	}
	
	
	/**
	 * Save yaml file on drive
	 */
	async void saveFile()
	{
		string file_path = "/data/yaml/" ~ this.get("stack_name") ~ "/" ~ this.get("file_name");
		string file_dirname = rs::dirname(file_path);
		string content = this.get("content");
		await fs::mkdir(file_dirname);
		await fs::saveFile(file_path, content);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions