Skip to content

Commit

Permalink
Merge pull request #55 from cloud-native-toolkit/feature/update-docs
Browse files Browse the repository at this point in the history
feat: Updated documentation and code examples for new release
  • Loading branch information
snehajais22 authored Aug 12, 2024
2 parents 8dcb096 + 900432e commit 9108791
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 39 deletions.
50 changes: 31 additions & 19 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ export class MyChart extends Chart {
constructor(scope: Construct, id: string, props: ChartProps = { }) {
super(scope, id, props);

new PipelineBuilder(this, 'my-pipeline')
.withName('clone-build-push')
const pipelineParam = new ParameterBuilder('repo-url');

new PipelineBuilder(this, 'clone-build-push')
.withDescription('This pipeline closes a repository, builds a Docker image, etc.')
.withTask(new TaskBuilder(this, 'fetch-source')
.withName('git-clone')
.withWorkspace(new WorkspaceBuilder('output').withName('task-output'))
.withStringParam(new ParameterBuilder('url').withPiplineParameter('url').withDescription('the URL for the thing')))
.withStringParam(pipelineParam)
.withTask(new TaskBuilder(this, 'git-clone')
.withName('fetch-source')
.withWorkspace(new WorkspaceBuilder('output').withBinding('task-output'))
.withStringParam(new ParameterBuilder('url')
.withValue(fromPipelineParam(pipelineParam))
.withDescription('the URL for the thing')))
.buildPipeline();
}
}
Expand All @@ -115,7 +119,7 @@ that extends `Chart`. For example, in this code:

```typescript
const app = new App();
new MyInstallPipeline(app, 'my-install-pipeline');
new MyChart(app, 'my-install-pipeline');
app.synth();
```

Expand Down Expand Up @@ -157,7 +161,7 @@ resources to create a Pipeline that closely matches the
[example here](https://tekton.dev/docs/how-to-guides/kaniko-build-push/):

```typescript
new Pipeline(this, 'test-pipeline', {
new Pipeline(this, 'clone-build-push', {
metadata: {
name: 'clone-build-push',
},
Expand Down Expand Up @@ -204,22 +208,24 @@ made for you automatically. Here is the same construct, but defined using the
`PipelineBuilder`.

```typescript
new PipelineBuilder(this, 'my-pipeline')
.withName('clone-build-push')
const param = new ParameterBuilder('repo-url');

new PipelineBuilder(this, 'clone-build-push')
.withDescription('This pipeline closes a repository, builds a Docker image, etc.')
.withTask(new PipelineTaskBuilder()
.withName('fetch-source')
.withTaskReference('git-clone')
.withWorkspace('output', 'shared-data', 'The files cloned by the task')
.withStringParam('url', 'repo-url', '$(params.repo-url)'))
.withStringParam(param)
.withTask(new TaskBuilder(this, 'task-id')
.withName('fetch-source')
.referencingTask('git-clone')
.withWorkspace(new WorkspaceBuilder('output').withBinding('shared-data'))
.withStringParam(new ParameterBuilder('url').withValue(fromPipelineParam(param))))
.buildPipeline();
```

The `build` method on the builders will validate the parameters and, if the
object is valid, will create the construct, making sure to add `workspace`
and `param` resources to the Task as well as the

Any resources that the `task` requires that needs to be defined at the `pipeline`
Any resources that the `task` requires that needs to be defined at the `pipeline` level.

## Related projects

Expand Down
13 changes: 9 additions & 4 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export class ParameterBuilder {

/**
* Sets the value for the parameter
* @param val
* @param val string value or ValueResolver for pipeline-level parameter
*/
public withValue(val: string | IValueResolver): ParameterBuilder {
// If you are giving it a value here, then you do not
Expand Down Expand Up @@ -655,19 +655,24 @@ export class TaskStepBuilder {
}
}

/**
* Resolves remote tasks or pipelines through different means.
* Can be implemented by user for git, hub, bundle, etc resolvers.
*/
export interface IRemoteResolver {
resolver?: string;
params?: ResolverParam[];
kind?: string;
/**
* Gets the taskRef yaml for a remote Task
* @returns RemoteTaskRef The yaml as an API Object
* Gets the yaml reference for a remote object
* @returns RemoteRef The yaml as an API Object
*/
get remoteRef(): RemoteRef;
}

/**
* Resolves the provided cluster-scoped task into yaml for the taskRef field.
* Resolves the provided cluster-scoped `Task` or `Pipeline` into yaml
* for the taskRef or pipelineRef field, respectively.
*/
export class ClusterRemoteResolver implements IRemoteResolver {
resolver?: string;
Expand Down

0 comments on commit 9108791

Please sign in to comment.