Skip to content

Commit d82c896

Browse files
committed
fix(action): enable CGO dependencies for golangci-lint action
This change will install and enable CGO dependencies for the golangci-lint GitHub action. The golangci-lint GitHub action was failing to import the saml2aws package, because the package uses C functions and or libraries. The addition of CGO dependencies allow the golangci-lint GitHub action to complete as expected. Signed-off-by: Rob Casale <rcasale48@verizon.net>
1 parent d93cd58 commit d82c896

File tree

34 files changed

+101
-62
lines changed

34 files changed

+101
-62
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ updates:
33
- package-ecosystem: "gomod"
44
directory: "/"
55
schedule:
6-
interval: "weekly"
6+
interval: "monthly"
77
- package-ecosystem: "gomod"
88
directory: "/hack/tools"
99
schedule:
10-
interval: "weekly"
10+
interval: "monthly"

.github/workflows/golangci-lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ jobs:
2020
go-version: '1.22'
2121
cache: false
2222
- uses: actions/checkout@v4
23+
- name: Install CGO dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y build-essential pkg-config gcc g++ libusb-1.0-0-dev libudev-dev libhidapi-dev
2327
- name: golangci-lint
2428
uses: golangci/golangci-lint-action@v8
29+
env:
30+
CGO_ENABLED: 1
2531
with:
2632
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
2733
version: latest

api/v1alpha1/configuration_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type ListItem struct {
7272
type Configuration struct {
7373
metav1.TypeMeta `json:",inline"`
7474

75-
Spec ConfigurationSpec `json:"spec,omitempty"`
75+
Spec ConfigurationSpec `json:"spec"`
7676
}
7777

7878
// NewConfiguration will create a new configuration
@@ -109,15 +109,15 @@ func (c *Configuration) ToTable() *metav1.Table {
109109
if c.Spec.Global != nil {
110110
convertedArgs := argsToString(c.Spec.Global)
111111
row := metav1.TableRow{
112-
Cells: []interface{}{"GLOBAL", convertedArgs},
112+
Cells: []any{"GLOBAL", convertedArgs},
113113
}
114114
table.Rows = append(table.Rows, row)
115115
}
116116

117117
for providerKey, providerDefaults := range c.Spec.Providers {
118118
convertedArgs := argsToString(providerDefaults)
119119
row := metav1.TableRow{
120-
Cells: []interface{}{providerKey, convertedArgs},
120+
Cells: []any{providerKey, convertedArgs},
121121
}
122122
table.Rows = append(table.Rows, row)
123123
}

api/v1alpha1/history_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ type HistoryEntryStatus struct {
6060
// HistoryEntry represents a history entry
6161
type HistoryEntry struct {
6262
metav1.TypeMeta `json:",inline"`
63-
metav1.ObjectMeta `json:"metadata,omitempty"`
63+
metav1.ObjectMeta `json:"metadata"`
6464

65-
Spec HistoryEntrySpec `json:"spec,omitempty"`
66-
Status HistoryEntryStatus `json:"status,omitempty"`
65+
Spec HistoryEntrySpec `json:"spec"`
66+
Status HistoryEntryStatus `json:"status"`
6767
}
6868

6969
// +kubebuilder:object:root=true
7070

7171
// HistoryEntryList is a list of history entries
7272
type HistoryEntryList struct {
7373
metav1.TypeMeta `json:",inline"`
74-
metav1.ListMeta `json:"metadata,omitempty"`
74+
metav1.ListMeta `json:"metadata"`
7575

7676
Items []HistoryEntry `json:"items"`
7777
}
@@ -244,7 +244,7 @@ func (l *HistoryEntryList) ToTable(currentContextID string) *metav1.Table {
244244
username := entry.Spec.Flags["username"]
245245

246246
row = metav1.TableRow{
247-
Cells: []interface{}{
247+
Cells: []any{
248248
currentContextIndicator,
249249
entry.ObjectMeta.Name,
250250
*entry.Spec.Alias,

internal/commands/alias/add.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ func addCommand() (*cobra.Command, error) { //nolint: dupl
6565
PreRunE: func(cmd *cobra.Command, args []string) error {
6666
flags.BindFlags(cmd)
6767
flags.PopulateConfigFromCommand(cmd, cfg)
68+
6869
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
6970
if err != nil {
7071
return fmt.Errorf("getting common config: %w", err)
7172
}
73+
7274
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
7375
return fmt.Errorf("applying app config: %w", err)
7476
}
@@ -77,6 +79,7 @@ func addCommand() (*cobra.Command, error) { //nolint: dupl
7779
},
7880
RunE: func(cmd *cobra.Command, args []string) error {
7981
zap.S().Debug("running `alias add` command")
82+
8083
params := &app.AliasAddInput{}
8184

8285
if err := config.Unmarshall(cfg, params); err != nil {
@@ -87,6 +90,7 @@ func addCommand() (*cobra.Command, error) { //nolint: dupl
8790
if err != nil {
8891
return fmt.Errorf("getting history loader with path %s: %w", params.Location, err)
8992
}
93+
9094
store, err := history.NewStore(maxHistoryEntries, historyLoader)
9195
if err != nil {
9296
return fmt.Errorf("creating history store: %w", err)

internal/commands/alias/ls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ func lsCommand() (*cobra.Command, error) { //nolint: dupl
6868
PreRunE: func(cmd *cobra.Command, args []string) error {
6969
flags.BindFlags(cmd)
7070
flags.PopulateConfigFromCommand(cmd, cfg)
71+
7172
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
7273
if err != nil {
7374
return fmt.Errorf("getting common config: %w", err)
7475
}
76+
7577
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
7678
return fmt.Errorf("applying app config: %w", err)
7779
}
@@ -80,6 +82,7 @@ func lsCommand() (*cobra.Command, error) { //nolint: dupl
8082
},
8183
RunE: func(cmd *cobra.Command, args []string) error {
8284
zap.S().Debug("running `alias ls` command")
85+
8386
params := &app.AliasListInput{}
8487

8588
if err := config.Unmarshall(cfg, params); err != nil {
@@ -90,6 +93,7 @@ func lsCommand() (*cobra.Command, error) { //nolint: dupl
9093
if err != nil {
9194
return fmt.Errorf("getting history loader with path %s: %w", params.Location, err)
9295
}
96+
9397
store, err := history.NewStore(maxHistoryEntries, historyLoader)
9498
if err != nil {
9599
return fmt.Errorf("creating history store: %w", err)

internal/commands/alias/remove.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ func removeCommand() (*cobra.Command, error) { //nolint: dupl
6969
PreRunE: func(cmd *cobra.Command, args []string) error {
7070
flags.BindFlags(cmd)
7171
flags.PopulateConfigFromCommand(cmd, cfg)
72+
7273
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
7374
if err != nil {
7475
return fmt.Errorf("getting common config: %w", err)
7576
}
77+
7678
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
7779
return fmt.Errorf("applying app config: %w", err)
7880
}
@@ -81,6 +83,7 @@ func removeCommand() (*cobra.Command, error) { //nolint: dupl
8183
},
8284
RunE: func(cmd *cobra.Command, args []string) error {
8385
zap.S().Debug("running `alias remove` command")
86+
8487
params := &app.AliasRemoveInput{}
8588

8689
if err := config.Unmarshall(cfg, params); err != nil {
@@ -91,6 +94,7 @@ func removeCommand() (*cobra.Command, error) { //nolint: dupl
9194
if err != nil {
9295
return fmt.Errorf("getting history loader with path %s: %w", params.Location, err)
9396
}
97+
9498
store, err := history.NewStore(maxHistoryEntries, historyLoader)
9599
if err != nil {
96100
return fmt.Errorf("creating history store: %w", err)

internal/commands/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ func Command() (*cobra.Command, error) {
7373
PreRunE: func(cmd *cobra.Command, args []string) error {
7474
flags.BindFlags(cmd)
7575
flags.PopulateConfigFromCommand(cmd, cfg)
76+
7677
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
7778
if err != nil {
7879
return fmt.Errorf("getting common config: %w", err)
7980
}
81+
8082
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
8183
return fmt.Errorf("applying app config: %w", err)
8284
}
@@ -91,6 +93,7 @@ func Command() (*cobra.Command, error) {
9193
}
9294

9395
a := app.New()
96+
9497
return a.Configuration(cmd.Context(), input)
9598
},
9699
}

internal/commands/history/export.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ func exportCommand() (*cobra.Command, error) {
6060
PreRunE: func(cmd *cobra.Command, args []string) error {
6161
flags.BindFlags(cmd)
6262
flags.PopulateConfigFromCommand(cmd, cfg)
63+
6364
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
6465
if err != nil {
6566
return fmt.Errorf("getting common config: %w", err)
6667
}
68+
6769
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
6870
return fmt.Errorf("applying app config: %w", err)
6971
}
@@ -72,6 +74,7 @@ func exportCommand() (*cobra.Command, error) {
7274
},
7375
RunE: func(cmd *cobra.Command, args []string) error {
7476
zap.S().Debug("running `history export` command")
77+
7578
params := &app.HistoryExportInput{}
7679

7780
if err := config.Unmarshall(cfg, params); err != nil {
@@ -82,6 +85,7 @@ func exportCommand() (*cobra.Command, error) {
8285
if err != nil {
8386
return fmt.Errorf("getting history loader with path %s: %w", params.Location, err)
8487
}
88+
8589
store, err := history.NewStore(maxHistoryEntries, historyLoader)
8690
if err != nil {
8791
return fmt.Errorf("creating history store: %w", err)

internal/commands/history/import.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ func importCommand() (*cobra.Command, error) {
7272
PreRunE: func(cmd *cobra.Command, args []string) error {
7373
flags.BindFlags(cmd)
7474
flags.PopulateConfigFromCommand(cmd, cfg)
75+
7576
commonCfg, err := helpers.GetCommonConfig(cmd, cfg)
7677
if err != nil {
7778
return fmt.Errorf("getting common config: %w", err)
7879
}
80+
7981
if err := config.ApplyToConfigSet(commonCfg.ConfigFile, cfg); err != nil {
8082
return fmt.Errorf("applying app config: %w", err)
8183
}
@@ -84,6 +86,7 @@ func importCommand() (*cobra.Command, error) {
8486
},
8587
RunE: func(cmd *cobra.Command, args []string) error {
8688
zap.S().Debug("running `history import` command")
89+
8790
params := &app.HistoryImportInput{}
8891

8992
if err := config.Unmarshall(cfg, params); err != nil {
@@ -94,6 +97,7 @@ func importCommand() (*cobra.Command, error) {
9497
if err != nil {
9598
return fmt.Errorf("getting history loader with path %s: %w", params.Location, err)
9699
}
100+
97101
store, err := history.NewStore(maxHistoryEntries, historyLoader)
98102
if err != nil {
99103
return fmt.Errorf("creating history store: %w", err)

0 commit comments

Comments
 (0)