Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request for service_repository data source #92

Open
joncolby opened this issue May 24, 2023 · 7 comments
Open

request for service_repository data source #92

joncolby opened this issue May 24, 2023 · 7 comments

Comments

@joncolby
Copy link

It would be extremely useful to have a data source lookup for service_repository. With this, we could fetch a list of repositories associated with an ops-level service.

It would be useful if the user could filter on service id or repository url

At this time, it is only possible to get a list of repositories by Tier. Furthermore, the service data source does not return any information about the associated repositories.

@rocktavious
Copy link
Collaborator

rocktavious commented May 25, 2023

@joncolby - could you give me a usecase example of how you'd use this datasource?

I suspect it would be something like this but i'd like to confirm with your concrete usecases.

data "opslevel_service_repository" "my_service" {
  service = "my-service-alias"
}

output "repository_url" {
  value = data.opslevel_service_repository.my_service.repositories[1].defaultAlias
}

and

data "opslevel_service_repository" "my_repo" {
  repository = "github.com:OpsLevel/example"
}

output "service_tier" {
  value = data.opslevel_service_repository.my_repo.services[1].tier
}

@joncolby
Copy link
Author

joncolby commented May 25, 2023

@rocktavious - thanks for the quick reply! yes the use case would be similar to your examples. However, we would really like the "raw" repo urls to be exported as well, not only the alias and tier.

A high level explanation of what we want to do with this: we are increasingly using ops-level as the source of truth for all metadata about our services (for example tags, repos that belong to a given service). We would like to retrieve a list of git repo urls using terraform, and pass these repos to the gitlab terraform provider, to set some CI/CD variables that are specific to the service. this would greatly reduce manual setup of gitlab CI/CD variables that are necessary for CI/CD pipelines.

by the way, in case you're curious, I'm writing from OLX, but this is my personal github account.

@rocktavious
Copy link
Collaborator

@joncolby - so defaultAlias is the field name in the API which generally has values like github.com:my-org/example or gitlab.com:my-project/example

We don't have the "clone url" in the API if thats what you are looking for. I would have to check with the integrations team to see if they can expose that in the API first.

I'll loop in our Customer Success employees and they can help drive this through our product roadmap. Thanks for the request. I close this issue out once we have something like this available.

@joncolby
Copy link
Author

@rocktavious - after working a bit with the opslevel golang api, i reached the same conclusion that clone url would probably need to be added to the api. The clone url is however the main point of my feature request. I understand it might take a bit longer, but it would be great if this could go on the opslevel short term roadmap.

Ok you can close it. Please do follow up with customer success, I will talk to the opslevel guys we are working with on the integration.

@rocktavious
Copy link
Collaborator

@joncolby 👍 - i'll keep this issue open so I can report here once its all the way through the pipe but rest assured i've let customer success know already and they are working with product to find a place in the roadmap for it it just might not be till Q3 since Q2 is locked down already.

@rocktavious
Copy link
Collaborator

rocktavious commented May 25, 2023

Hey @joncolby -

After speaking with an integrations engineer it does seems like we provide 2 fields that might suffice given a small format tweak.

So looking at the query

query ListRepos {
  account {
    repositories {
      nodes {
        defaultAlias
        url
      }
    }
  }
}

we get data like

          {
            "defaultAlias": "github.com:OpsLevel/kubectl-opslevel",
            "url": "https://github.com/OpsLevel/kubectl-opslevel"
          },
          {
            "defaultAlias": "gitlab.com:jklabsinc/hackdays/custom-objects",
            "url": "https://gitlab.com/jklabsinc/hackdays/custom-objects"
          },
          {
            "defaultAlias": "gitlab.com:jklabsinc/customer-success",
            "url": "https://gitlab.com/jklabsinc/customer-success"
          },

while these are not technically the clone urls that github or gitlab provide they are close and the url one actually works for http based clones it seems. IE

git clone https://github.com/OpsLevel/kubectl-opslevel

does infact work.

For ssh it looks like you'd use defaultAlias and append git@ to the front and .git to the end

git clone [email protected]:OpsLevel/kubectl-opslevel.git

So give these - would your usecase work if you were able to get at both / either the defaultAlias or url ?

@joncolby
Copy link
Author

joncolby commented May 26, 2023

@rocktavious - yes this would be awesome! sorry I didn't really mean we needed the exactly clone url, but rather the ops-level repository, and ideally the github/gitlab project repo url/alias. So what you have described would help us out a lot.

The main issue we are facing is that it is currently not possible to fetch all the repositories by service. Further, the repositories object does not have information about the service(s) associated with it. So we would like to see some kind of call that joins these concepts. Ideally, this would be to lookup repos by service.

thanks again for your attention on this.

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

No branches or pull requests

2 participants