Giter Club home page Giter Club logo

capi-yaml-gen's People

Contributors

ashish-amarnath avatar chuckha avatar dependabot[bot] avatar joonas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

capi-yaml-gen's Issues

Some messaging about overriding values

I think it would be good, if the user picks aws provider, to show a message saying

Environment is not configured properly, please set

  • CONTROL_PLANE_INSTANCE_TYPE
  • SSH_KEY_NAME

And then perhaps even defaults to copy paste like

export CONTROL_PLANE_INSTANCE_TYPE=t2.medium
export SSH_KEY_NAME=default

and then a way to avoid this error such as --allow-unset-env-vars (-f?)

Add some default values

We should start thinking about scenarios and how to get things like cloud provider flags piped into the right places.

If I am using kubeadm and i ask for the aws infrastructure provider, I should see all the required cloud-provider: aws flags in all the right places as well as a default secret I could fill in. In addition, we'd also need sshkey, iaminstance profile and instance size variables. I'm not sure a great way to get these values. But I think something like some YAML that can be run through envsubst would be great. Or perhaps we can accept a configuration file and output valid YAML? Perhaps both if no configuration is defined?

I'm not entirely sure how it would work yet as you can see, but this would be the start of something very useful imo.

At the very least we can put in the hardcoded defaults for AWS.

Support <Infra>MachineTemplate

This should also support MachineDeployments + templates.

Not sure what the API for that will look like...

Maybe it's just a flag

--machine-deployment - Produces a machine deployment for worker nodes instead of raw Machines.

Adding support for new providers should be easier

Right now it's a bit onerous to add a new provider. I think we can make interfaces for the various types and then grab the right struct satisfying the interface.

What if we had, for each provider, a struct like this:

package aws
type Generator struct {}
func (g *Generator) GetInfraMachineYAML() {}
func (g *Generator) GetInfraClusterYAML() {}
then in the cmd package we can define some interfaces like:

type InfrastructureProvider interface {
GetInfraMachineYAML()
GetInfraClusterYAML()
}

type BootstrapProvider interface {
GetConfig()
}

type CoreProvider Interface{
GetMachineYAML() {}
GetClusterYAML() {}
}
Then we can do a switch like

var infraProvider InfrastructurePRovider
switch p.InfraProvider {
case "aws"
infraProvider = &capa.Generator{}
...
}
and we'll always be able to call the same method regardless of provider.

Unit tests should verify new changes don't break yaml generation

With no unit tests, it is difficult to verify new changes don't unintentionally break yaml.

Add unit tests as follows:

  1. Operating under the premise that current master HEAD is golden, create a dir, say test/golden/ generate yaml for all provider combinations and add it to the repo.
  2. Write generate_test.go that will call runGenerateCommand with necessary options, capture output and compare w/ yaml in test/golden.
  3. if the yaml files match, then the change is good. If the yaml files don't match, then there is an unintended change to the generated yaml or the golden files need to be updated.

Improvements on the abstraction

The provider abstraction is still not quite there.

The providers should not have to know about the generator.Object type. This means we'll need to add one more layer to the abstraction.

We will need something that can wrap up the actual providers and keep that logic out of the generate.go file.

Something like this:

// generate.go
machineFactory, err := generator.NewMachineFactory(provider)
machine := machineFactory.Machine(name, namespace)

// generator.go

type Object interface {...}

// MachineFactory
type Factory struct {
  provider string
}

func NewFactory(provider string) (Factory, error) {
 // if provider is unknown return an error otherwise return a factory
}

func (f Factory) Machine(name, namespace string) Object {
  switch f.provider
  case "aws":
    capa.GenerateMachine()
  case "docker":
    capd.GenerateMachine()
  ...
}

// capd.go

// Notice the return type, no longer referencing generator.Object
func (p Provider) GenerateMachine(...arguments...) *infrav1.Machine {}

This would also negate the need for the Provider shell struct. The factory can just call the correct function from the correct package.

Add a tag for v1a2 and get support for v1a3

I suggest we add a branch or maybe a tag for v1alpha2 generation and then move master along to v1alpha3. I've got a PR i'm about to open to support v1alpha3 but I know for a fact i'll need v1alpha2 support as well and need to switch between the versions

should not print status

this should not print status to objects.

If necessary we could hide it behind a flag, but I can't think of a use case right now that would ever necessitate needing the status object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.