Skip to content

Commit

Permalink
Merge pull request #138 from robertsirc/update-to-gh-actions
Browse files Browse the repository at this point in the history
Update to gh actions
  • Loading branch information
mattfarina authored Jul 26, 2024
2 parents 7c1fcc2 + de944df commit 3b2604a
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
9 changes: 9 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- If you need help or think you have found a bug, please help us with your issue by entering the following information (otherwise you can delete this text): -->

Output of `helm version`:

Output of `helm-mapkubeapis`:

Output of `kubectl version`:

Cloud Provider/Platform (AKS, GKE, EKS, etc.):
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Thanks for sending a pull request! Here are some tips for you:
1. Make sure to read the Contributing Guide before submitting your PR:
https://github.com/helm/helm-mapkubeapis/blob/main/CONTRIBUTING.md
2. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context.-->

**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
28 changes: 28 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ bin/
dist/
tmp/
releases/

.idea/
12 changes: 10 additions & 2 deletions cmd/mapkubeapis/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/mapping/mapfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/v3/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 3b2604a

Please sign in to comment.