-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh2gcs: Initial commit of utility for uploading GH releases to GCS
Signed-off-by: Stephen Augustus <[email protected]>
- Loading branch information
1 parent
44172ed
commit dbb5012
Showing
11 changed files
with
732 additions
and
116 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,32 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["main.go"], | ||
importpath = "k8s.io/release/cmd/gh2gcs", | ||
visibility = ["//visibility:private"], | ||
deps = ["//cmd/gh2gcs/cmd:go_default_library"], | ||
) | ||
|
||
go_binary( | ||
name = "kubepkg", | ||
embed = [":go_default_library"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [ | ||
":package-srcs", | ||
"//cmd/gh2gcs/cmd:all-srcs", | ||
], | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:public"], | ||
) |
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,28 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["root.go"], | ||
importpath = "k8s.io/release/cmd/gh2gcs/cmd", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/github:go_default_library", | ||
"//pkg/log:go_default_library", | ||
"@com_github_sirupsen_logrus//:go_default_library", | ||
"@com_github_spf13_cobra//:go_default_library", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:public"], | ||
) |
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,119 @@ | ||
/* | ||
Copyright 2020 The Kubernetes 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 cmd | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
"k8s.io/release/pkg/github" | ||
"k8s.io/release/pkg/log" | ||
) | ||
|
||
// rootCmd represents the base command when called without any subcommands | ||
var rootCmd = &cobra.Command{ | ||
Use: "debs [--arch <architectures>] [--channels <channels>]", | ||
Short: "debs creates Debian-based packages for Kubernetes components", | ||
Example: "kubepkg debs --arch amd64 --channels nightly", | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
PersistentPreRunE: initLogging, | ||
RunE: func(*cobra.Command, []string) error { | ||
return run(opts) | ||
}, | ||
} | ||
|
||
type options struct { | ||
githubToken string | ||
org string | ||
repo string | ||
tag string | ||
gcsEndpoint string | ||
logLevel string | ||
} | ||
|
||
var opts = &options{} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
if err := rootCmd.Execute(); err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().StringVar( | ||
&opts.org, | ||
"org", | ||
// TODO: Remove test value | ||
"containernetworking", | ||
"org", | ||
) | ||
|
||
rootCmd.PersistentFlags().StringVar( | ||
&opts.repo, | ||
"repo", | ||
// TODO: Remove test value | ||
"plugins", | ||
"repo", | ||
) | ||
|
||
rootCmd.PersistentFlags().StringVar( | ||
&opts.tag, | ||
"tag", | ||
// TODO: Remove test value | ||
"", | ||
"tag", | ||
) | ||
|
||
rootCmd.PersistentFlags().StringVar( | ||
&opts.gcsEndpoint, | ||
"gcs-endpoint", | ||
// TODO: Remove test value | ||
"k8s-staging-release-test/augustus/cni", | ||
"org", | ||
) | ||
|
||
rootCmd.PersistentFlags().StringVar( | ||
&opts.logLevel, | ||
"log-level", | ||
"info", | ||
"the logging verbosity, either 'panic', 'fatal', 'error', 'warn', 'warning', 'info', 'debug' or 'trace'", | ||
) | ||
} | ||
|
||
func initLogging(*cobra.Command, []string) error { | ||
return log.SetupGlobalLogger(opts.logLevel) | ||
} | ||
|
||
func run(opts *options) error { | ||
// Create a real GitHub API client | ||
gh := github.New() | ||
|
||
if err := gh.DownloadReleaseAssets(opts.org, opts.repo, opts.tag); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// Validate verifies if all set options are valid | ||
func (o *options) Validate() error { | ||
// TODO: Add validation logic for options | ||
return nil | ||
} |
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,23 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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 main | ||
|
||
import "k8s.io/release/cmd/gh2gcs/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ set -o pipefail | |
|
||
RELEASE_TOOLS=( | ||
blocking-testgrid-tests | ||
gh2gcs | ||
kubepkg | ||
krel | ||
) | ||
|
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
Oops, something went wrong.