-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more test case to validator (#201)
- Loading branch information
1 parent
8d0082a
commit b0b2c3b
Showing
3 changed files
with
338 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package pkg | ||
|
||
import ( | ||
"github.com/IceWhaleTech/CasaOS-AppManagement/codegen" | ||
"github.com/IceWhaleTech/CasaOS-AppManagement/common" | ||
"github.com/IceWhaleTech/CasaOS-AppManagement/service" | ||
"github.com/compose-spec/compose-go/loader" | ||
) | ||
|
||
func VaildDockerCompose(yaml []byte) (err error) { | ||
err = nil | ||
// recover | ||
defer func() { | ||
if r := recover(); r != nil { | ||
err = r.(error) | ||
} | ||
}() | ||
docker, err := service.NewComposeAppFromYAML(yaml, false, false) | ||
|
||
ex, ok := docker.Extensions[common.ComposeExtensionNameXCasaOS] | ||
if !ok { | ||
return service.ErrComposeExtensionNameXCasaOSNotFound | ||
} | ||
|
||
var storeInfo codegen.ComposeAppStoreInfo | ||
if err = loader.Transform(ex, &storeInfo); err != nil { | ||
return | ||
} | ||
|
||
return | ||
} |
Oops, something went wrong.