{"id":22071060,"url":"https://github.com/vshn/billing-collector-cloudservices","last_synced_at":"2025-03-23T19:15:09.751Z","repository":{"id":59887322,"uuid":"528745648","full_name":"vshn/billing-collector-cloudservices","owner":"vshn","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-19T15:16:35.000Z","size":794,"stargazers_count":0,"open_issues_count":16,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2023-12-19T15:21:42.576Z","etag":null,"topics":["commodore-component","vshn-project-appcat","vshn-project-ignore"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vshn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-08-25T07:41:02.000Z","updated_at":"2024-01-23T16:20:19.503Z","dependencies_parsed_at":"2023-10-23T13:26:09.959Z","dependency_job_id":"f0aac6cb-625f-4280-b251-e66942e3d581","html_url":"https://github.com/vshn/billing-collector-cloudservices","commit_stats":null,"previous_names":["vshn/exoscale-metrics-collector"],"tags_count":26,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fbilling-collector-cloudservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fbilling-collector-cloudservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fbilling-collector-cloudservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vshn%2Fbilling-collector-cloudservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vshn","download_url":"https://codeload.github.com/vshn/billing-collector-cloudservices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245153894,"owners_count":20569408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commodore-component","vshn-project-appcat","vshn-project-ignore"],"created_at":"2024-11-30T20:22:34.248Z","updated_at":"2025-03-23T19:15:09.729Z","avatar_url":"https://github.com/vshn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# billing-collector-cloudservices\n\n[![Build](https://img.shields.io/github/workflow/status/vshn/billing-collector-cloudservices/Test)][build]\n![Go version](https://img.shields.io/github/go-mod/go-version/vshn/billing-collector-cloudservices)\n[![Version](https://img.shields.io/github/v/release/vshn/billing-collector-cloudservices)][releases]\n[![GitHub downloads](https://img.shields.io/github/downloads/vshn/billing-collector-cloudservices/total)][releases]\n\n[build]: https://github.com/vshn/billing-collector-cloudservices/actions?query=workflow%3ATest\n[releases]: https://github.com/vshn/billing-collector-cloudservices/releases\n\nBatch job to sync usage data from the Exoscale and Cloudscale API to Odoo16.\n\nMetrics are collected based on [metered billing data flow](https://docs.central.vshn.ch/metered-billing-data-flow.html)\n\nSee the [documentation](https://kb.vshn.ch/app-catalog/reference/cloud-usage-reporting.html) for more information.\n\n## APPUiO Cloud vs APPUiO Managed\n\nThe tool operates in 2 modes - APPUiO Cloud and APPUiO Managed. \nThe mode is decided by the environment variable `APPUIO_MANAGED_SALES_ORDER`.\nIf the sales order is set, the tool assumes that the whole cluster is APPUiO Managed thus changing the business logic accordingly.\n\n## Getting started for developers\n\nIn order to run this tool, you need\n* Access to the Exoscale and Cloudscale accounts which has the services to be invoiced\n* Access to the Kubernetes cluster which has the claims corresponding to the Exoscale services\n* Access to Odoo16 where to send the metrics data\n\nGet all this (see below), and put it all into an 'env' file:\n\n```\nexport EXOSCALE_API_KEY=\"...\"\nexport EXOSCALE_API_SECRET=\"...\"\nexport APPUIO_MANAGED_SALES_\"...\"\nexport ODOO_OAUTH_CLIENT_SECRET=\"...\"\nexport ODOO_OAUTH_TOKEN_URL=\"...\"\nexport ODOO_URL=\"...\"\nexport CLUSTER_ID=\"...\"\n```\n\nThen source the env file and run the client:\n\n```\n$ . ./env\n$ make build\n```\n\nThen, run one of the available commands:\n\n* Exoscale DBaaS:\n```\n$ ./billing-collector-cloudservices exoscale dbaas\n```\n\n### Create Resources in Lab Cluster to test metrics collector\n\nYou can first connect to your cluster and then create a claim for Postgres Database by applying a claim, for example:\n\n```\napiVersion: appcat.vshn.io/v1\nkind: ExoscalePostgreSQL\nmetadata:\n  namespace: default\n  name: exoscale-postgres-lab-test-1\nspec:\n  parameters:\n    size:\n      plan: hobbyist-2\n  writeConnectionSecretToRef:\n    name: postgres-connection-details\n```\n\nOnce the database is created and `Ready`, you can run locally the command with the required env variables:\n```\n$ ./billing-collector-cloudservices exoscale dbaas\n```\n\nThe same works for other resources. Just apply the right claim and run the proper command.\n\nAnd don't forget to delete the resource(s) you created once you're done testing.\n\n### Exoscale API key and secret\n\nYou can get your Exoscale API key and secret from the Exoscale web UI. Be sure to select the correct project.\n\nThe token should be restricted to the 'sos' and 'dbaas' services.\n\n### Integration tests\n\nIntegration tests create an envtest cluster and export the metrics locally. This is all automated when running:\n\n```bash\n$ make test-integration\n```\n\nTo run integration tests in your IDE of choice, be sure to set build tag `integration` and the following env variables:\n\n```bash\n# path to directory where the respective go modules are installed. You can also specify the path to the local clone of the respective repositories.\nEXOSCALE_CRDS_PATH=\"$(go list -f '{{.Dir}}' -m github.com/vshn/provider-exoscale)/package/crds)\"\nCLOUDSCALE_CRDS_PATH=\"$(go list -f '{{.Dir}}' -m github.com/vshn/provider-cloudscale)/package/crds)\"\n\n# make sure to run make target `test-integration` first to have everything setup correctly.\nKUBEBUILDER_ASSETS=\"$(/path/to/billing-collector-cloudservices/.work/bin/setup-envtest --bin-dir \"/path/to/billing-collector-cloudservices/.work/bin\" use -i -p path '1.24.x!')\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshn%2Fbilling-collector-cloudservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvshn%2Fbilling-collector-cloudservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvshn%2Fbilling-collector-cloudservices/lists"}