application

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Description

func Description(value string) basic.Op

func Id

func Id(value string) basic.Op

func Tags

func Tags(value []string) basic.Op

Types

type Application

type Application interface {
	Get() Getter
	Set(sync bool, ops ...basic.Op) (err error)
	Delete(attributes ...string) (err error)
	Prettify(p pretty.Prettier, resources []pretty.PrettyResourceIface) map[string]interface{}
}
Example
package main

import (
	"fmt"

	"github.com/spf13/afero"
	"github.com/taubyte/go-project-schema/application"
	"github.com/taubyte/go-project-schema/project"
)

func main() {
	// Create a new file system in memory
	fs := afero.NewMemMapFs()

	// Open a new project with a virtual file system
	project, err := project.Open(project.VirtualFS(fs, "/"))
	if err != nil {
		return
	}

	// Create or open an application
	app, err := project.Application("test_app")
	if err != nil {
		return
	}

	// Set and write application fields
	err = app.Set(true,
		application.Id("123456"),
		application.Description("this is an application"),
		application.Tags([]string{"tag1", "tag2"}),
	)
	if err != nil {
		return
	}

	// Display the Description
	fmt.Println(app.Get().Description())

	// Open the config.yaml of the application
	config, err := afero.ReadFile(fs, "/applications/test_app/config.yaml")
	if err != nil {
		return
	}

	// Print config.yaml
	fmt.Println(string(config))

}
Output:

this is an application
id: "123456"
description: this is an application
tags:
    - tag1
    - tag2

func Open

func Open(seer *seer.Seer, name string) (Application, error)

Open opens the application at root/applications/<name>, returns Application and error

type Getter

type Getter interface {
	basic.Getter
	Tags() []string
}

Getter is an abstraction for getting values from an application config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL