This change does a few things: * First and foremost, it tracks configuration variables that are initialized, and optionally prints them out as part of the prelude/header (based on --show-config), both in a dry-run (plan) and in an actual deployment (apply). * It tidies up some of the colorization and messages, and includes nice banners like "Deploying changes:", etc. * Fix an assertion. * Issue a new error "One or more errors occurred while applying X's configuration" just to make it easier to distinguish configuration-specific failures from ordinary ones. * Change config keys to tokens.Token, not tokens.ModuleMember, since it is legal for keys to represent class members (statics).
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
// Copyright 2016 Pulumi, Inc. All rights reserved.
|
|
|
|
package diag
|
|
|
|
// ID is a unique diagnostics identifier.
|
|
type ID int
|
|
|
|
// Diag is an instance of an error or warning generated by the compiler.
|
|
type Diag struct {
|
|
ID ID // a unique identifier for this diagnostic.
|
|
Message string // a human-friendly message for this diagnostic.
|
|
Doc *Document // the document in which this diagnostic occurred.
|
|
Loc *Location // the document location at which this diagnostic occurred.
|
|
}
|
|
|
|
// Message returns an anonymous diagnostic message without any source or ID information.
|
|
func Message(msg string) *Diag {
|
|
return &Diag{Message: msg}
|
|
}
|
|
|
|
// Diagable can be used to determine a diagnostic's position.
|
|
type Diagable interface {
|
|
Where() (*Document, *Location)
|
|
}
|
|
|
|
// At adds a position to an existing diagnostic, retaining its ID and message.
|
|
func (diag *Diag) At(d Diagable) *Diag {
|
|
var doc *Document
|
|
var loc *Location
|
|
if d != nil {
|
|
doc, loc = d.Where()
|
|
}
|
|
return &Diag{
|
|
ID: diag.ID,
|
|
Message: diag.Message,
|
|
Doc: doc,
|
|
Loc: loc,
|
|
}
|
|
}
|
|
|
|
// AtFile adds a file to an existing diagnostic, retaining its ID and message.
|
|
func (diag *Diag) AtFile(file string) *Diag {
|
|
return &Diag{
|
|
ID: diag.ID,
|
|
Message: diag.Message,
|
|
Doc: NewDocument(file),
|
|
}
|
|
}
|