Matthew Rich
e71d177984
All checks were successful
Declarative Tests / test (push) Successful in 51s
66 lines
1.1 KiB
Go
66 lines
1.1 KiB
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
//
|
|
package resource
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
_ "os"
|
|
"gopkg.in/yaml.v3"
|
|
_ "os/exec"
|
|
_ "strings"
|
|
_ "log"
|
|
"net/url"
|
|
)
|
|
|
|
type Exec struct {
|
|
loader YamlLoader
|
|
Id string `yaml:"id"`
|
|
// create command
|
|
// read command
|
|
// update command
|
|
// delete command
|
|
|
|
// state attributes
|
|
State string `yaml:"state"`
|
|
}
|
|
|
|
func init() {
|
|
ResourceTypes.Register("exec", func(u *url.URL) Resource {
|
|
x := NewExec()
|
|
return x
|
|
})
|
|
}
|
|
|
|
func NewExec() *Exec {
|
|
return &Exec { loader: YamlLoadDecl }
|
|
}
|
|
|
|
func (x *Exec) URI() string {
|
|
return fmt.Sprintf("exec://%s", x.Id)
|
|
}
|
|
|
|
func (x *Exec) SetURI(uri string) error {
|
|
return nil
|
|
}
|
|
|
|
func (x *Exec) ResolveId(ctx context.Context) string {
|
|
return ""
|
|
}
|
|
|
|
func (x *Exec) Apply() error {
|
|
return nil
|
|
}
|
|
|
|
func (x *Exec) LoadDecl(yamlFileResourceDeclaration string) error {
|
|
return x.loader(yamlFileResourceDeclaration, x)
|
|
}
|
|
|
|
func (x *Exec) Type() string { return "exec" }
|
|
|
|
func (x *Exec) Read(ctx context.Context) ([]byte, error) {
|
|
return yaml.Marshal(x)
|
|
}
|
|
|