{"id":15406937,"url":"https://github.com/raphink/narcissus","last_synced_at":"2025-07-22T11:33:17.752Z","repository":{"id":57574580,"uuid":"65448057","full_name":"raphink/narcissus","owner":"raphink","description":"Map configuration files to Go structures using Augeas","archived":false,"fork":false,"pushed_at":"2020-05-24T20:56:17.000Z","size":118,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T01:47:55.091Z","etag":null,"topics":["augeas","configuration","configuration-management","golang","golang-library","parser","parsing"],"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/raphink.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["raphink"]}},"created_at":"2016-08-11T07:24:58.000Z","updated_at":"2024-05-31T16:54:55.000Z","dependencies_parsed_at":"2022-08-31T09:41:02.954Z","dependency_job_id":null,"html_url":"https://github.com/raphink/narcissus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/raphink/narcissus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphink%2Fnarcissus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphink%2Fnarcissus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphink%2Fnarcissus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphink%2Fnarcissus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raphink","download_url":"https://codeload.github.com/raphink/narcissus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphink%2Fnarcissus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266483627,"owners_count":23936388,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["augeas","configuration","configuration-management","golang","golang-library","parser","parsing"],"created_at":"2024-10-01T16:26:19.204Z","updated_at":"2025-07-22T11:33:17.694Z","avatar_url":"https://github.com/raphink.png","language":"Go","funding_links":["https://github.com/sponsors/raphink"],"categories":[],"sub_categories":[],"readme":"Narcissus: edit configuration files as go structs\n=================================================\n\n[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/raphink/narcissus)\n[![Build Status](https://img.shields.io/travis/raphink/narcissus/master.svg)](https://travis-ci.org/raphink/narcissus)\n[![Coverage Status](https://img.shields.io/coveralls/raphink/narcissus.svg)](https://coveralls.io/r/raphink/narcissus?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/raphink/narcissus)](https://goreportcard.com/report/github.com/raphink/narcissus)\n\nThis go package aims to provide reflection for the [Augeas](http://augeas.net) library.\n\nThis allows to turn Augeas lenses into Go structs for easy parsing and\nmodification of configuration files.\n\n## Example\n\n```go\nimport (\n\t\"log\"\n\n\t\"honnef.co/go/augeas\"\n\t\"github.com/raphink/narcissus\"\n)\n\nfunc main() {\n\taug, err := augeas.New(\"/\", \"\", augeas.None)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to create Augeas handler\")\n\t}\n\tn := narcissus.New(\u0026aug)\n\n\tuser := n.NewPasswdUser(\"raphink\")\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to retrieve user: %v\" err)\n\t}\n\n\tlog.Printf(\"UID=%v\", user.UID)\n\n\t// Modify UID\n\tuser.UID = 42\n  \n\terr = n.Write(user)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to save user: %v\", err)\n\t}\n}\n```\n\n## Available types\n\n### Fstab\n\n* [`Fstab`](https://godoc.org/github.com/raphink/narcissus#Fstab) maps a whole `/etc/fstab` file\n* [`FstabEntry`](https://godoc.org/github.com/raphink/narcissus#FstabEntry) maps a single `/etc/fstab` entry\n\n### Hosts\n\n* [`Hosts`](https://godoc.org/github.com/raphink/narcissus#Hosts) maps a whole `/etc/hosts` file\n* [`Host`](https://godoc.org/github.com/raphink/narcissus#Host) maps a single `/etc/hosts` entry\n\n### Passwd\n\n* [`Passwd`](https://godoc.org/github.com/raphink/narcissus#Passwd) maps a whole `/etc/passwd` file\n* [`PasswdUser`](https://godoc.org/github.com/raphink/narcissus#PasswdUser) maps a single `/etc/passwd` entry\n\n### Services\n\n* [`Services`](https://godoc.org/github.com/raphink/narcissus#Services) maps a whole `/etc/services` file\n* [`Service`](https://godoc.org/github.com/raphink/narcissus#Service) maps a single `/etc/services` entry\n\n\n## Mapping your own structures\n\n\n```go\nimport (\n\t\"log\"\n\n\t\"honnef.co/go/augeas\"\n\t\"github.com/raphink/narcissus\"\n)\n\ntype group struct {\n\taugeasPath string\n\tName       string   `narcissus:\".,value-from-label\"`\n\tPassword   string   `narcissus:\"password\"`\n\tGID        int      `narcissus:\"gid\"`\n\tUsers      []string `narcissus:\"user\"`\n}\n\n\nfunc main() {\n\taug, err := augeas.New(\"/\", \"\", augeas.None)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to create Augeas handler\")\n\t}\n\tn := narcissus.New(\u0026aug)\n\n\tgroup := \u0026group{\n\t\taugeasPath: \"/files/etc/group/docker\",\n\t}\n\terr = n.Parse(group)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to retrieve group: %v\", err)\n\t}\n\n\tlog.Printf(\"GID=%v\", group.GID)\n\tlog.Printf(\"Users=%v\", strings.Join(group.Users, \",\"))\n}\n```\n\n\n## Tag values\n\nThe `narcissus` tag accepts multiple comma separated values. The first value in\nthe list is the relative path where the field is mapped in the Augeas tree.\n\nOther possible (optional) values are:\n\n* `value-from-label`: get field value from the node label instead of its value;\n* `seq` (slice field only): will treat field as a seq entry in the Augeas tree;\n* `key-from-value` (map field only): get the key from the node label instead\n   of its value;\n* `purge` (map field only): purge all unknown keys in the map.\n\n\n## Fields\n\nDescribed structures have special fields to specify parameters for Augeas.\n\n* `augeasPath` (mandatory): the path to the structure in the Augeas tree;\n* `augeasFile` (optional): let Augeas load only this file. If `augeasLens` is\n  not specified, Augeas will use the default lens for the file if available;\n* `augeasLens` (optional): if `augeasFile` is set (ignored otherwise),\n  specifies which lens to use to parse the file. This is required when parsing\n  a file at a non-standard location.\n\n\nEach of these fields can be specified in one of two ways:\n\n* by using the `default` tag with a default value for the field, e.g.\n\n```go\ntype group struct {\n\taugeasPath string `default:\"/files/etc/group/root\"`\n}\n```\n\n* by specifying a value for the instance in the structure field, e.g.\n\n```go\nmyGroup := group {\n    augeasPath: \"/files/etc/group/docker\",\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphink%2Fnarcissus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphink%2Fnarcissus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphink%2Fnarcissus/lists"}