importcmd

package
v0.2.64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAVEN      = "maven"
	APPSERVER  = "appserver"
	LIBERTY    = "liberty"
	DROPWIZARD = "dropwizard"
)
View Source
const (
	ChartsDir = "charts"
)

Variables

This section is empty.

Functions

func CheckForUsesImage

func CheckForUsesImage(dir, triggersFile string) (bool, error)

CheckForUsesImage checks if the given dir and trigger file has a uses: image which if present assumes we are using uses: inheritance rather than kpt

func IsRemoteClusterGitRepository added in v0.0.203

func IsRemoteClusterGitRepository(dir string) (bool, error)

IsRemoteClusterGitRepository returns true if we have detected a GitOps repository for Jenkins X 3.x

func LoadTektonResourceAsPipelineRun

func LoadTektonResourceAsPipelineRun(data []byte, message string) (*tektonv1beta1.PipelineRun, error)

LoadTektonResourceAsPipelineRun loads a PipelineRun, Pipeline, Task or TaskRun and convert it to a PipelineRun

func NewCmdImport

func NewCmdImport() *cobra.Command

NewCmdImport the cobra command for jx-project import

func PomFlavour

func PomFlavour(packsDir, pomPath string) (string, error)

func QuestionAnswer

func QuestionAnswer(question, answer string) string

QuestionAnswer returns strings like Cobra question/answers for default cli options

func SaveDir

func SaveDir(c *chart.Chart, dest, packName string) error

SaveDir saves a chart as files in a directory.

Types

type CallbackFn

type CallbackFn func() error

CallbackFn callback function

type CreateRepoData

type CreateRepoData struct {
	Organisation string
	RepoName     string
	FullName     string
	Private      bool
}

type ImportDestination

type ImportDestination struct {
	JenkinsX          JenkinsXDestination
	Jenkins           JenkinsDestination
	JenkinsfileRunner JenkinsfileRunnerDestination
}

Destination where do we want to import the project to

type ImportOptions

type ImportOptions struct {
	options.BaseOptions

	Args             []string
	RepoURL          string
	GitProviderURL   string
	DiscoveredGitURL string
	Dir              string
	Organisation     string
	Repository       string
	// Credentials                        string
	AppName      string
	SelectFilter string
	Jenkinsfile  string
	// BranchPattern                      string
	ImportGitCommitMessage string
	Pack                   string
	DockerRegistryOrg      string
	DeployKind             string
	SchedulerName          string
	GitConfDir             string
	PipelineUserName       string
	PipelineServer         string
	// ImportMode                         string
	ServiceAccount                     string
	Namespace                          string
	OperatorNamespace                  string
	BootSecretName                     string
	PipelineCatalogDir                 string
	DisableMaven                       bool
	UseDefaultGit                      bool
	GithubAppInstalled                 bool
	GitHub                             bool
	DryRun                             bool
	SelectAll                          bool
	DisableBuildPack                   bool
	DisableWebhooks                    bool
	DisableDotGitSearch                bool
	DisableStartPipeline               bool
	InitialisedGit                     bool
	WaitForSourceRepositoryPullRequest bool
	NoDevPullRequest                   bool
	IgnoreExistingRepository           bool
	IgnoreCollaborator                 bool
	IgnoreJenkinsXFile                 bool
	PullRequestPollPeriod              time.Duration
	PullRequestPollTimeout             time.Duration
	DeployOptions                      v1.DeployOptions
	GitRepositoryOptions               scm.RepositoryInput
	KubeClient                         kubernetes.Interface
	JXClient                           versioned.Interface
	Input                              input.Interface
	ScmFactory                         scmhelpers.Factory
	Gitter                             gitclient.Interface
	CommandRunner                      cmdrunner.CommandRunner
	DevEnv                             *v1.Environment
	BootScmClient                      *scm.Client

	OnCompleteCallback    func() error
	PostDraftPackCallback CallbackFn

	Destination ImportDestination

	PackFilter func(*Pack)
	// env customization
	EnvName     string
	EnvStrategy string
	NestedRepo  bool
	// contains filtered or unexported fields
}

ImportOptions options struct for jx-project import

func NewCmdImportAndOptions

func NewCmdImportAndOptions() (*cobra.Command, *ImportOptions)

NewCmdImportAndOptions creates the cobra command for jx-project import and the options

func (*ImportOptions) AddAndAcceptCollaborator

func (o *ImportOptions) AddAndAcceptCollaborator(newRepository bool) error

func (*ImportOptions) AddImportFlags

func (o *ImportOptions) AddImportFlags(cmd *cobra.Command, createProject bool)

func (*ImportOptions) CloneDevEnvironment

func (o *ImportOptions) CloneDevEnvironment() (string, error)

CloneDevEnvironment clones the development environment to a directory

func (*ImportOptions) CloneRepository

func (o *ImportOptions) CloneRepository() error

CloneRepository clones a repository

func (*ImportOptions) ConfigureImportOptions

func (o *ImportOptions) ConfigureImportOptions(repoData *CreateRepoData)

ConfigureImportOptions updates the import options struct based on values from the create repo struct

func (*ImportOptions) CreateNewRemoteRepository

func (o *ImportOptions) CreateNewRemoteRepository() error

CreateNewRemoteRepository creates a new remote repository

func (*ImportOptions) CreateProwOwnersAliasesFile

func (o *ImportOptions) CreateProwOwnersAliasesFile() error

CreateProwOwnersAliasesFile creates an OWNERS_ALIASES file in the root of the project assigning the current Git user as an approver and a reviewer.

func (*ImportOptions) CreateProwOwnersFile

func (o *ImportOptions) CreateProwOwnersFile() error

CreateProwOwnersFile creates an OWNERS file in the root of the project assigning the current Git user as an approver and a reviewer. If the file already exists, does nothing.

func (*ImportOptions) DefaultGitIgnore

func (o *ImportOptions) DefaultGitIgnore() error

DefaultGitIgnore creates a default .gitignore

func (*ImportOptions) DefaultValuesFromTeamSettings

func (o *ImportOptions) DefaultValuesFromTeamSettings(settings *v1.TeamSettings) error

DefaultValuesFromTeamSettings defaults the repository options from the given team settings

func (*ImportOptions) DefaultsFromTeamSettings

func (o *ImportOptions) DefaultsFromTeamSettings() error

func (*ImportOptions) DiscoverBuildPack

func (o *ImportOptions) DiscoverBuildPack(dir string, projectConfig *config.ProjectConfig, packConfig string) (string, error)

DiscoverBuildPack discovers the build pack given the build pack configuration

func (*ImportOptions) DiscoverGit

func (o *ImportOptions) DiscoverGit() error

DiscoverGit checks if there is a git clone or prompts the user to import it

func (*ImportOptions) EvaluateBuildPack

func (o *ImportOptions) EvaluateBuildPack(devEnvCloneDir, jenkinsfile string) error

EvaluateBuildPack performs an evaluation of the build pack on the current source

func (*ImportOptions) GetGitRepositoryDetails

func (o *ImportOptions) GetGitRepositoryDetails() (*CreateRepoData, error)

GetGitRepositoryDetails determines the git repository details to use during the import command

func (*ImportOptions) GetOrganisation

func (o *ImportOptions) GetOrganisation() string

GetOrganisation gets the organisation from the RepoURL (if in the github format of github.com/org/repo). It will do this in preference to the Organisation field (if set). If the repo URL does not implicitly specify an organisation then the Organisation specified in the options is used.

func (*ImportOptions) GetOwner

func (o *ImportOptions) GetOwner(gitUsername string) (string, error)

func (*ImportOptions) GetReporter

func (o *ImportOptions) GetReporter() ImportReporter

GetReporter returns the reporter interface

func (*ImportOptions) Git

Git returns the gitter - lazily creating one if required

func (*ImportOptions) HasJenkinsfile

func (o *ImportOptions) HasJenkinsfile() (string, error)

HasJenkinsfile returns the ile name if there is a Jenkinsfile or empty string if there is not

func (*ImportOptions) InitBuildPacks

func (o *ImportOptions) InitBuildPacks(i *InvokeDraftPack) (string, *v1.TeamSettings, error)

InitBuildPacks initialise the build packs

func (*ImportOptions) InvokeDraftPack

func (o *ImportOptions) InvokeDraftPack(i *InvokeDraftPack) (string, error)

InvokeDraftPack invokes a draft pack copying in a Jenkinsfile if required

func (*ImportOptions) IsGitHubAppMode

func (o *ImportOptions) IsGitHubAppMode() (bool, error)

func (*ImportOptions) PickCatalogFolderName

func (o *ImportOptions) PickCatalogFolderName(dir, chosenPack string) (string, error)

PickCatalogFolderName if not in batch mode lets confirm to the user which catalog folder we are going to use

func (*ImportOptions) PickImportDestination

func (o *ImportOptions) PickImportDestination(devEnvCloneDir, jenkinsfile string) (ImportDestination, error)

PickImportDestination picks where to import the project to

func (*ImportOptions) PickNewOrExistingGitRepository

func (o *ImportOptions) PickNewOrExistingGitRepository() (*CreateRepoData, error)

func (*ImportOptions) PickOwner

func (o *ImportOptions) PickOwner(userName string) (string, error)

PickOwner picks a git owner

func (*ImportOptions) PickPipelineCatalog

PickPipelineCatalog lets you pick a build pack

func (*ImportOptions) PickRepoName

func (o *ImportOptions) PickRepoName(owner, defaultName string, allowExistingRepo bool) (string, error)

PickRepoName picks the repository name

func (*ImportOptions) ReplacePlaceholders

func (o *ImportOptions) ReplacePlaceholders(gitServerName, dockerRegistryOrg string) error

ReplacePlaceholders replaces app name, git server name, git org, and docker registry org placeholders

func (*ImportOptions) Run

func (o *ImportOptions) Run() error

Run executes the command

func (*ImportOptions) SetReporter

func (o *ImportOptions) SetReporter(reporter ImportReporter)

SetReporter overrides the reporter interface

func (*ImportOptions) Validate

func (o *ImportOptions) Validate() error

Validate validates the command line options

func (*ImportOptions) ValidateRepositoryName

func (o *ImportOptions) ValidateRepositoryName(owner, name string) error

ValidateRepositoryName validates the repository does not exist

type ImportReporter

type ImportReporter interface {
	// UsingGitUserName report progress
	UsingGitUserName(username string)
	// PushedGitRepository report progress
	PushedGitRepository(url string)
	// GitRepositoryCreated report progress
	GitRepositoryCreated()
	// CreatedDevRepoPullRequest report progress
	CreatedDevRepoPullRequest(prURL string, devGitURL string)
	// CreatedProject report progress
	CreatedProject(genDir string)
	// GeneratedQuickStartAt report progress
	GeneratedQuickStartAt(genDir string)

	// Trace report generic trace message
	Trace(message string, options ...interface{})
}

ImportReporter an interface for reporting updates from the process

type InvokeDraftPack

type InvokeDraftPack struct {
	Dir                         string
	DevEnvCloneDir              string
	CustomDraftPack             string
	Jenkinsfile                 string
	InitialisedGit              bool
	DisableAddFiles             bool
	UseNextGenPipeline          bool
	CreateJenkinsxYamlIfMissing bool
	ProjectConfig               *config.ProjectConfig
}

InvokeDraftPack used to pass arguments into the draft pack invocation

type JenkinsDestination

type JenkinsDestination struct {
	Server  string
	Enabled bool
}

JenkinsDestination configures how to import to a Jenkins server

type JenkinsXDestination

type JenkinsXDestination struct {
	Enabled bool
}

JenkinsXDestination configures how to import to Jenkins X

type JenkinsfileRunnerDestination

type JenkinsfileRunnerDestination struct {
	Enabled bool
	Image   string
}

JenkinsfileRunnerDestination configures how to import to JenkinfilesRunner

type LogImportReporter

type LogImportReporter struct {
}

LogImportReporter default implementation to log to the console

func (*LogImportReporter) CreatedDevRepoPullRequest

func (r *LogImportReporter) CreatedDevRepoPullRequest(prURL, devGitURL string)

CreatedDevRepoPullRequest report progress

func (*LogImportReporter) CreatedProject

func (r *LogImportReporter) CreatedProject(genDir string)

CreatedProject report progress

func (*LogImportReporter) GeneratedQuickStartAt

func (r *LogImportReporter) GeneratedQuickStartAt(genDir string)

GeneratedQuickStartAt report progress

func (*LogImportReporter) GitRepositoryCreated

func (r *LogImportReporter) GitRepositoryCreated()

GitRepositoryCreated report progress

func (*LogImportReporter) PushedGitRepository

func (r *LogImportReporter) PushedGitRepository(repoURL string)

PushedGitRepository report progress

func (*LogImportReporter) Trace

func (r *LogImportReporter) Trace(message string, args ...interface{})

Trace report generic trace message

func (*LogImportReporter) UsingGitUserName

func (r *LogImportReporter) UsingGitUserName(username string)

UsingGitUserName report progress

type Pack

type Pack struct {
	// Chart is the Helm chart to be installed with the Pack.
	Charts []*chart.Chart
	// Files are the files inside the Pack that will be installed.
	Files map[string]io.ReadCloser
}

Pack defines a Draft Starter Pack.

func FromDir

func FromDir(dir string) (*Pack, error)

CREDIT https://github.com/Azure/draft/blob/9705e36dc23c27c9ef54dc2469dd86ac6093f0f4/pkg/draft/pack/pack.go FromDir takes a string name, tries to resolve it to a file or directory, and then loads it.

This is the preferred way to load a pack. It will discover the pack encoding and hand off to the appropriate pack reader.

func (*Pack) SaveDir

func (p *Pack) SaveDir(dest, packName string) error

SaveDir saves a pack as files in a directory.

Directories

Path Synopsis
test_data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL