Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Add capability to disable subcomponent per environment #286

Merged
merged 8 commits into from
May 14, 2020

Conversation

marcel-dias
Copy link
Contributor

Add capability to disable subcomponent per environment

I'm really interested in this feature so opening this PR to contribute.
From the issue #277 I have preferred the property disabled over excluded.

what I changed

I'm proposing the addition of a disabled attribute to the Subcomponents Config.
The default value is false so all subcomponents will be enabled by default.

Basically we will be able to disabled components per environment:

..config/myenv.yaml..

subcomponents:
  my-subcomponent:
    disabled: true

closes #277

@joushx
Copy link

joushx commented Feb 25, 2020

Somehow this does not work for me. A component that is set to disabled in my config is still generated.

@marcel-dias
Copy link
Contributor Author

hey @joushx

I have created this gist with a stack example https://gist.github.com/marceldiass/9c72a4c7a17a524d8f6265db121a8ddd

the disabled property should be used in the files inside config folder.

config/
      local.yaml
      disabled.yaml
component.yaml

@evanlouie
Copy link
Contributor

Hi @marceldiass, thanks for the PR!
I took a look at your gist and while it works for the example you provided, if I modify the component.yaml to:

name: my-stack
type: component
subcomponents:
  - name: pod-info
    type: helm
    method: git
    source: https://github.com/stefanprodan/podinfo
    path: charts/podinfo
  - name: elasticsearch
    type: helm
    method: git
    source: https://github.com/helm/charts
    path: stable/elasticsearch
  - name: mysql
    type: helm
    method: git
    source: https://github.com/helm/charts
    path: stable/mysql
  - name: bookinfo # Istio BookInfo application - wrapped in Fabrikate component
    source: https://github.com/microsoft/fabrikate-definitions.git
    path: definitions/fabrikate-bookinfo
    method: git

and the config/disabled.yaml to:

subcomponents:
  pod-info:
    config:
      env: local
  elasticsearch:
    disabled: true
    config:
      env: local
  mysql:
    disabled: true
    config:
      env: local
  bookinfo:
    disabled: true

fab generate disabled still renders the bookinfo component. Think we'll need to iron this out before merging

@marcel-dias marcel-dias force-pushed the disable-subcomponent branch from c7e7e67 to 0860d31 Compare May 2, 2020 13:53
@marcel-dias marcel-dias force-pushed the disable-subcomponent branch from 0860d31 to 1341a78 Compare May 2, 2020 16:46
@marcel-dias marcel-dias changed the base branch from master to develop May 2, 2020 16:47
@marcel-dias
Copy link
Contributor Author

Hey @evanlouie

I found the issue. Added Generate test to cover that scenario.
Basically when subcomponent is component type it overrides the configs from the main component.

I'm not sure what is failing in the build as I can't see logs. Weird part is I forked the repo to mine Azure devops org and there build is passing with exactly same pipeline definition.

Could you help me find the build issue ?

Copy link
Contributor

@evanlouie evanlouie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT 👍

@evanlouie
Copy link
Contributor

@marcel-dias Re-ran the the build pipeline (after some recent changes made it into develop) and things are looking good. Thanks so much for your contribution :)

@evanlouie evanlouie merged commit 19220cb into microsoft:develop May 14, 2020
@ghost
Copy link

ghost commented Aug 15, 2020

@marcel-dias @evanlouie Could you please update or grant access to sample at https://gist.github.com/marceldiass/9c72a4c7a17a524d8f6265db121a8ddd, since I've no access (404) to this.

I tried to disabled component per environment but failed. This is my implementation:

config
  dev.yaml
  prod.yaml
  common.yaml

book
  admin
  enduser
  config
     common.yaml
  component.yaml

shop
  admin
  enduser
  config
     common.yaml
component.yaml

I want to disable subcomponents named admin, enduser in component book when generate fab folder dev, but don't know where to put disabled.yaml file

@marcel-dias marcel-dias deleted the disable-subcomponent branch August 17, 2020 17:22
@marcel-dias
Copy link
Contributor Author

@marcel-dias @evanlouie Could you please update or grant access to sample at https://gist.github.com/marceldiass/9c72a4c7a17a524d8f6265db121a8ddd, since I've no access (404) to this.

I tried to disabled component per environment but failed. This is my implementation:

config
  dev.yaml
  prod.yaml
  common.yaml

book
  admin
  enduser
  config
     common.yaml
  component.yaml

shop
  admin
  enduser
  config
     common.yaml
component.yaml

I want to disable subcomponents named admin, enduser in component book when generate fab folder dev, but don't know where to put disabled.yaml file

Hey @HideTran
You can find the gist in this link https://gist.github.com/marcel-dias/9c72a4c7a17a524d8f6265db121a8ddd

@ghost
Copy link

ghost commented Aug 18, 2020

@marcel-dias
Thank you for that, I've able to disable component, do you have any information when this feature is ready for release yet ?

@marcel-dias
Copy link
Contributor Author

@HideTran I'm also waiting for this to be released. Not sure which is the proper way to talk to the maintainers.

@ghost
Copy link

ghost commented Aug 19, 2020

@marcel-dias

Thank again for this feature, I am looking the way to force use this feature by modify build.sh to allow specified branch of fabrikate.

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

Successfully merging this pull request may close these issues.

Ability to include / exclude subcomponents based on config
3 participants