github.com/chenbh/concourse/v6@v6.4.2/atc/wrappa/reject_archived_wrappa.go (about)

     1  package wrappa
     2  
     3  import (
     4  	"github.com/chenbh/concourse/v6/atc"
     5  	"github.com/chenbh/concourse/v6/atc/api/pipelineserver"
     6  	"github.com/tedsuo/rata"
     7  )
     8  
     9  type RejectArchivedWrappa struct {
    10  	handlerFactory pipelineserver.RejectArchivedHandlerFactory
    11  }
    12  
    13  func NewRejectArchivedWrappa(factory pipelineserver.RejectArchivedHandlerFactory) *RejectArchivedWrappa {
    14  	return &RejectArchivedWrappa{
    15  		handlerFactory: factory,
    16  	}
    17  }
    18  
    19  func (rw *RejectArchivedWrappa) Wrap(handlers rata.Handlers) rata.Handlers {
    20  	wrapped := rata.Handlers{}
    21  
    22  	for name, handler := range handlers {
    23  		newHandler := handler
    24  
    25  		switch name {
    26  		case
    27  			atc.PausePipeline,
    28  			atc.UnpausePipeline,
    29  			atc.CreateJobBuild,
    30  			atc.ScheduleJob,
    31  			atc.CheckResource,
    32  			atc.CheckResourceType,
    33  			atc.DisableResourceVersion,
    34  			atc.EnableResourceVersion,
    35  			atc.PinResourceVersion,
    36  			atc.UnpinResource,
    37  			atc.SetPinCommentOnResource,
    38  			atc.RerunJobBuild:
    39  
    40  			newHandler = rw.handlerFactory.RejectArchived(handler)
    41  
    42  			// leave the handler as-is
    43  		case
    44  			atc.GetConfig,
    45  			atc.GetBuild,
    46  			atc.BuildResources,
    47  			atc.BuildEvents,
    48  			atc.ListBuildArtifacts,
    49  			atc.GetBuildPreparation,
    50  			atc.GetBuildPlan,
    51  			atc.AbortBuild,
    52  			atc.PruneWorker,
    53  			atc.LandWorker,
    54  			atc.ReportWorkerContainers,
    55  			atc.ReportWorkerVolumes,
    56  			atc.RetireWorker,
    57  			atc.ListDestroyingContainers,
    58  			atc.ListDestroyingVolumes,
    59  			atc.GetPipeline,
    60  			atc.GetJobBuild,
    61  			atc.PipelineBadge,
    62  			atc.JobBadge,
    63  			atc.ListJobs,
    64  			atc.GetJob,
    65  			atc.ListJobBuilds,
    66  			atc.ListPipelineBuilds,
    67  			atc.GetResource,
    68  			atc.ListBuildsWithVersionAsInput,
    69  			atc.ListBuildsWithVersionAsOutput,
    70  			atc.ListResources,
    71  			atc.ListResourceTypes,
    72  			atc.ListResourceVersions,
    73  			atc.GetResourceCausality,
    74  			atc.GetResourceVersion,
    75  			atc.CreateBuild,
    76  			atc.GetContainer,
    77  			atc.HijackContainer,
    78  			atc.ListContainers,
    79  			atc.ListVolumes,
    80  			atc.ListTeamBuilds,
    81  			atc.ListWorkers,
    82  			atc.RegisterWorker,
    83  			atc.HeartbeatWorker,
    84  			atc.DeleteWorker,
    85  			atc.GetTeam,
    86  			atc.SetTeam,
    87  			atc.RenameTeam,
    88  			atc.DestroyTeam,
    89  			atc.GetUser,
    90  			atc.GetInfo,
    91  			atc.GetCheck,
    92  			atc.DownloadCLI,
    93  			atc.CheckResourceWebHook,
    94  			atc.ListAllPipelines,
    95  			atc.ListBuilds,
    96  			atc.ListPipelines,
    97  			atc.ListAllJobs,
    98  			atc.ListAllResources,
    99  			atc.ListTeams,
   100  			atc.MainJobBadge,
   101  			atc.GetWall,
   102  			atc.GetLogLevel,
   103  			atc.SetLogLevel,
   104  			atc.GetInfoCreds,
   105  			atc.ListActiveUsersSince,
   106  			atc.SetWall,
   107  			atc.ClearWall,
   108  			atc.DeletePipeline,
   109  			atc.GetCC,
   110  			atc.GetVersionsDB,
   111  			atc.ListJobInputs,
   112  			atc.OrderPipelines,
   113  			atc.PauseJob,
   114  			atc.ArchivePipeline,
   115  			atc.RenamePipeline,
   116  			atc.SaveConfig,
   117  			atc.UnpauseJob,
   118  			atc.ExposePipeline,
   119  			atc.HidePipeline,
   120  			atc.CreatePipelineBuild,
   121  			atc.ClearTaskCache,
   122  			atc.CreateArtifact,
   123  			atc.GetArtifact:
   124  
   125  		default:
   126  			panic("how do archived pipelines affect your endpoint?")
   127  		}
   128  
   129  		wrapped[name] = newHandler
   130  	}
   131  
   132  	return wrapped
   133  }