diff --git a/approved/http.yaml b/approved/http.yaml index 5215eef..9592ad5 100644 --- a/approved/http.yaml +++ b/approved/http.yaml @@ -10,7 +10,8 @@ headers: x-api-key: <+secret.getValue("api_key")> content-type: "application/json" - assertion: "expression" + assertion: + code: 200 body: | identifier: "test" name: "test" diff --git a/approved/pipeline/failure-strategy.yaml b/approved/pipeline/failure-strategy.yaml new file mode 100644 index 0000000..10b5465 --- /dev/null +++ b/approved/pipeline/failure-strategy.yaml @@ -0,0 +1,168 @@ +# step with failure strategy + +pipeline: + stages: + - steps: + - run: + script: go test + on-failure: + errors: all + action: ignore +--- +# sample pipeline with a retry failure strategy +# that fails if all retry attempts fail. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ unknown ] + action: + retry: + attempts: 5 + interval: 10s + failure-action: fail + +--- + +# sample pipeline with a retry failure strategy +# that demonstrates multiple, staggered intervals. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ unknown ] + action: + retry: + attempts: 5 + interval: [ 10s, 30s, 1m, 5m, 10m ] + failure-action: fail + +--- + +# sample pipeline with retry failure strategy with a +# complex failure action. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ unknown ] + action: + retry: + attempts: 5 + interval: 10s + failure-action: + manual-intervention: + timeout: 60m + timeout-action: fail + +--- + +# sample pipeline with simplified retry strategy +# syntax that should apply sane defaults. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: all + action: retry + +--- + +# sample pipeline with manual-intervention +# failure strategy that fails on timeout. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ all ] + action: + manual-intervention: + timeout: 30m + timeout-action: fail + +--- + +# sample pipeline with manual-intervention +# failure strategy with a complex timeout +# action. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ all ] + action: + manual-intervention: + timeout: 30m + timeout-action: + retry: + attempts: 10 + interval: 30s + failure-action: success +--- + +# sample pipeline with a basic failure strategy at the stage +# level that aborts on all errors. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: all + action: abort + +--- + +# sample pipeline with a basic failure strategy at the step +# level that aborts on all errors. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: all + action: abort + +--- + +# sample pipeline with a retry failure strategy +# that aborts for enumerated error types. + +pipeline: + stages: + - steps: + - run: + script: go test + container: golang + on-failure: + errors: [ unknown, connectivity ] + action: abort diff --git a/approved/pipeline/pipeline.yaml b/approved/pipeline/pipeline.yaml new file mode 100644 index 0000000..a4c72bd --- /dev/null +++ b/approved/pipeline/pipeline.yaml @@ -0,0 +1,75 @@ +# sample pipeline with run step + +pipeline: + stages: + - steps: + - run: + script: go build + +--- + +# sample pipeline with run step, short syntax + +pipeline: + stages: + - steps: + - run: go build + +--- + +# sample pipeline with run step, shortest syntax + +pipeline: + stages: + - steps: + - go build + +--- + +# sample pipeline with conditional execution + +pipeline: + if: ${{ branch == "main" }} + stages: + - steps: + - run: + script: go build + +--- + +# sample pipeline with global envs + +pipeline: + env: + GOOS: linux + GOARCH: amd64 + stages: + - steps: + - go build + +--- + +# sample pipeline with optional repository override + +pipeline: + # repository should be optional. If undefined, + # the repository and conector are the same as + # where the yaml was stored. + repo: + name: drone/drone + connector: account.github + stages: + - steps: + - go build + +--- + +# sample pipeline, github compatible + +jobs: + test: + runs-on: ubuntu + steps: + - run: go build + +--- \ No newline at end of file diff --git a/approved/pipeline/stage.yaml b/approved/pipeline/stage.yaml new file mode 100644 index 0000000..1cca37a --- /dev/null +++ b/approved/pipeline/stage.yaml @@ -0,0 +1,155 @@ +# simple stage. + +pipeline: + stages: + - steps: + - run: + script: go build + +--- + +# simple stage, with id + +pipeline: + stages: + - id: build + steps: + - run: + script: go build + +--- + +# simple stage, with name + +pipeline: + stages: + - name: build + steps: + - run: + script: go build + +--- + +# simple stage, with conditions + +pipeline: + stages: + - if: ${{ branch == "main" }} + steps: + - run: + script: go build + + +--- + +# simple stage, pinned to delegate + +pipeline: + stages: + - delegate: some-delegate + steps: + - run: + script: go build + +--- + +# simple stage, with simple failure strategy + +pipeline: + stages: + - steps: + - run: + script: go build + on-failure: + errors: all + action: ignore + +--- + +# simple stage, with matrix strategy + +pipeline: + stages: + - steps: + - run: + script: go build + container: golang:${{ matrix.version }} + strategy: + matrix: + version: + - "1.19" + - "1.20" + +--- + +# simple stage, with cache intelligence settings + +pipeline: + stages: + - steps: + - run: + script: go build + cache: + path: /path/to/file + +--- + +# simple stage, with single service, single environment + +pipeline: + stages: + - steps: + - run: + script: go build + service: petstore + environment: prod + +--- + +# simple stage, with multi-service, multi-environment + +pipeline: + stages: + - steps: + - run: + script: go build + service: + items: + - petstore-frontend + - petstore-backend + environment: + parallel: true + items: + - name: prod + deploy-to: all + - name: stage + deploy-to: + - infra1 + - infra2 + - name: dev + deploy-to: infra3 + +--- + +# service and environment at the pipeline level, +# allows us to remove propagation configuration. + + +pipeline: + service: + items: + - petstore-frontend + - petstore-backend + environment: + parallel: true + items: + - name: prod + deploy-to: all + stages: + # override the service and environment + # at the stage level. + - service: petstore + environment: prod + steps: + - run: + script: go build diff --git a/approved/pipeline/step-group.yaml b/approved/pipeline/step-group.yaml new file mode 100644 index 0000000..1eb3f0e --- /dev/null +++ b/approved/pipeline/step-group.yaml @@ -0,0 +1,30 @@ +# simple group step. + +pipeline: + stages: + - steps: + - group: + steps: + - run: + container: golang + script: go build + - run: + container: golang + script: go test + +--- + +# simple group step with conditional + +pipeline: + stages: + - steps: + - if: ${{ branch == "main" }} + group: + steps: + - run: + container: golang + script: go build + - run: + container: golang + script: go test \ No newline at end of file diff --git a/approved/pipeline/step-parallel.yaml b/approved/pipeline/step-parallel.yaml new file mode 100644 index 0000000..850df38 --- /dev/null +++ b/approved/pipeline/step-parallel.yaml @@ -0,0 +1,30 @@ +# simple parallel step. + +pipeline: + stages: + - steps: + - parallel: + steps: + - run: + container: golang + script: go build + - run: + container: golang + script: go test + +--- + +# simple parallel step with conditional + +pipeline: + stages: + - steps: + - if: ${{ branch == "main" }} + parallel: + steps: + - run: + container: golang + script: go build + - run: + container: golang + script: go test diff --git a/approved/pipeline/step.yaml b/approved/pipeline/step.yaml new file mode 100644 index 0000000..8218190 --- /dev/null +++ b/approved/pipeline/step.yaml @@ -0,0 +1,52 @@ +# simple step. + +pipeline: + stages: + - steps: + - run: + script: go build + +--- + +# step with conditions + +pipeline: + stages: + - steps: + - if: ${{ branch == "main" }} + run: + script: go build + +--- + +# step with id + +pipeline: + stages: + - steps: + - id: build + run: + script: go build + +--- + +# step with name + +pipeline: + stages: + - steps: + - name: build + run: + script: go build + +--- + +# step with timeout (10 minutes) + +pipeline: + stages: + - steps: + - name: build + timeout: 10m + run: + script: go build diff --git a/approved/service.yaml b/approved/service.yaml new file mode 100644 index 0000000..c4b43cc --- /dev/null +++ b/approved/service.yaml @@ -0,0 +1,50 @@ +version: 1 +kind: service +spec: + type: native-helm + spec: + manifests: + primary: <+input> + sources: + - type: HelmChart + id: manifest1 (id is mandatory) + spec: + type: Github | S3 | GCS + spec: + connector: liquibaselabrepoconn + repo: helm-charts ##### optional + location: refs/heads/main:/charts ##### following git notation + values: ##### optional + - /abc/xyz.yaml + skip_versioning: false ##### optional + declarative_rollback: false ##### optional + artifacts: + primary: <+inputs.abc> + sources: + - id: artifact1 + type: DockerRegistry + spec: + connector: curl + location: /abc/wsz:<+ variables.tag> ##### imagePath + tag field combined + - id: artifact1 + type: DockerRegistry + spec: + connector: curl + location: /abc/wsz:<+ variables.tag> + - id: artifact1 + sidecar: true ##### adding this sidecar tag instead of separate section + type: DockerRegistry + spec: + connector: curl + location: /abc/wsz:<+ variables.tag> + config_files: + - id: config-file1 ##### alternate we can have similar sources field here + type: Harness + id: config-file1 + spec: + files: + - /abc.yaml + variables: + tag (variable_name): + type: String + value: 1.9.0 diff --git a/samples/actions/helm-rollback.yaml b/samples/actions/helm-rollback.yaml new file mode 100644 index 0000000..3f99bff --- /dev/null +++ b/samples/actions/helm-rollback.yaml @@ -0,0 +1,5 @@ +- action: + uses: helm-rollback + with: + steady-state: false + timeout: 10m \ No newline at end of file diff --git a/samples/actions/kubernetes-scale.yaml b/samples/actions/kubernetes-scale.yaml new file mode 100644 index 0000000..ced91c7 --- /dev/null +++ b/samples/actions/kubernetes-scale.yaml @@ -0,0 +1,9 @@ +- action: + uses: kubernetes-scale + with: + workload: default/Deployment/harness-example + replica: 2 + percentage: 100 # optional (either replica or percentage) + steady-state-check: false # optional - default is false + + diff --git a/samples/actions/sam-build.yaml b/samples/actions/sam-build.yaml new file mode 100644 index 0000000..79ce4db --- /dev/null +++ b/samples/actions/sam-build.yaml @@ -0,0 +1,45 @@ +## Sam Build & Deploy + +## Cloning the Repository +- action: + uses: git-clone + with: + branch: main + repo: Product-Management + connector: cd-demo +--- + +## Download Manifest +- action: + uses: harness-download + +--- + +## SAM Build +- action: + uses: sam-build + with: + command: "--use-container" ## Optional + build-container-registry: "ecr" ## Optional + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SAM_LOG: "true" + +--- + +## SAM Deploy +- action: + uses: sam-deploy + with: + command: "--use-container" ## Optional + build-container-registry: "ecr" ## Optional + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SAM_LOG: "true" + diff --git a/samples/actions/serverless.yaml b/samples/actions/serverless.yaml new file mode 100644 index 0000000..aaecd22 --- /dev/null +++ b/samples/actions/serverless.yaml @@ -0,0 +1,65 @@ +## Cloning the Repository +- action: + uses: git-clone + with: + branch: main + repo: Product-Management + connector: cd-demo + +--- +## Download Manifest +- action: + uses: harness-download + +--- + +## Serverless Package +- action: + uses: serverless-package + with: + command: "" ## Optional + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SERVERLESS_LOG: "true" + +--- +## Serverless Deploy +- action: + uses: serverless-deploy + with: + command: "" ## Optional + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SERVERLESS_LOG: "true" + +--- + +## Serverless Prepare Rollback +- action: + uses: serverless-prepare-rollback + with: + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SERVERLESS_LOG: "true" + +--- + +## Serverless Rollback +- action: + uses: serverless-rollback + with: + image-pull-policy: always + user: 1000 + memory: 10mb + cpu: 0.25 + args: + - SERVERLESS_LOG: "true" diff --git a/samples/actions/terraform-plan.yaml b/samples/actions/terraform-plan.yaml new file mode 100644 index 0000000..332c760 --- /dev/null +++ b/samples/actions/terraform-plan.yaml @@ -0,0 +1,101 @@ +## Cloning the Repository +- action: + uses: git-clone + with: + branch: main + repo: Product-Management + connector: cd-demo + + +## Terraform Plan +- action: + uses: terraform-plan + with: + command: apply | destroy + aws-provider: account.aws_connector + workspace: dev + backend-config: |- + terraform { + backend "gcs" { + bucket = "tf-state-prod" + prefix = "terraform/state" + } + } + secrets-manager: Harness Secrets Manager + env: + - TF_LOG_PATH: ./terraform.log + args: + - refresh: --args + export-plan: true + human-readable-plan: true + state-storage: false + skip-refresh: false + + + + + + +### Curent NG Step Design +# - step: +# type: TerraformPlan +# name: TerraformPlan_1 +# identifier: TerraformPlan_1 +# spec: +# provisionerIdentifier: dev +# configuration: +# command: Apply +# configFiles: +# store: +# spec: +# connectorRef: account.CDNGAuto_GithubRepoPipelinesNgAutomationiDYaC0PbFx +# folderPath: dev +# gitFetchType: Branch +# branch: prod +# type: Github +# providerCredential: +# type: Aws +# spec: +# connectorRef: <+input> +# region: <+input> +# roleArn: <+input> +# backendConfig: +# type: Inline +# spec: +# content: |- +# terraform { +# backend "gcs" { +# bucket = "tf-state-prod" +# prefix = "terraform/state" +# } +# } +# environmentVariables: +# - name: TF_LOG_PATH +# value: ./terraform.log +# type: String +# targets: +# - module.s3_bucket +# commandFlags: +# - commandType: WORKSPACE +# flag: <+input> +# varFiles: +# - varFile: +# type: Remote +# identifier: dev +# spec: +# store: +# type: Bitbucket +# spec: +# gitFetchType: Branch +# repoName: prod +# branch: proad +# paths: +# - /prod/tf.vars +# connectorRef: <+input> +# secretManagerRef: org.pl_hashicorp_withsecret_jSlq +# workspace: <+input> +# exportTerraformPlanJson: <+input> +# skipStateStorage: <+input> +# exportTerraformHumanReadablePlan: <+input> +# skipRefreshCommand: <+input> +# timeout: 10m diff --git a/samples/environment.yaml b/samples/environment.yaml new file mode 100644 index 0000000..67e603c --- /dev/null +++ b/samples/environment.yaml @@ -0,0 +1,7 @@ +environment: + name: envin + id: envin + tags: {} + type: production + org: default + project: TcSvcOverrideTest diff --git a/samples/service.yaml b/samples/service.yaml new file mode 100644 index 0000000..7bd0ff3 --- /dev/null +++ b/samples/service.yaml @@ -0,0 +1,91 @@ +service: + name: s11 + identifier: s11 + serviceDefinition: + type: Kubernetes + spec: + manifests: + - manifest: + identifier: aaa + type: Values + spec: + store: + type: Github + spec: + connectorRef: org.adi_org_github + gitFetchType: Branch + paths: + - aa + repoName: aa + branch: aa + - manifest: + identifier: aaaaa + type: K8sManifest + spec: + store: + type: Github + spec: + connectorRef: <+input> + gitFetchType: Commit + paths: + - aaaa + repoName: aaaa + commitId: aaaaa + skipResourceVersioning: false + enableDeclarativeRollback: false + artifacts: + primary: + primaryArtifactRef: <+input> + sources: + - spec: + connectorRef: account.asdsads + imagePath: aa + tag: <+input> + digest: aa + identifier: aa + type: DockerRegistry + - name: aaa + identifier: aaa + template: + templateRef: org.wxcartifactsource + versionLabel: v8 + templateInputs: + type: CustomArtifact + spec: + type: CustomArtifact + inputs: + - name: GITHUB_ORG + type: String + value: <+input>.default(CloudCalling) + - name: REPO_NAME + type: String + value: <+input> + - name: DEFAULT_BRANCH + type: String + value: <+input>.default(master) + version: <+input> + sidecars: + - sidecar: + spec: + connectorRef: account.asdsads + imagePath: aa + tag: <+input> + digest: aa + identifier: aa + type: DockerRegistry + configFiles: + - configFile: + identifier: aa + spec: + store: + type: Harness + spec: + files: + - /fileA + variables: + - name: aa + type: String + description: aaa + required: true + value: aa + gitOpsEnabled: false