From 50b59e8d8d2328a174a23f5991924f1167cf6b6b Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Sat, 24 Mar 2018 17:26:38 +0100 Subject: [PATCH] refactor: remove hcl support Signed-off-by: Yvonnick Esnault --- cli/cds/action/add.go | 6 +- cli/cds/environment/export.go | 2 +- cli/cds/pipeline/export.go | 2 +- cli/cds/pipeline/import.go | 2 - cli/cdsctl/pipeline.go | 2 - sdk/action_script_test.go | 295 ------------------------------ sdk/exportentities/common.go | 2 - sdk/exportentities/common_test.go | 5 +- sdk/exportentities/pipeline.go | 12 +- sdk/exportentities/types.go | 1 - 10 files changed, 10 insertions(+), 319 deletions(-) delete mode 100644 sdk/action_script_test.go diff --git a/cli/cds/action/add.go b/cli/cds/action/add.go index 0530bd8f98..6d25f04cbf 100644 --- a/cli/cds/action/add.go +++ b/cli/cds/action/add.go @@ -20,11 +20,7 @@ func cmdActionAdd() *cobra.Command { Short: "cds action add []", Long: `cds action add [] - is mandatory if you don't use --url flag - -Examples of usage: - -$cds action add --url $HOME/src/github.com/ovh/cds/contrib/actions/action-scripts/cds-docker-package.hcl + is mandatory `, Run: addAction, diff --git a/cli/cds/environment/export.go b/cli/cds/environment/export.go index bab9dc29f7..d62de56a1c 100644 --- a/cli/cds/environment/export.go +++ b/cli/cds/environment/export.go @@ -52,7 +52,7 @@ func exportCmd() *cobra.Command { }, } - cmd.Flags().StringVarP(&exportFormat, "format", "", "yaml", "Format: json|yaml|hcl") + cmd.Flags().StringVarP(&exportFormat, "format", "", "yaml", "Format: json|yaml") cmd.Flags().StringVarP(&exportOutput, "output", "", "", "Output filename") return cmd diff --git a/cli/cds/pipeline/export.go b/cli/cds/pipeline/export.go index 4f953c5178..9d88f28672 100644 --- a/cli/cds/pipeline/export.go +++ b/cli/cds/pipeline/export.go @@ -55,7 +55,7 @@ func exportCmd() *cobra.Command { }, } - cmd.Flags().StringVarP(&exportFormat, "format", "", "yaml", "Format: json|yaml|hcl") + cmd.Flags().StringVarP(&exportFormat, "format", "", "yaml", "Format: json|yaml") cmd.Flags().StringVarP(&exportOutput, "output", "", "", "Output filename") cmd.Flags().BoolVarP(&exportWithPermissions, "withPermissions", "", false, "Export pipeline configuration with permission") diff --git a/cli/cds/pipeline/import.go b/cli/cds/pipeline/import.go index b59138eb7f..3d2bb72f4a 100644 --- a/cli/cds/pipeline/import.go +++ b/cli/cds/pipeline/import.go @@ -36,8 +36,6 @@ func importCmd() *cobra.Command { importFormat = "yaml" if strings.HasSuffix(name, ".json") { importFormat = "json" - } else if strings.HasSuffix(name, ".hcl") { - importFormat = "hcl" } var err error btes, _, err = exportentities.ReadFile(name) diff --git a/cli/cdsctl/pipeline.go b/cli/cdsctl/pipeline.go index cdda643754..077e639e93 100644 --- a/cli/cdsctl/pipeline.go +++ b/cli/cdsctl/pipeline.go @@ -161,8 +161,6 @@ func pipelineImportRun(v cli.Values) error { if strings.HasSuffix(v["path"], ".json") { format = "json" - } else if strings.HasSuffix(v["path"], ".hcl") { - format = "hcl" } isURL, _ := regexp.MatchString(`http[s]?:\/\/(.*)`, v["path"]) diff --git a/sdk/action_script_test.go b/sdk/action_script_test.go deleted file mode 100644 index 6330f57fde..0000000000 --- a/sdk/action_script_test.go +++ /dev/null @@ -1,295 +0,0 @@ -package sdk - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestLoadFromActionScript(t *testing.T) { - b := []byte(` -name = "TestGitClone" -description = "Clone git repository" - -// Requirements -requirements = { - "git" = { - type = "binary" - value = "git" - } - "ssh-keygen" = { - type = "binary" - value = "ssh-keygen" - } -} - -// Parameters -parameters = { - "branch" = { - type = "string" - value = "{{.git.branch}}" - } - "commit" = { - type = "string" - value = "{{.git.hash}}" - } - "directory" = { - type = "string" - description = "target directory" - } - "gitOptions" = { - type = "string" - description = "git clone options" - } - "url" = { - type = "string" - description = "git URL" - value = "{{.cds.app.repo}}" - } -} - -// Steps -steps = [{ - script = < 0) - - b, _, _ = ReadURL("https://raw.githubusercontent.com/ovh/tat/master/.travis.yml", "yml") + b, _, _ := ReadURL("https://raw.githubusercontent.com/ovh/tat/master/.travis.yml", "yml") assert.True(t, len(b) > 0) } diff --git a/sdk/exportentities/pipeline.go b/sdk/exportentities/pipeline.go index 7445735baf..38bc0c4510 100644 --- a/sdk/exportentities/pipeline.go +++ b/sdk/exportentities/pipeline.go @@ -32,8 +32,8 @@ type Pipeline struct { Parameters map[string]ParameterValue `json:"parameters,omitempty" yaml:"parameters,omitempty"` Stages map[string]Stage `json:"stages,omitempty" yaml:"stages,omitempty"` Jobs map[string]Job `json:"jobs,omitempty" yaml:"jobs,omitempty"` - Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty" hcl:"requirement,omitempty"` - Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty" hcl:"step,omitempty"` + Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"` + Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty"` } // Stage represents exported sdk.Stage @@ -49,10 +49,10 @@ type Job struct { Stage string `json:"stage,omitempty" yaml:"stage,omitempty"` //This will ONLY be set with Pipelinev1 Description string `json:"description,omitempty" yaml:"description,omitempty"` Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` - Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty" hcl:"step,omitempty"` - Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty" hcl:"requirement,omitempty"` - Optional *bool `json:"optional,omitempty" yaml:"optional,omitempty" hcl:"optional,omitempty"` - AlwaysExecuted *bool `json:"always_executed,omitempty" yaml:"always_executed,omitempty" hcl:"always_executed,omitempty"` + Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty"` + Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"` + Optional *bool `json:"optional,omitempty" yaml:"optional,omitempty"` + AlwaysExecuted *bool `json:"always_executed,omitempty" yaml:"always_executed,omitempty"` } // Step represents exported step used in a job diff --git a/sdk/exportentities/types.go b/sdk/exportentities/types.go index eb624475e0..c1c2f46e7d 100644 --- a/sdk/exportentities/types.go +++ b/sdk/exportentities/types.go @@ -34,7 +34,6 @@ const ( FormatJSON Format = iota FormatYAML FormatTOML - FormatHCL UnknownFormat )