Skip to content

Commit

Permalink
Merge pull request #9061 from smartcontractkit/chore/2.0.0-merge-release
Browse files Browse the repository at this point in the history
release/2.0.0 -> develop
  • Loading branch information
ajgrande924 authored Apr 26, 2023
2 parents fcf7471 + ad23321 commit 71b57eb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ jobs:
uses: smartcontractkit/chainlink-solana/.github/actions/build_contract_artifacts@23816fcf7d380a30c87b6d87e4fb0ca94419b259 # stable action on April 17 2023
with:
ref: ${{ needs.get_solana_sha.outputs.sha }}

solana-build-test-image:
environment: integration
permissions:
Expand Down
19 changes: 15 additions & 4 deletions core/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ func NewApp(client *Client) *cli.App {
client.CloseLogger = closeLggr
}

err := client.setConfigFromFlags(&opts, c)
if err != nil {
return err
if c.IsSet("config") || c.IsSet("secrets") {
if err := client.setConfig(&opts, c.StringSlice("config"), c.String("secrets")); err != nil {
return err
}
client.configInitialized = true
}

if c.Bool("json") {
Expand Down Expand Up @@ -195,7 +197,16 @@ func NewApp(client *Client) *cli.App {
},
},
Before: func(c *cli.Context) error {
return client.setConfigFromFlags(&opts, c)
if client.configInitialized {
if c.IsSet("config") || c.IsSet("secrets") {
// invalid mix of flags here and root
return fmt.Errorf("multiple commands with --config or --secrets flags. only one command may specify these flags. when secrets are used, they must be specific together in the same command")
}
// flags at root
return nil
}
// flags here, or ENV VAR only
return client.setConfig(&opts, c.StringSlice("config"), c.String("secrets"))
},
},
{
Expand Down
25 changes: 5 additions & 20 deletions core/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/getsentry/sentry-go"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/urfave/cli"
clipkg "github.com/urfave/cli"
"go.uber.org/multierr"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -92,30 +91,16 @@ func (cli *Client) errorOut(err error) error {
return nil
}

func (cli *Client) setConfigFromFlags(opts *chainlink.GeneralConfigOpts, ctx *cli.Context) error {

configToProcess := ctx.IsSet("config") || ctx.IsSet("secrets")
if !configToProcess {
return nil
}

if cli.configInitialized && configToProcess {
return fmt.Errorf("multiple commands with --config or --secrets flags. only one command may specify these flags. when secrets are used, they must be specific together in the same command")
}

cli.configInitialized = true

fileNames := ctx.StringSlice("config")
if err := loadOpts(opts, fileNames...); err != nil {
func (cli *Client) setConfig(opts *chainlink.GeneralConfigOpts, configFiles []string, secretsFile string) error {
if err := loadOpts(opts, configFiles...); err != nil {
return err
}

secretsTOML := ""
if ctx.IsSet("secrets") {
secretsFileName := ctx.String("secrets")
b, err := os.ReadFile(secretsFileName)
if secretsFile != "" {
b, err := os.ReadFile(secretsFile)
if err != nil {
return errors.Wrapf(err, "failed to read secrets file: %s", secretsFileName)
return errors.Wrapf(err, "failed to read secrets file: %s", secretsFile)
}
secretsTOML = string(b)
}
Expand Down
8 changes: 6 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- unreleased -->
## [dev]

...

<!-- unreleasedstop -->

## 2.0.0 - 2023-04-20

### Added

### Changed
Expand Down Expand Up @@ -40,8 +46,6 @@ if any Database-specific configuration is invalid.

- Configuration with legacy environment variables is no longer supported. TOML is required.

<!-- unreleasedstop -->

## 1.13.1 - 2023-04-06

### Fixed
Expand Down

0 comments on commit 71b57eb

Please sign in to comment.