jenkins-x / vscode-jx-tools

Jenkins X extension for Visual Studio Code
22 stars 9 forks source link

chore: prework for watching multiple crd #31

Closed mkramb closed 6 years ago

mkramb commented 6 years ago

Prework for adding support for environments

@jstrachan @rawlingsj

rawlingsj commented 6 years ago

I wrote my first bit of typescript last week so I'm gonna say merge whenever you're happy @mkramb :)

I really wanted to setup a way to build a preview version in CI that we can point our local vscode at using the debug port, or even deploy the change and access via a browser, but I couldn't figure out how or if it's even possible.

jstrachan commented 6 years ago

@mkramb looks good - though it might be simpler to have a separate KubeWatcher for each CRD URL - as under the covers you can only watch one URL at once in the k8s REST API.

So I wonder if we should have a way to make a KubeWatcher for any URL (anything in k8s or any CRD etc)?

jstrachan commented 6 years ago

then we could have something like...

let pipelineWatcher = new KubeWatcher(CRDs.Pipeline);
let envWatcher = new KubeWatcher(CRDs.Environment);
...
pipelineWatcher.addCallback()...
mkramb commented 6 years ago

@jstrachan i like that approach! will refactor and update PR

jstrachan commented 6 years ago

yeah - we may wanna watch other stuff (CRD or k8s resources like Deployment / Service) in other namespaces too so leaving it nice and simple - we pass in a URL or something - should mean we can later on build more complex watchers etc.

e.g. when we're on helm3 we could watch the helm CRDs as releases happen in Staging / Production

mkramb commented 6 years ago

@jstrachan updated, so API looks like const pipelines = new KubeWatcher(KubeCrd.Pipelines);

jstrachan commented 6 years ago

@mkramb looks great thanks!