{"id":28919272,"url":"https://github.com/web-seven/function-switcher","last_synced_at":"2026-05-19T04:12:17.734Z","repository":{"id":226065362,"uuid":"766103873","full_name":"web-seven/function-switcher","owner":"web-seven","description":"Crossplane Composition function to enable creation of resources by Composite annotations.","archived":false,"fork":false,"pushed_at":"2024-10-15T07:32:13.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-23T14:13:12.039Z","etag":null,"topics":["composition","crossplane","function","kndp","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/web-seven.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-02T10:54:01.000Z","updated_at":"2024-12-13T00:59:58.000Z","dependencies_parsed_at":"2024-06-21T05:29:07.705Z","dependency_job_id":"f6da946d-2da1-4557-8c84-21163a0057a0","html_url":"https://github.com/web-seven/function-switcher","commit_stats":null,"previous_names":["kndpio/function-switcher"],"tags_count":0,"template":false,"template_full_name":"crossplane/function-template-go","purl":"pkg:github/web-seven/function-switcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-seven%2Ffunction-switcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-seven%2Ffunction-switcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-seven%2Ffunction-switcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-seven%2Ffunction-switcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-seven","download_url":"https://codeload.github.com/web-seven/function-switcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-seven%2Ffunction-switcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33201543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["composition","crossplane","function","kndp","kubernetes"],"created_at":"2025-06-22T03:04:42.580Z","updated_at":"2026-05-19T04:12:17.714Z","avatar_url":"https://github.com/web-seven.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# function-switcher\n[![CI](https://github.com/kndpio/function-switcher/actions/workflows/ci.yml/badge.svg)](https://github.com/kndpio/function-switcher/actions/workflows/ci.yml)\n\nFunction Switcher is a Crossplane function that enables Composition users to enable or disable creation of resources, without update schema of XRD, just using annotations like in on this example:\n```yaml\napiVersion: example.crossplane.io/v1\nkind: XR\nmetadata:\n  name: example-xr\n  annotations:\n    ## Annotations for enable/disable resources of Composition.\n    switcher.fn.kndp.io/disabled: \"resourceTwo,resourceThree\"\n    switcher.fn.kndp.io/enabled: \"resourceOne\"\nspec:\n  resourceOne:\n    field1: \"one\"\n    field2: \"two\"\n  resourceTwo:\n    field1: \"three\"\n    field2: \"four\"\n  resourceThree:\n    field1: \"five\"\n    field2: \"six\"\n```\n## Installation:\n\n1. Create function using function package from registry: \n```yaml\napiVersion: pkg.crossplane.io/v1beta1\nkind: Function\nmetadata:\n  name: function-switcher\nspec:\n  package: xpkg.upbound.io/kndp/function-switcher:v0.0.1\n```\n\n2. Setup function required to add it after resources generation function like `function-patch-and-transform`:\n```yaml\napiVersion: apiextensions.crossplane.io/v1\nkind: Composition\nmetadata:\n  name: function-switcher\nspec:\n  mode: Pipeline\n  pipeline:\n  - step: patch-and-transform\n    functionRef:\n      name: function-patch-and-transform\n    input:\n      apiVersion: pt.fn.crossplane.io/v1beta1\n      kind: Resources\n      resources:\n\n      - name: resourceOne\n        base:\n          apiVersion: example.crossplane.io/v1\n          kind: Resource\n          spec:\n            field1: \"\"\n            field2: \"\"\n        patches:\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceOne.field1\"\n            toFieldPath: \"spec.field1\"\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceOne.field2\"\n            toFieldPath: \"spec.field2\"\n\n      - name: resourceTwo\n        base:\n          apiVersion: example.crossplane.io/v1\n          kind: Resource\n          spec:\n            field1: \"\"\n            field2: \"\"\n        patches:\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceTwo.field1\"\n            toFieldPath: \"spec.field1\"\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceTwo.field2\"\n            toFieldPath: \"spec.field2\"\n\n      - name: resourceThree\n        base:\n          apiVersion: example.crossplane.io/v1\n          kind: Resource\n          spec:\n            field1: \"\"\n            field2: \"\"\n        patches:\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceThree.field1\"\n            toFieldPath: \"spec.field1\"\n          - type: FromCompositeFieldPath\n            fromFieldPath: \"spec.resourceThree.field2\"\n            toFieldPath: \"spec.field2\"\n  ## Enable or disable resources from previous step\n  - step: enable-disable\n    functionRef:\n      name: function-switcher\n\n  compositeTypeRef:\n    apiVersion: example.crossplane.io/v1\n    kind: XR\n```\n## Templates\nYou could use simple Go template in function annotation for enable or disable composition resources conditionally using `.observed` and `.desired`, or even print name of resource:\n```yaml\napiVersion: example.crossplane.io/v1\nkind: XR\nmetadata:\n  name: example-xr\n  annotations:\n    switcher.fn.kndp.io/enabled: 'resourceThree,resourceOne'\n    switcher.fn.kndp.io/disabled: '{{ if ne .observed.composite.resource.status.ready true }}resourceThree{{ end }}'\nspec:\n  resourceOne:\n    field1: \"one\"\n    field2: \"two\"\n  resourceTwo:\n    field1: \"three\"\n    field2: \"four\"\n  resourceThree:\n    field1: \"five\"\n    field2: \"six\"\nstatus:\n  ready: false\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-seven%2Ffunction-switcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-seven%2Ffunction-switcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-seven%2Ffunction-switcher/lists"}