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

     1  // Copyright 2018 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  	"strings"
    20  
    21  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold"
    22  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input"
    23  	"github.com/operator-framework/operator-sdk/version"
    24  )
    25  
    26  // Dockerfile specifies the Helm Dockerfile scaffold
    27  type Dockerfile struct {
    28  	input.Input
    29  
    30  	HelmChartsDir string
    31  	ImageTag      string
    32  }
    33  
    34  // GetInput gets the scaffold execution input
    35  func (d *Dockerfile) GetInput() (input.Input, error) {
    36  	if d.Path == "" {
    37  		d.Path = filepath.Join(scaffold.BuildDir, scaffold.DockerfileFile)
    38  	}
    39  	d.HelmChartsDir = HelmChartsDir
    40  	d.ImageTag = strings.TrimSuffix(version.Version, "+git")
    41  	d.TemplateBody = dockerFileHelmTmpl
    42  	return d.Input, nil
    43  }
    44  
    45  const dockerFileHelmTmpl = `FROM quay.io/operator-framework/helm-operator:{{.ImageTag}}
    46  
    47  COPY watches.yaml ${HOME}/watches.yaml
    48  COPY {{.HelmChartsDir}}/ ${HOME}/{{.HelmChartsDir}}/
    49  `