Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: add --go-ldflags argument to operator-sdk build command #1582

Merged
merged 2 commits into from
Jun 24, 2019
Merged

scripts: add --go-ldflags argument to operator-sdk build command #1582

merged 2 commits into from
Jun 24, 2019

Conversation

ZoltanOnody
Copy link
Contributor

Description of the change:
Add --go-ldflags support to operator-sdk build command

Motivation for the change:
I need to provide build time arguments to my operator such as version. With this MR I am able to run:

operator-sdk build image-name --go-ldflags "-X package.Version=vX.Y.Z"

Fixes #1435

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 21, 2019
@openshift-ci-robot
Copy link

Hi @ZoltanOnody. Thanks for your PR.

I'm waiting for a operator-framework or openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 21, 2019
Copy link
Member

@lilic lilic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks for your PR! I am wondering if we can make this more generic, but allowing the user to pass in additional go build args in a similar way as we do with imageBuildArgs.

@ZoltanOnody
Copy link
Contributor Author

Sure, I'll have a look at it.

@ZoltanOnody
Copy link
Contributor Author

I generalized it & amended my commit, now we can provide any additional arguments. Now it works like:

operator-sdk build image-name --go-build-args "-ldflags -X=package.Version=vX.Y.Z"

@lilic
Copy link
Member

lilic commented Jun 24, 2019

@ZoltanOnody thanks so much!

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 24, 2019
@lilic
Copy link
Member

lilic commented Jun 24, 2019

You can ignore the marker test, it seems to be behaving oddly right now. But the e2e test seems to be failing as well.

@shawn-hurley
Copy link
Member

/retest

@ZoltanOnody
Copy link
Contributor Author

The test seems to be working locally:

+ kubectl create namespace test-memcached
namespace/test-memcached created
+ operator-sdk test local ./test/e2e --up-local --namespace=test-memcached
INFO[0000] Testing operator locally.                    
ok  	github.com/operator-framework/operator-sdk/test/test-framework/test/e2e	47.360s
INFO[0049] Local operator test successfully completed.  

In Travis I see:

+operator-sdk test local ./test/e2e --up-local --namespace=test-memcached
INFO[0000] Testing operator locally.                    
time="2019-06-21T17:22:13Z" level=info msg="Started local operator"
--- FAIL: TestMemcached (80.15s)
    --- FAIL: TestMemcached/memcached-group (0.00s)
        --- FAIL: TestMemcached/memcached-group/Cluster2 (60.02s)
            memcached_test.go:100: Initialized cluster resources
            wait_util.go:48: Operator is running locally; skip waitForDeployment
            client.go:57: resource type  with namespace/name (test-memcached/example-memcached) created
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            wait_util.go:64: Waiting for full availability of example-memcached deployment (0/3)
            memcached_test.go:114: timed out waiting for the condition
            client.go:75: resource type  with namespace/name (test-memcached/example-memcached) successfully deleted
FAIL

I think is just some random error caused by network issues in Travis. Could you please restart the job https://travis-ci.org/operator-framework/operator-sdk/jobs/548782267?

@lilic
Copy link
Member

lilic commented Jun 24, 2019

@ZoltanOnody retriggered that test.
Can you also rebase to current master, the marker test should be fixed by doing that, thanks for your patience!

this enables to set additional arguments for Go builds

Fixes #1435
@ZoltanOnody
Copy link
Contributor Author

ZoltanOnody commented Jun 24, 2019

I rebased my branch and forcepushed it. When you retriggered the job, it passed so the failing test was not caused by my changes. :)

Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2019
Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit with the CHANGELOG line.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@lilic lilic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm after that one small suggestion by Joe.

Thanks so much for your contribution and patience!

Co-Authored-By: Joe Lanford <joe.lanford@gmail.com>
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2019
@ZoltanOnody
Copy link
Contributor Author

Is it OK to change it using "Commit suggestion" via Github (I've seen this feature for the first time), or should a squash my commits locally and force push?

BTW, do you have any ETA for the next release of operator-sdk?

@joelanford
Copy link
Member

Is it OK to change it using "Commit suggestion" via Github (I've seen this feature for the first time), or should a squash my commits locally and force push?

Yep. Using "commit suggestion" is totally fine. When one of the maintainers actually does the merge, GitHub automatically squahes everything for us, so you don't have to squash and force push.

BTW, do you have any ETA for the next release of operator-sdk?

Probably later this week unless something comes up that forces us to push it back.

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for adding this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flag to provide Go build arguments
6 participants