Skip to content

Commit a0b5b6a

Browse files
author
Shawn Hurley
authored
Merge pull request operator-framework#3 from openshift/openshift-4.0
Bringing forked version downstream for bug fixes
2 parents 284789c + 668d5b2 commit a0b5b6a

File tree

73 files changed

+1678
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1678
-383
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,10 @@ jobs:
9090
script:
9191
- make image/build/helm
9292
- make image/push/helm
93+
94+
# Build and deploy scorecard-proxy docker image
95+
- <<: *deploy
96+
name: Docker image for scorecard-proxy
97+
script:
98+
- make image/build/scorecard-proxy
99+
- make image/push/scorecard-proxy

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,39 @@
22

33
### Added
44

5+
### Changed
6+
7+
### Deprecated
8+
9+
### Removed
10+
11+
### Bug Fixes
12+
13+
- Do not create namespaced resources when running `test local` subcommand with `--up-local` flag
14+
15+
## v0.4.1
16+
17+
### Bug Fixes
18+
19+
- Make `up local` subcommand respect `KUBECONFIG` env var ([#996](https://github.com/operator-framework/operator-sdk/pull/996))
20+
- Make `up local` subcommand use default namespace set in kubeconfig instead of hardcoded `default` and also add ability to watch all namespaces for ansible and helm type operators ([#996](https://github.com/operator-framework/operator-sdk/pull/996))
21+
- Added k8s_status modules back to generation ([#972](https://github.com/operator-framework/operator-sdk/pull/972))
22+
- Update checks for gvk registration to cover all cases for ansible ([#973](https://github.com/operator-framework/operator-sdk/pull/973) & [#1019](https://github.com/operator-framework/operator-sdk/pull/1019))
23+
- Update reconciler for ansible and helm to use the cache rather than the API client. ([#1022](https://github.com/operator-framework/operator-sdk/pull/1022) & [#1048](https://github.com/operator-framework/operator-sdk/pull/1048) & [#1054](https://github.com/operator-framework/operator-sdk/pull/1054))
24+
- Update reconciler to will update the status everytime for ansible ([#1066](https://github.com/operator-framework/operator-sdk/pull/1066))
25+
- Update ansible proxy to recover dependent watches when pod is killed ([#1067](https://github.com/operator-framework/operator-sdk/pull/1067))
26+
- Update ansible proxy to handle watching cluster scoped dependent watches ([#1031](https://github.com/operator-framework/operator-sdk/pull/1031))
27+
28+
## v0.4.0
29+
30+
### Added
31+
532
- A new command [`operator-sdk migrate`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#migrate) which adds a main.go source file and any associated source files for an operator that is not of the "go" type. ([#887](https://github.com/operator-framework/operator-sdk/pull/887) and [#897](https://github.com/operator-framework/operator-sdk/pull/897))
633
- New commands [`operator-sdk run ansible`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#ansible) and [`operator-sdk run helm`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#helm) which run the SDK as ansible and helm operator processes, respectively. These are intended to be used when running in a Pod inside a cluster. Developers wanting to run their operator locally should continue to use `up local`. ([#887](https://github.com/operator-framework/operator-sdk/pull/887) and [#897](https://github.com/operator-framework/operator-sdk/pull/897))
734
- Ansible operator proxy added the cache handler which allows the get requests to use the operators cache. [#760](https://github.com/operator-framework/operator-sdk/pull/760)
835
- Ansible operator proxy added ability to dynamically watch dependent resource that were created by ansible operator. [#857](https://github.com/operator-framework/operator-sdk/pull/857)
36+
- Ansible-based operators have leader election turned on by default. When upgrading, add environment variable `POD_NAME` to your operator's Deployment using the Kubernetes downward API. To see an example, run `operator-sdk new --type=ansible ...` and see file `deploy/operator.yaml`.
37+
938
### Changed
1039

1140
- The official images for the Ansible and Helm operators have moved! Travis now builds, tags, and pushes operator base images during CI ([#832](https://github.com/operator-framework/operator-sdk/pull/832)).

Gopkg.lock

Lines changed: 82 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ PKGS = $(shell go list ./... | grep -v /vendor/)
1616

1717
ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
1818
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
19+
SCORECARD_PROXY_BASE_IMAGE = quay.io/operator-framework/scorecard-proxy
1920

2021
ANSIBLE_IMAGE ?= $(ANSIBLE_BASE_IMAGE)
2122
HELM_IMAGE ?= $(HELM_BASE_IMAGE)
23+
SCORECARD_PROXY_IMAGE ?= $(SCORECARD_PROXY_BASE_IMAGE)
2224

2325
export CGO_ENABLED:=0
2426

@@ -39,7 +41,7 @@ clean:
3941
.PHONY: all test format dep clean
4042

4143
install:
42-
$(Q)go install $(BUILD_PATH)
44+
$(Q)go install -gcflags "all=-trimpath=${GOPATH}" -asmflags "all=-trimpath=${GOPATH}" $(BUILD_PATH)
4345

4446
release_x86_64 := \
4547
build/operator-sdk-$(VERSION)-x86_64-linux-gnu \
@@ -51,7 +53,7 @@ build/operator-sdk-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64
5153
build/operator-sdk-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64
5254

5355
build/%:
54-
$(Q)$(GOARGS) go build -o $@ $(BUILD_PATH)
56+
$(Q)$(GOARGS) go build -gcflags "all=-trimpath=${GOPATH}" -asmflags "all=-trimpath=${GOPATH}" -o $@ $(BUILD_PATH)
5557

5658
build/%.asc:
5759
$(Q){ \
@@ -111,20 +113,26 @@ test/markdown:
111113

112114
image: image/build image/push
113115

114-
image/build: image/build/ansible image/build/helm
116+
image/build: image/build/ansible image/build/helm image/build/scorecard-proxy
115117

116118
image/build/ansible: build/operator-sdk-dev-x86_64-linux-gnu
117119
./hack/image/build-ansible-image.sh $(ANSIBLE_BASE_IMAGE):dev
118120

119121
image/build/helm: build/operator-sdk-dev-x86_64-linux-gnu
120122
./hack/image/build-helm-image.sh $(HELM_BASE_IMAGE):dev
121123

122-
image/push: image/push/ansible image/push/helm
124+
image/build/scorecard-proxy:
125+
./hack/image/build-scorecard-proxy-image.sh $(SCORECARD_PROXY_BASE_IMAGE):dev
126+
127+
image/push: image/push/ansible image/push/helm image/push/scorecard-proxy
123128

124129
image/push/ansible:
125130
./hack/image/push-image-tags.sh $(ANSIBLE_BASE_IMAGE):dev $(ANSIBLE_IMAGE)
126131

127132
image/push/helm:
128133
./hack/image/push-image-tags.sh $(HELM_BASE_IMAGE):dev $(HELM_IMAGE)
129134

135+
image/push/scorecard-proxy:
136+
./hack/image/push-image-tags.sh $(SCORECARD_PROXY_BASE_IMAGE):dev $(SCORECARD_PROXY_IMAGE)
137+
130138
.PHONY: image image/build image/build/ansible image/build/helm image/push image/push/ansible image/push/helm

commands/operator-sdk/cmd/add/api.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ Example:
5454
}
5555

5656
apiCmd.Flags().StringVar(&apiVersion, "api-version", "", "Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)")
57-
apiCmd.MarkFlagRequired("api-version")
57+
if err := apiCmd.MarkFlagRequired("api-version"); err != nil {
58+
log.Fatalf("Failed to mark `api-version` flag for `add api` subcommand as required")
59+
}
5860
apiCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes resource Kind name. (e.g AppService)")
59-
apiCmd.MarkFlagRequired("kind")
61+
if err := apiCmd.MarkFlagRequired("kind"); err != nil {
62+
log.Fatalf("Failed to mark `kind` flag for `add api` subcommand as required")
63+
}
6064

6165
return apiCmd
6266
}

commands/operator-sdk/cmd/add/controller.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func NewControllerCmd() *cobra.Command {
27-
apiCmd := &cobra.Command{
27+
controllerCmd := &cobra.Command{
2828
Use: "controller",
2929
Short: "Adds a new controller pkg",
3030
Long: `operator-sdk add controller --kind=<kind> --api-version=<group/version> creates a new
@@ -47,12 +47,16 @@ Example:
4747
Run: controllerRun,
4848
}
4949

50-
apiCmd.Flags().StringVar(&apiVersion, "api-version", "", "Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)")
51-
apiCmd.MarkFlagRequired("api-version")
52-
apiCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes resource Kind name. (e.g AppService)")
53-
apiCmd.MarkFlagRequired("kind")
50+
controllerCmd.Flags().StringVar(&apiVersion, "api-version", "", "Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)")
51+
if err := controllerCmd.MarkFlagRequired("api-version"); err != nil {
52+
log.Fatalf("Failed to mark `api-version` flag for `add controller` subcommand as required")
53+
}
54+
controllerCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes resource Kind name. (e.g AppService)")
55+
if err := controllerCmd.MarkFlagRequired("kind"); err != nil {
56+
log.Fatalf("Failed to mark `kind` flag for `add controller` subcommand as required")
57+
}
5458

55-
return apiCmd
59+
return controllerCmd
5660
}
5761

5862
func controllerRun(cmd *cobra.Command, args []string) {

commands/operator-sdk/cmd/add/crd.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ Generated CR filename: <project-name>/deploy/crds/<group>_<version>_<kind>_cr.y
4343
Run: crdFunc,
4444
}
4545
crdCmd.Flags().StringVar(&apiVersion, "api-version", "", "Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)")
46-
crdCmd.MarkFlagRequired("api-version")
46+
if err := crdCmd.MarkFlagRequired("api-version"); err != nil {
47+
log.Fatalf("Failed to mark `api-version` flag for `add crd` subcommand as required")
48+
}
4749
crdCmd.Flags().StringVar(&kind, "kind", "", "Kubernetes CustomResourceDefintion kind. (e.g AppService)")
48-
crdCmd.MarkFlagRequired("kind")
50+
if err := crdCmd.MarkFlagRequired("kind"); err != nil {
51+
log.Fatalf("Failed to mark `kind` flag for `add crd` subcommand as required")
52+
}
4953
return crdCmd
5054
}
5155

commands/operator-sdk/cmd/build.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ func buildFunc(cmd *cobra.Command, args []string) {
144144

145145
projutil.MustInProjectRoot()
146146
goBuildEnv := append(os.Environ(), "GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=0")
147+
goTrimFlags := []string{"-gcflags", "all=-trimpath=${GOPATH}", "-asmflags", "all=-trimpath=${GOPATH}"}
147148
absProjectPath := projutil.MustGetwd()
149+
projectName := filepath.Base(absProjectPath)
148150

149151
// Don't need to build go code if Ansible Operator
150152
if mainExists() {
151153
managerDir := filepath.Join(projutil.CheckAndGetProjectGoPkg(), scaffold.ManagerDir)
152-
outputBinName := filepath.Join(absProjectPath, scaffold.BuildBinDir, filepath.Base(absProjectPath))
153-
buildCmd := exec.Command("go", "build", "-o", outputBinName, managerDir)
154+
outputBinName := filepath.Join(absProjectPath, scaffold.BuildBinDir, projectName)
155+
goBuildArgs := append(append([]string{"build"}, goTrimFlags...), "-o", outputBinName, managerDir)
156+
buildCmd := exec.Command("go", goBuildArgs...)
154157
buildCmd.Env = goBuildEnv
155158
buildCmd.Stdout = os.Stdout
156159
buildCmd.Stderr = os.Stderr
@@ -181,9 +184,10 @@ func buildFunc(cmd *cobra.Command, args []string) {
181184
}
182185

183186
if enableTests {
184-
if mainExists() {
185-
testBinary := filepath.Join(absProjectPath, scaffold.BuildBinDir, filepath.Base(absProjectPath)+"-test")
186-
buildTestCmd := exec.Command("go", "test", "-c", "-o", testBinary, testLocationBuild+"/...")
187+
if projutil.GetOperatorType() == projutil.OperatorTypeGo {
188+
testBinary := filepath.Join(absProjectPath, scaffold.BuildBinDir, projectName+"-test")
189+
goTestBuildArgs := append(append([]string{"test"}, goTrimFlags...), "-c", "-o", testBinary, testLocationBuild+"/...")
190+
buildTestCmd := exec.Command("go", goTestBuildArgs...)
187191
buildTestCmd.Env = goBuildEnv
188192
buildTestCmd.Stdout = os.Stdout
189193
buildTestCmd.Stderr = os.Stderr

commands/operator-sdk/cmd/migrate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func migrateAnsible() {
6969
Watches: true,
7070
Roles: true,
7171
}
72-
_, err := os.Stat("playbook.yaml")
72+
_, err := os.Stat("playbook.yml")
7373
switch {
7474
case err == nil:
7575
dockerfile.Playbook = true
7676
case os.IsNotExist(err):
7777
log.Info("No playbook was found, so not including it in the new Dockerfile")
7878
default:
79-
log.Fatalf("Error trying to stat playbook.yaml: (%v)", err)
79+
log.Fatalf("Error trying to stat playbook.yml: (%v)", err)
8080
}
8181

8282
renameDockerfile()
@@ -88,6 +88,7 @@ func migrateAnsible() {
8888
&dockerfile,
8989
&ansible.Entrypoint{},
9090
&ansible.UserSetup{},
91+
&ansible.K8sStatus{},
9192
)
9293
if err != nil {
9394
log.Fatalf("Migrate scaffold failed: (%v)", err)

commands/operator-sdk/cmd/scorecard.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
package cmd
1616

1717
import (
18+
"fmt"
19+
"strings"
20+
1821
log "github.com/sirupsen/logrus"
1922
"github.com/spf13/cobra"
2023

2124
"github.com/operator-framework/operator-sdk/commands/operator-sdk/cmd/scorecard"
25+
"github.com/operator-framework/operator-sdk/version"
2226
)
2327

2428
func NewScorecardCmd() *cobra.Command {
@@ -39,7 +43,7 @@ func NewScorecardCmd() *cobra.Command {
3943
scorecardCmd.Flags().StringVar(&scorecard.SCConf.NamespacedManifest, "namespaced-manifest", "", "Path to manifest for namespaced resources (e.g. RBAC and Operator manifest)")
4044
scorecardCmd.Flags().StringVar(&scorecard.SCConf.GlobalManifest, "global-manifest", "", "Path to manifest for Global resources (e.g. CRD manifests)")
4145
scorecardCmd.Flags().StringVar(&scorecard.SCConf.CRManifest, "cr-manifest", "", "Path to manifest for Custom Resource")
42-
scorecardCmd.Flags().StringVar(&scorecard.SCConf.ProxyImage, "proxy-image", "quay.io/operator-framework/scorecard-proxy", "Image name for scorecard proxy")
46+
scorecardCmd.Flags().StringVar(&scorecard.SCConf.ProxyImage, "proxy-image", fmt.Sprintf("quay.io/operator-framework/scorecard-proxy:%s", strings.TrimSuffix(version.Version, "+git")), "Image name for scorecard proxy")
4347
scorecardCmd.Flags().StringVar(&scorecard.SCConf.ProxyPullPolicy, "proxy-pull-policy", "Always", "Pull policy for scorecard proxy image")
4448
scorecardCmd.Flags().BoolVar(&scorecard.SCConf.Verbose, "verbose", false, "Enable verbose logging")
4549
// Since it's difficult to handle multiple CRs, we will require users to specify what CR they want to test; we can handle this better in the future

0 commit comments

Comments
 (0)