jx/internal/resource/resource.go
Matthew Rich e695278d0c
All checks were successful
Declarative Tests / test (push) Successful in 48s
go fmt
2024-03-25 13:31:06 -07:00

54 lines
897 B
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"
_ "fmt"
_ "gopkg.in/yaml.v3"
_ "net/url"
)
type Resource interface {
Type() string
URI() string
//SetURI(string) error
ResolveId(context.Context) string
ResourceLoader
StateTransformer
ResourceReader
}
// validate the type/uri
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
}