microsoft / fabrikate

Making GitOps with Kubernetes easier one component at a time
MIT License
38 stars 5 forks source link

fab add may not be idempotent #294

Open mtarng opened 4 years ago

mtarng commented 4 years ago

Describe the bug: When calling fab add it excludes type: component at the top level of the component.yaml. Subsequently, if you run the same command again, type:component will be added as, I suspect, it's being added to the object when loading from the component.yaml file.

To Reproduce:

Screenshots:

Additional context:

Desktop (please complete the following information):

andrewDoing commented 4 years ago

I reproduced this bug on Windows. The bug occurs within the function LoadComponent() in component.go

1st run: the error os.PathError is returned from UnmarshalComponent("yaml", ...) loadedComponents and the error message "Error loading component in path ./" are returned.

2nd run: There is no error, as component.yaml now exists in the current directory. Moving forward, the function applyDefaultsAndMigrations() is called, adding the ComponentType of "component".

Potential Solution: Handle the specific error of os.PathError, adding the ComponentType of "component" in this case.