Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #120 from nre-learning/support-curriculum-version
Browse files Browse the repository at this point in the history
Support option to specify curriculum version
  • Loading branch information
Mierdin committed Jul 30, 2019
2 parents 5ae5d63 + fc92c4b commit 3a6643e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Limit volume mount to lesson directory [#109](https://github.com/nre-learning/syringe/pull/109)
- Add configuration options to influxdb export [#108](https://github.com/nre-learning/syringe/pull/108)
- Add config flag to permit egress traffic [#119](https://github.com/nre-learning/syringe/pull/119)
- Support option to specify curriculum version [#120](https://github.com/nre-learning/syringe/pull/120)

## v0.3.2 - April 19, 2019

Expand Down
5 changes: 5 additions & 0 deletions api/exp/lessons.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ func validateLesson(syringeConfig *config.SyringeConfig, lesson *pb.Lesson) erro
return fail
}

if strings.Contains(ep.Image, ":") {
log.Error("Tags are not allowed in endpoint image refs")
return fail
}

if ep.ConfigurationType == "" {
continue
}
Expand Down
10 changes: 10 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type SyringeConfig struct {
TSDBEnabled bool

CurriculumLocal bool
CurriculumVersion string
CurriculumRepoRemote string
CurriculumRepoBranch string

Expand Down Expand Up @@ -107,6 +108,15 @@ func LoadConfigVars() (*SyringeConfig, error) {
config.CurriculumLocal = true
}

// +syringeconfig SYRINGE_CURRICULUM_VERSION is the version of the curriculum to use.
version := os.Getenv("SYRINGE_CURRICULUM_VERSION")
if version == "" {
// This is used to form docker image refs, so we're specifying "latest" here by default.
config.CurriculumVersion = "latest"
} else {
config.CurriculumVersion = version
}

// +syringeconfig SYRINGE_CURRICULUM_REPO_REMOTE is the git repo from which pull lesson content
remote := os.Getenv("SYRINGE_CURRICULUM_REPO_REMOTE")
if remote == "" {
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestConfigJSON(t *testing.T) {
TSDBExportInterval: 0,
TSDBEnabled: false,
CurriculumLocal: false,
CurriculumVersion: "latest",
CurriculumRepoRemote: "https://github.com/nre-learning/nrelabs-curriculum.git",
CurriculumRepoBranch: "master",
AllowEgress: false,
Expand Down
10 changes: 5 additions & 5 deletions scheduler/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (ls *LessonScheduler) createPod(ep *pb.Endpoint, networks []string, req *Le
Containers: []corev1.Container{
{
Name: ep.GetName(),
Image: ep.GetImage(),
Image: fmt.Sprintf("%s:%s", ep.GetImage(), ls.SyringeConfig.CurriculumVersion),

// Omitting in order to keep things speedy. For debugging, uncomment this, and the image will be pulled every time.
ImagePullPolicy: "Always",
Expand Down Expand Up @@ -116,10 +116,10 @@ func (ls *LessonScheduler) createPod(ep *pb.Endpoint, networks []string, req *Le
// Privileged status is currently required by both the lite and full vqfx versions.
// It may also be required by other images we bring on board.
privilegedImages := map[string]string{
"antidotelabs/vqfx:snap1": "",
"antidotelabs/vqfx:snap2": "",
"antidotelabs/vqfx:snap3": "",
"antidotelabs/vqfx-full:18.1R1.9": "",
"antidotelabs/container-vqfx": "",
// "antidotelabs/vqfx:snap2": "",
// "antidotelabs/vqfx:snap3": "",
// "antidotelabs/vqfx-full:18.1R1.9": "",
}
if _, ok := privilegedImages[ep.Image]; ok {
b := true
Expand Down

0 comments on commit 3a6643e

Please sign in to comment.