mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 01:04:59 +00:00
Previously `go install` fails to install holos. ``` ❯ go install github.com/holos-run/holos/cmd/holos@latest ../../go/pkg/mod/github.com/holos-run/holos@v0.86.0/internal/frontend/frontend.go:25:12: pattern holos/dist/holos/ui/index.html: no matching files found ../../go/pkg/mod/github.com/holos-run/holos@v0.86.0/doc/website/website.go:14:12: pattern all:build: no matching files found ``` This is because we do not commit required files. This patch fixes the problem by following Rob Pike's guidance to commit generated files. This patch also replaces the previous use of Makefile tasks to generate code with //go:generate directives. This means the process of keeping the source code clean is straight forward: ``` git clone make tools make generate make build ``` Refer to https://go.dev/blog/generate > Also, if the containing package is intended for import by go get, once > the file is generated (and tested!) it must be checked into the source > code repository to be available to clients. - Rob Pike
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
"github.com/gofrs/uuid"
|
|
storage "github.com/holos-run/holos/service/gen/holos/storage/v1alpha1"
|
|
)
|
|
|
|
type Platform struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (Platform) Mixin() []ent.Mixin {
|
|
return []ent.Mixin{
|
|
IDMixin{},
|
|
TimestampMixin{},
|
|
EditorMixin{},
|
|
}
|
|
}
|
|
|
|
func (Platform) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.UUID("org_id", uuid.UUID{}),
|
|
field.String("name").NotEmpty(),
|
|
field.String("display_name"),
|
|
field.JSON("form", &storage.Form{}).
|
|
Optional().
|
|
Comment("JSON representation of FormlyFormConfig[] refer to https://github.com/holos-run/holos/issues/161"),
|
|
field.JSON("model", &storage.Model{}).
|
|
Optional().
|
|
Comment("JSON representation of the form model which holds user input values refer to https://github.com/holos-run/holos/issues/161"),
|
|
field.Bytes("cue").
|
|
Optional().
|
|
Comment("CUE definition to vet the model against e.g. #PlatformConfig"),
|
|
field.String("cue_definition").
|
|
Optional().
|
|
Comment("The definition name to vet config_values against config_cue e.g. '#PlatformSpec'"),
|
|
}
|
|
}
|
|
|
|
func (Platform) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("organization", Organization.Type).
|
|
Field("org_id").
|
|
Unique().
|
|
Required(),
|
|
}
|
|
}
|
|
|
|
func (Platform) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
// One org cannot have two platforms with the same name.
|
|
index.Fields("org_id", "name").Unique(),
|
|
}
|
|
}
|