From 29f78c0e124fdb8bbb30aec57341a0b7d90ee51b Mon Sep 17 00:00:00 2001 From: ShauliSolomovich <44635474+ShauliSolomovich@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:35:38 +0200 Subject: [PATCH] GitHub status (#20) * Add github status resource type --- README.md | 13 ++++---- package.dhall | 2 +- resource-types/GithubStatus.dhall | 54 +++++++++++++++++++++++++++++++ resource-types/package.dhall | 3 ++ 4 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 resource-types/GithubStatus.dhall diff --git a/README.md b/README.md index b76620e..6e45e19 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ This allows the user to more easily generate type-safe Concourse CI pipelines, t * Github List Repos - [`coralogix/eng-concourse-resource-github-list-repos`](https://github.com/coralogix/eng-concourse-resource-github-list-repos) * Github PR - [`telia-oss/github-pr-resource`](https://github.com/telia-oss/github-pr-resource) * Github Release - [`concourse/github-release-resource`](https://github.com/concourse/github-release-resource) +* Github Status - [`colstrom/concourse-github-status`](https://github.com/colstrom/concourse-github-status) * Git Multibranch - [`cloudfoundry-community/git-multibranch-resource`](https://github.com/cloudfoundry-community/git-multibranch-resource) * Helm 3 - [`Typositoire/concourse-helm3-resource`](https://github.com/Typositoire/concourse-helm3-resource) * Kops - [`coralogix/eng-concourse-resource-kops`](https://github.com/coralogix/eng-concourse-resource-kops) @@ -32,11 +33,11 @@ For stability, users are encouraged to import from a tagged release, not from th You should generally import `domain.dhall`, which includes `Resource`, `ResourceType`, `Step`, `Task`, `Job`, `Group`, `Pipeline`, and `VarSource`, and merge it with the resource types that you need. For example, ```dhall let Concourse = - https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/domain.dhall sha256:036b9de47a7f54d4ed21b87c50987fb8a318c62524d7f6317d3ec98bbe9c784c + https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/domain.dhall sha256:036b9de47a7f54d4ed21b87c50987fb8a318c62524d7f6317d3ec98bbe9c784c ∧ { RegistryImage = - https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/resource-types/RegistryImage.dhall sha256:2ca4df79f82f54275f919d759344a6478749f7d0f32bddbc0389877ede11da03 + https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/resource-types/RegistryImage.dhall sha256:2ca4df79f82f54275f919d759344a6478749f7d0f32bddbc0389877ede11da03 , Git = - https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/resource-types/Git.dhall sha256:830b9d7d0e9e0992ee2473f78e05838a86be3e13c7bcf5df661b8829dbc3d558 + https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/resource-types/Git.dhall sha256:830b9d7d0e9e0992ee2473f78e05838a86be3e13c7bcf5df661b8829dbc3d558 } in Concourse @@ -64,16 +65,16 @@ This introduces a question - what should the type of the `source` field be? Main This repository allows the user to construct the type of `Resource` and of `ResourceType` based on a union that the downstream user constructs, consisting only of the resource types which the downstream user actually uses in their pipeline. This solves both the code-reusage problem, and keeps the implementation performant. For example: ```dhall -let Git = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/resource-types/Git.dhall sha256:830b9d7d0e9e0992ee2473f78e05838a86be3e13c7bcf5df661b8829dbc3d558 +let Git = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/resource-types/Git.dhall sha256:830b9d7d0e9e0992ee2473f78e05838a86be3e13c7bcf5df661b8829dbc3d558 -let S3 = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/resource-types/S3.dhall sha256:b49ec06747630f6d6951fde4f04f7bbffab7cee1a9ef299464314ad049422d04 +let S3 = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/resource-types/S3.dhall sha256:b49ec06747630f6d6951fde4f04f7bbffab7cee1a9ef299464314ad049422d04 let Source = < Git : Git.Source.Type | S3 : S3.Source.Type > let Version = < Git : Git.Version.Type | S3 : S3.Version.Type > let Resource = - let import = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.10.0/Resource.dhall sha256:206f784b14f3fb78809bafffbde955fbc177ca0427c8fe9cf4a983a8aaf463c1 + let import = https://raw.githubusercontent.com/coralogix/dhall-concourse/v0.11.0/Resource.dhall sha256:206f784b14f3fb78809bafffbde955fbc177ca0427c8fe9cf4a983a8aaf463c1 in import { Source, Version } diff --git a/package.dhall b/package.dhall index 1e03f60..427ef94 100644 --- a/package.dhall +++ b/package.dhall @@ -1,5 +1,5 @@ { resource-types = - ./resource-types/package.dhall sha256:fc1d84e1b7901ca2b90b3dd11e8688a09a8490427ecbe226694d91f74823005c + ./resource-types/package.dhall sha256:130fd5ab6ba3ec7458889d5f0ea733a9f70aade5916cc62ab9ebf3c806e9c670 ? ./resource-types/package.dhall } ∧ ( ./domain.dhall sha256:036b9de47a7f54d4ed21b87c50987fb8a318c62524d7f6317d3ec98bbe9c784c diff --git a/resource-types/GithubStatus.dhall b/resource-types/GithubStatus.dhall new file mode 100644 index 0000000..06df011 --- /dev/null +++ b/resource-types/GithubStatus.dhall @@ -0,0 +1,54 @@ +{ meta = { name = "github-status", repository = "resource/github-status" } +, Version = { Type = { `context@sha` : Text }, default = {=} } +, Params = + { Get = + { Type = { path : Text, context : Optional Text } + , default.context = None Text + } + , Put = + let StatusObject = + { Type = + { state : Text + , context : Optional Text + , description : Optional Text + , target_url : Optional Text + } + , default = + { context = None Text + , description = None Text + , target_url = None Text + } + } + + let Statuses = + { Type = { path : Text, statuses : List StatusObject.Type } + , default = {=} + , StatusObject + } + + let Status = + { Type = { path : Text } ⩓ StatusObject.Type + , default = StatusObject.default + } + + let Put = + let Put = < Status : Status.Type | Statuses : Statuses.Type > + + in { Type = Put + , Status = λ(status : Status.Type) → Put.Status status + , Statuses = λ(statuses : Statuses.Type) → Put.Statuses statuses + , Options = { Status, Statuses } + } + + let test = + Put.Status Put.Options.Status::{ path = "test", state = "successs" } + + in Put + } +, Source = + let Source = { Type = { repo : Text, access_token : Text }, default = {=} } + + let test = Source::{ repo = "test", access_token = "my-token" } + + in Source +} diff --git a/resource-types/package.dhall b/resource-types/package.dhall index 408bd45..e0f60f9 100644 --- a/resource-types/package.dhall +++ b/resource-types/package.dhall @@ -25,6 +25,9 @@ , GithubRelease = ./GithubRelease.dhall sha256:1b782f3c5b49ccce426bb3364add8290aa83e267da5af95b5493ba2038f5ab36 ? ./GithubRelease.dhall +, GithubStatus = + ./GithubStatus.dhall sha256:386931b4d5af36df90523b09e4f99b2da1eb172a713860c72d1d253b07545b6f + ? ./GithubStatus.dhall , Helm3 = ./Helm3.dhall sha256:b105c98ee64027bc50deaea0951da2a8b235a43a5af3e9f4720bd2a57bda5474 ? ./Helm3.dhall