fix: fix static bin paths and required flags (#50)

This commit is contained in:
Robert Kaussow 2024-05-04 14:35:41 +02:00 committed by GitHub
parent 93819eb5b2
commit 2f1a89a6cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 22 deletions

View File

@ -28,6 +28,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
Name: "inventory",
Usage: "path to inventory file",
EnvVars: []string{"PLUGIN_INVENTORY", "PLUGIN_INVENTORIES"},
Required: true,
Destination: &settings.Inventories,
Category: category,
},
@ -35,6 +36,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
Name: "playbook",
Usage: "list of playbooks to apply",
EnvVars: []string{"PLUGIN_PLAYBOOK", "PLUGIN_PLAYBOOKS"},
Required: true,
Destination: &settings.Playbooks,
Category: category,
},

View File

@ -76,7 +76,7 @@ properties:
description: |
Path to inventory file.
type: list
required: false
required: true
- name: limit
description: |
@ -115,7 +115,7 @@ properties:
description: |
List of playbooks to apply.
type: list
required: false
required: true
- name: private_key
description: |

View File

@ -18,10 +18,10 @@ const (
ansibleFolder = "/etc/ansible"
ansibleConfig = "/etc/ansible/ansible.cfg"
pipBin = "/usr/bin/pip"
ansibleBin = "/usr/bin/ansible"
ansibleGalaxyBin = "/usr/bin/ansible-galaxy"
ansiblePlaybookBin = "/usr/bin/ansible-playbook"
pipBin = "/usr/local/bin/pip"
ansibleBin = "/usr/local/bin/ansible"
ansibleGalaxyBin = "/usr/local/bin/ansible-galaxy"
ansiblePlaybookBin = "/usr/local/bin/ansible-playbook"
strictFilePerm = 0o600
)

View File

@ -2,7 +2,6 @@ package plugin
import (
"context"
"errors"
"fmt"
"os"
@ -10,13 +9,7 @@ import (
"golang.org/x/sys/execabs"
)
var (
ErrPluginPlaybookNotSet = errors.New("playbook is required")
ErrPluginInventoryNotSet = errors.New("inventory is required")
)
//nolint:revive
func (p *Plugin) run(ctx context.Context) error {
func (p *Plugin) run(_ context.Context) error {
if err := p.Validate(); err != nil {
return fmt.Errorf("validation failed: %w", err)
}
@ -30,14 +23,6 @@ func (p *Plugin) run(ctx context.Context) error {
// Validate handles the settings validation of the plugin.
func (p *Plugin) Validate() error {
if len(p.Settings.Playbooks.Value()) == 0 {
return ErrPluginPlaybookNotSet
}
if len(p.Settings.Inventories.Value()) == 0 {
return ErrPluginInventoryNotSet
}
return nil
}