Search in sources :

Example 1 with ApplyReplicasDecorator

use of io.dekorate.openshift.decorator.ApplyReplicasDecorator in project dekorate by dekorateio.

the class OpenshiftManifestGenerator method addDecorators.

protected void addDecorators(String group, OpenshiftConfig config, ImageConfiguration imageConfig) {
    super.addDecorators(group, config);
    if (config.getReplicas() != 1) {
        resourceRegistry.decorate(group, new ApplyReplicasDecorator(config.getName(), config.getReplicas()));
    }
    resourceRegistry.decorate(group, new ApplyDeploymentTriggerDecorator(config.getName(), imageConfig.getName() + ":" + imageConfig.getVersion()));
    resourceRegistry.decorate(group, new AddRouteDecorator(config));
    if (config.hasAttribute(RUNTIME_TYPE)) {
        resourceRegistry.decorate(group, new AddLabelDecorator(config.getName(), new Label(OpenshiftLabels.RUNTIME, config.getAttribute(RUNTIME_TYPE), new String[0])));
    }
    resourceRegistry.decorate(group, new RemoveAnnotationDecorator(config.getName(), Annotations.VCS_URL));
    Project project = getProject();
    Optional<VcsConfig> vcsConfig = configurationRegistry.get(VcsConfig.class);
    String remote = vcsConfig.map(VcsConfig::getRemote).orElse(Git.ORIGIN);
    boolean httpsPrefered = vcsConfig.map(VcsConfig::isHttpsPreferred).orElse(false);
    String vcsUrl = project.getScmInfo() != null && Strings.isNotNullOrEmpty(project.getScmInfo().getRemote().get(Git.ORIGIN)) ? Git.getRemoteUrl(project.getRoot(), remote, httpsPrefered).orElse(Labels.UNKNOWN) : Labels.UNKNOWN;
    resourceRegistry.decorate(group, new AddVcsUrlAnnotationDecorator(config.getName(), OpenshiftAnnotations.VCS_URL, vcsUrl));
    resourceRegistry.decorate(group, new AddCommitIdAnnotationDecorator());
}
Also used : RemoveAnnotationDecorator(io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator) Label(io.dekorate.kubernetes.config.Label) AddVcsUrlAnnotationDecorator(io.dekorate.kubernetes.decorator.AddVcsUrlAnnotationDecorator) VcsConfig(io.dekorate.option.config.VcsConfig) AddRouteDecorator(io.dekorate.openshift.decorator.AddRouteDecorator) WithProject(io.dekorate.WithProject) Project(io.dekorate.project.Project) AddCommitIdAnnotationDecorator(io.dekorate.kubernetes.decorator.AddCommitIdAnnotationDecorator) ApplyDeploymentTriggerDecorator(io.dekorate.openshift.decorator.ApplyDeploymentTriggerDecorator) AddLabelDecorator(io.dekorate.kubernetes.decorator.AddLabelDecorator) ApplyReplicasDecorator(io.dekorate.openshift.decorator.ApplyReplicasDecorator)

Aggregations

WithProject (io.dekorate.WithProject)1 Label (io.dekorate.kubernetes.config.Label)1 AddCommitIdAnnotationDecorator (io.dekorate.kubernetes.decorator.AddCommitIdAnnotationDecorator)1 AddLabelDecorator (io.dekorate.kubernetes.decorator.AddLabelDecorator)1 AddVcsUrlAnnotationDecorator (io.dekorate.kubernetes.decorator.AddVcsUrlAnnotationDecorator)1 RemoveAnnotationDecorator (io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator)1 AddRouteDecorator (io.dekorate.openshift.decorator.AddRouteDecorator)1 ApplyDeploymentTriggerDecorator (io.dekorate.openshift.decorator.ApplyDeploymentTriggerDecorator)1 ApplyReplicasDecorator (io.dekorate.openshift.decorator.ApplyReplicasDecorator)1 VcsConfig (io.dekorate.option.config.VcsConfig)1 Project (io.dekorate.project.Project)1