-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
994 additions
and
1,282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 Undistro Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// 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 worker | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
"github.com/caarlos0/env/v9" | ||
) | ||
|
||
// config represents worker configuration | ||
type config struct { | ||
DoneFile string `env:"DONE_FILE" envDefault:"/tmp/zora/results/done"` | ||
ErrorFile string `env:"ERROR_FILE" envDefault:"/tmp/zora/results/error"` | ||
PluginName string `env:"PLUGIN_NAME,required"` | ||
ClusterName string `env:"CLUSTER_NAME,required"` | ||
Namespace string `env:"NAMESPACE,required"` | ||
JobName string `env:"JOB_NAME,required"` | ||
JobUID string `env:"JOB_UID,required"` | ||
PodName string `env:"POD_NAME,required"` | ||
WaitInterval time.Duration `env:"WAIT_INTERVAL" envDefault:"1s"` | ||
|
||
suffix string | ||
} | ||
|
||
// configFromEnv returns a config from environment variables | ||
func configFromEnv() (*config, error) { | ||
cfg := &config{} | ||
if err := env.Parse(cfg); err != nil { | ||
return nil, err | ||
} | ||
if i := strings.LastIndex(cfg.PodName, "-"); i > 0 && len(cfg.PodName) > i+1 { | ||
cfg.suffix = cfg.PodName[i+1:] | ||
} | ||
return cfg, nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.