github.com/joelanford/operator-sdk@v0.8.2/internal/pkg/scaffold/helm/dockerfilehybrid.go (about)

     1  // Copyright 2019 The Operator-SDK Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package helm
    16  
    17  import (
    18  	"path/filepath"
    19  
    20  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold"
    21  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input"
    22  )
    23  
    24  //DockerfileHybrid - Dockerfile for a hybrid operator
    25  type DockerfileHybrid struct {
    26  	input.Input
    27  
    28  	// HelmCharts - if true, include a COPY statement for the helm-charts directory
    29  	HelmCharts bool
    30  
    31  	// Watches - if true, include a COPY statement for watches.yaml
    32  	Watches bool
    33  }
    34  
    35  // GetInput - gets the input
    36  func (d *DockerfileHybrid) GetInput() (input.Input, error) {
    37  	if d.Path == "" {
    38  		d.Path = filepath.Join(scaffold.BuildDir, scaffold.DockerfileFile)
    39  	}
    40  	d.TemplateBody = dockerFileHybridHelmTmpl
    41  	return d.Input, nil
    42  }
    43  
    44  const dockerFileHybridHelmTmpl = `FROM registry.access.redhat.com/ubi7/ubi-minimal:latest
    45  
    46  ENV OPERATOR=/usr/local/bin/helm-operator \
    47      USER_UID=1001 \
    48      USER_NAME=helm \
    49      HOME=/opt/helm
    50  
    51  {{- if .Watches }}
    52  COPY watches.yaml ${HOME}/watches.yaml{{ end }}
    53  
    54  # install operator binary
    55  COPY build/_output/bin/{{.ProjectName}} ${OPERATOR}
    56  
    57  COPY bin /usr/local/bin
    58  RUN  /usr/local/bin/user_setup
    59  
    60  {{- if .HelmCharts }}
    61  COPY helm-charts/ ${HOME}/helm-charts/{{ end }}
    62  
    63  ENTRYPOINT ["/usr/local/bin/entrypoint"]
    64  
    65  USER ${USER_UID}`