-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDI-1459: CLI v2 Command Connector: Platform Export / PingOne (Early …
…access) (#39) * PDI-1459: CLI v2 Command Connector: Platform Export / PingOne (Early access) - Add framework and one resource export (pingone_agreement) to pingctl. Further work will follow this adding remaining resources to export subcommand. - Update test funcs to use NewRootCommand() to gain viper functionality in test cases. - Update most output messages to use Error instead of Fatal to propigate error messages back through the call stack. This is useful for chaining error messages to trace what pingctl was trying to do, as well as make test cases recieve stdout for error messaging. - Update Cobra Run functions to use RunE to allow error propigation as well. - Update export.go to use PingOne SDK and loop through user specified services exports. Use user define export format and override varibles to do so. Default export output directory to pwd. Fail to export if previous export files are present. - Update ExportableResource to define an ImportBlock struct to house API data and use in text template output to file. Add utility ResourceType function to interface as well. - Create pingone_platform_connector.go to define a connector for the pingone platform service. Pingone SSO service to be added in further work. - Create resources subfolder structure for connectors to define each individual resource, as well as their sdk specific logic or exporting data. * Remove generated import block export for pingone_agreement resource. * PR Review changes. Moved template to be embedded. Added custom type for service parameter on the export command. * Remove noop from login/logout commands. Update export command test to write to a temp dir to cleanup make devcheck locally * Update workflow to use github secrets for environment variables * Add custom type for export format in export.go, and move cobra custom types to custom_types.go * reduce scope of serviceName in connector, and verify custom types for export command implement pflag.Value interface. * Update export command to use viper generated env vars, and improve user messaging on success path * Update workflow to use new viper env vars for PingOne SDK client * Add nil check to MultiService Set function
- Loading branch information
1 parent
1e74302
commit 83dcc5c
Showing
20 changed files
with
546 additions
and
117 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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package platform | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/pingidentity/pingctl/internal/connector" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
const ( | ||
serviceEnumPlatform = "pingone-platform" | ||
) | ||
|
||
type MultiService struct { | ||
services *[]string | ||
} | ||
|
||
type ExportFormat string | ||
|
||
// Verify that the custom type satisfies the pflag.Value interface | ||
var ( | ||
_ pflag.Value = (*MultiService)(nil) | ||
_ pflag.Value = (*ExportFormat)(nil) | ||
) | ||
|
||
// Implement pflag.Value interface for custom type in cobra service parameter | ||
|
||
func (s *MultiService) Set(service string) error { | ||
switch service { | ||
case serviceEnumPlatform: | ||
if *s.services == nil { | ||
s.services = &[]string{} | ||
} | ||
*s.services = append(*s.services, service) | ||
default: | ||
return fmt.Errorf("unrecognized service %q", service) | ||
} | ||
return nil | ||
} | ||
|
||
func (s *MultiService) Type() string { | ||
return "string" | ||
} | ||
|
||
func (s *MultiService) String() string { | ||
return fmt.Sprintf("[ %s ]", strings.Join(*s.services, ", ")) | ||
} | ||
|
||
// Implement pflag.Value interface for custom type in cobra export-format parameter | ||
|
||
func (s *ExportFormat) Set(format string) error { | ||
switch format { | ||
case connector.ENUMEXPORTFORMAT_HCL: | ||
*s = ExportFormat(format) | ||
default: | ||
return fmt.Errorf("unrecognized export format %q", format) | ||
} | ||
return nil | ||
} | ||
|
||
func (s *ExportFormat) Type() string { | ||
return "string" | ||
} | ||
|
||
func (s *ExportFormat) String() string { | ||
return string(*s) | ||
} |
Oops, something went wrong.