Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider utility functions for setting names etc. #36

Open
obmarg opened this issue Feb 20, 2018 · 1 comment
Open

Consider utility functions for setting names etc. #36

obmarg opened this issue Feb 20, 2018 · 1 comment

Comments

@obmarg
Copy link
Owner

obmarg commented Feb 20, 2018

Naming objects you create with kazan is not ideal right now - names live inside ObjectMeta, so you need to do something like:

alias Kazan.Apis.Core.V1, as: Core

%Core.Namespace{
    metadata: %Kazan.Models.Apimachinery.Meta.V1.ObjectMeta{name: "test"}
}
|> Core.create_namespace!() 
|> Kazan.run!

It might be worth exploring a pipe function that sets the name/other metadata:

%Core.Namespace{}
|> with_name("test")
|> Core.create_namespace!() 
|> Kazan.run!

or

%Core.Namespace{}
|> with_meta(name: "test")
|> Core.create_namespace!() 
|> Kazan.run!

It's not clear what module these functions could live in. But it's worth thinking about.

@obmarg obmarg changed the title Consider utility functions for setting names. Consider utility functions for setting names etc. Feb 20, 2018
@obmarg
Copy link
Owner Author

obmarg commented Feb 21, 2018

I've made a test branch for this here: https://github.com/obmarg/kazan/tree/feature/with_name

Wondering if it'd make sense to generate Model.with_name functions for each model that could have a name. For example, I might want to create a namespace with only a name, so:

Core.Namespace.with_name("test") |> Core.create_namespace!

Not sure if creating an object with only a name property is that common though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant