{"id":18472030,"url":"https://github.com/nginxinc/nginx-go-crossplane","last_synced_at":"2025-04-05T15:04:38.975Z","repository":{"id":64301036,"uuid":"168130660","full_name":"nginxinc/nginx-go-crossplane","owner":"nginxinc","description":"A library for working with NGINX configs in Go ","archived":false,"fork":false,"pushed_at":"2025-03-24T17:09:56.000Z","size":1177,"stargazers_count":64,"open_issues_count":9,"forks_count":15,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-03-29T14:06:12.116Z","etag":null,"topics":["configuration","configuration-files","configuration-management","go","golang","nginx","nginx-configuration","nginx-server"],"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/nginxinc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-29T09:49:55.000Z","updated_at":"2025-03-24T17:09:44.000Z","dependencies_parsed_at":"2023-02-14T20:31:34.213Z","dependency_job_id":"f8a887a8-b568-41c4-8a7d-31a866df8427","html_url":"https://github.com/nginxinc/nginx-go-crossplane","commit_stats":null,"previous_names":["nginxinc/crossplane-go"],"tags_count":118,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginxinc%2Fnginx-go-crossplane","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginxinc%2Fnginx-go-crossplane/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginxinc%2Fnginx-go-crossplane/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nginxinc%2Fnginx-go-crossplane/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nginxinc","download_url":"https://codeload.github.com/nginxinc/nginx-go-crossplane/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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":["configuration","configuration-files","configuration-management","go","golang","nginx","nginx-configuration","nginx-server"],"created_at":"2024-11-06T10:18:47.736Z","updated_at":"2025-04-05T15:04:38.955Z","avatar_url":"https://github.com/nginxinc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nginx-go-crossplane\nA Go port of the NGINX config/JSON converter [crossplane](https://github.com/nginxinc/crossplane).\n\n## Parse\nThis is an example that takes a path to an NGINX config file, converts it to JSON, and prints the result to stdout.\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/nginxinc/nginx-go-crossplane\"\n)\n\nfunc main() {\n\tpath := os.Args[1]\n\n\tpayload, err := crossplane.Parse(path, \u0026crossplane.ParseOptions{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tb, err := json.Marshal(payload)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(string(b))\n}\n```\n\n## Build\nThis is an example that takes a path to a JSON file, converts it to an NGINX config, and prints the result to stdout.\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\n\t\"github.com/nginxinc/nginx-go-crossplane\"\n)\n\nfunc main() {\n\tpath := os.Args[1]\n\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcontent, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar payload crossplane.Payload\n\tif err = json.Unmarshal(content, \u0026payload); err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar buf bytes.Buffer\n\tif err = crossplane.Build(\u0026buf, payload.Config[0], \u0026crossplane.BuildOptions{}); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(buf.String())\n}\n```\n\n# Generate support for third-party modules\nThis is a simple example that takes the path of a third-party module source code to generate support for it. For detailed usage of the tool, please run\n`go run ./cmd/generate/ --help`.\nAssuming the source code path of that module is `./src`, you can call `go run ./cmd/generate/ --src-path=./src -directive-map-name=directives -match-func-name=Match -match-func-comment=comment`. The output will be similar to:\n\n```go\n/**\n * Copyright (c) F5, Inc.\n *\n * This source code is licensed under the Apache License, Version 2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// Code generated by generator; DO NOT EDIT.\n// All the definitions are extracted from the source code\n// Each bit mask describes these behaviors:\n//   - how many arguments the directive can take\n//   - whether or not it is a block directive\n//   - whether this is a flag (takes one argument that's either \"on\" or \"off\")\n//   - which contexts it's allowed to be in\n\npackage crossplane\n\nvar directives = map[string][]uint{\n    \"my_directive_1\": {\n        bitmask01|bitmask02|...,\n\t\tbitmask11|bitmask12|...,\n\t\t...\n    },\n    \"my_directive_2\": {\n        bitmask01|bitmask02|...,\n\t\tbitmask11|bitmask12|...,\n\t\t...\n    },\n}\n\n// comment\nfunc Match(directive string) ([]uint, bool) {\n    m, ok := directives[directive]\n    return m, ok\n}\n```\nYou can redirect the stdout into a `.go` file, and pass the generated `matchFunc` to `ParseOptions.DirectiveSources` when invoking `Parse`.\n\n## Contributing\n\nIf you'd like to contribute to the project, please read our [Contributing guide](CONTRIBUTING.md).\n\n## License\n\n[Apache License, Version 2.0](https://github.com/nginxinc/nginx-go-crossplane/blob/main/LICENSE)\n\n\u0026copy; [F5 Networks, Inc.](https://www.f5.com/) 2022\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginxinc%2Fnginx-go-crossplane","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnginxinc%2Fnginx-go-crossplane","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnginxinc%2Fnginx-go-crossplane/lists"}