Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --skip-content-type-check option for skipping check of content type of assets. #96

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ func init() {
rootCmd.Flags().StringVarP(&sOpt.BinMatch, "bin-match", "", "", "regexp to match bin path in asset")
rootCmd.Flags().BoolVarP(&sOpt.Force, "force", "f", false, "enable force setup")
rootCmd.Flags().BoolVarP(&opt.Strict, "strict", "", false, "require strict match")
rootCmd.Flags().BoolVarP(&opt.SkipContentTypeCheck, "skip-content-type-check", "", false, "skip check content-type of assets")
rootCmd.Flags().BoolVarP(&verbose, "verbose", "", false, "show verbose log")
}
13 changes: 7 additions & 6 deletions gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ var supportContentType = []string{
const versionLatest = "latest"

type AssetOption struct {
Match string
Version string
OS string
Arch string
Strict bool
Match string
Version string
OS string
Arch string
Strict bool
SkipContentTypeCheck bool
}

func GetReleaseAsset(ctx context.Context, owner, repo string, opt *AssetOption) (*releaseAsset, fs.FS, error) {
Expand Down Expand Up @@ -133,7 +134,7 @@ func detectAsset(assets []*releaseAsset, opt *AssetOption) (*releaseAsset, error
}
assetScores := []*assetScore{}
for _, a := range assets {
if a.ContentType != "" && !contains(supportContentType, a.ContentType) {
if (opt == nil || !opt.SkipContentTypeCheck) && a.ContentType != "" && !contains(supportContentType, a.ContentType) {
slog.Info("Skip",
slog.String("name", a.Name),
slog.String("reason", "Unsupported content type"),
Expand Down