jx/internal/resource/resource.go
2024-03-20 12:23:31 -07:00

53 lines
824 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
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
}