https://github.com/mockersf/concourse-resource-rs
Helper crate to create a Concourse resource in Rust
https://github.com/mockersf/concourse-resource-rs
concourse rust
Last synced: about 1 year ago
JSON representation
Helper crate to create a Concourse resource in Rust
- Host: GitHub
- URL: https://github.com/mockersf/concourse-resource-rs
- Owner: mockersf
- License: apache-2.0
- Created: 2019-03-13T23:33:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T04:54:31.000Z (over 2 years ago)
- Last Synced: 2024-05-02T01:37:00.580Z (about 2 years ago)
- Topics: concourse, rust
- Language: Rust
- Homepage:
- Size: 896 KB
- Stars: 12
- Watchers: 2
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# concourse-resource-rs [](https://opensource.org/licenses/Apache-2.0) [](https://travis-ci.org/mockersf/concourse-resource-rs) [](https://docs.rs/concourse-resource) [](https://crates.io/crates/concourse-resource)
The API docs for the master branch are published [here](https://mockersf.github.io/concourse-resource-rs/).
Helper to create a [Concourse](https://concourse-ci.org) resource in Rust following https://concourse-ci.org/implementing-resource-types.html.
## Examples
See [examples](https://github.com/mockersf/concourse-resource-rs/tree/master/examples) for more examples.
The included multi-stage Dockerfile shows how to build a minimal docker image to deploy the concourse resource. To run it:
```
docker build --build-arg EXAMPLE=hello_world .
```
### Simple hello world
```rust
use std::{fs::File, io::Write, path::Path};
use serde::{Deserialize, Serialize};
use concourse_resource::*;
struct HelloWorld {}
#[derive(Serialize, Deserialize)]
struct Version {
ver: String,
}
impl Resource for HelloWorld {
type Version = Version;
type Source = concourse_resource::Empty;
type InParams = concourse_resource::Empty;
type InMetadata = concourse_resource::Empty;
type OutParams = concourse_resource::Empty;
type OutMetadata = concourse_resource::Empty;
fn resource_check(_: Option, _: Option) -> Vec {
vec![Self::Version {
ver: String::from("static"),
}]
}
fn resource_in(
_source: Option,
_version: Self::Version,
_params: Option,
output_path: &str,
) -> Result, Box> {
let mut path = Path::new(output_path).to_path_buf();
path.push("hello_world.txt");
let mut file = File::create(path)?;
file.write_all(b"hello, world!")?;
Ok(InOutput {
version: Self::Version {
ver: String::from("static"),
},
metadata: None,
})
}
fn resource_out(
_: Option,
_: Option,
_: &str,
) -> OutOutput {
unimplemented!()
}
}
create_resource!(HelloWorld);
```