yashiro

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

Yashiro

Yashiro is a templating engine with the external stores.

Service

AWS

Usage

See Godoc.

go get github.com/dwango/yashiro
Authorization

AWS

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ssm:GetParameter",
                "secretsmanager:GetSecretValue"
            ],
            "Resource": ["*"],
        },
    ]
}

CLI Tool

Installation
From release page

Download binary from release page.

Homebrew Users

Download and install by homebrew.

brew tap dwango/yashiro
brew install ysr
Example

See example.

Documentation

Overview

Example
package main

import (
	"context"
	"log"
	"os"
	"time"

	awsconfig "github.com/aws/aws-sdk-go-v2/config"
	"github.com/dwango/yashiro"
	"github.com/dwango/yashiro/pkg/config"
)

func main() {
	ctx := context.TODO()

	sdkConfig, err := awsconfig.LoadDefaultConfig(ctx)
	if err != nil {
		log.Fatalf("failed to load config: %s", err)
	}

	refName := "example"
	cfg := &config.Config{
		Global: config.GlobalConfig{
			EnableCache: true, // enable cache
			Cache: config.CacheConfig{
				Type:           config.CacheTypeMemory,
				ExpireDuration: config.Duration(30 * time.Minute),
			},
		},
		Aws: &config.AwsConfig{
			ParameterStoreValues: []config.AwsParameterStoreValueConfig{
				{
					ValueConfig: config.ValueConfig{
						Name:   "/example",
						Ref:    &refName,
						IsJSON: true,
					},
				},
			},
			SdkConfig: &sdkConfig,
		},
	}

	eng, err := yashiro.NewEngine(cfg, yashiro.IgnoreNotFound(true)) // ignore not found value
	if err != nil {
		log.Fatalf("failed to create engine: %s", err)
	}

	text := `This is example code. The message is {{ .example.message }}.`

	if err := eng.Render(ctx, text, os.Stdout); err != nil {
		log.Fatalf("failed to render text: %s", err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// NewEngine returns a new Engine.
	NewEngine = engine.New

	// IgnoreNotFound is an option to ignore missing external store values.
	IgnoreNotFound = engine.IgnoreNotFound
)

Functions

This section is empty.

Types

type Config added in v0.3.0

type Config = config.Config

Config is the configuration for this library.

type Engine

type Engine = engine.Engine

Engine initializes external store client and template.

Directories

Path Synopsis
cmd
ysr
internal
cmd
values
*
*
pkg
config
*
*
*

Jump to

Keyboard shortcuts

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