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

Modularize convert into loader & transformer #72

Merged
merged 3 commits into from
Aug 5, 2016

Conversation

ngtuna
Copy link
Contributor

@ngtuna ngtuna commented Aug 1, 2016

This is an initial step of modularizing convert function into loader and transformer. I found a bit difficult to create the komposeObject interface due to Go import cycle problem. The easiest thing I can do is creating the shared struct komposeObject in a separate package which loader and transformer can use. Although I think komposeObject interface is still a good idea.

@kadel I'm looking for comment from your side.

@ngtuna
Copy link
Contributor Author

ngtuna commented Aug 1, 2016

#55

@kadel
Copy link
Member

kadel commented Aug 2, 2016

Hi @ngtuna I just give quick look to this PR.

kobject pkg looks goot.
But with loaders and transformers I had something little bit else in my mind.
I thought that every loader and every transformer would be in its own package.
so we would have kubernets, openshift, dockercompose and bundle packages.

Decisions which loader or transformer to use would be in app.go. You are on good track with loaders switch I think that there should be something similar for transformers also. If we put all that decisions outsde of tranfromers packages, it will be easy to add more transformers in the future.
But i guess this is little bit harder to do right now, as openshift and kubernetes are tight together right now :-( - but I can help with that.

@ngtuna
Copy link
Contributor Author

ngtuna commented Aug 2, 2016

@kadel Agreed. I suggest that I should add one more commit to the PR for creating separate packages for every loader and transformer, then we can merge it upstream and let people contribute more based on this construction.

@ngtuna
Copy link
Contributor Author

ngtuna commented Aug 2, 2016

I'm creating shared functions (lot of) for both k8s and openshift packages then we should be good. For the switch decision of which output provider that transformer should refer to, I think at this moment if --deploymentconfig is used, then go to openshift, otherwise go by default to k8s.

@ngtuna
Copy link
Contributor Author

ngtuna commented Aug 3, 2016

@kadel There are things happened on my mind:

  • Loader and transformer would be sit in their own packages no doubt. So we have at this time bundlefile, dockercompose, kubernetes, openshift packages.
  • With bundlefile & dockercompose, they shared the same sort of functions such as:
    • loadImage()
    • loadEnvvars()
    • loadPorts()
    • others: loadWorkingDir(), loadCommand(), loadVolumes(), etc
  • Similar to k8s and openshift, they also looks the same. Even they shared lot of common functions.
    • initRC()
    • initSC()
    • initDC()
    • initDS()
    • initDeploymentConfig() (OpenShift only)
    • configEnvvars()
    • configPorts()
    • configServicePorts()
    • configVolumes()
    • others: configWorkingDir(), configCommand(), etc

So, I would suggest to create loader and transformer interfaces. Then let bundlefile, dockercompose, k8s, openshift implement the interface they belong to. Upcoming providers and input formats will be implemented following this structure.

Thought?
/cc @Runseb @janetkuo

@kadel
Copy link
Member

kadel commented Aug 3, 2016

👍 @ngtuna
I would only suggest to make those interfaces smaller and generic so it is easy to add more transformers/loaders in future.

for loader I can image just something like this:

loadFiles(files []string) (KomposeObject, err)

for transformer:

loadKomopse(kobject KomposeObject, format string) (map[string]string, err)

returned map[string]string would look for example like this:

{ 
   "foobar-rc.yaml": "
apiVersion: v1
kind: ReplicationController
.........
",
   "foobar-service.yaml": "
apiVersion: v1
kind: service
.........
}

That this returned map could be either saved to files, or displayed to stdout.
But I'm not sure if returning it as this big map is good idea. :-(

@ngtuna
Copy link
Contributor Author

ngtuna commented Aug 5, 2016

@kadel I'm gonna merge this PR to skippbox:loader-transfomer and then switch to work on that branch, because there are some changes of convert function I would like to rebase from skippbox:master. I will send another PR for that work.

@ngtuna ngtuna merged commit 7d66c6b into kubernetes:loader-transfomer Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants