-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support organization-level runner #97
Conversation
93a3ab1
to
cb1f5bb
Compare
29bd4c2
to
b99d070
Compare
Signed-off-by: kouki <kouworld0123@gmail.com>
Signed-off-by: kouki <kouworld0123@gmail.com>
e368318
to
cc4b31a
Compare
Signed-off-by: kouki <kouworld0123@gmail.com>
Signed-off-by: kouki <kouworld0123@gmail.com>
cc4b31a
to
09dd58b
Compare
Signed-off-by: kouki <kouworld0123@gmail.com>
Signed-off-by: kouki <kouworld0123@gmail.com>
Signed-off-by: kouki <kouworld0123@gmail.com>
This reverts commit aa63350.
Short: "set slack channel to notify.", | ||
Long: `This command TODO description`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short: "set slack channel to notify.", | |
Long: `This command TODO description`, | |
Short: "set slack channel to notify.", | |
Long: `set slack channel to notify.`, |
channel = os.Getenv(constants.SlackChannelEnvName) | ||
} | ||
|
||
err = ioutil.WriteFile(slackChannelFilePath, []byte(channel), 0644) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you read These documents?
https://golang.org/doc/go1.16#ioutil
https://pkg.go.dev/io/ioutil#WriteFile
You can use os.WriteFile
instead.
And {os/ioutil}.WriteFile
will overwrite if target file exists.
So you need not remove the slack channel file before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know about this information. Thank you.
I'll fix it together with some other places that use ioutil
.
if len(args) == 1 { | ||
channel = args[0] | ||
} | ||
err := os.MkdirAll(constants.RunnerVarDirPath, 0755) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not create /var/meows
here.
Since an emptyDir will be mounted in /var/meows
, so usually the directory exists.
And if -file /path/to/otherDir/otherFile
flag is set, the slack channel will be written in the other dir.
err := os.MkdirAll(constants.RunnerVarDirPath, 0755) | |
err := os.MkdirAll(constants.RunnerVarDirPath, 0755) |
54536b3
to
0dc818b
Compare
Signed-off-by: kouki <kouworld0123@gmail.com>
Signed-off-by: kouki <kouworld0123@gmail.com>
58762cf
to
cf57f87
Compare
When I commanded |
docs/commands.md
Outdated
This sub command set a Slack channel to notified job result. | ||
This is used by calling it in the workflow yaml file. | ||
If it is not specified, the environment variable `MEOWS_SLACK_CHANNEL` is specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sub command set a Slack channel to notified job result. | |
This is used by calling it in the workflow yaml file. | |
If it is not specified, the environment variable `MEOWS_SLACK_CHANNEL` is specified. | |
This sub command sets a Slack channel that a job result will be notified to. | |
This command should be called in a workflow. | |
Users can specify the Slack channel as an argument. | |
If the argument is not specified, the environment variable `MEOWS_SLACK_CHANNEL` is read instead. |
docs/user-manual.md
Outdated
|
||
The following methods exist for specifying the channel for Slack notifications. | ||
The priority order of the specification method is 4>3>2>1. | ||
Any channel specification method should look like `#<channel_name>`. (e.g. `#general`, `#test1`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any channel specification method should look like `#<channel_name>`. (e.g. `#general`, `#test1`) | |
Any method accepts a channel name in the format of `#<channel_name>`. (e.g. `#general`, `#test1`) |
docs/user-manual.md
Outdated
1. Slack app secret to be created in [How to deploy Slack agent](#how-to-deploy-slack-agent) | ||
2. `RunnerPool` resource in `.spec.slackAgent.channel`. [docs to SlackAgentConfig](crd-runner-pool.md#SlackAgentConfig) | ||
3. Environment variables in the workflow. | ||
- The `MEOWS_SLACK_CHANNEL` environment variable is read when `job-started` is executed. | ||
4. Call command `meows slackagent set-channel "#channel"` in the workflow step. | ||
- You can specify the channel to be notified by using the command as follows. | ||
```yaml | ||
name: slack-channel-specified | ||
on: push | ||
|
||
jobs: | ||
build: | ||
name: job-name | ||
env: | ||
MEOWS_SLACK_CHANNEL: "#test2" | ||
steps: | ||
- run: job-started | ||
# The environment variable `MEOWS_SLACK_CHANNEL` is ignored and the job results are reported to the "#test1" channel. | ||
- run: meows slackagent set-channel "#test1" | ||
- run: job-success | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. `SLACK_CHANNEL` value in the `slack-app-secret` secret. See [How to deploy Slack agent](#how-to-deploy-slack-agent). 2. `.spec.slackAgent.channel` field in a `RunnerPool` resource. See [SlackAgentConfig](crd-runner-pool.md#SlackAgentConfig). 3. `MEOWS_SLACK_CHANNEL` environment variable in a workflow. 4. Call `meows slackagent set-channel "#channel"` command in a workflow. For example, you can specify the channel in a workflow as follows. ```yaml name: slack-channel-specified on: push jobs: build: name: job-name env: # Basically, a job result will be reported to the "#test1" channel. MEOWS_SLACK_CHANNEL: "#test1" steps: - run: job-started # Only when a job fails, the result will be reported to the "#test2" channel. - run: meows slackagent set-channel "#test2" if: failure() - run: job-success ```
Long: `This command set a Slack channel to notified job result. | ||
This is used by calling it in the workflow yaml file. | ||
If SLACK_CHANNEL_NAME is not specified, the environment variable MEOWS_SLACK_CHANNEL is specified as a Slack channel to notified.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long: `This command set a Slack channel to notified job result. | |
This is used by calling it in the workflow yaml file. | |
If SLACK_CHANNEL_NAME is not specified, the environment variable MEOWS_SLACK_CHANNEL is specified as a Slack channel to notified.`, | |
Long: `This command sets a Slack channel that a job result to be notified to. | |
This should be called in a workflow. | |
If SLACK_CHANNEL_NAME is not specified, the environment variable MEOWS_SLACK_CHANNEL is read.`, |
api/v1alpha1/runnerpool_types.go
Outdated
@@ -25,6 +25,8 @@ var reservedEnvNames = map[string]bool{ | |||
// RunnerPoolSpec defines the desired state of RunnerPool | |||
type RunnerPoolSpec struct { | |||
// RepositoryName describes repository name to register Pods as self-hosted runners. | |||
// RepositoryName is not necessary, If you want to use it as an organization-level self-hosted runner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// RepositoryName is not necessary, If you want to use it as an organization-level self-hosted runner | |
// If this field is omitted or the empty string (`""`) is specified, Pods will be registered as organization-level self-hosted runners. |
Signed-off-by: kouki <kouworld0123@gmail.com>
b790480
to
5625de1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#74
Signed-off-by: kouki kouworld0123@gmail.com