-
Notifications
You must be signed in to change notification settings - Fork 294
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 #959 from buildpacks/921-config-t-builders
Add config trusted-builders subcommands
- Loading branch information
Showing
20 changed files
with
677 additions
and
156 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,64 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/buildpacks/pack/internal/config" | ||
"github.com/buildpacks/pack/logging" | ||
) | ||
|
||
func NewConfigCommand(logger logging.Logger, cfg config.Config, cfgPath string) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "config", | ||
Short: "Interact with Pack's configuration", | ||
RunE: nil, | ||
} | ||
|
||
cmd.AddCommand(trustedBuilder(logger, cfg, cfgPath)) | ||
return cmd | ||
} | ||
|
||
type editCfgFunc func(args []string, logger logging.Logger, cfg config.Config, cfgPath string) error | ||
|
||
func generateAdd(cmdName string, logger logging.Logger, cfg config.Config, cfgPath string, addFunc editCfgFunc) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "add", | ||
Args: cobra.ExactArgs(1), | ||
Short: fmt.Sprintf("Add a %s", cmdName), | ||
RunE: logError(logger, func(cmd *cobra.Command, args []string) error { | ||
return addFunc(args, logger, cfg, cfgPath) | ||
}), | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func generateRemove(cmdName string, logger logging.Logger, cfg config.Config, cfgPath string, rmFunc editCfgFunc) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "remove", | ||
Args: cobra.ExactArgs(1), | ||
Short: fmt.Sprintf("Remove a %s", cmdName), | ||
RunE: logError(logger, func(cmd *cobra.Command, args []string) error { | ||
return rmFunc(args, logger, cfg, cfgPath) | ||
}), | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
type listFunc func(logger logging.Logger, cfg config.Config) | ||
|
||
func generateListCmd(cmdName string, logger logging.Logger, cfg config.Config, listFunc listFunc) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: fmt.Sprintf("List %s", cmdName), | ||
RunE: logError(logger, func(cmd *cobra.Command, args []string) error { | ||
listFunc(logger, cfg) | ||
return nil | ||
}), | ||
} | ||
|
||
return cmd | ||
} |
Oops, something went wrong.