mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
jobspec: remove HCL1 support (#23912)
This changeset removes support for parsing jobspecs via the long-deprecated HCLv1. Fixes: https://github.com/hashicorp/nomad/issues/20195 Ref: https://hashicorp.atlassian.net/browse/NET-10220
This commit is contained in:
10
api/jobs.go
10
api/jobs.go
@@ -75,9 +75,6 @@ type JobsParseRequest struct {
|
||||
// JobHCL is an hcl jobspec
|
||||
JobHCL string
|
||||
|
||||
// HCLv1 indicates whether the JobHCL should be parsed with the hcl v1 parser
|
||||
HCLv1 bool `json:"hclv1,omitempty"`
|
||||
|
||||
// Variables are HCL2 variables associated with the job. Only works with hcl2.
|
||||
//
|
||||
// Interpreted as if it were the content of a variables file.
|
||||
@@ -105,7 +102,7 @@ func (j *Jobs) ParseHCL(jobHCL string, canonicalize bool) (*Job, error) {
|
||||
}
|
||||
|
||||
// ParseHCLOpts is used to request the server convert the HCL representation of a
|
||||
// Job to JSON on our behalf. Accepts HCL1 or HCL2 jobs as input.
|
||||
// Job to JSON on our behalf. Only accepts HCL2 jobs as input.
|
||||
func (j *Jobs) ParseHCLOpts(req *JobsParseRequest) (*Job, error) {
|
||||
var job Job
|
||||
_, err := j.client.put("/v1/jobs/parse", req, &job, nil)
|
||||
@@ -929,10 +926,11 @@ type ParameterizedJobConfig struct {
|
||||
// the job submission.
|
||||
type JobSubmission struct {
|
||||
// Source contains the original job definition (may be in the format of
|
||||
// hcl1, hcl2, or json).
|
||||
// hcl1, hcl2, or json). HCL1 jobs can no longer be parsed.
|
||||
Source string
|
||||
|
||||
// Format indicates what the Source content was (hcl1, hcl2, or json).
|
||||
// Format indicates what the Source content was (hcl1, hcl2, or json). HCL1
|
||||
// jobs can no longer be parsed.
|
||||
Format string
|
||||
|
||||
// VariableFlags contains the CLI "-var" flag arguments as submitted with the
|
||||
|
||||
@@ -1685,7 +1685,7 @@ func TestJobs_Submission_namespaces(t *testing.T) {
|
||||
_, wm, err = jobs.RegisterOpts(job2, &RegisterOptions{
|
||||
Submission: &JobSubmission{
|
||||
Source: "second job source",
|
||||
Format: "hcl1",
|
||||
Format: "hcl2",
|
||||
},
|
||||
}, &WriteOptions{Namespace: "second"})
|
||||
must.NoError(t, err)
|
||||
@@ -2577,7 +2577,6 @@ func TestJobs_Parse(t *testing.T) {
|
||||
// Test ParseHCLOpts
|
||||
req := &JobsParseRequest{
|
||||
JobHCL: jobspec,
|
||||
HCLv1: false,
|
||||
Canonicalize: false,
|
||||
}
|
||||
|
||||
@@ -2588,31 +2587,9 @@ func TestJobs_Parse(t *testing.T) {
|
||||
// Test ParseHCLOpts with Canonicalize=true
|
||||
req = &JobsParseRequest{
|
||||
JobHCL: jobspec,
|
||||
HCLv1: false,
|
||||
Canonicalize: true,
|
||||
}
|
||||
job2Canonicalized, err := c.Jobs().ParseHCLOpts(req)
|
||||
must.NoError(t, err)
|
||||
must.Eq(t, job1Canonicalized, job2Canonicalized)
|
||||
|
||||
// Test ParseHCLOpts with HCLv1=true
|
||||
req = &JobsParseRequest{
|
||||
JobHCL: jobspec,
|
||||
HCLv1: true,
|
||||
Canonicalize: false,
|
||||
}
|
||||
|
||||
job3, err := c.Jobs().ParseHCLOpts(req)
|
||||
must.NoError(t, err)
|
||||
must.Eq(t, job1, job3)
|
||||
|
||||
// Test ParseHCLOpts with HCLv1=true and Canonicalize=true
|
||||
req = &JobsParseRequest{
|
||||
JobHCL: jobspec,
|
||||
HCLv1: true,
|
||||
Canonicalize: true,
|
||||
}
|
||||
job3Canonicalized, err := c.Jobs().ParseHCLOpts(req)
|
||||
must.NoError(t, err)
|
||||
must.Eq(t, job1Canonicalized, job3Canonicalized)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user