diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4155996 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 + +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000..cb83506 --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,9 @@ + + +Output of `helm version`: + +Output of `helm-mapkubeapis`: + +Output of `kubectl version`: + +Cloud Provider/Platform (AKS, GKE, EKS, etc.): diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..2c89be4 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ + + +**What this PR does / why we need it**: + +**Special notes for your reviewer**: + +**If applicable**: +- [ ] this PR contains documentation +- [ ] this PR contains unit tests +- [ ] this PR has been tested for backwards compatibility diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..1001a14 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: build-test + +on: + push: + branches: + - "main" + - "release-**" + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22" + - name: Run Test + run: make test + - name: Build + run: make build diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..2a28fee --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,21 @@ +name: golangci-lint + +on: + push: + pull_request: + +jobs: + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22" + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58 diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..e7c6552 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + create: + tags: + - v* + push: + branches: + - main + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - + name: Set Up Go + uses: actions/setup-go@v5 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 13ab009..84ec399 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ bin/ dist/ tmp/ releases/ + +.idea/ diff --git a/cmd/mapkubeapis/map.go b/cmd/mapkubeapis/map.go index aa2efe1..09a606b 100644 --- a/cmd/mapkubeapis/map.go +++ b/cmd/mapkubeapis/map.go @@ -49,7 +49,10 @@ func newMapCmd(out io.Writer, args []string) *cobra.Command { SilenceUsage: true, Args: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { - cmd.Help() + err := cmd.Help() + if err != nil { + return err + } os.Exit(1) } else if len(args) > 1 { return errors.New("only one release name may be passed at a time") @@ -61,7 +64,12 @@ func newMapCmd(out io.Writer, args []string) *cobra.Command { } flags := cmd.PersistentFlags() - flags.Parse(args) + flags.ParseErrorsWhitelist.UnknownFlags = true + err := flags.Parse(args) + if err != nil { + return nil + } + settings = new(EnvSettings) // Get the default mapping file diff --git a/pkg/mapping/mapfile.go b/pkg/mapping/mapfile.go index d056aa6..29f9161 100644 --- a/pkg/mapping/mapfile.go +++ b/pkg/mapping/mapfile.go @@ -17,14 +17,14 @@ limitations under the License. package mapping import ( - "io/ioutil" + "os" "sigs.k8s.io/yaml" ) // LoadMapfile loads a Map.yaml file into a *Metadata. func LoadMapfile(filename string) (*Metadata, error) { - b, err := ioutil.ReadFile(filename) + b, err := os.ReadFile(filename) if err != nil { return nil, err } diff --git a/pkg/v3/connect.go b/pkg/v3/connect.go index 87226b4..1f34d04 100644 --- a/pkg/v3/connect.go +++ b/pkg/v3/connect.go @@ -55,6 +55,9 @@ func GetActionConfig(namespace string, kubeConfig common.KubeConfig) (*action.Co func debug(format string, v ...interface{}) { if settings.Debug { format = fmt.Sprintf("[debug] %s\n", format) - log.Output(2, fmt.Sprintf(format, v...)) + err := log.Output(2, fmt.Sprintf(format, v...)) + if err != nil { + return + } } }