diff --git a/Makefile b/Makefile index c99d218..f66606b 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ version=$(shell git rev-parse HEAD) # Global release version. # Change this to bump the build version! -version="0.3.2" +version="1.0.0" compile: ## Compile for the local architecture ⚙ @echo "Compiling..." diff --git a/README.md b/README.md index 37d6483..26dc5e9 100644 --- a/README.md +++ b/README.md @@ -60,26 +60,21 @@ There is a "repository" of examples to borrow/fork: As long as there is a Go system that implements this interface it can be used with `naml`. See examples for how to include an implementation in your project. ```go -// changelog: naml v1.0.0 breaks Deployable and replaces *kubernetes.Clienset with kubernetes.Interface - // Deployable is an interface that can be implemented // for deployable applications. type Deployable interface { - // Install will attempt to install in Kubernetes - Install(client kubernetes.Interface) error - - // Uninstall will attempt to uninstall in Kubernetes - Uninstall(client kubernetes.Interface) error +// Install will attempt to install in Kubernetes +Install(client kubernetes.Interface) error - // Meta returns the Kubernetes native ObjectMeta which is used to manage applications with naml. - Meta() *metav1.ObjectMeta +// Uninstall will attempt to uninstall in Kubernetes +Uninstall(client kubernetes.Interface) error - // Description returns the application description - Description() string +// Meta returns a NAML Meta structure which embed Kubernetes *metav1.ObjectMeta +Meta() *AppMeta - // Objects will return the runtime objects defined for each application - Objects() []runtime.Object +// Objects will return the runtime objects defined for each application +Objects() []runtime.Object } ``` diff --git a/embed_gen.go b/embed_gen.go index e9afe6a..ab70da4 100644 --- a/embed_gen.go +++ b/embed_gen.go @@ -83,6 +83,7 @@ func New{{ .AppNameTitle }}(name, description string) *{{ .AppNameTitle }} { Description: description, ObjectMeta: metav1.ObjectMeta{ Name: name, + ResourceVersion: Version, }, }, } @@ -137,65 +138,49 @@ package {{ .PackageName }} import ( "context" -{{ .Packages }} + {{ .Packages }} + "github.com/kris-nova/naml" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes" ) -// {{ .AppNameTitle }}Version is the current release of your application. var {{ .AppNameTitle }}Version string = "{{ .Version }}" -// App is a very important grown up business application. -type App struct { - metav1.ObjectMeta - description string +type {{ .AppNameTitle }} struct { + naml.AppMeta objects []runtime.Object - // ---------------------------------- - // Add your configuration fields here - // ---------------------------------- } -// NewApp will create a new instance of App. -// -// See https://github.com/naml-examples for more examples. -// -// This is where you pass in fields to your application (similar to Values.yaml) -// Example: func NewApp(name string, example string, something int) *App -func NewApp(name, description string) *App { - return &App{ - description: description, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - ResourceVersion: {{ .AppNameTitle }}Version, +func New{{ .AppNameTitle }}(name, description string) *{{ .AppNameTitle }} { + return &{{ .AppNameTitle }}{ + AppMeta: naml.AppMeta{ + Description: description, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + ResourceVersion: {{ .AppNameTitle }}Version, + }, }, - // ---------------------------------- - // Add your configuration fields here - // ---------------------------------- } } -func (a *App) Install(client kubernetes.Interface) error { +func (x *{{ .AppNameTitle }}) Install(client kubernetes.Interface) error { var err error {{ .Install }} return err } -func (a *App) Uninstall(client kubernetes.Interface) error { +func (x *{{ .AppNameTitle }}) Uninstall(client kubernetes.Interface) error { var err error {{ .Uninstall }} return err } -func (a *App) Description() string { - return a.description -} - -func (a *App) Meta() *metav1.ObjectMeta { - return &a.ObjectMeta +func (x *{{ .AppNameTitle }}) Meta() *naml.AppMeta { + return &x.AppMeta } -func (a *App) Objects() []runtime.Object { - return a.objects +func (x *{{ .AppNameTitle }}) Objects() []runtime.Object { + return x.objects } ` diff --git a/src/library.go.tpl b/src/library.go.tpl index fe22e32..f54d93a 100644 --- a/src/library.go.tpl +++ b/src/library.go.tpl @@ -25,64 +25,48 @@ package {{ .PackageName }} import ( "context" -{{ .Packages }} + {{ .Packages }} + "github.com/kris-nova/naml" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes" ) -// {{ .AppNameTitle }}Version is the current release of your application. var {{ .AppNameTitle }}Version string = "{{ .Version }}" -// App is a very important grown up business application. -type App struct { - metav1.ObjectMeta - description string +type {{ .AppNameTitle }} struct { + naml.AppMeta objects []runtime.Object - // ---------------------------------- - // Add your configuration fields here - // ---------------------------------- } -// NewApp will create a new instance of App. -// -// See https://github.com/naml-examples for more examples. -// -// This is where you pass in fields to your application (similar to Values.yaml) -// Example: func NewApp(name string, example string, something int) *App -func NewApp(name, description string) *App { - return &App{ - description: description, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - ResourceVersion: {{ .AppNameTitle }}Version, +func New{{ .AppNameTitle }}(name, description string) *{{ .AppNameTitle }} { + return &{{ .AppNameTitle }}{ + AppMeta: naml.AppMeta{ + Description: description, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + ResourceVersion: {{ .AppNameTitle }}Version, + }, }, - // ---------------------------------- - // Add your configuration fields here - // ---------------------------------- } } -func (a *App) Install(client kubernetes.Interface) error { +func (x *{{ .AppNameTitle }}) Install(client kubernetes.Interface) error { var err error {{ .Install }} return err } -func (a *App) Uninstall(client kubernetes.Interface) error { +func (x *{{ .AppNameTitle }}) Uninstall(client kubernetes.Interface) error { var err error {{ .Uninstall }} return err } -func (a *App) Description() string { - return a.description +func (x *{{ .AppNameTitle }}) Meta() *naml.AppMeta { + return &x.AppMeta } -func (a *App) Meta() *metav1.ObjectMeta { - return &a.ObjectMeta +func (x *{{ .AppNameTitle }}) Objects() []runtime.Object { + return x.objects } - -func (a *App) Objects() []runtime.Object { - return a.objects -} \ No newline at end of file diff --git a/src/main.go.tpl b/src/main.go.tpl index f9493a6..21a0c64 100644 --- a/src/main.go.tpl +++ b/src/main.go.tpl @@ -57,6 +57,7 @@ func New{{ .AppNameTitle }}(name, description string) *{{ .AppNameTitle }} { Description: description, ObjectMeta: metav1.ObjectMeta{ Name: name, + ResourceVersion: Version, }, }, } diff --git a/tests/manifest_test.go b/tests/manifest_test.go index b73c38e..06f010a 100644 --- a/tests/manifest_test.go +++ b/tests/manifest_test.go @@ -47,6 +47,7 @@ func TestManifests(t *testing.T) { err := generateCompileRunYAML(filepath.Join("manifests", file.Name())) if err != nil { t.Errorf(err.Error()) + t.FailNow() } }(file.Name()) }