2023-12-10 21:27:57 +01:00
|
|
|
// 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 (
|
2024-07-23 01:32:14 +02:00
|
|
|
"github.com/urfave/cli/v3"
|
2023-12-10 21:27:57 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ForgeTypeGitea = "gitea"
|
2024-07-18 20:32:09 +02:00
|
|
|
ForgeTypeForgejo = "forgejo"
|
2023-12-10 21:27:57 +01:00
|
|
|
ForgeTypeGitHub = "github"
|
|
|
|
ForgeTypeGitLab = "gitlab"
|
|
|
|
ForgeTypeBitbucket = "bitbucket"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Forge defines metadata for integration with a forge.
|
|
|
|
type Forge struct {
|
|
|
|
Type string `json:"type,omitempty"`
|
2024-02-15 19:53:26 +01:00
|
|
|
URL string `json:"url,omitempty"`
|
|
|
|
|
|
|
|
// Deprecated: Please use URL instead.
|
2023-12-10 21:27:57 +01:00
|
|
|
Link string `json:"link,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func forgeFlags() []cli.Flag {
|
|
|
|
return []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "forge.type",
|
2024-07-18 20:32:09 +02:00
|
|
|
Usage: "forge type (gitea, forgejo, github, gitlab, bitbucket)",
|
2024-07-23 01:32:14 +02:00
|
|
|
Sources: cli.EnvVars(
|
2023-12-10 21:27:57 +01:00
|
|
|
"CI_FORGE_TYPE",
|
2024-07-23 01:32:14 +02:00
|
|
|
),
|
2023-12-10 21:27:57 +01:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2024-02-15 19:53:26 +01:00
|
|
|
Name: "forge.url",
|
|
|
|
Aliases: []string{"forge.link"},
|
|
|
|
Usage: "forge url",
|
2024-07-23 01:32:14 +02:00
|
|
|
Sources: cli.EnvVars(
|
2023-12-10 21:27:57 +01:00
|
|
|
"CI_FORGE_URL",
|
|
|
|
"CI_FORGE_LINK",
|
2024-07-23 01:32:14 +02:00
|
|
|
),
|
2023-12-10 21:27:57 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-23 01:32:14 +02:00
|
|
|
func forgeFromContext(c *cli.Command) Forge {
|
2023-12-10 21:27:57 +01:00
|
|
|
return Forge{
|
2024-07-23 01:32:14 +02:00
|
|
|
Type: c.String("forge.type"),
|
|
|
|
Link: c.String("forge.url"),
|
|
|
|
URL: c.String("forge.url"),
|
2023-12-10 21:27:57 +01:00
|
|
|
}
|
|
|
|
}
|