-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ConductorOne/marcos/feat/roles
ref: Refresh connector pattern
- Loading branch information
Showing
2,543 changed files
with
3,570,536 additions
and
1,940,515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/conductorone/baton-sdk/pkg/cli" | ||
"github.com/spf13/cobra" | ||
"github.com/conductorone/baton-sdk/pkg/field" | ||
) | ||
|
||
// config defines the external configuration required for the connector to run. | ||
type config struct { | ||
cli.BaseConfig `mapstructure:",squash"` // Puts the base config options in the same place as the connector options | ||
|
||
CompanyDomain string `mapstructure:"company-domain"` | ||
ApiKey string `mapstructure:"api-key"` | ||
} | ||
|
||
// validateConfig is run after the configuration is loaded, and should return an error if it isn't valid. | ||
func validateConfig(ctx context.Context, cfg *config) error { | ||
if cfg.CompanyDomain == "" { | ||
return fmt.Errorf("company domain is missing") | ||
var ( | ||
CompanyDomainField = field.StringField( | ||
"company-domain", | ||
field.WithDescription("The company domain for your BambooHR account"), | ||
field.WithRequired(true), | ||
) | ||
ApiKeyField = field.StringField( | ||
"api-key", | ||
field.WithDescription("The api key for your BambooHR account"), | ||
field.WithRequired(true), | ||
) | ||
configurationFields = []field.SchemaField{ | ||
CompanyDomainField, | ||
ApiKeyField, | ||
} | ||
if cfg.ApiKey == "" { | ||
return fmt.Errorf("api key is missing") | ||
} | ||
return nil | ||
} | ||
|
||
// cmdFlags sets the cmdFlags required for the connector. | ||
func cmdFlags(cmd *cobra.Command) { | ||
cmd.PersistentFlags().String("company-domain", "", "The company domain for your BambooHR account. ($BATON_COMPANY_DOMAIN)") | ||
cmd.PersistentFlags().String("api-key", "", "The api key for your BambooHR account. ($BATON_API_KEY)") | ||
} | ||
Configuration = field.NewConfiguration(configurationFields) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.