Skip to content
This repository has been archived by the owner on Jun 22, 2020. It is now read-only.

Commit

Permalink
Update TypeScript config, clean up some things
Browse files Browse the repository at this point in the history
Update TypeScript config and supporting files.  Migrate README to
latest standard, pointing to documentation.  Fix location of API
tests.  Add test coverage.
  • Loading branch information
David Dooling committed Oct 19, 2018
1 parent 3270ad6 commit 627b51d
Show file tree
Hide file tree
Showing 7 changed files with 1,571 additions and 192 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,7 +10,9 @@ node_modules/
*.js.map
*.log
*.txt
/.nyc_output/
/build/
/coverage/
/doc/
/log/
git-info.json
6 changes: 5 additions & 1 deletion .npmignore
Expand Up @@ -4,18 +4,22 @@
*~
.#*
.dockerignore
.gitignore
.git*
.npmrc*
.travis.yml
.atomist/
.nyc_output/
/build/
/doc/
/config/
/coverage/
/log/
/scripts/
/src/
/test/
/CO*.md
/Dockerfile
/assets/kubectl/
*.log
*.txt
*.ts
Expand Down
86 changes: 66 additions & 20 deletions README.md
@@ -1,16 +1,61 @@
<p align="center">
<img src="https://images.atomist.com/sdm/SDM-Logo-Dark.png">
</p>

# @atomist/sdm-pack-k8

[![atomist sdm goals](http://badge.atomist.com/T29E48P34/atomist/sdm-pack-k8/36919e92-7d10-4e4c-87b7-a0fd58bca349)](https://app.atomist.com/workspace/T29E48P34)
[![npm version](https://img.shields.io/npm/v/@atomist/sdm-pack-k8/next.svg)](https://www.npmjs.com/package/@atomist/sdm-pack-k8/v/next)
[![npm version](https://img.shields.io/npm/v/@atomist-seeds/sdm-pack-k8.svg)](https://www.npmjs.com/package/@atomist/sdm-pack-k8)

[Atomist][atomist] software delivery machine (SDM) extension Pack for
an Atomist SDM to integrate [Kubernetes][kubernetes] deployments.

[Atomist][atomist] software delivery machine (SDM) extension Pack for an Atomist SDM to integrate [Kubernetes](https://kubernetes.io) deployments.
[kubernetes]: https://kubernetes.io (Kubernetes)

See the [Atomist documentation][atomist-doc] for more information on
what SDMs are and what they can do for you using the Atomist API for
software.
Software delivery machines enable you to control your delivery process
in code. Think of it as an API for your software delivery. See the
[Atomist documentation][atomist-doc] for more information on the
concept of a software delivery machine and how to create and develop
an SDM.

[atomist-doc]: https://docs.atomist.com/ (Atomist Documentation)

## Getting started

See the [Developer Quick Start][atomist-quick] to jump straight to
creating an SDM.

[atomist-quick]: https://docs.atomist.com/quick-start/ (Atomist - Developer Quick Start)

## Contributing

Contributions to this project from community members are encouraged
and appreciated. Please review the [Contributing
Guidelines](CONTRIBUTING.md) for more information. Also see the
[Development](#development) section in this document.

## Code of conduct

This project is governed by the [Code of
Conduct](CODE_OF_CONDUCT.md). You are expected to act in accordance
with this code by participating. Please report any unacceptable
behavior to code-of-conduct@atomist.com.

## Documentation

Please see [docs.atomist.com][atomist-doc] for
[developer][atomist-doc-sdm] documentation.

[atomist-doc-sdm]: https://docs.atomist.com/developer/sdm/ (Atomist Documentation - SDM Developer)

## Connect

Follow [@atomist][atomist-twitter] and [The Composition][atomist-blog]
blog related to SDM.

[atomist-twitter]: https://twitter.com/atomist (Atomist on Twitter)
[atomist-blog]: https://the-composition.com/ (The Composition - The Official Atomist Blog)

## Usage

1. First install the dependency in your SDM project
Expand All @@ -28,7 +73,7 @@ sdm.addExtensionPacks(kubernetesSupport({
deployments: [{
goal: StagingDeploymentGoal,
pushTest: IsNode,
callback: kubernetesDataCallback(sdm.configuration),
callback: kubernetesDataCallback(sdm.configuration),
}, {
goal: ProductionDeploymentGoal,
pushTest: IsNode,
Expand All @@ -50,28 +95,29 @@ channel in the [Atomist community Slack workspace][slack].

If you find a problem, please create an [issue][].

[issue]: https://github.com/atomist/sdm-pack-spring/issues
[issue]: https://github.com/atomist/sdm-pack-k8/issues

## Development

You will need to install [Node][node] to build and test this project.
You will need to install [Node.js][node] to build and test this
project.

[node]: https://nodejs.org/ (Node.js)

### Build and test

Use the following package scripts to build, test, and perform other
development tasks.

Command | Reason
------- | ------
`npm install` | install project dependencies
`npm run build` | compile, test, lint, and generate docs
`npm run lint` | run TSLint against the TypeScript
`npm run compile` | generate types from GraphQL and compile TypeScript
`npm test` | run tests
`npm run autotest` | run tests every time a file changes
`npm run clean` | remove files generated during build
Install dependencies.

```
$ npm install
```

Use the `build` package script to compile, test, lint, and build the
documentation.

```
$ npm run build
```

### Release

Expand Down
18 changes: 9 additions & 9 deletions lib/support/api.ts
Expand Up @@ -28,29 +28,29 @@ import { preErrMsg } from "./error";

// tslint:disable:max-file-line-count

function configPath(): string {
return process.env.KUBECONFIG || path.join(os.homedir(), ".kube", "config");
}

/**
* Get Kubernetes configuration either from the creds directory or the
* in-cluster client.
*/
export function getKubeConfig(context?: string): k8.ClusterConfiguration | k8.ClientConfiguration {
let k8Config: k8.ClusterConfiguration | k8.ClientConfiguration;
const cfgPath = process.env.KUBECONFIG || path.join(os.homedir(), ".kube", "config");
const cfgPath = configPath();
try {
const kubeconfig = k8.config.loadKubeconfig(cfgPath);
k8Config = k8.config.fromKubeconfig(kubeconfig, context);
} catch (e) {
logger.debug(`failed to use ${cfgPath}: ${e.message}`);
try {
k8Config = k8.config.getInCluster();
} catch (er) {
throw er;
}
k8Config = k8.config.getInCluster();
}
return k8Config;
}

export function loadKubeConfig(): any {
const cfgPath = process.env.KUBECONFIG || path.join(os.homedir(), ".kube", "config");
const cfgPath = configPath();
return k8.config.loadKubeconfig(cfgPath);
}

Expand Down Expand Up @@ -965,8 +965,8 @@ const ingressName = "atm-ingress";
export function endpointBaseUrl(req: KubeApplication): string {
const defaultProtocol = (req.tlsSecret) ? "https" : "http";
const protocol = (req.protocol) ? req.protocol : defaultProtocol;
const host = req.host ? req.host : "localhost";
const tail = req.path && req.path !== "/" ? `${req.path}/` : "/";
const host = (req.host) ? req.host : "localhost";
const tail = (req.path && req.path !== "/") ? `${req.path}/` : "/";
return `${protocol}://${host}${tail}`;
}

Expand Down

0 comments on commit 627b51d

Please sign in to comment.