giantswarm / roadmap

Giant Swarm Product Roadmap
https://github.com/orgs/giantswarm/projects/273
Apache License 2.0
3 stars 0 forks source link

Enable navigation from a UI to the Git source of a resource #1179

Open marians opened 2 years ago

marians commented 2 years ago

User story

Details

In user interfaces like our web UI we want to offer users a way to quickly navigate to the Git source defining the resource, given that the resource is managed in a GitOps way.

Using our own cluster c68pn in installation gollum as an example, the URL would be:

https://github.com/giantswarm/workload-clusters-fleet/tree/main/management-clusters/gollum/organizations/giantswarm/workload-clusters/c68pn/cluster

For the docs app, the URL would be:

https://github.com/giantswarm/workload-clusters-fleet/tree/main/management-clusters/gollum/organizations/giantswarm/workload-clusters/c68pn/apps/docs

marians commented 2 years ago

We talked about this one today. You seemed to have an idea on the solution. Could you please add some notes regarding that while the memory is still fresh? @ljakimczuk Thank you!

ljakimczuk commented 2 years ago

Hey @marians, the support for something like this has been added in this PR, though this may not be the perfect solution, depending on the use case I guess. The originAnnotation seems to be given value relative to the kustomization.yaml path, and I think it may be hard to build the absolute path based on it.

marians commented 2 years ago

I can't find any documentation for what originAnnotations produces. Can you point me somewhere? And is it in action somewhere?

ljakimczuk commented 2 years ago

Sure, you can try it yourself in the gitops-template repository, for example use the script we put in there to generate some resources, for example:

> ./tools/fake-flux-build build MC_NAME ORG_NAME WC_NAME_NO_OUT_OF_BAND apps/hello-world
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
  annotations:
    config.kubernetes.io/origin: |
      path: appcr.yaml
  name: hello-world
  namespace: org-
spec:
  catalog: giantswarm
  kubeConfig:
    inCluster: false
  name: hello-world-app
  namespace: hello-world
  version: 0.2.0

As you can see, the annotation is included in the final manifest, though it has little value because it points to the path relative to the kustomization.yaml, which in this case lives in the same directory as appcr.yaml.

About the docs, I haven't found good ones myself, but the help command explains it to some degree:

> kustomize edit set buildmetadata --help
Sets one or more buildMetadata options to the kustomization.yaml in the current directory.
Existing options in the buildMetadata field will be replaced entirely by the new options set by this command.
The following options are valid:
  - originAnnotations
  - transformerAnnotations
  - managedByLabel
originAnnotations will add the annotation config.kubernetes.io/origin to each resource, describing where
each resource originated from.
transformerAnnotations will add the annotation alpha.config.kubernetes.io/transformations to each resource,
describing the transformers that have acted upon the resource.
managedByLabel will add the label app.kubernetes.io/managed-by to each resource, describing which version
of kustomize managed the resource.
marians commented 2 years ago

Looks like that's indeed not helping us. We need a different solution then.

ljakimczuk commented 2 years ago

I will check if there is something on the Flux's side that we could use.

marians commented 1 year ago

@ljakimczuk Any update on this?

We have https://github.com/giantswarm/roadmap/issues/624 in place now and offering a link to e. g. the GitHub UI for the repo would be a great improvement.

ljakimczuk commented 1 year ago

Unfortunately there is nothing that can give the absolute path to the file in the repository.

marians commented 1 year ago

Is there at least a label or annotation or some source for the repo URL (without path)?

ljakimczuk commented 1 year ago

None that I'm aware of. You can however locate the Kustomization thanks to the annotations you already have, and in this Kustomization find the reference to the source, and then get the URL from the source. See @uvegla comment in the ticket you linked: https://github.com/giantswarm/roadmap/issues/624#issuecomment-1230382423

marians commented 1 year ago

That looks promosing, thanks!

marians commented 3 weeks ago

@gusevda We talked about this yesterday.

I want to pick this up again and spec what we want to achieve, from the user perspective.