PR comments

This commit is contained in:
Vivek Lakshmanan 2021-01-19 09:55:40 -08:00
parent c51cee7fcd
commit f5f08ef403

View file

@ -344,27 +344,27 @@ func (pkg *pkgContext) inputType(t schema.Type, optional bool) string {
// always marked as required. Caller should check if the property is
// optional and convert the type to a pointer if necessary.
func (pkg *pkgContext) resolveResourceType(t *schema.ResourceType) string {
if t.Resource != nil && pkg.pkg != nil && t.Resource.Package != pkg.pkg {
extPkg := t.Resource.Package
var goInfo GoPackageInfo
contract.AssertNoError(extPkg.ImportLanguages(map[string]schema.Language{"go": Importer}))
if info, ok := extPkg.Language["go"].(GoPackageInfo); ok {
goInfo = info
}
extPkgCtx := &pkgContext{
pkg: extPkg,
importBasePath: goInfo.ImportBasePath,
pkgImportAliases: goInfo.PackageImportAliases,
modToPkg: goInfo.ModuleToPackage,
}
resType := extPkgCtx.tokenToResource(t.Token)
if !strings.Contains(resType, ".") {
resType = fmt.Sprintf("%s.%s", extPkg.Name, resType)
}
return resType
if t.Resource == nil || pkg.pkg == nil || t.Resource.Package == pkg.pkg {
return pkg.tokenToResource(t.Token)
}
return pkg.tokenToResource(t.Token)
extPkg := t.Resource.Package
var goInfo GoPackageInfo
contract.AssertNoError(extPkg.ImportLanguages(map[string]schema.Language{"go": Importer}))
if info, ok := extPkg.Language["go"].(GoPackageInfo); ok {
goInfo = info
}
extPkgCtx := &pkgContext{
pkg: extPkg,
importBasePath: goInfo.ImportBasePath,
pkgImportAliases: goInfo.PackageImportAliases,
modToPkg: goInfo.ModuleToPackage,
}
resType := extPkgCtx.tokenToResource(t.Token)
if !strings.Contains(resType, ".") {
resType = fmt.Sprintf("%s.%s", extPkg.Name, resType)
}
return resType
}
// resolveObjectType resolves resource references in properties while
@ -372,23 +372,23 @@ func (pkg *pkgContext) resolveResourceType(t *schema.ResourceType) string {
// always marked as required. Caller should check if the property is
// optional and convert the type to a pointer if necessary.
func (pkg *pkgContext) resolveObjectType(t *schema.ObjectType) string {
if t.Package != nil && pkg.pkg != nil && t.Package != pkg.pkg {
extPkg := t.Package
var goInfo GoPackageInfo
contract.AssertNoError(extPkg.ImportLanguages(map[string]schema.Language{"go": Importer}))
if info, ok := extPkg.Language["go"].(GoPackageInfo); ok {
goInfo = info
}
extPkgCtx := &pkgContext{
pkg: extPkg,
importBasePath: goInfo.ImportBasePath,
pkgImportAliases: goInfo.PackageImportAliases,
modToPkg: goInfo.ModuleToPackage,
}
return extPkgCtx.plainType(t, false)
if t.Package == nil || pkg.pkg == nil || t.Package == pkg.pkg {
return pkg.tokenToType(t.Token)
}
return pkg.tokenToType(t.Token)
extPkg := t.Package
var goInfo GoPackageInfo
contract.AssertNoError(extPkg.ImportLanguages(map[string]schema.Language{"go": Importer}))
if info, ok := extPkg.Language["go"].(GoPackageInfo); ok {
goInfo = info
}
extPkgCtx := &pkgContext{
pkg: extPkg,
importBasePath: goInfo.ImportBasePath,
pkgImportAliases: goInfo.PackageImportAliases,
modToPkg: goInfo.ModuleToPackage,
}
return extPkgCtx.plainType(t, false)
}
func (pkg *pkgContext) outputType(t schema.Type, optional bool) string {
@ -607,7 +607,7 @@ func (pkg *pkgContext) genEnumType(w io.Writer, name string, enumType *schema.En
elementType := pkg.enumElementType(enumType.ElementType, false)
fmt.Fprintf(w, "type %s %s\n\n", name, elementType)
_, _ = fmt.Fprintln(w, "const (")
fmt.Fprintln(w, "const (")
for _, e := range enumType.Elements {
printCommentWithDeprecationMessage(w, e.Comment, e.DeprecationMessage, true)