idpd

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 3 Imported by: 0

README

CircleCI codecov Go Report Card Go Reference

Internal Developer Platform

An Internal Developer Platform (IDP) is built by a platform team to build golden paths and enable developer self-service.

Why a service?

Internal developer portals serve as the interface through which developers can discover and access internal developer platform capabilities.

Server

The server is composed of RESTful API.

Each of the endpoints is documented using the following style guide.

Token

Set the token to be reused.

token=$(cat test/secrets/token| base64 -d)
Pipeline

We have a pipeline that we can use for testing, it is located here.

Create a pipeline

This endpoint takes pipeline definition and persists it.

POST /pipelines

Example request:

curl --header "Authorization: Bearer $token"  --header "Content-Type: application/json" --request POST --data @test/pipeline --url "http://localhost:11000/pipelines"

Example response:

{
   "meta":{
      "ipAddr":"127.0.0.1",
      "ipAddrKind":"remote",
      "requestId":"ae429023-e070-433b-846c-47cf8a209b42",
      "traceId":"893bf1648d88427b14a9ebd8f8f73437",
      "userAgent":"IDP-ruby-client/1.0 HTTP/1.0"
   },
   "pipeline":{
      "id":1,
      "name":"test",
      "jobs":[
         {
            "name":"test",
            "steps":[
               "test",
               "test2"
            ]
         }
      ]
   }
}
Get a pipeline

This endpoint gets a pipeline by an ID.

GET /pipelines/{id}

Example request:

curl --header "Authorization: Bearer $token"  --header "Content-Type: application/json" --request GET --url "http://localhost:11000/pipelines/1"

Example response:

{
   "meta":{
      "ipAddr":"127.0.0.1",
      "ipAddrKind":"remote",
      "requestId":"ae429023-e070-433b-846c-47cf8a209b42",
      "traceId":"893bf1648d88427b14a9ebd8f8f73437",
      "userAgent":"IDP-ruby-client/1.0 HTTP/1.0"
   },
   "pipeline":{
      "id":1,
      "name":"test",
      "jobs":[
         {
            "name":"test",
            "steps":[
               "test",
               "test2"
            ]
         }
      ]
   }
}
Update a Pipeline

This endpoint updates a pipeline by an ID.

PUT /pipelines/{id}

Example request:

curl --header "Authorization: Bearer $token"  --header "Content-Type: application/json" --request PUT --data @test/pipeline --url "http://localhost:11000/pipelines/1"

Example response:

{
   "meta":{
      "ipAddr":"127.0.0.1",
      "ipAddrKind":"remote",
      "requestId":"ae429023-e070-433b-846c-47cf8a209b42",
      "traceId":"893bf1648d88427b14a9ebd8f8f73437",
      "userAgent":"IDP-ruby-client/1.0 HTTP/1.0"
   },
   "pipeline":{
      "id":1,
      "name":"test",
      "jobs":[
         {
            "name":"test",
            "steps":[
               "test",
               "test2"
            ]
         }
      ]
   }
}
Delete a Pipeline

This endpoint deletes a pipeline by an ID.

DELETE /pipelines/{id}

Example request:

curl --header "Authorization: Bearer $token"  --header "Content-Type: application/json" --request DELETE --url "http://localhost:11000/pipelines/1"

Example response:

{
   "meta":{
      "ipAddr":"127.0.0.1",
      "ipAddrKind":"remote",
      "requestId":"ae429023-e070-433b-846c-47cf8a209b42",
      "traceId":"893bf1648d88427b14a9ebd8f8f73437",
      "userAgent":"IDP-ruby-client/1.0 HTTP/1.0"
   },
   "pipeline":{
      "id":1,
      "name":"test",
      "jobs":[
         {
            "name":"test",
            "steps":[
               "test",
               "test2"
            ]
         }
      ]
   }
}
Trigger a Pipeline

This endpoint triggers a pipeline by an ID.

POST /pipelines/{id}/trigger

Example request:

curl --header "Authorization: Bearer $token"  --header "Content-Type: application/json" --request POST --url "http://localhost:11000/pipelines/1/trigger"

Example response:

```json
{
   "meta":{
      "ipAddr":"127.0.0.1",
      "ipAddrKind":"remote",
      "requestId":"ae429023-e070-433b-846c-47cf8a209b42",
      "traceId":"893bf1648d88427b14a9ebd8f8f73437",
      "userAgent":"IDP-ruby-client/1.0 HTTP/1.0"
   },
   "pipeline":{
      "id":1,
      "name":"test",
      "jobs":[
         {
            "name":"test",
            "steps":[
               "output of command",
               "output of command"
            ]
         }
      ]
   }
}

Health

The system defines a way to monitor all of it's dependencies.

To configure we just need the have the following configuration:

health:
  duration: 1s (how often to check)
  timeout: 1s (when we should timeout the check)

Design

The design is heavily influenced by go-service, using the rest package.

The api package calls the pipeline package.

API

This package handles encoding and decoding of the API and making sure the correct status codes are set.

Pipeline

This package contains all the domain knowledge that deals with pipelines, from validation to execution.

Other Systems

Check out the available tooling.

Development

If you would like to contribute, here is how you can get started.

Structure

The project follows the structure in golang-standards/project-layout.

Dependencies

Please make sure that you have the following installed:

Style

This project favours the Uber Go Style Guide

Setup

Let's get you setup.

Submodules

We need to get the git submodules.

git submodule sync
git submodule update --init
Application

To get the application running, do the following:

  1. Let's get the dependencies:
make go-dep
  1. Let's build the application:
make build
  1. Let's run the application:
make run
Features

If you want to run the features, do the following:

  1. Let's get the dependencies:
make ruby-dep
  1. Let's run the features:
make features
Changes

To see what has changed, please have a look at CHANGELOG.md

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
The api package contains all the different api definitions.
The api package contains all the different api definitions.
pipeline
The package pipeline defines the api.
The package pipeline defines the api.
The package cmd provides fx modules for all specified commands, e.g.
The package cmd provides fx modules for all specified commands, e.g.
The package pipeline contains the bounded context that is pipeline.
The package pipeline contains the bounded context that is pipeline.
The package token adds an opaque key that is verified to provide auth.
The package token adds an opaque key that is verified to provide auth.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL