github.com/joelanford/operator-sdk@v0.8.2/internal/pkg/scaffold/go_mod.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 scaffold
    16  
    17  import (
    18  	"fmt"
    19  
    20  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input"
    21  	"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/internal/deps"
    22  )
    23  
    24  const GoModFile = "go.mod"
    25  
    26  type GoMod struct {
    27  	input.Input
    28  }
    29  
    30  func (s *GoMod) GetInput() (input.Input, error) {
    31  	if s.Path == "" {
    32  		s.Path = GoModFile
    33  	}
    34  	s.TemplateBody = goModTmpl
    35  	return s.Input, nil
    36  }
    37  
    38  const goModTmpl = `module {{ .Repo }}
    39  
    40  require (
    41  	contrib.go.opencensus.io/exporter/ocagent v0.4.9 // indirect
    42  	github.com/Azure/go-autorest v11.5.2+incompatible // indirect
    43  	github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30 // indirect
    44  	github.com/coreos/prometheus-operator v0.26.0 // indirect
    45  	github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
    46  	github.com/emicklei/go-restful v2.8.1+incompatible // indirect
    47  	github.com/go-logr/logr v0.1.0 // indirect
    48  	github.com/go-logr/zapr v0.1.0 // indirect
    49  	github.com/go-openapi/spec v0.18.0 // indirect
    50  	github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4 // indirect
    51  	github.com/golang/mock v1.2.0 // indirect
    52  	github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
    53  	github.com/google/uuid v1.0.0 // indirect
    54  	github.com/googleapis/gnostic v0.2.0 // indirect
    55  	github.com/gophercloud/gophercloud v0.0.0-20190318015731-ff9851476e98 // indirect
    56  	github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
    57  	github.com/grpc-ecosystem/grpc-gateway v1.8.5 // indirect
    58  	github.com/imdario/mergo v0.3.6 // indirect
    59  	github.com/operator-framework/operator-sdk v0.8.x
    60  	github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 // indirect
    61  	github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
    62  	github.com/spf13/pflag v1.0.3
    63  	go.opencensus.io v0.19.2 // indirect
    64  	go.uber.org/atomic v1.3.2 // indirect
    65  	go.uber.org/multierr v1.1.0 // indirect
    66  	go.uber.org/zap v1.9.1 // indirect
    67  	golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
    68  	k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
    69  	k8s.io/client-go v2.0.0-alpha.0.0.20181126152608-d082d5923d3c+incompatible
    70  	k8s.io/code-generator v0.0.0-20180823001027-3dcf91f64f63
    71  	k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6
    72  	k8s.io/kube-openapi v0.0.0-20180711000925-0cf8f7e6ed1d
    73  	sigs.k8s.io/controller-runtime v0.1.10
    74  	sigs.k8s.io/controller-tools v0.1.10
    75  	sigs.k8s.io/testing_frameworks v0.1.0 // indirect
    76  )
    77  
    78  // Pinned to kubernetes-1.13.1
    79  replace (
    80  	k8s.io/api => k8s.io/api v0.0.0-20181213150558-05914d821849
    81  	k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20181213153335-0fe22c71c476
    82  	k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93
    83  	k8s.io/client-go => k8s.io/client-go v0.0.0-20181213151034-8d9ed539ba31
    84  )
    85  
    86  replace (
    87  	github.com/coreos/prometheus-operator => github.com/coreos/prometheus-operator v0.29.0
    88  	k8s.io/code-generator => k8s.io/code-generator v0.0.0-20181117043124-c2090bec4d9b
    89  	k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20180711000925-0cf8f7e6ed1d
    90  	sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.1.10
    91  	sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.1.11-0.20190411181648-9d55346c2bde
    92  )
    93  
    94  replace github.com/operator-framework/operator-sdk => github.com/operator-framework/operator-sdk v0.8.2
    95  `
    96  
    97  func PrintGoMod(asFile bool) error {
    98  	b, err := deps.ExecGoModTmpl(goModTmpl)
    99  	if err != nil {
   100  		return err
   101  	}
   102  	if asFile {
   103  		fmt.Print(string(b))
   104  		return nil
   105  	}
   106  	return deps.PrintGoMod(b)
   107  }