Skip to content

Commit

Permalink
chore) initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Dostert committed Mar 12, 2018
0 parents commit 6d614bb
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Jetbrains
.idea/

# opctl
*args*.yml
20 changes: 20 additions & 0 deletions .opspec/build/op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: build
description: builds the package
inputs:
srcDir:
dir:
default: .
outputs:
srcDir:
dir: {}
run:
serial:
- op:
pkg: { ref: test }
inputs: { srcDir }
- op:
pkg: { ref: github.com/opspec-pkgs/_.pkg.bootstrap#1.0.0 }
inputs:
srcDir:
outputs:
srcDir:
3 changes: 3 additions & 0 deletions .opspec/provision-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM node:9.5.0-alpine

RUN yarn add js-yaml
44 changes: 44 additions & 0 deletions .opspec/provision-image/op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: provision-image
description: |
Provisions image for the pkg w/ name `opspecpkgs/$(opDotYml.name):${opDotYml.version}`.
> Before first use, a Dockerfile MUST be added to `.opspec/provision-image`
inputs:
dockerUsername:
string:
constraints: { minLength: 1 }
description: user for logging in to docker hub
dockerPassword:
string:
constraints: { minLength: 1 }
description: password for logging in to docker hub
isSecret: true
srcDir:
dir:
default: .
run:
serial:
- op:
pkg: { ref: github.com/opspec-pkgs/yaml.parse#1.0.0 }
inputs: { yaml: $(srcDir/op.yml) }
outputs: { opDotYml: result }
- container:
image: { ref: 'alpine:3.6' }
cmd: [sh, -ce, 'echo -n opspecpkgs/${opName#*/*/}:$(opDotYml.version) > /imageName']
envVars:
opName: $(opDotYml.name)
files:
/imageName: $(imageName)
- op:
pkg: { ref: github.com/opspec-pkgs/docker.image.build#2.0.1 }
inputs:
dockerfile: $(/Dockerfile)
imageName:
outputs: { imageTar }
- op:
pkg: { ref: github.com/opspec-pkgs/docker.image.push#2.0.1 }
inputs:
imageTar:
imageName:
username: $(dockerUsername)
password: $(dockerPassword)
51 changes: 51 additions & 0 deletions .opspec/release/op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release
description: releases the package
inputs:
githubUsername:
string:
constraints: { minLength: 1 }
description: user for logging in to github
githubPassword:
string:
constraints: { minLength: 1 }
description: password for logging in to github
isSecret: true
srcDir:
dir:
default: .
outputs:
srcDir:
dir: {}
run:
serial:
- op:
pkg: { ref: build }
inputs:
srcDir:
outputs:
srcDir:
- op:
pkg: { ref: github.com/opspec-pkgs/yaml.parse#1.0.0 }
inputs: { yaml: $(srcDir/op.yml) }
outputs: { opDotYml: result }
- op:
pkg: { ref: github.com/opspec-pkgs/git.resolve-commit#1.0.2 }
inputs: { dotGitDir: $(srcDir/.git) }
outputs: { commit: }
- container:
image: { ref: 'alpine:3.6' }
cmd: [sh, -ce, 'echo -n ${opName#*/*/} > /opRepo']
envVars:
opName: $(opDotYml.name)
files:
/opRepo: $(opRepo)
- op:
pkg: { ref: github.com/opspec-pkgs/github.release.create#1.0.0 }
inputs:
owner: opspec-pkgs
repo: $(opRepo)
loginUsername: $(githubUsername)
loginPassword: $(githubPassword)
tag: $(opDotYml.version)
commitish: $(commit)
name: $(opDotYml.version)
10 changes: 10 additions & 0 deletions .opspec/test/op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: test
description: tests the package
inputs:
srcDir:
dir:
default: .
run:
op:
pkg: { ref: github.com/opspec-pkgs/opspec.pkg.validate#1.0.0 }
inputs: { pkg: $(srcDir) }
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: generic
sudo: required
before_script:
- curl -L https://bin.equinox.io/c/4fmGop7rntx/opctl-beta-linux-amd64.tgz | sudo tar -xzv -C /usr/local/bin
services:
- docker
script:
- opctl run build
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log

All notable changes will be documented in this file in accordance with
[![keepachangelog 1.0.0](https://img.shields.io/badge/keepachangelog-1.0.0-brightgreen.svg)](http://keepachangelog.com/en/1.0.0/)

## \[Unreleased]

## \[1.0.0] 2018-03-11
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @opspec-pkgs/maintainers
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[![Build Status](https://travis-ci.org/opspec-pkgs/opspec.dir.list-ops.svg?branch=master)](https://travis-ci.org/opspec-pkgs/opspec.dir.list-ops)

# Problem statement

lists ops in a directory

# Format

this version of the pkg is in [![opspec 0.1.5](https://img.shields.io/badge/opspec-0.1.5-brightgreen.svg?colorA=6b6b6b&colorB=fc16be)](https://opspec.io/0.1.5/packages.html) format

# Example usage

## Install

```shell
opctl pkg install github.com/opspec-pkgs/opspec.dir.list-ops#1.0.0
```

## Run

```
opctl run github.com/opspec-pkgs/opspec.dir.list-ops#1.0.0
```

## Compose

```yaml
op:
pkg: { ref: github.com/opspec-pkgs/opspec.dir.list-ops#1.0.0 }
inputs:
# params w/ default
dir:
outputs:
ops:
```
# Support
join us on
[![Slack](https://opspec-slackin.herokuapp.com/badge.svg)](https://opspec-slackin.herokuapp.com/)
or
[open an issue](https://github.com/opspec-pkgs/opspec.dir.list-ops/issues)
# Releases
releases are versioned according to
[![semver 2.0.0](https://img.shields.io/badge/semver-2.0.0-brightgreen.svg)](http://semver.org/spec/v2.0.0.html)
and [tagged](https://git-scm.com/book/en/v2/Git-Basics-Tagging); see
[CHANGELOG.md](CHANGELOG.md) for release notes
# Contributing
see
[project/CONTRIBUTING.md](https://github.com/opspec-pkgs/project/blob/master/CONTRIBUTING.md)
23 changes: 23 additions & 0 deletions cmd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require('fs');
const path = require('path');
const jsYaml = require('js-yaml');
const PATH_PREFIX = '/dir/';

const listOps = dir =>
fs.readdirSync(dir)
.reduce((files, file) => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
files.push(...listOps(path.join(dir, file)))
} else if(file === 'op.yml') {
const opYmlPath = path.join(dir, file);
const op = jsYaml.safeLoad(fs.readFileSync(opYmlPath))
files.push({
path: opYmlPath.slice(PATH_PREFIX.length),
name: op.name,
});
}
return files;
},
[]);

fs.writeFileSync('/ops', JSON.stringify(listOps(PATH_PREFIX)));
26 changes: 26 additions & 0 deletions op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: github.com/opspec-pkgs/opspec.dir.list-ops
description: lists ops in a directory
inputs:
dir:
dir:
description: directory to (recursively) list ops from
default: .
outputs:
ops:
array:
description: lists name & path of ops in the directory
constraints:
items:
properties:
name: {}
path: {}
version: 1.0.0
run:
container:
image: { ref: 'opspecpkgs/opspec.dir.list-ops:1.0.0' }
cmd: [node, /cmd.js]
dirs:
/dir: $(dir)
files:
/cmd.js:
/ops: $(ops)

0 comments on commit 6d614bb

Please sign in to comment.