mirror of
https://codeberg.org/woodpecker-plugins/go-plugin.git
synced 2024-11-24 22:35:39 +01:00
30c031631d
`_LINK` -> `_URL` Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/19 Reviewed-by: anbraten <anbraten@noreply.codeberg.org> Co-authored-by: Lauris BH <lauris@nix.lv> Co-committed-by: Lauris BH <lauris@nix.lv>
95 lines
2.2 KiB
Go
95 lines
2.2 KiB
Go
// Copyright 2023 Woodpecker Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package plugin
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Repository defines runtime metadata for a repository.
|
|
type Repository struct {
|
|
Name string `json:"name,omitempty"`
|
|
Owner string `json:"owner,omitempty"`
|
|
Link string `json:"link,omitempty"`
|
|
CloneURL string `json:"clone_url,omitempty"`
|
|
Private bool `json:"private,omitempty"`
|
|
Branch string `json:"default_branch,omitempty"`
|
|
}
|
|
|
|
func repositoryFlags() []cli.Flag {
|
|
return []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "repo.name",
|
|
Usage: "repo name",
|
|
EnvVars: []string{
|
|
"CI_REPO_NAME",
|
|
"DRONE_REPO_NAME",
|
|
},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "repo.owner",
|
|
Usage: "repo owner",
|
|
EnvVars: []string{
|
|
"CI_REPO_OWNER",
|
|
"DRONE_REPO_OWNER",
|
|
},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "repo.link",
|
|
Usage: "repo link",
|
|
EnvVars: []string{
|
|
"CI_REPO_URL",
|
|
"CI_REPO_LINK",
|
|
"DRONE_REPO_LINK",
|
|
},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "repo.clone-url",
|
|
Usage: "repo clone url",
|
|
EnvVars: []string{
|
|
"CI_REPO_CLONE_URL",
|
|
"DRONE_GIT_HTTP_URL",
|
|
},
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "repo.private",
|
|
Usage: "repo private",
|
|
EnvVars: []string{
|
|
"CI_REPO_PRIVATE",
|
|
"DRONE_REPO_PRIVATE",
|
|
},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "repo.default-branch",
|
|
Usage: "repo default branch",
|
|
EnvVars: []string{
|
|
"CI_REPO_DEFAULT_BRANCH",
|
|
"DRONE_REPO_BRANCH",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func repositoryFromContext(c *cli.Context) Repository {
|
|
return Repository{
|
|
Name: c.String("repo.name"),
|
|
Owner: c.String("repo.owner"),
|
|
Link: c.String("repo.link"),
|
|
CloneURL: c.String("repo.clone-url"),
|
|
Private: c.Bool("repo.private"),
|
|
Branch: c.String("repo.default-branch"),
|
|
}
|
|
}
|