Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for create env on prow and add filtering to jx get build log on tekton #3286

Merged
merged 6 commits into from Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/jx/cmd/create_env.go
Expand Up @@ -221,14 +221,14 @@ func (o *CreateEnvOptions) Run() error {
return err
}
if o.Prow {
repo := fmt.Sprintf("%s/environment-%s-%s", gitInfo.Organisation, o.Prefix, env.Name)
repo := fmt.Sprintf("%s/%s", gitInfo.Organisation, gitInfo.Name)
err = prow.AddEnvironment(kubeClient, []string{repo}, devEnv.Spec.Namespace, env.Spec.Namespace, &devEnv.Spec.TeamSettings)
if err != nil {
return fmt.Errorf("failed to add repo %s to Prow config in namespace %s: %v", repo, env.Spec.Namespace, err)
}
}
/* It is important this pull secret handling goes after any namespace creation code; the service account exists in the created namespace */

/* It is important this pull secret handling goes after any namespace creation code; the service account exists in the created namespace */
if o.PullSecrets != "" {
// We need the namespace to be created first - do the check
if !o.GitOpsMode {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jx/cmd/get_build_logs.go
Expand Up @@ -502,7 +502,7 @@ func (o *GetBuildLogsOptions) loadPipelines(kubeClient kubernetes.Interface, tek
log.Warnf("Error creating PipelineRunInfo for PipelineRun %s: %s\n", pr.Name, err)
return names, defaultName, buildMap, pipelineMap, err
}
if pri != nil {
if pri != nil && o.BuildFilter.BuildMatches(pri.ToBuildPodInfo()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll eventually want to change BuildFilter to be a PipelineRunInfoFilter, but it does seem easier to just keep it compatible for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - or we could have a filter interface which we support on both BuildRunInfo and PipeilneRunInfo that both take the filter parmeters and do their thing

buildInfos = append(buildInfos, pri)
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/jx/cmd/install.go
Expand Up @@ -338,9 +338,9 @@ func (options *InstallOptions) addInstallFlags(cmd *cobra.Command, includesInit
cmd.Flags().StringVarP(&flags.DockerRegistry, "docker-registry", "", "", "The Docker Registry host or host:port which is used when tagging and pushing images. If not specified it defaults to the internal registry unless there is a better provider default (e.g. ECR on AWS/EKS)")
cmd.Flags().StringVarP(&flags.ExposeControllerPathMode, "exposecontroller-pathmode", "", "", "The ExposeController path mode for how services should be exposed as URLs. Defaults to using subnets. Use a value of `path` to use relative paths within the domain host such as when using AWS ELB host names")
cmd.Flags().StringVarP(&flags.Version, "version", "", "", "The specific platform version to install")
cmd.Flags().BoolVarP(&flags.Prow, "prow", "", false, "Enable Prow")
cmd.Flags().BoolVarP(&flags.Tekton, "tekton", "", false, "Enables the Tekton pipeline engine (which used to be called knative build pipeline) along with Prow. Otherwise we default to use Knative Build if you enable Prow")
cmd.Flags().BoolVarP(&flags.GitOpsMode, "gitops", "", false, "Sets up the local file system for GitOps so that the current installation can be configured or upgraded at any time via GitOps")
cmd.Flags().BoolVarP(&flags.Prow, "prow", "", false, "Enable Prow to implement Serverless Jenkins and support ChatOps on Pull Requests")
cmd.Flags().BoolVarP(&flags.Tekton, "tekton", "", false, "Enables the Tekton pipeline engine (which used to be called knative build pipeline) along with Prow to provide Serverless Jenkins. Otherwise we default to use Knative Build if you enable Prow")
cmd.Flags().BoolVarP(&flags.GitOpsMode, "gitops", "", false, "Creates a git repository for the Dev environment to manage the installation, configuration, upgrade and addition of Apps in Jenkins X all via GitOps")
cmd.Flags().BoolVarP(&flags.NoGitOpsEnvApply, "no-gitops-env-apply", "", false, "When using GitOps to create the source code for the development environment and installation, don't run 'jx step env apply' to perform the install")
cmd.Flags().BoolVarP(&flags.NoGitOpsEnvRepo, "no-gitops-env-repo", "", false, "When using GitOps to create the source code for the development environment this flag disables the creation of a git repository for the source code")
cmd.Flags().BoolVarP(&flags.NoGitOpsVault, "no-gitops-vault", "", false, "When using GitOps to create the source code for the development environment this flag disables the creation of a vault")
Expand Down
2 changes: 1 addition & 1 deletion pkg/jx/cmd/step_create_task.go
Expand Up @@ -359,7 +359,7 @@ func (o *StepCreateTaskOptions) GenerateTektonCRDs(packsDir string, projectConfi
return nil, nil, nil, nil, nil, err
}

if lifecycles.Pipeline != nil {
if lifecycles != nil && lifecycles.Pipeline != nil {
// TODO: Seeing weird behavior seemingly related to https://golang.org/doc/faq#nil_error
// if err is reused, maybe we need to switch return types (perhaps upstream in build-pipeline)?
if validateErr := lifecycles.Pipeline.Validate(); validateErr != nil {
Expand Down
28 changes: 28 additions & 0 deletions pkg/tekton/pipeline_info.go
Expand Up @@ -534,6 +534,34 @@ func (pri *PipelineRunInfo) Status() string {
return string(pod.Status.Phase)
}

// ToBuildPodInfo converts the object into a BuildPodInfo so it can be easily filtered
func (pri PipelineRunInfo) ToBuildPodInfo() *builds.BuildPodInfo {
answer := &builds.BuildPodInfo{
Name: pri.Name,
Organisation: pri.Organisation,
Repository: pri.Repository,
Branch: pri.Branch,
Build: pri.Build,
BuildNumber: pri.BuildNumber,
Pipeline: pri.Pipeline,
LastCommitSHA: pri.LastCommitSHA,
LastCommitURL: pri.LastCommitURL,
LastCommitMessage: pri.LastCommitMessage,
GitInfo: pri.GitInfo,
}
pod := pri.FindFirstStagePod()
if pod != nil {
answer.Pod = pod
answer.PodName = pod.Name
containers := pod.Spec.Containers
if len(containers) > 0 {
answer.FirstStepImage = containers[0].Image
}
answer.CreatedTime = pod.CreationTimestamp.Time
}
return answer
}

// PipelineRunInfoOrder allows sorting of a slice of PipelineRunInfos
type PipelineRunInfoOrder []*PipelineRunInfo

Expand Down