From 04d5f11aeb26345314f8a215093bb0e6e7fc48f5 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 1 Nov 2022 19:13:00 -0400 Subject: [PATCH 01/35] add info cobra command --- cmd/info.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cmd/info.go diff --git a/cmd/info.go b/cmd/info.go new file mode 100644 index 00000000..19a80fd0 --- /dev/null +++ b/cmd/info.go @@ -0,0 +1,44 @@ +package cmd + +import ( + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +type Format string + +const ( + JSON Format = "json" +) + +type infoCmd struct { + format string +} + +func newInfoCmd() *cobra.Command { + ic := &infoCmd{} + var cmd = &cobra.Command{ + Use: "info", + Short: "Prints draft supported values in machine-readable format", + Long: `This command prints information about the current draft environment and supported values such as supported dockerfile languages and deployment manifest types.`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := ic.run(); err != nil { + return err + } + return nil + }, + } + f := cmd.Flags() + f.StringVarP(&ic.format, "format", "f", ".", "specify the format to print draft information in (json, yaml, etc)") + + return cmd +} + +func (uc *infoCmd) run() error { + log.Println("infoCmd.run() called with format: ", uc.format) + return nil +} + +func init() { + rootCmd.AddCommand(newInfoCmd()) +} From 6af98507ea5f3d3829213f9ef75423f1461efd16 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Thu, 3 Nov 2022 16:43:12 -0400 Subject: [PATCH 02/35] add info command with languages and deploytypes --- cmd/info.go | 30 ++++++++++++++++++++++++++++-- pkg/deployments/deployments.go | 7 +++++++ pkg/languages/languages.go | 7 +++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index 19a80fd0..7da515e1 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -1,8 +1,15 @@ package cmd import ( + "encoding/json" + "fmt" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/Azure/draft/pkg/deployments" + "github.com/Azure/draft/pkg/languages" + "github.com/Azure/draft/template" ) type Format string @@ -13,6 +20,12 @@ const ( type infoCmd struct { format string + info *draftInfo +} + +type draftInfo struct { + SupportedLanguages []string `json:"supported_languages"` + SupportedDeploymentTypes []string `json:"supported_deployment_types"` } func newInfoCmd() *cobra.Command { @@ -34,8 +47,21 @@ func newInfoCmd() *cobra.Command { return cmd } -func (uc *infoCmd) run() error { - log.Println("infoCmd.run() called with format: ", uc.format) +func (ic *infoCmd) run() error { + log.Debugf("getting supported languages") + l := languages.CreateLanguagesFromEmbedFS(template.Dockerfiles, "") + d := deployments.CreateDeploymentsFromEmbedFS(template.Deployments, "") + + ic.info = &draftInfo{ + SupportedLanguages: l.Names(), + SupportedDeploymentTypes: d.DeployTypes(), + } + + infoText, err := json.MarshalIndent(ic.info, "", " ") + if err != nil { + return fmt.Errorf("could not marshal draft info into json: %w", err) + } + log.Println(string(infoText)) return nil } diff --git a/pkg/deployments/deployments.go b/pkg/deployments/deployments.go index 13a492a9..54ccf029 100644 --- a/pkg/deployments/deployments.go +++ b/pkg/deployments/deployments.go @@ -6,6 +6,7 @@ import ( "io/fs" log "github.com/sirupsen/logrus" + "golang.org/x/exp/maps" "gopkg.in/yaml.v3" "github.com/Azure/draft/pkg/config" @@ -26,6 +27,12 @@ type Deployments struct { deploymentTemplates fs.FS } +// DeployTypes returns a slice of the supported deployment types +func (d *Deployments) DeployTypes() []string { + names := maps.Keys(d.deploys) + return names +} + func (d *Deployments) CopyDeploymentFiles(deployType string, customInputs map[string]string, templateWriter templatewriter.TemplateWriter) error { val, ok := d.deploys[deployType] if !ok { diff --git a/pkg/languages/languages.go b/pkg/languages/languages.go index bd8a3e8b..bfcf1093 100644 --- a/pkg/languages/languages.go +++ b/pkg/languages/languages.go @@ -6,6 +6,7 @@ import ( "io/fs" log "github.com/sirupsen/logrus" + "golang.org/x/exp/maps" "gopkg.in/yaml.v3" "github.com/Azure/draft/pkg/config" @@ -25,6 +26,12 @@ type Languages struct { dockerfileTemplates fs.FS } +// Names returns a slice of the names of the supported languages +func (l *Languages) Names() []string { + names := maps.Keys(l.langs) + return names +} + func (l *Languages) ContainsLanguage(lang string) bool { _, ok := l.langs[lang] return ok From eda81dd087ca468ab1464f74f5ecdcffdecb9325 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Fri, 4 Nov 2022 17:01:07 -0400 Subject: [PATCH 03/35] add integration test for draft info --- .github/workflows/integration-info.yml | 20 ++++++++++++++ test/integration/info_json_schema.json | 38 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/integration-info.yml create mode 100644 test/integration/info_json_schema.json diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml new file mode 100644 index 00000000..8a81be14 --- /dev/null +++ b/.github/workflows/integration-info.yml @@ -0,0 +1,20 @@ +name: Draft Info Integration Test + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.2 + - name: make + run: make + - run: + ./draft info > info.json + - name: Validate JSON + uses: docker://orrosenblatt/validate-json-action:latest + env: + INPUT_SCHEMA: ./test/info_json_schema.json + INPUT_JSONS: ./info.json \ No newline at end of file diff --git a/test/integration/info_json_schema.json b/test/integration/info_json_schema.json new file mode 100644 index 00000000..73fdada0 --- /dev/null +++ b/test/integration/info_json_schema.json @@ -0,0 +1,38 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Root", + "type": "object", + "required": [ + "supported_languages", + "supported_deployment_types" + ], + "properties": { + "supported_languages": { + "$id": "#root/supported_languages", + "title": "Supported_languages", + "type": "array", + "default": [], + "items":{ + "$id": "#root/supported_languages/items", + "title": "Items", + "type": "string", + "default": "", + "pattern": "^.*$" + } + }, + "supported_deployment_types": { + "$id": "#root/supported_deployment_types", + "title": "Supported_deployment_types", + "type": "array", + "default": [], + "items":{ + "$id": "#root/supported_deployment_types/items", + "title": "Items", + "type": "string", + "default": "", + "pattern": "^.*$" + } + } + } +} From 871eec3680f20f21208a901fd846f5274379d0d8 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Fri, 4 Nov 2022 17:03:21 -0400 Subject: [PATCH 04/35] run info integration test on pr --- .github/workflows/integration-info.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 8a81be14..dd071277 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -1,4 +1,7 @@ name: Draft Info Integration Test +on: + pull_request: + branches: [ main ] jobs: build: From ec1d20e616a020c1e42597d9f9474c3682ad1863 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Fri, 4 Nov 2022 17:08:16 -0400 Subject: [PATCH 05/35] missing pipe --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index dd071277..9726b5cf 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -14,7 +14,7 @@ jobs: go-version: 1.18.2 - name: make run: make - - run: + - run: | ./draft info > info.json - name: Validate JSON uses: docker://orrosenblatt/validate-json-action:latest From a05f472d6eed8f29a2ec60fa39c43334aa10e4d0 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Fri, 4 Nov 2022 17:10:11 -0400 Subject: [PATCH 06/35] tab --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 9726b5cf..795ea971 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -15,7 +15,7 @@ jobs: - name: make run: make - run: | - ./draft info > info.json + ./draft info > info.json - name: Validate JSON uses: docker://orrosenblatt/validate-json-action:latest env: From 67643e9831beb1542ba375db72caca66effc7ab1 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Fri, 4 Nov 2022 17:13:24 -0400 Subject: [PATCH 07/35] relative pathing --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 795ea971..e9dc9625 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -15,7 +15,7 @@ jobs: - name: make run: make - run: | - ./draft info > info.json + ./draft info > ./info.json - name: Validate JSON uses: docker://orrosenblatt/validate-json-action:latest env: From 2ed2f252a08eb67271f2a0c62b76fda4baf333a9 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 15:36:11 -0500 Subject: [PATCH 08/35] wrong schema path --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index e9dc9625..7f1b54e2 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -19,5 +19,5 @@ jobs: - name: Validate JSON uses: docker://orrosenblatt/validate-json-action:latest env: - INPUT_SCHEMA: ./test/info_json_schema.json + INPUT_SCHEMA: ./test/integration/info_json_schema.json INPUT_JSONS: ./info.json \ No newline at end of file From 5b19a7ccac000fe53b8fc6f2a12ef8755c821e9c Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 16:50:44 -0500 Subject: [PATCH 09/35] update json validation --- .github/workflows/integration-info.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 7f1b54e2..fe1b665f 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -7,7 +7,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v2 with: @@ -17,7 +17,7 @@ jobs: - run: | ./draft info > ./info.json - name: Validate JSON - uses: docker://orrosenblatt/validate-json-action:latest + uses: nhalstead/validate-json-action@0.1.3 env: INPUT_SCHEMA: ./test/integration/info_json_schema.json INPUT_JSONS: ./info.json \ No newline at end of file From 5460b5cb6f170965395ec375129f085accf4c040 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 17:20:37 -0500 Subject: [PATCH 10/35] update inputs --- .github/workflows/integration-info.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index fe1b665f..2d1b2c9a 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -18,6 +18,6 @@ jobs: ./draft info > ./info.json - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 - env: - INPUT_SCHEMA: ./test/integration/info_json_schema.json - INPUT_JSONS: ./info.json \ No newline at end of file + with: + schema: ./test/integration/info_json_schema.json + jsons: ./info.json \ No newline at end of file From 7f8ade8ba027df68b224a2bc5ef54628608a9b36 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 17:51:26 -0500 Subject: [PATCH 11/35] whyy --- .github/workflows/integration-info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 2d1b2c9a..20ad88e1 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,6 +16,7 @@ jobs: run: make - run: | ./draft info > ./info.json + ls - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 with: From 11286c04c164e7c0b75b11ecc994bcebf8a52235 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 18:21:09 -0500 Subject: [PATCH 12/35] pwd for debug --- .github/workflows/integration-info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 20ad88e1..c8d75c87 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -17,6 +17,7 @@ jobs: - run: | ./draft info > ./info.json ls + pwd - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 with: From 9f83a5a1a501d91484889210ac72788bc3e7a0b8 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 18:26:50 -0500 Subject: [PATCH 13/35] src dir" --- .github/workflows/integration-info.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index c8d75c87..d6c7bf06 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -8,6 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + path: src - name: Set up Go uses: actions/setup-go@v2 with: @@ -21,5 +22,5 @@ jobs: - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 with: - schema: ./test/integration/info_json_schema.json - jsons: ./info.json \ No newline at end of file + schema: ./src/test/integration/info_json_schema.json + jsons: ./src/info.json \ No newline at end of file From 1624b57d42d677305f6ef3bf3ad876294751e4a9 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 18:28:50 -0500 Subject: [PATCH 14/35] yaml with fix --- .github/workflows/integration-info.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index d6c7bf06..b888a997 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -8,7 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - path: src + with: + path: "./src" - name: Set up Go uses: actions/setup-go@v2 with: From 42254732296ec0287a223243efe86fff4132a61a Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 21:53:52 -0500 Subject: [PATCH 15/35] cd to src; --- .github/workflows/integration-info.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index b888a997..5a055e25 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -15,7 +15,9 @@ jobs: with: go-version: 1.18.2 - name: make - run: make + run: | + cd src + make - run: | ./draft info > ./info.json ls From dd659f474b3af7df99b72c693b4e74b5f5215852 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Mon, 7 Nov 2022 23:36:13 -0500 Subject: [PATCH 16/35] yet another fix --- .github/workflows/integration-info.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 5a055e25..798a86b8 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -19,11 +19,11 @@ jobs: cd src make - run: | - ./draft info > ./info.json + ./src/draft info > ./info.json ls pwd - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 with: schema: ./src/test/integration/info_json_schema.json - jsons: ./src/info.json \ No newline at end of file + jsons: ./info.json \ No newline at end of file From 329f9abe53f348b9714bcec1897e7802f2a8c50f Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 09:10:35 -0500 Subject: [PATCH 17/35] use ghworkspace env --- .github/workflows/integration-info.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 798a86b8..aabb3c83 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -9,17 +9,17 @@ jobs: steps: - uses: actions/checkout@v3 with: - path: "./src" + path: "$GITHUB_WORKSPACE/src" - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.18.2 - name: make run: | - cd src + cd $GITHUB_WORKSPACE/src make - run: | - ./src/draft info > ./info.json + $GITHUB_WORKSPACE/src/draft info > $GITHUB_WORKSPACE/info.json ls pwd - name: Validate JSON From a78d827165b364d2dfab334abab5b68f1d72638a Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 11:25:58 -0500 Subject: [PATCH 18/35] try absolute paths --- .github/workflows/integration-info.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index aabb3c83..0d5fc886 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -8,22 +8,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - path: "$GITHUB_WORKSPACE/src" - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.18.2 - name: make run: | - cd $GITHUB_WORKSPACE/src + ls + pwd make - run: | - $GITHUB_WORKSPACE/src/draft info > $GITHUB_WORKSPACE/info.json + ./draft info > ./info.json ls pwd - name: Validate JSON uses: nhalstead/validate-json-action@0.1.3 with: - schema: ./src/test/integration/info_json_schema.json - jsons: ./info.json \ No newline at end of file + schema: /home/runner/work/draft/draft/test/integration/info_json_schema.json + jsons: /home/runner/work/draft/draft/info.json \ No newline at end of file From f97aff70f6b3881ecb8e110e5fb1029732ac07cc Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 12:46:14 -0500 Subject: [PATCH 19/35] clone to github workspace --- .github/workflows/integration-info.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 0d5fc886..4dd155e9 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -8,6 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + - path: ${{ github.workspace }} - name: Set up Go uses: actions/setup-go@v2 with: From e4aa7b9d5da4cba24d75db44f6b501d3b41507c3 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 12:53:24 -0500 Subject: [PATCH 20/35] im done with premade github actions. cli ftw --- .github/workflows/integration-info.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 4dd155e9..764a2609 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -8,23 +8,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - - path: ${{ github.workspace }} - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.18.2 - name: make - run: | - ls - pwd - make - run: | ./draft info > ./info.json ls pwd - name: Validate JSON - uses: nhalstead/validate-json-action@0.1.3 - with: - schema: /home/runner/work/draft/draft/test/integration/info_json_schema.json - jsons: /home/runner/work/draft/draft/info.json \ No newline at end of file + run: | + npm install -g ajv-cli + ajv validate -s ./test/integration/info.schema.json -d ./info.json \ No newline at end of file From dca44cf2a3c0d1080ca0e5eb4c4ae5ae257fbe9c Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 12:54:56 -0500 Subject: [PATCH 21/35] missing make --- .github/workflows/integration-info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 764a2609..63378c8f 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -13,6 +13,7 @@ jobs: with: go-version: 1.18.2 - name: make + run: make - run: | ./draft info > ./info.json ls From bd471920062df24aaa95372bb401a15c94cb9fd1 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 13:21:00 -0500 Subject: [PATCH 22/35] fix info schema naming --- .github/workflows/integration-info.yml | 2 +- test/integration/{info_json_schema.json => info_schema.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/integration/{info_json_schema.json => info_schema.json} (100%) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 63378c8f..5ddbf8d0 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -21,4 +21,4 @@ jobs: - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s ./test/integration/info.schema.json -d ./info.json \ No newline at end of file + ajv validate -s ./test/integration/info_schema.json -d ./info.json \ No newline at end of file diff --git a/test/integration/info_json_schema.json b/test/integration/info_schema.json similarity index 100% rename from test/integration/info_json_schema.json rename to test/integration/info_schema.json From 80a47b862ba756ead43f7a4408c146ee48baed7c Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 13:24:31 -0500 Subject: [PATCH 23/35] ls the integration dir --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 5ddbf8d0..362a88ef 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,7 +16,7 @@ jobs: run: make - run: | ./draft info > ./info.json - ls + ls ./test/integration pwd - name: Validate JSON run: | From a7d8ee03f3e213461526776dca68dea418d4cd08 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 13:29:09 -0500 Subject: [PATCH 24/35] it was missing the pkg dir --- .github/workflows/integration-info.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 362a88ef..9a439d13 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,9 +16,7 @@ jobs: run: make - run: | ./draft info > ./info.json - ls ./test/integration - pwd - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s ./test/integration/info_schema.json -d ./info.json \ No newline at end of file + ajv validate -s .pkg/test/integration/info_schema.json -d ./info.json \ No newline at end of file From ab91d88a8abbc072b807c93640e750e42be652ff Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:13:01 -0500 Subject: [PATCH 25/35] missing slash --- .github/workflows/integration-info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 9a439d13..55b0b5e9 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -19,4 +19,4 @@ jobs: - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s .pkg/test/integration/info_schema.json -d ./info.json \ No newline at end of file + ajv validate -s ./pkg/test/integration/info_schema.json -d ./info.json \ No newline at end of file From 1d0c4755f17e157aa235bdb1767f3350f0377268 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:23:45 -0500 Subject: [PATCH 26/35] ls --- .github/workflows/integration-info.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 55b0b5e9..8b6a1d44 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,6 +16,8 @@ jobs: run: make - run: | ./draft info > ./info.json + pwd + ls ./pkg/test/integration - name: Validate JSON run: | npm install -g ajv-cli From 7320a127ba9a0d7f93a3902ef2ab920c1e143876 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:25:47 -0500 Subject: [PATCH 27/35] another ls --- .github/workflows/integration-info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 8b6a1d44..07daa16a 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -17,6 +17,7 @@ jobs: - run: | ./draft info > ./info.json pwd + ls ls ./pkg/test/integration - name: Validate JSON run: | From fbd25721eb84dd5848fdbe1ef17d220a1814b8b2 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:28:42 -0500 Subject: [PATCH 28/35] again --- .github/workflows/integration-info.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 07daa16a..faa5401a 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -18,8 +18,8 @@ jobs: ./draft info > ./info.json pwd ls - ls ./pkg/test/integration + ls ./test/integration - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s ./pkg/test/integration/info_schema.json -d ./info.json \ No newline at end of file + ajv validate -s ./test/integration/info_schema.json -d ./info.json \ No newline at end of file From 4a610b7768db156c01d1c451f4b14c1e37c0e3f9 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:38:03 -0500 Subject: [PATCH 29/35] no dots --- .github/workflows/integration-info.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index faa5401a..2e7133fb 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,10 +16,10 @@ jobs: run: make - run: | ./draft info > ./info.json - pwd ls + pwd ls ./test/integration - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s ./test/integration/info_schema.json -d ./info.json \ No newline at end of file + ajv validate -s test/integration/info_schema.json -d info.json \ No newline at end of file From ff711b4bda9f3e2acd17ee94af79cd022449f7dc Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:41:14 -0500 Subject: [PATCH 30/35] add cat --- .github/workflows/integration-info.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 2e7133fb..54661156 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -19,6 +19,7 @@ jobs: ls pwd ls ./test/integration + cat test/integration/info_schema.json - name: Validate JSON run: | npm install -g ajv-cli From 09c0a15969b7ff6aeb70254356737d0e3cd958a5 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:44:24 -0500 Subject: [PATCH 31/35] rename again --- .github/workflows/integration-info.yml | 4 ++-- test/integration/{info_schema.json => info.json} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename test/integration/{info_schema.json => info.json} (100%) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index 54661156..d4f989a7 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -19,8 +19,8 @@ jobs: ls pwd ls ./test/integration - cat test/integration/info_schema.json + cat test/integration/info.json - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s test/integration/info_schema.json -d info.json \ No newline at end of file + ajv validate -s test/integration/info.json -d info.json \ No newline at end of file diff --git a/test/integration/info_schema.json b/test/integration/info.json similarity index 100% rename from test/integration/info_schema.json rename to test/integration/info.json From 3eedb129b21f90142ac665fb54890e2dcd97c9c1 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:48:17 -0500 Subject: [PATCH 32/35] ahhh make deletes the integration folder --- .github/workflows/integration-info.yml | 6 +++--- test/{integration/info.json => info_schema.json} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename test/{integration/info.json => info_schema.json} (100%) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index d4f989a7..fc7b07c8 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -18,9 +18,9 @@ jobs: ./draft info > ./info.json ls pwd - ls ./test/integration - cat test/integration/info.json + ls ./test + cat test/info_schema.json - name: Validate JSON run: | npm install -g ajv-cli - ajv validate -s test/integration/info.json -d info.json \ No newline at end of file + ajv validate -s test/info_schema.json -d info.json \ No newline at end of file diff --git a/test/integration/info.json b/test/info_schema.json similarity index 100% rename from test/integration/info.json rename to test/info_schema.json From 6ae7f0d72912a383613493be33d62713b6a3c15c Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 15:55:41 -0500 Subject: [PATCH 33/35] cat jsons --- .github/workflows/integration-info.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-info.yml b/.github/workflows/integration-info.yml index fc7b07c8..932b6810 100644 --- a/.github/workflows/integration-info.yml +++ b/.github/workflows/integration-info.yml @@ -16,10 +16,10 @@ jobs: run: make - run: | ./draft info > ./info.json - ls - pwd - ls ./test + echo "Draft Info JSON schema:" cat test/info_schema.json + echo "Draft Info JSON:" + cat info.json - name: Validate JSON run: | npm install -g ajv-cli From 479ff7ded0b9b3ffddd30135969f5764ba109e1a Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 8 Nov 2022 16:11:47 -0500 Subject: [PATCH 34/35] use system fmt print to get rid of log prefix --- cmd/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/info.go b/cmd/info.go index 7da515e1..46734267 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -61,7 +61,7 @@ func (ic *infoCmd) run() error { if err != nil { return fmt.Errorf("could not marshal draft info into json: %w", err) } - log.Println(string(infoText)) + fmt.Println(string(infoText)) return nil } From 4b8cf305c37f4075be738c70bc9ddc7d3b1a6cb3 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Wed, 9 Nov 2022 17:54:48 -0500 Subject: [PATCH 35/35] add example and update readme for info --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 45cfaa47..5097217e 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,33 @@ If you don’t plan on using the GitHub Action, you can directly apply your depl If you plan on deploying your application through your GitHub Action, commit all the files to your repository and watch your application get deployed! +### `draft info` +The `draft info` command prints information about supported languages and deployment types. +Example output: +``` +{ + "supported_languages": [ + "php", + "python", + "rust", + "swift", + "csharp", + "go", + "gradle", + "javascript", + "ruby", + "clojure", + "erlang", + "gomodule", + "java" + ], + "supported_deployment_types": [ + "helm", + "kustomize", + "manifests" + ] +} +``` ## About The Project @@ -61,6 +88,7 @@ Draft makes it easier for developers to get started building apps that run on Ku - `draft setup-gh` automates the GitHub OIDC setup process for your project. - `draft generate-workflow` generates a GitHub Actions workflow for automatic build and deploy to a Kubernetes cluster. - `draft update` automatically make your application to be internet accessible. +- `draft info` print supported language and field information in json format. Use `draft [command] --help` for more information about a command.