Skip to content

Commit

Permalink
Merge 5a092e5 into f89e9a2
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Sep 2, 2021
2 parents f89e9a2 + 5a092e5 commit f6d8dbd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cmd/pulumi/schema_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func newSchemaCheckCommand() *cobra.Command {
diagWriter := hcl.NewDiagnosticTextWriter(os.Stderr, nil, 0, true)
wrErr := diagWriter.WriteDiagnostics(diags)
contract.IgnoreError(wrErr)
if err == nil && len(diags) != 0 {
// We don't want to print an error, but we do want to indicate
// that the check was not successful
os.Exit(1)
}
return err
}),
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/codegen/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,11 @@ func errorf(path, message string, args ...interface{}) *hcl.Diagnostic {
func bindSpec(spec PackageSpec, languages map[string]Language, loader Loader) (*Package, hcl.Diagnostics, error) {
var diags hcl.Diagnostics

// Validate that there is a name
if spec.Name == "" {
diags = diags.Append(errorf("#/name", "No name provided"))
}

// Parse the version, if any.
var version *semver.Version
if spec.Version != "" {
Expand All @@ -1417,6 +1422,8 @@ func bindSpec(spec PackageSpec, languages map[string]Language, loader Loader) (*
} else {
version = &v
}
} else {
diags = diags.Append(errorf("#/version", "No version provided"))
}

// Parse the module format, if any.
Expand Down Expand Up @@ -1878,6 +1885,9 @@ func (t *types) bindType(path string, spec TypeSpec, inputShape bool) (result Ty
var discriminator string
var mapping map[string]string
if spec.Discriminator != nil {
if spec.Discriminator.PropertyName == "" {
diags = diags.Append(errorf(path, "Discriminator must provide a property name"))
}
discriminator = spec.Discriminator.PropertyName
mapping = spec.Discriminator.Mapping
}
Expand Down Expand Up @@ -2023,6 +2033,9 @@ func bindDefaultValue(path string, value interface{}, spec *DefaultSpec, typ Typ
for name, raw := range spec.Language {
language[name] = json.RawMessage(raw)
}
if spec.Environment == nil {
diags = diags.Append(errorf(path, "Default must specify an environment"))
}

dv.Environment, dv.Language = spec.Environment, language
}
Expand Down

0 comments on commit f6d8dbd

Please sign in to comment.