Skip to content

Commit

Permalink
fix: lint error (#1550)
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-stewart authored Feb 22, 2024
1 parent 7e5d8e6 commit ebadce0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
18 changes: 14 additions & 4 deletions lwcomponent/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ func (c *Catalog) Install(component *CDKComponent) (err error) {
return
}

CreateHostInfo(componentDir, component.Description, component.Type)
component.HostInfo, err = CreateHostInfo(componentDir, component.Description, component.Type)
if err != nil {
return
}

if component.ApiInfo != nil &&
(component.ApiInfo.ComponentType == BinaryType || component.ApiInfo.ComponentType == CommandType) {
Expand All @@ -219,8 +222,6 @@ func (c *Catalog) Install(component *CDKComponent) (err error) {
}
}

component.HostInfo, err = NewHostInfo(componentDir)

return
}

Expand Down Expand Up @@ -349,6 +350,10 @@ func LoadLocalComponents() (components map[string]CDKComponent, err error) {

// Prototype backwards compatibility
prototypeState, err := LocalState()
if err != nil {
prototypeState = new(State)
err = nil
}
prototypeComponents := make(map[string]Component, len(prototypeState.Components))
for _, component := range prototypeState.Components {
prototypeComponents[component.Name] = component
Expand Down Expand Up @@ -380,7 +385,12 @@ func LoadLocalComponents() (components map[string]CDKComponent, err error) {
}
components[hostInfo.Name()] = NewCDKComponent(hostInfo.Name(), devInfo.Desc, devInfo.ComponentType, nil, hostInfo)
} else {
components[hostInfo.Name()] = NewCDKComponent(hostInfo.Name(), hostInfo.Description, hostInfo.ComponentType, nil, hostInfo)
components[hostInfo.Name()] = NewCDKComponent(
hostInfo.Name(),
hostInfo.Description,
hostInfo.ComponentType,
nil,
hostInfo)
}
}

Expand Down
10 changes: 10 additions & 0 deletions lwcomponent/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,16 @@ func CreateLocalComponent(componentName string, version string, development bool
panic(err)
}

info := lwcomponent.HostInfo{Dir: "", Description: "", ComponentType: lwcomponent.BinaryType}
data, err := json.Marshal(info)
if err != nil {
panic(err)
}

if err := os.WriteFile(filepath.Join(path, lwcomponent.InfoFile), []byte(data), 0666); err != nil {
panic(err)
}

if err := os.WriteFile(filepath.Join(path, lwcomponent.SignatureFile), []byte(version), 0666); err != nil {
panic(err)
}
Expand Down
7 changes: 0 additions & 7 deletions lwcomponent/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,6 @@ var currentSignatureTests = []currentSignatureTest{
Component: mockComponent2,
Error: errors.New("component signature file does not exist"),
},
{
Name: "bad",
Component: mockComponent,
Signature: "-",
Expected: []byte{},
Error: errors.New("unable to decode component signature"),
},
{
Name: "ok",
Component: mockComponent,
Expand Down

0 comments on commit ebadce0

Please sign in to comment.