GithubHelp home page GithubHelp logo

secretary's Introduction

Secretary

Tool that makes easy to store API keys outside of repository.

Usage

Secretary </path/to/secrets.plist> </path/to/secrets.swift>

It takes two arguments:

  1. Path to plist file, containing the real secrets.

    Secrets.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>keyOne</key>
        <string>ValueOne</string>
        <key>keyTwo</key>
        <string>ValueTwo</string>
        <key>keyThree</key>
        <string>ValueThree</string>
    </dict>
    </plist>
  2. Path to swift file with empty enum Secrets.

    Secrets.swift

    enum Secrets {
    
        static let keyOne = "<<changeme>>"
    }

The tool changes the values of variables, that names found in plist as keys, to corresponding values.

So using with the examples above, after the tool will finish, the file Secrets.swift will look like this:

enum Secrets {

    static let keyOne = "ValueOne"
    static let keyTwo = "ValueTwo"
    static let keyThree = "ValueThree"
}

Usage With Xcode

  1. Create the file that contains only namespace enum Secrets with the static variables representing the secrets, as in the example above.

  2. Create the plist file with secrets and exclude it from version control system.

  3. Add run script build phase prior to Compile Sources phase:

    Build Phase Xcode

    With script like this:

        ~/bin/Secretary $SRCROOT/Secrets.plist $SRCROOT/MyProject/Secrets.swift
  4. Consider to marking your Secrets.swift file with git update-index --assume-unchanged command, as the real secrets will be added in it on build.

Build/Install

You should use make install command to build and install this tool.

For example, to install it to default location at /usr/local/bin just run:

$ make install

You can specify the installation path by setting the variable INSTALLPATH=~/bin/ like this:

$ make install INSTALLPATH=\~/bin/

TODO

  • Support secrets in formats:
    • plist
    • json
    • yaml
  • Add tests.
  • Add Secrets.swift generation from scratch.

secretary's People

Contributors

anton-m-kashin avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.