Code Monkey home page Code Monkey logo

services's Introduction

services Build Status

A tool for promoting between GitHub repositories.

This is a pre-alpha PoC for promoting versions of files between environments, represented as repositories.

Building

You need Go version 1.14 to build this project.

$ go build ./cmd/services

Running

You'll need a GitHub token to test this out.

$ export GITHUB_TOKEN=<paste in GitHub access token>
$ ./services promote --from https://github.com/organisation/first-environment.git --to https://github.com/organisation/second-environment.git --service service-a --commit-name <User to commit as> --commit-email <Email to commit as>

If the commit-name and commit-email are not provided, it will attempt to find them in ~/.gitconfig, otherwise it will fail.

This will copy all files under /services/service-a/base/config/* in first-environment to second-environment, commit and push, and open a PR for the change.

Testing

$ go test ./...

To run the complete integration tests, including pushing to the Git repository:

$ TEST_GITHUB_TOKEN=<a valid github auth token> go test ./...

Note that the tests in pkg/git/repository_test.go will clone and manipulate a remote Git repository locally.

To run a particular test: for example,

go test ./pkg/git -run TestCopyServiceWithFailureCopying

Getting started

This section is temporary. To create a sample promotion Pull Request, until rhd-gitops-example#8 is done:

./services promote --from [url.to.dev] --to [url.to.staging] --service service-a`

At a high level the services command currently:

  • git clones the source and target repositories into ~/.promotion/cache
  • creates a branch (as per the given --branch-name)
  • checks out the branch
  • copies the relevant files from the cloned source into the cloned target
  • pushes the cloned target
  • creates a PR from the new branch in the target to master in the target

Important Notes:

  • We need to remove the local cache between requests. See rhd-gitops-example#20. Until then, add rm -rf ~/.promotion/cache; before subsequent requests.
  • New pull requests need new branches (i.e you cannot run the same command twice). Add --branch [unique branch name] before submitting further promotion PRs. See rhd-gitops-example#21.
  • See rhd-gitops-example#19 for an issue related to problems 'promoting' config from a source repo into a gitops repo.

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.