microsoft / fabrikate

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

Static type with git method doesn't work #287

Open BertelBB opened 4 years ago

BertelBB commented 4 years ago

Describe the bug:
I have a subcomponent that sources a private git repository, including raw YAML files in a subdirectory. As described in the component definition for type

if type: static: Option 1: the component holds raw kubernetes manifest files in path, these manifests will be copied to the generated output.

Here is my component.yaml file

name: hld
type: component
subcomponents:
- name: cloud-native
  type: component
  source: https://github.com/microsoft/fabrikate-definitions
  method: git
  path: definitions/fabrikate-cloud-native
  branch: master
- name: sample-service
  type: static
  source: <repo_url>
  method: git
  path: manifests # "./manifests" does not work either
  branch: master
- name: sealed-secrets
  type: static
  source: https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.9.7/controller.yaml
  method: http

Here is the ouput I get when running fab install (with sample-service as the only subcomponent for simplicity)

INFO[22-02-2020 19:33:14] fab version 0.17.3                           
INFO[22-02-2020 19:33:14] 🔍  Using git: /usr/bin/git                   
INFO[22-02-2020 19:33:14] 🔍  Using helm: /home/linuxbrew/.linuxbrew/opt/helm@2/bin/helm 
INFO[22-02-2020 19:33:14] 🔍  Using sh: /bin/sh                         
INFO[22-02-2020 19:33:14] 🔍  Using curl: /usr/bin/curl                 
INFO[22-02-2020 19:33:14] 👉  Initializing Helm                         
DEBU[22-02-2020 19:33:14] Preparing component ''                       
DEBU[22-02-2020 19:33:14] Attempting to unmarshal yaml for component '' 
INFO[22-02-2020 19:33:14] 💾  Loading component.yaml                    
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field %!s(bool=false)         
DEBU[22-02-2020 19:33:14] merging struct field map[]                   
DEBU[22-02-2020 19:33:14] merging struct field map[]                   
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field                         
DEBU[22-02-2020 19:33:14] merging struct field %!s(bool=false)         
DEBU[22-02-2020 19:33:14] merging struct field map[]                   
DEBU[22-02-2020 19:33:14] merging struct field map[]                   
DEBU[22-02-2020 19:33:14] Install root component'hld'                  
DEBU[22-02-2020 19:33:14] Adding subcomponent 'hld' to queue with physical path './' and logical path './' 
INFO[22-02-2020 19:33:14] 👉  Starting install for component: hld       
INFO[22-02-2020 19:33:14] 💾  Loading access.yaml                       
INFO[22-02-2020 19:33:14] 👈  Finished install for component: hld       
DEBU[22-02-2020 19:33:14] Adding subcomponent 'sample-service' to queue with physical path './' and logical path './' 
DEBU[22-02-2020 19:33:14] Adding subcomponent 'sample-service' to queue with physical path './' and logical path './' 
INFO[22-02-2020 19:33:14] 👉  Starting install for component: sample-service 
INFO[22-02-2020 19:33:14] 💾  Loading access.yaml                       
INFO[22-02-2020 19:33:14] 👈  Finished install for component: sample-service 
INFO[22-02-2020 19:33:14] ✅  Installed successfully: hld               
INFO[22-02-2020 19:33:14] ✅  Installed successfully: sample-service    
INFO[22-02-2020 19:33:14] 🙌  Finished install

As you can see, the command seems to run successfully. However, the resulting components directory is missing the sample-service all together (see screenshot below).

I have also tried defining the sample-service subcomponent as the root component with no children, and am getting the same results.

To Reproduce:
Define a (sub)component of type: static, method: git, and path: <subpath> and execute TOKEN=<token> fab install (SAMPLE_SERVICE_TOKEN in my case)

Expected behavior:
I would expect the components directory to contain a sample-service directory, including its YAML files found in the path: manifests subdirectory of the repository.

Screenshots:
The resulting components directory after running SAMPLE_SERVICE_TOKEN=<token> fab install
  image

Additional context:
The sample-service is on a BitBucket Server and I am using a Personal Access Token. I have setup the access.yaml file in the root directory (same level as component.yaml) and that works fine.

access.yaml:

<repo_url>: SAMPLE_SERVICE_TOKEN

Desktop (please complete the following information):

andrewDoing commented 4 years ago

Verified this bug (feature request?).

component.yaml file

name: hld
type: component
subcomponents:
- name: sample-service
  type: static
  source: https://github.com/andrewDoing/test-sample-service
  method: git
  path: "./manifests"
  branch: master

Ran ./fab install image

After running fab install image

Bug Details: The sample-service component uses type: static with method: git. In static.go, the Install function only handles components with method: http. There needs to be a case added for method: git. Since the case isn't handled, this might need to be reclassified as a feature request.