jx/internal/resource/resource.go
Matthew Rich f6f4258609
Some checks failed
Lint / golangci-lint (push) Failing after 9m57s
Declarative Tests / test (push) Failing after 12s
add file size and checksum
2024-04-23 15:35:08 -07:00

69 lines
1.4 KiB
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
// The resource package handles CRUD operations on resources and YAML (de)serialization
package resource
import (
"context"
_ "encoding/json"
_ "fmt"
_ "gopkg.in/yaml.v3"
_ "net/url"
)
type ResourceSelector func(r *Declaration) bool
type Resource interface {
Type() string
URI() string
SetURI(string) error
ResolveId(context.Context) string
ResourceLoader
StateTransformer
ResourceReader
ResourceValidator
Clone() Resource
}
type ResourceValidator interface {
Validate() error
}
type ResourceCreator interface {
Create(context.Context) error
}
type ResourceReader interface {
Read(context.Context) ([]byte, error)
}
type ResourceUpdater interface {
Update() error
}
type ResourceDeleter interface {
Delete() error
}
type ResourceDecoder struct {
}
func NewResource(uri string) Resource {
r, e := ResourceTypes.New(uri)
if e == nil {
return r
}
return nil
}
/*
func Machine() {
// start_destroy -> absent -> start_create -> present -> start_destroy
stater := machine.New("absent")
stater.AddStates("absent", "start_create", "present", "start_delete")
stater.AddTransition("creating", "absent", "start_create")
stater.AddTransition("created", "start_create", "present")
stater.AddTransition("deleting", "present", "start_delete")
stater.AddTransition("deleted", "start_delete", "absent")
}
*/