narcissus

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 6 Imported by: 0

README

Narcissus

PkgGoDev

Narcissus updates a Golang struct with fields that have been tagged with ssm:"Parameter" according to the corresponding value in SSM Parameter Store using reflection.

Installation

go get github.com/yhakbar/narcissus

Example Usage

import "github.com/yhakbar/narcissus"
type Name struct {
    FirstName string `ssm:"Name/FirstName"`
    LastName  string `ssm:"Name/LastName"`
}

type Contact struct {
    Email  string `ssm:"Contact/Email"`
    Number string `ssm:"Contact/Number"`
}

type Person struct {
    Name                       Name
    Contact                    Contact
    FavoriteNumber             int     `ssm:"FavoriteNumber"`
    FavoriteInconvenientNumber float64 `ssm:"FavoriteInconvenientNumber"`
}
person := Person{}
ssmPath := "/path/to/parameters/"
// You can get this wrapper like so: wrapper := narcissus.Wrapper{Client: client}
_ = narcissus.UpdateBySSM(&person, &ssmPath)
// If you want to reuse an SSM client, do so like this:
// wrapper := narcissus.Wrapper{Client: client}
// wrapper.UpdateBySSM(&person, &ssmPath)

Documentation

Overview

Package narcissus updates a struct with fields that have been tagged with `ssm:"Parameter"` according to the corresponding value in SSM Parameter Store using reflection.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateBySSM

func UpdateBySSM(generic interface{}, ssmPath *string) error

UpdateBySSM updates a struct by fields tagged `ssm`.

Example
type Name struct {
	FirstName string `ssm:"Name/FirstName"`
	LastName  string `ssm:"Name/LastName"`
}

type Contact struct {
	Email  string `ssm:"Contact/Email"`
	Number string `ssm:"Contact/Number"`
}

type Person struct {
	Name                       Name
	Contact                    Contact
	FavoriteNumber             int     `ssm:"FavoriteNumber"`
	FavoriteInconvenientNumber float64 `ssm:"FavoriteInconvenientNumber"`
}

person := Person{}
ssmPath := "/path/to/parameters/"
// You can get this wrapper like so: wrapper := narcissus.Wrapper{Client: client}
_ = wrapper.UpdateBySSM(&person, &ssmPath)
// If you don't want to reuse a client, simply use narcissus.UpdateBySSM(&person, &ssmPath)
fmt.Println(person)
Output:

{{Jane Doe} {jane.doe@email.com (123)456-7890} 26 26.24}

Types

type Wrapper

type Wrapper struct {
	Client ssmiface.SSMAPI
}

Wrapper wraps the SSM Client so that it can be mocked. Also allows for client reuse.

func (*Wrapper) UpdateBySSM

func (wrapper *Wrapper) UpdateBySSM(generic interface{}, ssmPath *string) error

UpdateBySSM updates a struct by fields tagged `ssm` using a given wrapped SSM client.

Jump to

Keyboard shortcuts

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