Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions cmd/ansible-operator/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Comment thread
varshaprasad96 marked this conversation as resolved.
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/operator-sdk/pkg/ansible"
aoflags "github.com/operator-framework/operator-sdk/pkg/ansible/flags"
"github.com/operator-framework/operator-sdk/pkg/log/zap"
)

func main() {
flags := aoflags.AddTo(pflag.CommandLine)
pflag.Parse()
logf.SetLogger(zap.Logger())

if err := ansible.Run(flags); err != nil {
log.Fatal(err)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 The Operator-SDK Authors
// Copyright 2020 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,37 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package execentrypoint
package main

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/operator-sdk/pkg/helm"
hoflags "github.com/operator-framework/operator-sdk/pkg/helm/flags"
Comment thread
varshaprasad96 marked this conversation as resolved.
"github.com/operator-framework/operator-sdk/pkg/log/zap"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

// newRunHelmCmd returns a command that will run a helm operator.
func newRunHelmCmd() *cobra.Command {
var flags *hoflags.HelmOperatorFlags
runHelmCmd := &cobra.Command{
Use: "helm",
Short: "Runs as a helm operator",
Long: `Runs as a helm operator. This is intended to be used when running
in a Pod inside a cluster. Developers wanting to run their operator locally
should use 'run local' instead.`,
RunE: func(cmd *cobra.Command, args []string) error {
logf.SetLogger(zap.Logger())
func main() {
flags := hoflags.AddTo(pflag.CommandLine)
pflag.Parse()
logf.SetLogger(zap.Logger())

if err := helm.Run(flags); err != nil {
log.Fatal(err)
}
return nil
},
if err := helm.Run(flags); err != nil {
log.Fatal(err)
}
flags = hoflags.AddTo(runHelmCmd.Flags())

return runHelmCmd
}
Comment thread
varshaprasad96 marked this conversation as resolved.
2 changes: 0 additions & 2 deletions cmd/operator-sdk/cli/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/bundle"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/execentrypoint"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/new"
Expand Down Expand Up @@ -76,7 +75,6 @@ func GetCLIRoot() *cobra.Command {
bundle.NewCmdLegacy(),
cleanup.NewCmdLegacy(),
completion.NewCmd(),
execentrypoint.NewCmd(),
generate.NewCmdLegacy(),
migrate.NewCmd(),
new.NewCmd(),
Expand Down
74 changes: 0 additions & 74 deletions cmd/operator-sdk/execentrypoint/ansible.go

This file was deleted.

36 changes: 0 additions & 36 deletions cmd/operator-sdk/execentrypoint/cmd.go

This file was deleted.

5 changes: 4 additions & 1 deletion hack/image/build-ansible-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ BASEIMAGEDIR="$TMPDIR/ansible-operator"
mkdir -p "$BASEIMAGEDIR"
go build -o $BASEIMAGEDIR/scaffold-ansible-image ./hack/image/ansible/scaffold-ansible-image.go

# build binary for specific target platform (for purposes of base image only)
env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/ansible-operator-dev-linux-gnu ./cmd/ansible-operator/main.go

Comment thread
varshaprasad96 marked this conversation as resolved.
# build operator binary and base image
pushd "$BASEIMAGEDIR"
./scaffold-ansible-image

mkdir -p build/_output/bin/
cp $ROOTDIR/build/operator-sdk-dev-linux-gnu build/_output/bin/ansible-operator
cp $BASEIMAGEDIR/ansible-operator-dev-linux-gnu build/_output/bin/ansible-operator
operator-sdk build $1
# If using a kind cluster, load the image into all nodes.
load_image_if_kind "$1"
Expand Down
5 changes: 4 additions & 1 deletion hack/image/build-helm-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ BASEIMAGEDIR="$TMPDIR/helm-operator"
mkdir -p "$BASEIMAGEDIR"
go build -o $BASEIMAGEDIR/scaffold-helm-image ./hack/image/helm/scaffold-helm-image.go

# build binary for specific target platform (for purposes of base image only)
env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/helm-operator-dev-linux-gnu ./cmd/helm-operator/main.go

# build operator binary and base image
pushd "$BASEIMAGEDIR"
./scaffold-helm-image

mkdir -p build/_output/bin/
cp $ROOTDIR/build/operator-sdk-dev-linux-gnu build/_output/bin/helm-operator
cp $BASEIMAGEDIR/helm-operator-dev-linux-gnu build/_output/bin/helm-operator
operator-sdk build $1
# If using a kind cluster, load the image into all nodes.
load_image_if_kind "$1"
Expand Down
2 changes: 1 addition & 1 deletion internal/scaffold/ansible/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func (e *Entrypoint) GetInput() (input.Input, error) {
const entrypointTmpl = `#!/bin/bash -e

cd $HOME
exec ${OPERATOR} exec-entrypoint ansible --watches-file=$HOME/watches.yaml $@
exec ${OPERATOR} --watches-file=$HOME/watches.yaml $@
`
2 changes: 1 addition & 1 deletion internal/scaffold/helm/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func (e *Entrypoint) GetInput() (input.Input, error) {
const entrypointTmpl = `#!/bin/sh -e

cd $HOME
exec ${OPERATOR} exec-entrypoint helm --watches-file=$HOME/watches.yaml $@
exec ${OPERATOR} --watches-file=$HOME/watches.yaml $@
Comment thread
varshaprasad96 marked this conversation as resolved.
`